:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.972 0.004 210);
  --surface-strong: oklch(0.94 0.008 210);
  --ink: oklch(0.19 0.026 224);
  --muted: oklch(0.43 0.026 224);
  --line: oklch(0.88 0.01 215);
  --primary: oklch(0.54 0.11 200);
  --primary-hover: oklch(0.49 0.12 200);
  --accent: oklch(0.62 0.15 35);
  --success-bg: oklch(0.94 0.055 151);
  --success-fg: oklch(0.32 0.09 151);
  --warn-bg: oklch(0.95 0.075 88);
  --warn-fg: oklch(0.38 0.09 68);
  --bad-bg: oklch(0.94 0.06 24);
  --bad-fg: oklch(0.39 0.13 24);
  --radius: 8px;
  --shadow: 0 8px 24px oklch(0 0 0 / 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--primary);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.crumb,
.label,
.section-heading p,
.field-help,
#saveState {
  color: var(--muted);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.crumb {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 16px;
}

.topbar-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  min-height: 36px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 12px;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-action {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.primary-action:hover:not(:disabled) {
  background: var(--primary-hover);
}

.ghost-button {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover:not(:disabled) {
  background: var(--surface);
}

.danger-button {
  background: var(--bad-bg);
  color: var(--bad-fg);
  border-color: oklch(0.86 0.05 24);
  font-weight: 700;
}

.site-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  display: block;
  height: auto;
  min-height: 54px;
  padding: 8px 10px;
}

.site-item:hover,
.site-item.active {
  background: var(--bg);
  border-color: var(--line);
}

.site-item strong,
.site-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-item span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.connect-panel,
.audit-panel,
.editor-panel,
.preview-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.connect-panel {
  max-width: 620px;
}

.connect-form,
.audit-panel,
.editor-panel,
.preview-panel,
.empty-state {
  padding: 18px;
}

.connect-form,
.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.section-heading.compact {
  margin-bottom: 2px;
}

.section-heading p {
  margin: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px oklch(0.54 0.11 200 / 0.16);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  margin-bottom: 16px;
}

.status-strip > div {
  min-width: 0;
  background: var(--surface);
  padding: 12px;
}

.label {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.status-strip strong,
.status-strip a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 800;
}

.status-good {
  background: var(--success-bg);
  color: var(--success-fg);
}

.status-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.status-bad {
  background: var(--bad-bg);
  color: var(--bad-fg);
}

.audit-panel {
  margin-bottom: 16px;
}

.audit-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 14px;
}

#auditState {
  color: var(--muted);
  font-weight: 700;
}

.audit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.audit-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  min-width: 0;
}

.audit-card strong,
.audit-card span {
  display: block;
}

.audit-card span,
.audit-card li {
  color: var(--muted);
}

.audit-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-help {
  min-height: 17px;
  font-weight: 600;
  font-size: 12px;
}

.serp-preview {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.serp-title {
  color: oklch(0.38 0.17 265);
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 3px;
}

.serp-url {
  color: oklch(0.35 0.12 150);
  font-size: 13px;
  overflow-wrap: anywhere;
  margin-bottom: 6px;
}

.serp-desc {
  color: var(--muted);
  line-height: 1.45;
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.check-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.check-item:last-child {
  border-bottom: 0;
}

.check-item span {
  color: var(--muted);
}

.empty-state {
  max-width: 680px;
  background: var(--surface);
}

.empty-state p {
  color: var(--muted);
  max-width: 68ch;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: var(--ink);
  color: white;
  border-radius: var(--radius);
  padding: 11px 13px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .site-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .editor-layout,
  .status-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .field-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .form-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
