/* ─────────────────────────────────────────────────────────────
   GnB Article Scoring — design system
   Editorial / data-report aesthetic. No candy gradients, no
   purple-blue fade, no glassmorphism, no decorative emoji.
   Typography does the heavy lifting.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Surface — warm whites, stone neutrals, restrained accent */
  --surface-1: #fafaf9;        /* page bg */
  --surface-2: #ffffff;        /* card */
  --surface-3: #f5f5f4;        /* hover, subtle bg */

  --rule-1: #e7e5e4;           /* primary border */
  --rule-2: #f1ede9;           /* hairline / secondary */

  --ink-1: #1c1917;            /* primary text */
  --ink-2: #44403c;            /* secondary text */
  --ink-3: #78716c;            /* muted */
  --ink-4: #a8a29e;            /* faint */

  --accent: #0d9488;           /* teal — for actions only */
  --accent-strong: #115e59;
  --accent-soft: #f0fdfa;

  --good: #047857;             /* deep emerald — pass / met */
  --good-soft: #ecfdf5;
  --warn: #b45309;             /* deep amber */
  --warn-soft: #fffbeb;
  --bad: #b91c1c;              /* deep red */
  --bad-soft: #fef2f2;

  /* Type system */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;

  /* Layout */
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--surface-1);
  color: var(--ink-1);
  font: 14px/1.5 var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent-soft); color: var(--accent-strong); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 2px 6px;
  background: var(--surface-3);
  border: 1px solid var(--rule-1);
  border-radius: 4px;
}

/* ─────────── TOPBAR ─────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule-1);
  height: var(--topbar-h);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: var(--ink-1); color: var(--surface-2);
  border-radius: 4px;
  font-weight: 800; font-size: 11px; letter-spacing: .04em;
  font-feature-settings: "ss01";
}
.brand-name {
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  color: var(--ink-1);
}
.brand-sub {
  color: var(--ink-3); font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.brand-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink-3);
  font-size: 16px;
  transition: background .15s, color .15s;
}
.brand-back:hover { background: var(--surface-3); color: var(--ink-1); text-decoration: none; }

.topbar-right { display: flex; align-items: center; gap: 18px; }

.editor-meta {
  font-size: 12px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.editor-meta strong {
  color: var(--ink-1);
  font-weight: 600;
}

.save-indicator {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-3);
  min-width: 56px; text-align: center;
}
.save-indicator[data-state="saving"]      { background: var(--warn-soft); color: var(--warn); }
.save-indicator[data-state="saved"]       { background: var(--good-soft); color: var(--good); }
.save-indicator[data-state="editing"]     { background: var(--accent-soft); color: var(--accent-strong); }
.save-indicator[data-state="save failed"] { background: var(--bad-soft); color: var(--bad); }

/* ─────────── DASHBOARD ─────────── */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}

.dashboard-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule-1);
}
.dashboard-title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
}
.dashboard-sub {
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1px;
  background: var(--rule-1);
  border: 1px solid var(--rule-1);
}

/* ─────────── FOLDER GRID ─────────── */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--rule-1);
  border: 1px solid var(--rule-1);
}
.folder-card {
  display: flex; flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--surface-2);
  padding: 22px 24px 18px;
  min-height: 160px;
  transition: background .12s;
}
.folder-card:hover {
  background: var(--surface-3);
  text-decoration: none;
}
.folder-row-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.folder-name {
  margin: 0;
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink-1);
  flex: 1;
}
.folder-stat-badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--ink-1);
  color: var(--surface-2);
}
.folder-stats {
  display: flex; gap: 28px;
  margin: 0 0 18px;
  flex: 1;
}
.folder-stat {
  display: flex; flex-direction: column;
  align-items: flex-start;
}
.folder-stat strong {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}
.folder-stat-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-top: 6px;
}
.folder-row-bottom {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-4);
  border-top: 1px solid var(--rule-2);
  padding-top: 10px;
  margin-top: auto;
}
.folder-time { font-variant-numeric: tabular-nums; }

/* ─────────── BREADCRUMB / CLIENT HEADER ─────────── */
.breadcrumb-link { color: var(--ink-3); text-decoration: none; }
.breadcrumb-link:hover { color: var(--ink-1); text-decoration: none; }

.client-stats {
  display: flex; gap: 28px;
  align-items: center;
}

/* ─────────── EDITOR TABLE ─────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule-1);
  background: var(--surface-2);
}
.editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.editor-table thead th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--rule-1);
  background: var(--surface-1);
  white-space: nowrap;
}
.editor-table tbody tr {
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--rule-2);
}
.editor-table tbody tr:hover { background: var(--surface-3); }
.editor-table tbody tr:last-child { border-bottom: 0; }
.editor-table td {
  padding: 14px;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
.col-keyword { font-weight: 600; color: var(--ink-1); min-width: 220px; }
.col-num     { text-align: right; white-space: nowrap; }
.col-loc     { white-space: nowrap; color: var(--ink-2); }
.col-writer  { color: var(--ink-2); }
.col-time    { color: var(--ink-4); white-space: nowrap; font-size: 12px; }
.col-action  { text-align: right; width: 36px; }

.row-keyword { font-weight: 600; }
.row-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--surface-2);
  background: var(--ink-1);
  padding: 2px 6px;
  border-radius: 3px;
}

.row-delete {
  background: none; border: 0;
  color: var(--ink-4);
  font-size: 16px; line-height: 1;
  width: 26px; height: 26px;
  cursor: pointer;
  border-radius: 4px;
  transition: background .12s, color .12s;
}
.row-delete:hover { background: var(--bad-soft); color: var(--bad); }

.score-pass { color: var(--good); font-weight: 700; }
.score-fail { color: var(--warn); font-weight: 700; }
.surfer-cell { color: var(--ink-2); font-weight: 600; }

.delta-good { color: var(--good); font-weight: 600; }
.delta-warn { color: var(--warn); font-weight: 600; }
.delta-bad  { color: var(--bad); font-weight: 600; }

.editor-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface-2);
  padding: 22px 24px 18px;
  transition: background .12s;
  position: relative;
}
.editor-card:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.card-row-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 4px;
}
.card-name {
  margin: 0;
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-1);
}
.card-keyword {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--ink-3);
  margin-bottom: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-score {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--good);
  font-variant-numeric: tabular-nums;
}
.card-score strong {
  font-size: 18px;
  font-weight: 700;
  margin-right: 1px;
}
.card-score.fail { color: var(--warn); }
.card-score-empty {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 600;
}

.card-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 14px;
}
.card-meta-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.card-meta-chip.pending {
  background: var(--warn-soft); color: var(--warn);
}
.card-meta-chip.card-validation {
  background: var(--ink-1); color: var(--surface-2);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.editor-card.is-validation {
  background: linear-gradient(to right, var(--surface-2) calc(100% - 3px), var(--ink-1) 0);
}

.card-row-bottom {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-4);
  border-top: 1px solid var(--rule-2);
  padding-top: 10px;
  margin-top: 4px;
}
.card-time { font-variant-numeric: tabular-nums; }
.card-delete {
  background: none; border: none;
  color: var(--ink-4);
  font-size: 16px; line-height: 1;
  width: 22px; height: 22px;
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.card-delete:hover { background: var(--bad-soft); color: var(--bad); }

.dashboard-empty {
  text-align: left;
  padding: 80px 0;
  border-top: 1px solid var(--rule-1);
  max-width: 480px;
}
.dashboard-empty h3 {
  margin: 6px 0 14px;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink-1);
}
.dashboard-empty p {
  color: var(--ink-2);
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.55;
}

.dashboard-error {
  background: var(--bad-soft); color: var(--bad);
  padding: 16px 20px;
  border: 1px solid #fecaca;
  border-radius: 4px;
  font-size: 13px;
}

/* ─────────── EDITOR LAYOUT ─────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 1px;
  background: var(--rule-1);
  border-bottom: 1px solid var(--rule-1);
  min-height: calc(100vh - var(--topbar-h));
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}

.left-pane, .right-pane {
  background: var(--surface-2);
  padding: 28px 32px 36px;
  min-width: 0;
}
.right-pane { padding: 0; }

/* Sticky inner content — stays in view as the left pane scrolls */
.right-pane-inner {
  position: sticky;
  top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.right-pane-inner::-webkit-scrollbar { width: 6px; }
.right-pane-inner::-webkit-scrollbar-thumb { background: var(--rule-1); border-radius: 999px; }
.right-pane-inner::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* Writer field at top of right pane */
.writer-row {
  padding: 18px 32px 16px;
  border-bottom: 1px solid var(--rule-1);
}
.writer-field { display: block; }
.writer-field .eyebrow { display: block; margin-bottom: 8px; }
.writer-field input {
  width: 100%;
  border: 0;
  background: transparent;
  font: 15px/1.4 var(--font-sans);
  color: var(--ink-1);
  font-weight: 500;
  padding: 4px 0;
  outline: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.writer-field input::placeholder { color: var(--ink-4); font-weight: 400; }
.writer-field input:hover { border-bottom-color: var(--rule-1); }
.writer-field input:focus { border-bottom-color: var(--ink-1); }

/* ─────────── EDITOR HEADER (left) ─────────── */
.editor-head {
  margin-bottom: 28px;
}
.editor-head .eyebrow {
  display: block;
  margin-bottom: 10px;
}
.editor-keyword {
  margin: 0 0 14px;
  font-size: 32px; font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.05;
  color: var(--ink-1);
}
.editor-meta-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--ink-2);
  letter-spacing: 0.01em;
}
.meta-chip strong { color: var(--ink-1); font-weight: 600; }

.topbar-divider {
  color: var(--ink-4);
  margin: 0 4px;
  font-weight: 400;
}

/* ─────────── FORM ELEMENTS ─────────── */
.field {
  display: block;
  margin-bottom: 18px;
}
.field > span {
  display: block;
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule-1);
  border-radius: 4px;
  font: 14px/1.5 var(--font-sans);
  background: var(--surface-2);
  color: var(--ink-1);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink-1);
}
.field textarea {
  resize: vertical;
  min-height: 240px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}

/* ─────────── QUILL ─────────── */
.ql-toolbar.ql-snow {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  border: 1px solid var(--rule-1) !important;
  border-bottom: 0 !important;
  border-radius: 4px 4px 0 0;
  background: var(--surface-1);
  padding: 8px 10px;
}
#draft-editor.ql-container.ql-snow {
  border: 1px solid var(--rule-1) !important;
  border-radius: 0 0 4px 4px;
  font: 15px/1.65 var(--font-sans) !important;
  min-height: 360px;
}
.ql-editor {
  min-height: 340px;
  padding: 18px 20px;
  color: var(--ink-1);
}
.ql-editor.ql-blank::before {
  font-style: normal;
  color: var(--ink-4);
  left: 20px; right: 20px;
}
.ql-editor h2 {
  font-size: 20px; font-weight: 700; letter-spacing: -0.015em;
  margin: 22px 0 8px;
}
.ql-editor h3 {
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  margin: 18px 0 6px;
}
.ql-editor p { margin: 0 0 12px; }
.ql-snow .ql-stroke { stroke: var(--ink-2); }
.ql-snow .ql-fill   { fill: var(--ink-2); }
.ql-snow .ql-active .ql-stroke,
.ql-snow .ql-picker-label.ql-active { color: var(--accent); }
.ql-snow .ql-active .ql-fill { fill: var(--accent); }

/* ─────────── BUTTONS ─────────── */
.actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 6px;
}
.btn {
  padding: 9px 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  font: 13px/1 var(--font-sans);
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--ink-1); color: var(--surface-2);
}
.btn-primary:hover:not(:disabled) { background: #000; }

.btn-ghost {
  background: transparent; border-color: var(--rule-1);
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--ink-1);
  border-color: var(--ink-3);
}

.status {
  color: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.status.error { color: var(--bad); }
.status.loading::after { content: "…"; }

.score-help {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface-1);
  border: 1px solid var(--rule-1);
  border-radius: 4px;
  font-size: 12px; line-height: 1.55;
  color: var(--ink-3);
}
.score-help[hidden] { display: none; }

.live-toggle {
  display: flex; align-items: center; gap: 8px;
  margin-top: 16px;
  font-size: 13px; color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.live-toggle input { width: 14px; height: 14px; cursor: pointer; accent-color: var(--ink-1); }
.live-hint {
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 4px;
}
.live-hint.active { color: var(--good); }

/* ─────────── RIGHT PANE: EMPTY / SCORE PANEL ─────────── */
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-3);
  display: inline-block;
}

.empty-state {
  padding: 72px 32px;
  max-width: 380px;
}
.empty-state .eyebrow {
  margin-bottom: 14px;
}
.empty-state h3 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-1);
}
.empty-state p {
  color: var(--ink-2);
  font-size: 14px; line-height: 1.6;
  margin: 0 0 14px;
}
.empty-state .empty-hint {
  color: var(--ink-3);
  font-size: 13px;
}

.score-panel { padding: 28px 32px 8px; }

.score-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.score-help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border: 1px solid var(--rule-1);
  border-radius: 50%;
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  cursor: help;
  background: var(--surface-2);
}
.score-help-icon:hover { color: var(--ink-1); border-color: var(--ink-1); }

/* ─────────── SCORE: editorial number + threshold bar ─────────── */
.score-display {
  margin-bottom: 28px;
}
.score-num-row {
  display: flex; align-items: flex-end; gap: 18px;
  margin-bottom: 18px;
}
.score-num {
  font-family: var(--font-sans);
  font-size: 88px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.85;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "ss01", "tnum";
}
.score-aside {
  display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 8px;
}
.score-denom {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.verdict {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 3px;
  display: inline-block;
}
.verdict.pass { background: var(--good); color: var(--surface-2); }
.verdict.fail { background: var(--warn); color: var(--surface-2); }

/* threshold bar */
.score-bar { position: relative; padding: 10px 0 18px; }
.score-bar-track {
  position: relative;
  height: 6px;
  background: var(--rule-1);
  border-radius: 999px;
  overflow: visible;
}
.score-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink-1);
  border-radius: 999px;
  transition: width .35s cubic-bezier(.4,0,.2,1), background .25s;
}
.score-bar-fill.fail { background: var(--warn); }
.score-bar-tick {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 1px;
  background: var(--ink-3);
  pointer-events: none;
}
.score-bar-tick-label {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  white-space: nowrap;
  text-transform: uppercase;
  font-weight: 600;
}

/* ─────────── METRIC ROW: data-report style ─────────── */
.metric-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--rule-1);
  border-bottom: 1px solid var(--rule-1);
  margin: 0 -32px 0;
  padding: 18px 32px;
  gap: 0;
}
.metric-row.metric-row-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
.metric { padding: 0 12px; }
.metric:first-child { padding-left: 0; }
.metric:last-child { padding-right: 0; }
.metric + .metric { border-left: 1px solid var(--rule-2); }

.metric-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 8px;
}
.metric-value {
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}
.metric-target {
  font-size: 11px; color: var(--ink-3);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.metric-value.good { color: var(--good); }
.metric-value.warn { color: var(--warn); }
.metric-value.bad  { color: var(--bad); }

/* ─────────── SECTIONS ─────────── */
.section {
  border-top: 1px solid var(--rule-1);
  margin: 0 -32px;
  padding: 0 32px;
}
.section:first-of-type { border-top: 0; }
.section:last-of-type { border-bottom: 1px solid var(--rule-1); }

.section summary {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.section summary::-webkit-details-marker { display: none; }
.section summary::after {
  content: "+";
  margin-left: auto;
  color: var(--ink-3);
  font-size: 16px;
  font-weight: 400;
  transition: transform .15s, color .15s;
}
.section[open] summary::after {
  content: "−";
  color: var(--ink-1);
}
.section summary:hover .section-title { color: var(--ink-1); }

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--ink-1);
}
.section-meta {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  margin-left: auto;
  margin-right: 14px;
  text-transform: lowercase;
}
.section-body { padding: 0 0 22px; }

/* ─────────── TERMS: tabs + pills ─────────── */
.terms-tabs {
  display: flex; gap: 22px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule-1);
}
.terms-tab {
  background: none; border: 0;
  padding: 8px 0 12px;
  font: inherit;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.terms-tab:hover { color: var(--ink-1); }
.terms-tab.active {
  color: var(--ink-1);
  border-bottom-color: var(--ink-1);
}
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.terms-tab.active .tab-count {
  background: var(--ink-1);
  color: var(--surface-2);
}

.terms-copy-row {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0 6px;
}
.copy-status {
  font-size: 12px; color: var(--good); opacity: 0;
  transition: opacity .25s ease;
}
.copy-status.show { opacity: 1; }

.terms-pills {
  display: flex; flex-wrap: wrap; gap: 5px 6px;
  padding: 4px 0 4px;
}

/* Pills: filled by state for at-a-glance scan. Dot stays for redundancy. */
.term-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  line-height: 1.3;
  border: 1px solid var(--rule-1);
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  transition: background .15s, border-color .15s;
}
.term-pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-4);
  flex-shrink: 0;
}

/* MET — within target range: light green fill */
.term-pill.met {
  background: #d1fae5;        /* emerald-100 */
  border-color: #a7f3d0;      /* emerald-200 */
  color: #065f46;             /* emerald-800 */
}
.term-pill.met::before     { background: var(--good); }

/* PARTIAL — below target: light amber fill */
.term-pill.partial {
  background: #fef3c7;        /* amber-100 */
  border-color: #fde68a;      /* amber-200 */
  color: #78350f;             /* amber-900 */
}
.term-pill.partial::before { background: var(--warn); }

/* MISSING — zero usage: neutral, faded */
.term-pill.missing {
  background: var(--surface-3);
  border-color: var(--rule-1);
  color: var(--ink-3);
}
.term-pill.missing::before { background: var(--ink-4); }

/* OVER — above target ceiling: light red fill (over-stuffing risk) */
.term-pill.over {
  background: #fee2e2;        /* red-100 */
  border-color: #fecaca;      /* red-200 */
  color: #991b1b;             /* red-800 */
}
.term-pill.over::before    { background: var(--bad); }

.term-pill .pill-label {
  overflow-wrap: anywhere;
  white-space: normal;
}
.term-pill .pill-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: inherit;
  opacity: 0.85;
  margin-left: 2px;
  letter-spacing: 0;
}

/* H badge for terms appearing in competitor headings */
.term-pill.has-heading {
  box-shadow: inset 0 0 0 1px currentColor;
  opacity: 1;
}
.term-pill.has-heading .pill-label::after {
  content: " · H";
  color: currentColor;
  font-size: 10px;
  letter-spacing: 0.04em;
  font-weight: 700;
  opacity: 0.7;
}

.terms-empty {
  padding: 28px 0; text-align: left;
  color: var(--ink-3); font-size: 13px;
}

/* ─────────── COMPETITOR HEADINGS ─────────── */
.headings-list { list-style: none; margin: 0; padding: 0; }
.headings-list > li {
  padding: 14px 0;
  border-top: 1px solid var(--rule-2);
}
.headings-list > li:first-child { border-top: 0; padding-top: 4px; }

.headings-list .source-url {
  font-size: 11px; color: var(--ink-3);
  font-family: var(--font-mono);
  margin-bottom: 8px;
  word-break: break-all;
}
.headings-list .h2-chip,
.headings-list .h3-chip {
  display: inline-block;
  padding: 3px 9px;
  margin: 2px 4px 2px 0;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 500;
}
.headings-list .h2-chip {
  background: var(--surface-1);
  color: var(--ink-1);
  border: 1px solid var(--rule-1);
  font-weight: 600;
}
.headings-list .h3-chip {
  background: var(--surface-3);
  color: var(--ink-2);
}

/* ─────────── SOURCES ─────────── */
.source-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.source-list li {
  padding: 12px 0;
  border-top: 1px solid var(--rule-2);
}
.source-list li:first-child { border-top: 0; padding-top: 4px; }
.source-top-row {
  display: flex; align-items: baseline; gap: 8px;
}
.source-list .rank {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.source-list a { color: var(--ink-1); flex: 1; min-width: 0; word-break: break-all; }
.source-list a:hover { color: var(--accent); text-decoration: underline; }
.source-list .muted {
  color: var(--ink-4); font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.source-list li { position: relative; }

/* Competitor score badge */
.source-score {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.source-score.pass { background: var(--good-soft); color: var(--good); }
.source-score.mid  { background: var(--warn-soft);  color: var(--warn); }
.source-score.low  { background: var(--bad-soft);   color: var(--bad); }

/* Competitor benchmark header */
.competitor-benchmark {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px !important;
  background: var(--surface-3);
  border-radius: 6px;
  border-top: none !important;
  margin-bottom: 4px;
}
.bench-label {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}
.bench-score {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--ink-1);
  letter-spacing: -0.03em;
}
.bench-detail {
  font-size: 11px;
  color: var(--ink-3);
  margin-left: auto;
}

.forced-tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

/* Inline action button (✕ exclude, + include, ↺ reset) */
.source-action {
  position: relative;
  flex-shrink: 0;
  background: none;
  border: 1px solid transparent;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1;
  color: var(--ink-4);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}
.source-action:hover {
  background: var(--surface-3);
  color: var(--ink-1);
  border-color: var(--rule-1);
}
.source-action[data-action="include"]:hover {
  color: var(--good);
  background: var(--good-soft);
  border-color: #a7f3d0;
}
.source-action[data-action="exclude"]:hover {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: #fecaca;
}

.rejection-list li {
  grid-template-columns: 28px minmax(0, 1fr) auto 22px;
  align-items: center;
}
.rejection-list .source-action {
  position: static;
  margin-left: 4px;
}

/* ─────────── REJECTION LIST ─────────── */
.rejection-summary {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 14px;
}
.rejection-cat {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.rejection-cat strong {
  color: var(--ink-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 3px;
}

.rejection-list {
  list-style: none; margin: 0; padding: 0; font-size: 12px;
}
.rejection-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--rule-2);
}
.rejection-list li:first-child { border-top: 0; padding-top: 4px; }
.rejection-list .rank {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
}
.rejection-list a {
  color: var(--ink-2);
  font-size: 12px;
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.rejection-list a:hover { color: var(--accent); }
.rejection-reason {
  font-size: 11px;
  color: var(--ink-3);
  font-style: italic;
  text-align: right;
  white-space: nowrap;
}
.rejection-empty {
  padding: 16px 0;
  color: var(--ink-3);
  font-size: 12px;
  font-style: italic;
}
.rejection-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-2);
  font-size: 11px;
  color: var(--ink-4);
  font-family: var(--font-mono);
  letter-spacing: 0;
  word-spacing: 4px;
}

/* ─────────── MODAL ─────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(28, 25, 23, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--rule-1);
  width: 100%; max-width: 480px;
  padding: 28px 32px 22px;
  box-shadow: 0 30px 70px rgba(0,0,0,.18);
}
.modal h3 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-sub {
  color: var(--ink-3);
  font-size: 13px;
  margin: 0 0 22px;
  line-height: 1.5;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: 0;
  width: 28px; height: 28px;
  border-radius: 4px;
  font-size: 18px; line-height: 1;
  color: var(--ink-3); cursor: pointer;
  transition: background .15s;
}
.modal-close:hover { background: var(--surface-3); color: var(--ink-1); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--rule-1);
}
.modal .field em { font-style: normal; color: var(--ink-4); }
#modal-status { margin-top: 10px; min-height: 16px; font-size: 12px; }

.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ─────────── USER BADGE + AUTH ─────────── */
.user-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 4px 10px;
  background: var(--surface-3);
  border-radius: 4px;
  letter-spacing: 0.01em;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--rule-1);
  border: 1px solid var(--rule-1);
}
