/* Rete Consultori · Knowledge Base
   Colour carries one meaning only: validation status. Everything else is neutral. */

/* Server mode features, one stylesheet each. */
@import url("auth.css");
@import url("git.css");
@import url("live.css");

@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-hyperlegible-next-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Mono";
  src: url("../fonts/atkinson-hyperlegible-mono.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #e9edf1;
  --ink: #16202b;
  --ink-2: #3b4855;
  --muted: #5d6a78;
  --line: #d6dce2;
  --line-strong: #b5bfc9;
  --primary: #0f4c81;
  --primary-ink: #ffffff;
  --primary-soft: #dfe9f3;
  --focus: #1f6fbf;

  --st-draft: #9aa5b1;
  --st-to_validate: #e0a33a;
  --st-validated: #2e7d5b;
  --st-validated_with_changes: #3f8f9c;
  --st-to_review: #c4553f;
  --st-discarded: #6b7480;
  --st-ink-to_validate: #6b4605;
  --st-ink-validated: #1b5a3f;
  --st-ink-to_review: #8a3020;

  --danger: #b3402c;
  --mark: #fde7a8;
  --toast-success-bg: #2e7d5b;
  --toast-success-ink: #ffffff;
  --toast-warning-bg: #e0a33a;
  --toast-warning-ink: #16202b;
  --toast-error-bg: #b3402c;
  --toast-error-ink: #ffffff;

  --font: "Atkinson Next", system-ui, sans-serif;
  --mono: "Atkinson Mono", ui-monospace, monospace;
  --radius-s: 4px;
  --radius-m: 8px;
  --sidebar: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1720;
    --surface: #16212c;
    --surface-2: #1d2a37;
    --ink: #e6ebf0;
    --ink-2: #c3ccd5;
    --muted: #94a3b2;
    --line: #263443;
    --line-strong: #3a4b5c;
    --primary: #79b0e6;
    --primary-ink: #0b1622;
    --primary-soft: #1b3248;
    --focus: #8cc0f2;
    --st-draft: #7d8996;
    --st-to_validate: #e8b04f;
    --st-validated: #4fae84;
    --st-validated_with_changes: #5bb0bd;
    --st-to_review: #e07a63;
    --st-discarded: #8892a0;
    --st-ink-to_validate: #f3c978;
    --st-ink-validated: #7fd0aa;
    --st-ink-to_review: #f19f8b;
    --danger: #ef8a73;
    --mark: #5b4613;
    --toast-success-bg: #4fae84;
    --toast-success-ink: #0b1622;
    --toast-warning-bg: #e8b04f;
    --toast-warning-ink: #0b1622;
    --toast-error-bg: #ef8a73;
    --toast-error-ink: #0b1622;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1720;
  --surface: #16212c;
  --surface-2: #1d2a37;
  --ink: #e6ebf0;
  --ink-2: #c3ccd5;
  --muted: #94a3b2;
  --line: #263443;
  --line-strong: #3a4b5c;
  --primary: #79b0e6;
  --primary-ink: #0b1622;
  --primary-soft: #1b3248;
  --focus: #8cc0f2;
  --st-draft: #7d8996;
  --st-to_validate: #e8b04f;
  --st-validated: #4fae84;
  --st-validated_with_changes: #5bb0bd;
  --st-to_review: #e07a63;
  --st-discarded: #8892a0;
  --st-ink-to_validate: #f3c978;
  --st-ink-validated: #7fd0aa;
  --st-ink-to_review: #f19f8b;
  --danger: #ef8a73;
  --mark: #5b4613;
  --toast-success-bg: #4fae84;
  --toast-success-ink: #0b1622;
  --toast-warning-bg: #e8b04f;
  --toast-warning-ink: #0b1622;
  --toast-error-bg: #ef8a73;
  --toast-error-ink: #0b1622;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  font-feature-settings: "kern", "liga";
}
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-size: 1.85rem; letter-spacing: -0.015em; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.8em; }
code, .id { font-family: var(--mono); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 20px 14px 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.brand { display: block; padding: 0 8px; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-size: 0.85rem; }
.nav-group h2 { font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 0 8px; margin-bottom: 4px; }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-size: 0.95rem;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--primary-soft); color: var(--ink); font-weight: 600; }
button.nav-link { width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; }
.mobile-only { display: none; }
.nav-link .count { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 32px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.btn.menu-toggle { display: none; }
.search-trigger {
  flex: 1; max-width: 520px; display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-m);
  background: var(--surface); color: var(--muted); cursor: pointer; text-align: left;
}
.search-trigger kbd { font-family: var(--mono); font-size: 0.75rem; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.spacer { flex: 1; }

.theme-switch { display: inline-flex; align-self: flex-start; border: 1px solid var(--line-strong); border-radius: var(--radius-m); overflow: hidden; }
.theme-switch button {
  border: 0; background: transparent; padding: 8px 14px; cursor: pointer; color: var(--muted); font: inherit;
}
.theme-switch button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.content { padding: 28px 32px 64px; max-width: 1280px; width: 100%; }

/* --------------------------------------------------------------- common */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-m); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 600; font-size: 0.92rem;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.id {
  font-size: 0.86em; color: var(--ink-2); white-space: nowrap;
  background: none; border: 0; padding: 0; cursor: copy;
}
.id:hover { color: var(--primary); }

.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--ink-2); white-space: nowrap;
}
.status::before {
  content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--st, var(--st-draft));
  transform: rotate(45deg);
}
.st-draft { --st: var(--st-draft); }
.st-to_validate { --st: var(--st-to_validate); }
.st-validated { --st: var(--st-validated); }
.st-validated_with_changes { --st: var(--st-validated_with_changes); }
.st-to_review { --st: var(--st-to_review); }
.st-discarded { --st: var(--st-discarded); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.8rem; color: var(--ink-2);
  background: var(--surface); white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; }
.notice {
  border-left: 3px solid var(--st-to_validate); background: var(--surface); padding: 10px 14px; border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
.notice.error { border-color: var(--danger); }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ------------------------------------------------------------ dashboard */

.dash-head h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); letter-spacing: -0.025em; font-weight: 800; }
.dash-head .lede { font-size: 1.05rem; color: var(--ink-2); max-width: 64ch; margin-top: 8px; }

.mosaic-wrap { margin: 28px 0 8px; }
.mosaic { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-start; }
.mosaic-group h3 { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; display: flex; gap: 8px; align-items: baseline; }
.mosaic-group h3 span { font-family: var(--mono); color: var(--muted); font-weight: 400; }
.tiles { display: grid; grid-template-columns: repeat(var(--cols, 10), 14px); gap: 3px; }
.tile {
  width: 14px; height: 14px; border-radius: 2px; background: var(--st); display: block;
  outline-offset: 1px;
}
.tile:hover, .tile:focus-visible { outline: 2px solid var(--ink); }
.tile.st-discarded { background: repeating-linear-gradient(45deg, var(--st-discarded) 0 2px, transparent 2px 4px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px; font-size: 0.85rem; color: var(--ink-2); }
.legend .status { font-size: 0.85rem; }

.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 40px; margin-top: 36px; }
.dash-block { grid-column: span 6; padding: 22px 0; border-top: 1px solid var(--line); min-width: 0; }
.dash-block.wide { grid-column: span 12; }
.dash-block > h2 { margin-bottom: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.dash-block > h2 a { font-size: 0.85rem; font-weight: 600; }

.anomalies { margin: 0; padding-left: 1.2em; max-width: 90ch; }
.anomalies li { padding: 3px 0; }
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 24px; }
.figure a { color: var(--ink); text-decoration: none; display: block; }
.figure .num { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.figure .label { color: var(--ink-2); font-size: 0.9rem; margin-top: 4px; }
.figure .bar { display: flex; height: 6px; margin-top: 8px; border-radius: 3px; overflow: hidden; background: var(--surface-2); }
.figure .bar span { background: var(--st); }
.figure a:hover .label { color: var(--primary); }
.dash-block h3.sub { margin: 18px 0 2px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.dash-block details summary { cursor: pointer; padding: 7px 0; color: var(--ink-2); }

.heatmap { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.heatmap th, .heatmap td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.heatmap th:first-child, .heatmap td:first-child { text-align: left; }
.heatmap thead th { color: var(--muted); font-weight: 600; vertical-align: bottom; }
.heatmap td.cell { font-variant-numeric: tabular-nums; }
.heatmap td.cell span {
  display: inline-block; min-width: 2.2em; padding: 1px 6px; border-radius: 3px; text-align: center;
  background: color-mix(in srgb, var(--st) calc(var(--w, 0) * 100%), transparent);
}
.heatmap td.zero { color: var(--line-strong); }

.gaps { list-style: none; margin: 0; padding: 0; }
.gaps li { display: grid; grid-template-columns: 3.2em 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.gaps .n { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; text-align: right; }
.gaps details summary { cursor: pointer; }
.gaps details .chips { margin-top: 6px; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.rows li .id { white-space: normal; overflow-wrap: anywhere; }
.rows li a.title { color: var(--ink); text-decoration: none; }
.rows li a.title:hover { color: var(--primary); text-decoration: underline; }

/* ---------------------------------------------------------------- lists */

.list-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; align-items: start; }
.facets { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 18px; font-size: 0.9rem; }
.facet h3 { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.facet label { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; cursor: pointer; color: var(--ink-2); }
.facet label .n { margin-left: auto; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.facet input { accent-color: var(--primary); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-bar input[type="search"] {
  flex: 1; min-width: 220px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-m); background: var(--surface);
}
.result-count { color: var(--muted); font-size: 0.9rem; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 0.82rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table td a.title { color: var(--ink); text-decoration: none; font-weight: 600; }
.table td a.title:hover { color: var(--primary); text-decoration: underline; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.table .snippet { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.table-scroll { overflow-x: auto; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.thumb { display: block; color: var(--ink); text-decoration: none; }
.thumb .img {
  aspect-ratio: 16 / 11; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  overflow: hidden; display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.thumb .cap { margin-top: 6px; font-size: 0.88rem; line-height: 1.35; }
.thumb:hover .cap { color: var(--primary); }

/* --------------------------------------------------------------- detail */

.detail-head { margin-bottom: 22px; }
.detail-head .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-bottom: 8px; color: var(--muted); font-size: 0.9rem; }
.detail-head h1 { max-width: 34ch; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.prose { max-width: 72ch; }
.prose h2, .prose h3 { margin: 1.4em 0 0.5em; }
.doc h1, .doc h2, .doc h3, .doc h4 { scroll-margin-top: 80px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 0.8em; }
.prose table { border-collapse: collapse; margin: 0.6em 0 1em; font-size: 0.9rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose img { border: 1px solid var(--line); border-radius: var(--radius-s); }
.prose blockquote { margin: 0 0 1em; padding: 4px 14px; border-left: 3px solid var(--line-strong); color: var(--ink-2); }

.story {
  font-size: 1.15rem; line-height: 1.5; max-width: 60ch; margin-bottom: 22px;
}
.story b { font-weight: 700; color: var(--muted); font-size: 0.95rem; }
.section { margin-top: 28px; }
.section > h2 { font-size: 1.05rem; margin-bottom: 10px; }

.criteria { counter-reset: ac; list-style: none; padding: 0; margin: 0; }
.criteria li { border-top: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 4em 1fr; gap: 12px; }
.criteria dl { margin: 0; display: grid; grid-template-columns: 5.5em 1fr; gap: 2px 10px; }
.criteria dt { color: var(--muted); font-size: 0.88rem; }
.criteria dd { margin: 0; }

.fields-table td.small { font-size: 0.85rem; color: var(--ink-2); }
.dep { font-size: 0.8rem; color: var(--muted); display: block; }

.side { display: flex; flex-direction: column; gap: 22px; position: sticky; top: 72px; }
.side section h2 { font-size: 0.88rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.link-list { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.link-list li { padding: 4px 0; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: baseline; }
.link-list a { color: var(--ink); text-decoration: none; }
.link-list a:hover { color: var(--primary); text-decoration: underline; }
.link-group + .link-group { margin-top: 10px; }
.link-group h3 { font-size: 0.82rem; color: var(--ink-2); font-weight: 600; }
.quote { border-left: 3px solid var(--st-to_validate); padding: 2px 0 2px 12px; color: var(--ink-2); font-size: 0.92rem; margin: 8px 0; }
.mini-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mini-gallery button { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: zoom-in; overflow: hidden; aspect-ratio: 16/11; }
.mini-gallery img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }

.asset-view img { border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; cursor: zoom-in; }
.asset-view figure { margin: 0 0 20px; }

/* lightbox */
.lightbox { border: 0; padding: 0; max-width: 96vw; max-height: 96vh; background: transparent; }
.lightbox::backdrop { background: rgb(8 12 18 / 0.82); }
.lightbox img { max-width: 94vw; max-height: 86vh; display: block; background: #fff; border-radius: var(--radius-s); }
.lightbox .lb-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #e6ebf0; padding: 8px 2px; }
.lightbox .lb-bar button { background: transparent; color: inherit; border: 1px solid #5d6a78; border-radius: var(--radius-s); padding: 4px 10px; cursor: pointer; }

/* ---------------------------------------------------------------- forms */

.form { display: flex; flex-direction: column; gap: 18px; max-width: 860px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field > .label { font-weight: 600; font-size: 0.9rem; }
.field .hint { font-size: 0.8rem; color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface);
}
.field textarea { min-height: 7em; resize: vertical; line-height: 1.5; }
.field textarea.md { min-height: 14em; font-family: var(--mono); font-size: 0.88rem; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: 0.82rem; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px 14px; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: 0.9rem; padding: 0 6px; }
.repeat-item { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.repeat-item:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.repeat-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--muted); }
.link-picker { display: flex; flex-direction: column; gap: 6px; position: relative; }
.link-picker .tokens { display: flex; flex-wrap: wrap; gap: 4px; }
.token a { white-space: nowrap; }
.token { display: inline-flex; gap: 6px; align-items: center; padding: 2px 4px 2px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.82rem; background: var(--surface); }
.token button { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 0 4px; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 10; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s); max-height: 240px; overflow-y: auto; margin-top: 2px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); }
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 10px; cursor: pointer; font-size: 0.88rem; }
.suggest button:hover, .suggest button.active { background: var(--primary-soft); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.preview { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; background: var(--surface); min-height: 14em; }
.form-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; }

/* ----------------------------------------------------------------- trace */

.trace-wrap { position: relative; overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.trace { border-collapse: separate; border-spacing: 0; font-size: 0.82rem; }
.trace th, .trace td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 4px 6px; }
.trace thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; height: 9em; font-weight: 600; }
.trace tbody th { position: sticky; left: 0; background: var(--surface); text-align: left; font-weight: 400; white-space: nowrap; z-index: 1; max-width: 26em; overflow: hidden; text-overflow: ellipsis; }
.trace td { text-align: center; min-width: 26px; }
.trace td.hit::after { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--primary); transform: rotate(45deg); border-radius: 1px; }
.trace tr.uncovered th { color: var(--danger); }

/* -------------------------------------------------------------- palette */

.palette { border: 0; padding: 0; width: min(640px, 94vw); border-radius: var(--radius-m); background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgb(0 0 0 / 0.3); margin-top: 10vh; }
.palette::backdrop { background: rgb(8 12 18 / 0.5); }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; font-size: 1.05rem; background: transparent; outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow-y: auto; }
.palette li a { display: grid; grid-template-columns: 8.5em 1fr; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
.palette li a.active, .palette li a:hover { background: var(--primary-soft); }
.palette .snippet { grid-column: 2; color: var(--muted); font-size: 0.84rem; }
.palette .hint { padding: 10px 16px; color: var(--muted); font-size: 0.85rem; }


/* ----------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .dash-block { grid-column: span 12; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; background: var(--bg); transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgb(8 12 18 / 0.45); }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 48px; }
  .list-layout { grid-template-columns: minmax(0, 1fr); }
  .facets { position: static; flex-direction: row; flex-wrap: wrap; gap: 12px 24px; }
  .search-trigger kbd { display: none; }
  .search-trigger { min-width: 0; }
  .search-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar { gap: 8px; }
  .btn.reload { display: none; }
  .mobile-only { display: block; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .dash-block, .dash-block.wide { grid-column: auto; }
  .rows li { grid-template-columns: 1fr auto; }
  .rows li .id { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  /* Phones: the search gets its own full-width row below menu, sync and user. */
  .topbar { flex-wrap: wrap; }
  .search-trigger { order: 10; flex: 1 0 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
