/* Cogs app chrome. A tool, not a graphic: it borrows the house palette and type from
   the engine's design/tokens.css but keeps its own denser layout. Self-hosted font only. */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/engine/vendor/fonts/ibm-plex-sans/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: italic; font-display: swap; src: url("/engine/vendor/fonts/ibm-plex-sans/IBMPlexSans-Italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/engine/vendor/fonts/ibm-plex-sans/IBMPlexSans-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("/engine/vendor/fonts/ibm-plex-sans/IBMPlexSans-Bold.woff2") format("woff2"); }

:root {
  --font: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ink: #0c0c0c;            /* house ink */
  --ink-2: #3d3d3d;          /* 10.9:1 */
  --muted: #5f5f5f;          /* 6.4:1 on white, 5.9:1 on --bg-alt */
  --focus: #1f5fd6;          /* house focus, 5.7:1 */
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --bg-app: #efefed;
  --frame: #52514e;          /* house frame grey; white text 7.9:1 */
  --rule: #dcdcdc;
  --rule-strong: #b5b5b2;
  --blue: #2d5bb3;           /* darker step of house cat-1 for text: 6.4:1 */
  --blue-tint: #e0ecfe;
  --teal: #00675f;           /* darker step of house cat-2 for text: 6.9:1 */
  --teal-tint: #dcf2ef;
  --red: #a3401f;            /* darker step of house terracotta: 6.3:1 */
  --red-tint: #fbe7e0;
  --amber-ink: #6b4f00;      /* on amber tint: 7.4:1 */
  --amber-tint: #fdf1cc;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius: 4px;
  --header-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--bg-app); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 var(--space-3); }
a { color: var(--blue); }
a:hover { color: var(--ink); }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--bg-alt); padding: var(--space-3); border-radius: var(--radius); margin: 0 0 var(--space-3); max-height: 420px; overflow: auto; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1[tabindex="-1"]:focus, main:focus { outline: none; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: var(--space-2); top: -60px; background: var(--ink); color: #fff; padding: var(--space-2) var(--space-3); z-index: 100; border-radius: var(--radius); }
.skip-link:focus { top: var(--space-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre-text { white-space: pre-wrap; word-break: break-word; }
.unsafe-url { font-family: var(--mono); font-size: 13px; color: var(--red); }

/* ---------- Header ---------- */
.app-header { height: var(--header-h); background: var(--frame); color: #fff; display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--space-4); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 18px; color: #fff; text-decoration: none; letter-spacing: 0.02em; display: flex; align-items: center; gap: var(--space-2); }
.brand-mark { width: 22px; height: 22px; border: 3px dotted #fff; border-radius: 50%; display: inline-block; }
.app-nav { display: flex; gap: var(--space-1); flex: 1; min-width: 0; overflow-x: auto; }
.app-nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: var(--radius); white-space: nowrap; }
.app-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.app-nav a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 600; }
.app-nav .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; background: var(--amber-tint); color: var(--amber-ink); border-radius: 10px; font-size: 12px; font-weight: 600; text-align: center; }
.user-menu { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.user-menu .role { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; background: rgba(255, 255, 255, 0.16); padding: 2px 6px; border-radius: 3px; }
.user-menu a, .user-menu button { color: #fff; }
.app-header .btn-ghost { color: #fff; border-color: transparent; }
.app-header .btn-ghost:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

main { display: block; }
.page { max-width: 1200px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.page-head { display: flex; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.page-head h1 { margin: 0; flex: 1; }
.panel-box { background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-4); }
.banner { padding: var(--space-3) var(--space-4); border-radius: var(--radius); margin-bottom: var(--space-4); border: 1px solid; }
.banner-warn { background: var(--amber-tint); color: var(--amber-ink); border-color: #e0c370; }
.banner-info { background: var(--blue-tint); color: #1c2f62; border-color: #b9cff5; }
.banner-error { background: var(--red-tint); color: #5d1416; border-color: #f0bfae; }
.banner-ok { background: var(--teal-tint); color: #003d38; border-color: #a8dcd5; }

/* ---------- Controls ---------- */
.btn { font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; padding: 8px 14px; min-height: 36px; border-radius: var(--radius); border: 1px solid var(--rule-strong); background: var(--bg); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { background: var(--bg-alt); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); }
a.btn-primary, a.btn-primary:hover { color: #fff; }
.btn-approve { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-approve:hover { background: #004f49; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #7f2f15; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn[aria-busy="true"]::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-top: var(--space-3); }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 5px 10px; border: 0; background: var(--bg); color: var(--ink); cursor: pointer; min-height: 30px; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 600; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], input[type="date"], select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid #8c8c8c; border-radius: var(--radius); padding: 7px 10px; width: 100%; min-height: 36px;
}
textarea { resize: vertical; line-height: 1.4; }
textarea.code { font-family: var(--mono); font-size: 13px; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.field { margin-bottom: var(--space-3); }
.field label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field .hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.check { display: flex; gap: var(--space-2); align-items: flex-start; font-size: 14px; margin: var(--space-2) 0; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.form-error { color: var(--red); font-weight: 600; font-size: 14px; }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 160px; }

/* ---------- Chips ---------- */
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; background: var(--bg-alt); color: var(--ink-2); border: 1px solid var(--rule); vertical-align: middle; }
.chip-draft { background: #ececea; color: var(--ink-2); }
.chip-brief_approved { background: var(--blue-tint); color: #1c3f86; border-color: #b9cff5; }
.chip-draft_approved { background: var(--teal-tint); color: #003d38; border-color: #a8dcd5; }
.chip-published, .chip-live { background: var(--frame); color: #fff; border-color: var(--frame); }
.chip-proposed, .chip-pending, .chip-warn { background: var(--amber-tint); color: var(--amber-ink); border-color: #ecd486; }
.chip-approved { background: var(--teal-tint); color: #003d38; border-color: #a8dcd5; }
.chip-rejected, .chip-revoked, .chip-error { background: var(--red-tint); color: #5d1416; border-color: #f0bfae; }
.chip-superseded, .chip-withdrawn, .chip-stale, .chip-dropped { background: #ececea; color: var(--muted); }
.chip-answered { background: var(--teal-tint); color: #003d38; }
.chip-open { background: var(--amber-tint); color: var(--amber-ink); }
.chip-locked { background: #ececea; color: var(--ink-2); }
.chip-enabled { background: var(--teal-tint); color: #003d38; }
.chip-disabled { background: #ececea; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--bg); }
table.data th, table.data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-weight: 600; background: var(--bg-alt); color: var(--ink-2); position: sticky; top: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.md-table { margin: 8px 0; }
.md-table table.data { font-size: 13px; background: transparent; }
.md-table table.data th { position: static; }
table.data td.blank { background: repeating-linear-gradient(135deg, #f1f0ee 0 4px, #e3e1dd 4px 5px); color: var(--muted); font-style: italic; }
table.data td.symbol { background: var(--amber-tint); color: var(--amber-ink); }
table.compact th, table.compact td { padding: 4px 8px; font-size: 13px; }

/* ---------- Library ---------- */
.lib-tools { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--space-4); }
.lib-tools .field { margin: 0; }
.lib-tools .grow { flex: 1; min-width: 220px; }
.project-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-3); }
.project-card { background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: grid; grid-template-columns: minmax(0, 1fr) 132px; align-items: start; gap: var(--space-3); position: relative; }   /* the second column is exactly the picture's width: it used to be narrower, so the picture ran over the card's edge */
.project-card:hover { border-color: var(--rule-strong); }
.project-card:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.project-card h2 { font-size: 16px; margin: 0 0 4px; }
.project-card h2 a { color: var(--ink); text-decoration: none; }
.project-card h2 a::after { content: ""; position: absolute; inset: 0; }
/* Buttons sit above the stretched title link, or clicks open the project instead (10 Nov 2026 bug: Delete did nothing). */
.project-card .actions, .project-card button { position: relative; z-index: 1; }
.project-card h2 a:focus-visible { outline: none; }
.project-card .headline { font-size: 14px; color: var(--ink-2); margin: 0 0 var(--space-2); }
.project-card p.meta { margin: 6px 0 0; }
.grow { flex: 1; }
.project-card .meta { font-size: 13px; color: var(--muted); display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.thumb { display: block; width: 132px; height: 170px; box-sizing: border-box; border: 1px solid var(--rule); border-radius: calc(var(--radius) - 2px); background: var(--bg-alt); object-fit: cover; object-position: 50% 45%; }   /* the middle of the drawing: the chart, not the headline the card already shows */
.thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; }
.empty { text-align: center; padding: var(--space-6); color: var(--muted); background: var(--bg); border: 1px dashed var(--rule-strong); border-radius: var(--radius); }

/* ---------- Workspace ---------- */
.ws { position: relative; display: grid; grid-template-columns: minmax(340px, 0.8fr) minmax(420px, 1.4fr); grid-template-rows: auto 1fr; height: calc(100vh - var(--header-h)); min-height: 560px; }
.ws-head { grid-column: 1 / -1; display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-4); background: var(--bg); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.ws-head h1 { font-size: 18px; margin: 0; }
.ws-head .slug { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ws-head .spacer { flex: 1; }
.ws-col { min-height: 0; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--rule); }
.ws-col:last-child { border-right: 0; }
.ws-col > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--rule); }

/* Chat */
.chat { position: relative; }
.chat-log { flex: 1; overflow-y: auto; padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.msg { max-width: 92%; }
.msg-user { align-self: flex-end; }
.msg-assistant, .msg-system { align-self: flex-start; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg-user .who { text-align: right; }
.bubble { padding: var(--space-2) var(--space-3); border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.msg-user .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 2px; }
.msg-assistant .bubble { background: var(--bg-alt); border: 1px solid var(--rule); border-bottom-left-radius: 2px; }
.bubble + .bubble, .bubble + .tool, .tool + .bubble { margin-top: var(--space-1); }
.thinking { font-size: 13px; color: var(--muted); margin: 2px 0; }
.thinking summary { cursor: pointer; }
.thinking div { white-space: pre-wrap; padding: 4px 0 4px var(--space-3); border-left: 2px solid var(--rule); }
.tool { display: flex; gap: 6px; align-items: baseline; font-size: 13px; padding: 4px 8px; border-radius: var(--radius); background: #fafafa; border: 1px solid var(--rule); margin: 2px 0; }
.tool .tname { font-weight: 600; white-space: nowrap; }
.tool .tsum { color: var(--ink-2); }
.tool-running .tname::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 2px solid var(--blue); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; }
.tool-ok .tname::before { content: "✓ "; color: var(--teal); }
.tool-err { background: var(--red-tint); border-color: #f0bfae; }
.tool-err .tname::before { content: "✕ "; color: var(--red); }
.event-card { border: 1px solid var(--rule-strong); background: var(--bg); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: var(--space-1) 0; font-size: 14px; }
.event-card h3 { font-size: 14px; margin: 0 0 4px; }
.chat-error { background: var(--red-tint); color: #5d1416; border-radius: var(--radius); padding: var(--space-2) var(--space-3); font-size: 14px; }
.attach-chip { font-size: 13px; display: inline-flex; gap: 4px; align-items: center; background: var(--blue-tint); color: #1c2f62; border-radius: 12px; padding: 2px 4px 2px 10px; }
.attach-chip button { border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; color: inherit; border-radius: 50%; }
.composer { border-top: 1px solid var(--rule); padding: var(--space-2) var(--space-3) var(--space-3); background: var(--bg); }
.composer textarea { min-height: 64px; max-height: 200px; }
.composer .attachments { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-2); }
.composer .actions { margin-top: var(--space-2); justify-content: space-between; }
.dropzone-active::after { content: "Drop files to upload"; position: absolute; inset: 8px; display: flex; align-items: center; justify-content: center; border: 3px dashed var(--blue); background: rgba(224, 236, 254, 0.92); font-weight: 600; font-size: 18px; color: #1c2f62; border-radius: 8px; z-index: 5; pointer-events: none; }

/* Preview */
.preview-bar { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.preview-bar select { width: auto; min-height: 30px; padding: 3px 8px; font-size: 14px; }
.preview-stage { flex: 1; overflow: auto; background: #e9eef8; padding: var(--space-4); display: flex; flex-direction: column; align-items: safe center; gap: var(--space-2); }
.preview-banner { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber-ink); background: var(--amber-tint); padding: 3px 10px; border-radius: 3px; }
.preview-frame { border: 0; outline: 1px solid var(--rule-strong); background: #fff; display: block; height: 640px; flex: none; }   /* never narrower than the width chosen above it: the stage scrolls instead */
.preview-blocked { max-width: 600px; width: 100%; background: var(--bg); border: 1px solid var(--rule); padding: var(--space-4); }
.preview-issues { border-top: 1px solid var(--rule); max-height: 32%; overflow-y: auto; padding: var(--space-2) var(--space-3); }
.preview-issues h3 { font-size: 13px; margin-bottom: var(--space-2); }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.issue { display: grid; grid-template-columns: auto 1fr; column-gap: var(--space-2); font-size: 13px; padding: 4px 6px; border-radius: 3px; background: #fafafa; }
.issue .issue-meta { grid-column: 2; color: var(--muted); font-size: 12px; font-family: var(--mono); word-break: break-all; }
.lvl { font-weight: 700; font-size: 11px; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; align-self: start; margin-top: 1px; }
.lvl-error { background: var(--red); color: #fff; }
.lvl-warning { background: var(--amber-tint); color: var(--amber-ink); border: 1px solid #ecd486; }
.lvl-info { background: var(--blue-tint); color: #1c2f62; }

/* Right panel tabs */
.tabs { display: flex; border-bottom: 1px solid var(--rule); overflow-x: auto; flex: none; }
.tabs [role="tab"] { font: inherit; font-size: 13px; font-weight: 600; padding: 10px 7px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; background: var(--amber-tint); color: var(--amber-ink); border-radius: 9px; font-size: 11px; }
.tabpanel { flex: 1; overflow-y: auto; padding: var(--space-3); }
.tabpanel h3 { margin-top: var(--space-4); }
.tabpanel h3:first-child { margin-top: 0; }
.card { border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-3); background: var(--bg); }
.card-head { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; margin-bottom: var(--space-2); }
.card-head h4 { margin: 0; font-size: 14px; flex: 1; min-width: 0; word-break: break-word; }
.reading { background: var(--bg-alt); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0; white-space: pre-wrap; }
.reading-label { font-weight: 600; font-size: 13px; color: var(--blue); }
.flags { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0; }
.flag { font-size: 12px; padding: 1px 6px; border-radius: 3px; background: var(--amber-tint); color: var(--amber-ink); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--space-3); font-size: 14px; margin: 0; }
.kv dt { font-weight: 600; color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-word; }
.vlist { list-style: none; margin: 0; padding: 0; }
.vlist li { border-bottom: 1px solid var(--rule); padding: var(--space-2) 0; }
.vlist .vrow { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.vlist .vnum { font-weight: 700; font-variant-numeric: tabular-nums; }
.vlist .current { background: #f8fbff; }
.diff-sum { list-style: none; margin: 0 0 var(--space-3); padding: 0; font-size: 14px; }
.diff-sum li { padding: 3px 0 3px var(--space-3); border-left: 3px solid var(--blue); margin-bottom: 3px; }
.op-add { color: var(--teal); } .op-remove { color: var(--red); } .op-replace { color: var(--blue); }

/* ---------- Dialog ---------- */
dialog.dialog { border: 0; border-radius: 6px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); color: var(--ink); }
dialog.dialog-wide { width: min(820px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(12, 12, 12, 0.5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.dialog-head h2 { margin: 0; }
.dialog-close { font-size: 22px; padding: 2px 10px; }
.dialog-body { padding: var(--space-4); }
.confirm-headline { font-weight: 700; font-size: 17px; background: var(--bg-alt); padding: var(--space-2) var(--space-3); border-radius: var(--radius); }
.pub-result { border: 2px solid var(--frame); border-radius: var(--radius); padding: var(--space-3); }
.pub-result .big { font-size: 22px; font-weight: 700; margin-bottom: var(--space-2); }
.pub-result > :last-child, .pub-result .embed-box > :last-child { margin-bottom: 0; }
/* Publish dialog: one column of steps divided by rules, not cards inside a dialog */
.pub-dialog > .pub-step { border: 0; border-top: 1px solid var(--rule); border-radius: 0; box-shadow: none; background: none; padding: var(--space-5) 0 0; margin: var(--space-5) 0 0; }
.pub-dialog > .pub-state + .pub-step { border-top: 0; padding-top: 0; margin-top: var(--space-3); }
.pub-dialog .pub-step h3 { font-size: 17px; font-weight: 700; margin-bottom: var(--space-3); }
.pub-dialog > .pub-history { margin-top: var(--space-5); }
.pub-state { font-weight: 600; color: var(--muted); margin: 0; }
.pub-approved { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin-top: var(--space-1); color: var(--muted); }
.pub-approved .btn { margin-left: auto; color: var(--blue); }
.pub-lead { margin-bottom: var(--space-2); }
.pub-headline { font-weight: 700; font-size: 17px; }
.pub-warnings { margin-bottom: var(--space-3); }
.pub-actions .pub-gate { flex: 1 1 220px; margin: 0; color: var(--muted); }
.pub-actions .pub-gate[data-state="ready"] { color: var(--teal); font-weight: 600; }
.embed-box .field { margin-top: var(--space-3); margin-bottom: 0; }
.embed-box .actions { margin: var(--space-2) 0 var(--space-3); }
.embed-box textarea.code { word-break: break-all; }
.btn.is-done, .btn.is-done:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
@media (pointer: coarse) { .pub-dialog .btn { min-height: 44px; } }
@media (max-width: 700px) {
  .pub-dialog .pub-actions .btn-danger { flex: 1 1 auto; justify-content: center; }
  .pub-actions .pub-gate { flex-basis: 100%; order: -1; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); z-index: 1000; max-width: 380px; }
.toast { background: var(--ink); color: #fff; padding: var(--space-3) var(--space-4); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); font-size: 14px; }
.toast-error { background: #7f2f15; }
.toast-ok { background: #004f49; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.login-card { background: var(--bg); border-top: 6px solid var(--frame); width: min(400px, 100%); padding: var(--space-6) var(--space-5); border-radius: var(--radius); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); }
.login-card .brand { color: var(--ink); margin-bottom: var(--space-5); font-size: 22px; }
.login-card .brand-mark { border-color: var(--ink); }
#login-help { margin-top: var(--space-5); }

/* ---------- Admin ---------- */
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: var(--space-4); align-items: start; }
.rule-list { list-style: none; margin: 0; padding: 0; background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); }
.rule-list li + li { border-top: 1px solid var(--rule); }
.rule-list a { display: block; padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--ink); }
.rule-list a[aria-current="true"] { background: var(--blue-tint); }
.rule-list .rk { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.char-count { font-size: 12px; color: var(--muted); text-align: right; }
.char-count.over { color: var(--red); font-weight: 700; }
.test-result { border-top: 1px solid var(--rule); margin-top: var(--space-3); padding-top: var(--space-3); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1180px) {
  .ws { grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr); }
}
@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .ws { grid-template-columns: minmax(0, 1fr); min-height: 480px; }      /* one pane at a time: .ws-switch picks it */
  .ws.show-chat > .preview, .ws.show-preview > .chat { display: none; }
  .ws-switch { display: inline-flex; }
  .ws-col > h2, .ws-head .slug { display: none; }
  .app-header { gap: var(--space-2); }
  .user-menu .name { display: none; }
}

/* ---------- Approved sources, fetched datasets, calculations (DECISIONS #2, #10) ---------- */
.chip-tier { font-weight: 600; }
.chip-tier-government { background: var(--teal-tint); color: #003d38; }
.chip-tier-semi_state { background: var(--blue-tint); color: #1c2f62; }
.chip-tier-international_official { background: var(--bg-alt); color: var(--ink-2); border: 1px solid var(--rule-strong); }
.chip-tier-other_approved { background: var(--amber-tint); color: var(--amber-ink); }
.provenance { background: var(--bg-alt); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0 var(--space-3); border-radius: var(--radius); }
.provenance p { margin: 0 0 var(--space-1); }
.provenance .prov-url { word-break: break-all; }
.calc-card .method { font-weight: 600; background: var(--blue-tint); color: #1c2f62; padding: var(--space-2) var(--space-3); border-radius: var(--radius); }
.calc-card td.calc-out, .calc-card th.calc-out { background: var(--blue-tint); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--space-3); margin: var(--space-2) 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
ol.history li { margin-bottom: var(--space-3); }

/* ---------- Markdown in chat bubbles (markdown.js: safe subset, DOM nodes only) ---------- */
.bubble.md, .thinking div.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 var(--space-1); }
.md ul, .md ol { margin: 0 0 var(--space-1); padding-left: 1.4em; }
.md li + li { margin-top: 2px; }
.md code { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 0.92em; background: rgba(0, 0, 0, 0.06); padding: 0 3px; border-radius: 3px; }
.md pre { white-space: pre-wrap; background: rgba(0, 0, 0, 0.05); padding: var(--space-1) var(--space-2); border-radius: var(--radius); margin: 0 0 var(--space-1); }
.md pre code { background: none; padding: 0; }
.md .md-heading { margin-top: var(--space-1); }

/* ---------- Data plan card, rearranged tables (DECISIONS #2 addendum) ---------- */
.card-plan .plan-head h3 { margin-bottom: 2px; }
.card-plan .plan-head .btn { margin: 4px 0 var(--space-1); }
.card-plan .plan-item + .plan-item { border-top: 1px solid var(--rule); margin-top: var(--space-1); padding-top: var(--space-1); }
.plan-done { margin: 2px 0; }
.lineage { color: var(--muted); }
.before-after { display: grid; grid-template-columns: 1fr; gap: var(--space-1); }
.before-after .table-wrap { max-width: 100%; overflow-x: auto; }

/* Review panel (DECISIONS #12): everything outstanding for the current draft, beside the preview */
.chip-not-checked { background: var(--amber-tint); color: var(--amber-ink); border-color: #ecd486; }
.chip-not-checked[hidden] { display: none; }
.review-head { margin-bottom: var(--space-3); }
.review-count { font-weight: 600; margin: 0 0 2px; }
.review-head .btn { margin-top: var(--space-1); }
.review-section { margin: var(--space-3) 0; }
.review-section > h3 { font-size: 14px; margin: 0 0 var(--space-2); }
.review-item { border: 1px solid #e0c370; border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-2); background: var(--bg); }
.review-item h4 { font-size: 14px; margin: 0 0 4px; }
.review-item.review-rearranged { border-color: #a8dcd5; }
.review-item.review-check { border-color: #f0bfae; }
.review-item .method { margin: 0 0 4px; }
.review-q { margin: 0 0 4px; font-weight: 600; }
.review-answer { margin: 0 0 var(--space-2); }
.review-answer .row input { flex: 1; }
.review-send-form textarea { width: 100%; }
.event-card.card-review { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ---------- Details drawer (the summary column was removed in DECISIONS #19) ---------- */
.ws-col.side { position: relative; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; background: var(--amber-tint); color: var(--amber-ink); border-radius: 9px; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.side-detail { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.detail-head { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-start; padding: 4px var(--space-2); border-bottom: 1px solid var(--rule); background: var(--bg-alt); }
.detail-head h2 { font-size: 15px; margin: 0; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-head h2:focus { outline: none; }
.detail-head h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.side-detail .tabpanel { padding-top: var(--space-3); }
.evidence { margin: 4px 0 0; }
.evidence > summary { cursor: pointer; color: var(--blue); }
.evidence[open] > summary { margin-bottom: var(--space-2); }
.card-line { margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-item .actions { margin-top: 4px; }
.review-item .calc-card .card-head { margin-bottom: 2px; }
.review-item .calc-card > .card-head { display: none; }   /* the item line already names it; status is "waiting" by definition */
.review-correct { margin-top: 4px; }
.notes-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.notes-compare p { margin: 0 0 4px; }

/* Data tables: a page of rows, titles that don't wrap, long cells cut with an ellipsis (full text in the title) */
.dt { margin: var(--space-2) 0; }
.dt-head { display: flex; gap: var(--space-2); align-items: baseline; }
.dt-caption { color: var(--muted); }
.dt-constant { margin: 2px 0 4px; color: var(--ink-2); }
.dt-const { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-wide .dt-const { white-space: normal; }
.dt-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
table.dt-table { width: auto; min-width: 100%; table-layout: auto; }
table.dt-table th, table.dt-table td { white-space: nowrap; vertical-align: top; }
.dt-cell { display: block; max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num .dt-cell { margin-left: auto; }
.dt-wide .dt-cell { max-width: 28em; }
.dt-wide .dt-wrap { max-height: 70vh; overflow: auto; }
.dt-pager { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: 4px; }
.dt-pager .dt-range { margin-right: auto; }
.dt-pager .btn { min-height: 26px; padding: 2px 8px; }

/* Chat: one activity row per turn, one approach disclosure, compact one-line notes */
.activity { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); margin: 2px 0 var(--space-1); }
.activity-spin { width: 10px; height: 10px; border: 2px solid var(--blue); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
.activity-now { font-weight: 600; }
.activity-step { color: var(--muted); }
.activity-done { font-size: 13px; color: var(--muted); }
.activity-done summary { cursor: pointer; }
.activity-list { margin: 4px 0 0; padding-left: 1.6em; color: var(--ink-2); }
.activity-list .step-note { color: var(--muted); }
/* the sources a turn opened (owner, 27 Nov 2026): open while Cogs works, then one line, a click away */
.sources { font-size: 13px; color: var(--muted); margin: 2px 0 var(--space-1); }
.sources > summary { cursor: pointer; }
.sources-title { color: var(--ink-2); font-weight: 600; }
.source-list { list-style: none; margin: 6px 0 2px 4px; padding: 2px 0 2px 12px; border-left: 2px solid var(--rule); display: grid; gap: 8px; }
.source { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; align-items: start; animation: source-in 0.2s ease-out; }
.source-mark { width: 16px; height: 16px; margin-top: 1px; fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.source-file .source-mark { stroke: var(--blue); }
.source-body { display: flex; flex-direction: column; min-width: 0; }
.source-title { color: var(--ink); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
a.source-title { text-decoration: none; }
a.source-title:hover, a.source-title:focus-visible { text-decoration: underline; }
.source-meta { font-size: 12px; color: var(--muted); }
.source-results { list-style: none; margin: 3px 0 0; padding: 0; font-size: 12px; display: grid; gap: 1px; }
.source-results a { color: var(--ink-2); text-decoration: none; overflow-wrap: anywhere; }
.source-results a:hover, .source-results a:focus-visible { text-decoration: underline; }
.sources-foot { margin: 6px 0 0 18px; }
.sources-foot .btn { min-height: 26px; padding: 2px 8px; }
@keyframes source-in { from { opacity: 0; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .source { animation: none; } }
.event-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); font-size: 13px; padding: 2px 0; margin: var(--space-1) 0; }
.event-line .btn { min-height: 26px; padding: 2px 8px; }

/* Preview: checks folded into one line */
.preview-issues { max-height: 40%; }
.preview-checks > summary { cursor: pointer; font-size: 13px; font-weight: 600; padding: 2px 0; }
.preview-checks[open] > summary { margin-bottom: var(--space-2); }

/* "Cogs was updated — reload" */
.update-banner { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 900; display: flex; align-items: center; gap: var(--space-2); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 4px 4px 4px var(--space-3); font-size: 13px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }

/* New chart forms (DECISIONS #14): code shown as text, collapsed; the Forms library screen */
.form-code summary { cursor: pointer; font-size: .875rem; }
.form-code pre.code { max-height: 24rem; overflow: auto; background: var(--surface-alt, #f5f5f5); padding: var(--space-3); border-radius: var(--radius); font-size: .8125rem; line-height: 1.45; white-space: pre; }
.form-checks ul { margin: var(--space-2) 0 0; padding-left: 1.2em; }
.forms-layout { display: grid; grid-template-columns: minmax(14rem, 1fr) 2fr; gap: var(--space-4); align-items: start; }
.forms-list { display: grid; gap: var(--space-3); }
.forms-item ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.preview-new-form { margin: var(--space-2) 0; }
@media (max-width: 760px) { .forms-layout { grid-template-columns: 1fr; } }


/* ---------- DECISIONS #19: no right-hand column; the action bar and the detail drawer ---------- */
.ws-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.ws-nav .btn.active { background: var(--bg-alt); font-weight: 600; }
.ws-nav .badge { margin-left: 4px; }
.action-bar { border-top: 1px solid var(--rule); background: var(--bg-alt); padding: var(--space-2) var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.action-bar[hidden] { display: none; }
.ab-status { margin: 0; font-weight: 600; font-size: 14px; }
.ab-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.ab-actions .btn-primary { min-height: 34px; }
.ws-col.side-drawer { grid-row: 2; grid-column: 1 / -1; position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 20; border-left: 1px solid var(--rule); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12); }
.ws-col.side-drawer[hidden] { display: none; }
.detail-head .spacer { flex: 1; }

/* ---------- Chart library (DECISIONS #24) ---------- */
.chart-cats { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.chart-cats .btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chart-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: var(--space-4); }
.chart-card { background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.chart-card-head { display: flex; gap: var(--space-2); align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.chart-card h2 { margin: 0; font-size: 17px; }
.chart-card p { margin: 0; }
.chart-media { border: 1px solid var(--rule); background: #fff; border-radius: var(--radius); overflow: hidden; min-height: 120px; }
.chart-sample { display: block; width: 100%; height: auto; }
.chart-sample-empty { padding: var(--space-4); text-align: center; }
.chart-needs ul { margin: var(--space-1) 0 0; padding-left: 1.2em; }
.chart-use { margin-top: auto; border-top: 1px solid var(--rule); padding-top: var(--space-2); display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.chart-hint q { font-weight: 600; }
.house-status ul { margin: var(--space-1) 0 0; padding-left: 1.2em; }

/* Ways to show it (DECISIONS #27): suggested displays drawn from the project's own rows */
.advice { display: flex; flex-direction: column; gap: var(--space-3); }
.advice-grid { grid-template-columns: 1fr; }
.advice-card h3 { margin: 0; font-size: 16px; }
.advice-media { min-height: 160px; }
.advice-notes { margin: 0; padding-left: var(--space-4); }
.advice-own { display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-start; }
.advice-own textarea { width: 100%; }

/* Final check (DECISIONS #30) */
.final { display: flex; flex-direction: column; gap: var(--space-3); }
.final h3 { margin: var(--space-2) 0 0; }
.final-list { margin: 0; padding-left: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.final-ask { font-weight: 600; margin: 0; }
.final-gap { color: var(--ink); }
.final-problems { border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-3); }
.final-done { font-weight: 600; margin: 0; }
.final h4 { margin: var(--space-2) 0 0; font-size: 14px; }
.final-level { margin: 0; padding: var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius); }
.final-level-high { background: #e9f5ed; border-color: #a5d0b3; }
.final-level-moderate { background: var(--amber-tint); border-color: #e0c370; }
.final-level-low { background: var(--red-tint); border-color: #f0bfae; }
.final-checks .chip-ok { background: #e3f1e8; }
.chip-limit { background: #fbeed3; }
.final-checks .chip-problem, .chip-problem { background: #f7dcd9; }
.chip-ok { background: #e3f1e8; }
.ab-others { display: flex; flex-direction: column; gap: 4px; padding-top: var(--space-2); border-top: 1px solid var(--rule); }
.ab-others-label { margin: 0; font-size: 12px; color: var(--muted); }
.ab-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ab-chip { min-height: 32px; font-weight: 500; background: var(--bg); }
.action-bar .ab-link { min-height: 32px; text-decoration: underline; text-underline-offset: 2px; padding-left: 6px; padding-right: 6px; }
.action-bar .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.advice-draft { display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-start; }
.advice-draft p { margin: 0; }
.final-concerns { border: 1px solid #e0c370; border-radius: var(--radius); padding: var(--space-3); }
.final-concerns p { margin: 0 0 var(--space-2); }
.final-all > summary { font-weight: 600; }


/* The final check is a card in the conversation, not a side panel */
.chat-card { align-self: stretch; background: var(--bg); border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: var(--space-3); }
.chat-card-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.chat-card-head h3 { margin: 0; font-size: 1rem; }
.chat-card-head .spacer { flex: 1; }

/* ---------- Cogs theme (15 Nov 2026): brighter, sharper, rounder; the person is using Cogs ---------- */
:root {
  --bg-app: #f3f6fc;
  --bg-alt: #f0f3fa;
  --frame: #0f1b3d;           /* deep navy header; white text 16:1 */
  --ink: #0b1220;
  --ink-2: #2b3550;
  --muted: #55607a;           /* 6.1:1 on white */
  --rule: #e1e6f0;
  --rule-strong: #b9c2d6;
  --blue: #1d4fd8;            /* 6.6:1 on white */
  --blue-tint: #e6eeff;
  --accent: #2f6bff;          /* bright accent for fills and highlights (white text 4.6:1 on --accent-ink) */
  --accent-ink: #1d4fd8;
  --teal: #00705f;
  --teal-tint: #ddf6ef;
  --radius: 8px;
  --shadow-1: 0 1px 2px rgba(15, 27, 61, .06), 0 1px 3px rgba(15, 27, 61, .08);
  --shadow-2: 0 4px 16px rgba(15, 27, 61, .10);
  --focus: #2f6bff;
}
body { background: var(--bg-app); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { letter-spacing: -0.01em; }
.app-header { background: linear-gradient(90deg, #0f1b3d 0%, #172a5c 100%); box-shadow: 0 2px 10px rgba(15, 27, 61, .25); }
.brand { font-size: 20px; letter-spacing: -0.01em; }
.brand-mark { border-color: #6ea0ff; box-shadow: 0 0 0 2px rgba(110, 160, 255, .25); }
.app-nav a { border-radius: 999px; padding: 6px 12px; font-weight: 500; opacity: .92; }
.app-nav a:hover { opacity: 1; }
.app-nav a[aria-current="page"] { background: #fff; color: var(--frame); font-weight: 600; opacity: 1; }
.user-menu .role { border-radius: 999px; background: rgba(110, 160, 255, .22); }

.btn { border-radius: 999px; padding: 8px 16px; box-shadow: var(--shadow-1); transition: background .15s, box-shadow .15s, transform .05s; }
.btn:hover { box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-primary:hover { background: #163fb0; }
.btn-ghost { box-shadow: none; }
.btn-small { padding: 4px 12px; }
.seg { border-radius: 999px; }
.seg button[aria-pressed="true"] { background: var(--accent-ink); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], input[type="date"], select, textarea { border-color: var(--rule-strong); border-radius: var(--radius); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 107, 255, .2); outline: none; }

.panel-box, .project-card, .event-card, .chat-card { box-shadow: var(--shadow-1); border-color: var(--rule); }
.project-card:hover { box-shadow: var(--shadow-2); border-color: var(--rule-strong); }
.chip { border-radius: 999px; }
.chip-published, .chip-live { background: var(--accent-ink); border-color: var(--accent-ink); }

.ws-head { background: #fff; box-shadow: 0 1px 0 var(--rule); }
.ws-col { background: #fff; }
.ws-col > h2 { color: var(--accent-ink); font-weight: 700; background: #f7f9ff; text-transform: none; letter-spacing: 0; }
.chat-log { background: #fafbff; gap: var(--space-3); }
.bubble { border-radius: 16px; line-height: 1.5; }
.msg-user .bubble { background: var(--accent-ink); border-bottom-right-radius: 4px; box-shadow: var(--shadow-1); }
.msg-assistant .bubble { background: #fff; border: 1px solid var(--rule); border-bottom-left-radius: 4px; box-shadow: var(--shadow-1); }
.msg .who { font-weight: 600; letter-spacing: .02em; }
.msg-assistant .who { color: var(--accent-ink); }
.chat-card { border-color: #a9c1ff; border-radius: var(--radius); }
.composer { background: #fff; border-top: 1px solid var(--rule); box-shadow: 0 -4px 12px rgba(15, 27, 61, .05); }
.action-bar { background: linear-gradient(#f6f8ff, #eef3ff); border-color: var(--rule); }
.table-wrap, table.data { border-radius: var(--radius); }
table.data th { background: #eef2fb; }
.banner { border-radius: var(--radius); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

.chat.final-open .action-bar { display: none; }

/* Renaming a project in place (19 Nov 2026) */
.title-block { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.title-edit { font-size: 16px; line-height: 1; padding: 4px 6px; color: var(--muted); }
.title-edit:hover { color: var(--ink); }
.title-input { font: inherit; font-size: 20px; font-weight: 700; padding: 2px 6px; min-width: 14em; max-width: 100%; }


/* Adjust a zone or route by hand (DECISIONS #87) */
.shape-editor-map { height: min(62vh, 560px); min-height: 320px; border: 1px solid var(--line, #d0d0d0); border-radius: 6px; margin: 8px 0; }
.shape-editor-map .maplibregl-canvas { outline: none; }
/* drawing a zone by hand (DECISIONS #101): the chosen tool reads as pressed */
.zone-draw-tools { flex-wrap: wrap; margin-top: 6px; }
.zone-draw-tools .btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.zone-draw-map .maplibregl-canvas { touch-action: none; }
.preview-adjust { position: relative; display: inline-flex; }

/* Map shapes drawer beside the chat (DECISIONS #87) */
.shapes-toggle-bar { padding: 6px 12px 0; }
.shapes-toggle .chip { margin-left: 4px; }
.shapes-drawer { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--bg, #fff);
  border-right: 1px solid var(--line, #d0d0d0); box-shadow: 4px 0 18px rgba(0,0,0,.12); }
.shapes-drawer[hidden] { display: none; }
.shapes-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line, #d0d0d0); }
.shapes-drawer-head h2 { font-size: 16px; margin: 0; }
.shapes-drawer-body { flex: 1; overflow: auto; padding: 12px 14px 16px; }
.shapes-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius); }
.shapes-drawer-body h3 { margin: var(--space-5) 0 var(--space-2); }
.shapes-drawer-body > h3:first-of-type { margin-top: var(--space-2); }
.item + .item { border-top: 1px solid var(--rule); }
.item-head { display: flex; align-items: center; gap: var(--space-2); padding-right: var(--space-3); }
.item-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) 0 var(--space-2) var(--space-3); border: 0; border-radius: var(--radius); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.item-name:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.item-name::after { content: ""; flex: none; width: 7px; height: 7px; margin-left: auto; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); }
.item-name[aria-expanded="true"]::after { transform: rotate(-135deg) translate(-2px, -2px); }
.item-text { min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.item-thumb { flex: none; width: 40px; height: 40px; background: #f4f4f1; border-radius: 6px; }
.item-off .item-thumb { opacity: 0.6; }
.item-switch { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding-left: var(--space-2); cursor: pointer; }
.item-switch input { width: 18px; height: 18px; accent-color: var(--accent-ink); }
.item-why { margin: 0; padding: 0 var(--space-3) var(--space-2) 64px; }
.item-open { background: #f7f9ff; }
.item-panel { padding: var(--space-1) var(--space-3) var(--space-3); display: grid; gap: var(--space-3); }
.item-panel[hidden] { display: none; }
.item-panel p { margin: var(--space-1) 0 0; }
.item-panel h4 { margin: 0 0 var(--space-1); font-size: 13px; }
.item-choice { display: grid; grid-template-columns: 124px minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-2); }
.item-control { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.item-control input[type="range"] { flex: 1; min-width: 60px; min-height: 28px; accent-color: var(--accent-ink); }
.item-control output { min-width: 34px; font-variant-numeric: tabular-nums; }
.item-control input[type="text"], .item-control select { width: 100%; }
.item-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.item-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.item-versions li { display: flex; align-items: center; gap: var(--space-2); }
.item-versions li > span { flex: 1; min-width: 0; }
.item-point { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3); min-height: 48px; }
.item-point .item-text { flex: 1; }
.point-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.item-points, .item-look { margin-top: var(--space-5); }
.item-points > summary, .item-look > summary, .editor-help > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.item-look .item-choice { margin-top: var(--space-2); }
.item-looks { border: 0; border-top: 1px solid var(--rule); margin: 0; padding: var(--space-2) 0 0; display: grid; gap: var(--space-2); min-width: 0; }
.item-looks > legend { float: left; width: 100%; font-size: 13px; font-weight: 600; padding: 0; }
.item-looks > legend + * { clear: both; }
.item-looks.item-panel { padding: var(--space-2) var(--space-3) var(--space-3); }
.item-colours { grid-template-columns: 124px minmax(0, 1fr); }
.item-colour-name { display: block; }
@media (max-width: 700px) { .item-choice.item-colours { grid-template-columns: minmax(0, 1fr); } .item-colour-name { display: inline; margin-left: 6px; } }
.item-swatches { display: flex; flex-wrap: wrap; gap: 2px; }
.swatch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; cursor: pointer; }
.swatch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgb(0 0 0 / 0.45); }
.swatch-house { background: linear-gradient(135deg, #fff 46%, var(--muted) 46%, var(--muted) 54%, #fff 54%); }
.swatch input:checked + .swatch-dot { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.swatch input:focus-visible + .swatch-dot { outline: 3px solid var(--accent-ink); outline-offset: 3px; }
@media (pointer: coarse) { .swatch { width: 44px; height: 44px; } }
.item-add > summary { list-style: none; }
.item-add > summary::-webkit-details-marker { display: none; }
.item-add > summary::after { content: ""; width: 6px; height: 6px; margin-left: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); display: inline-block; }
.item-add { position: sticky; top: -12px; z-index: 4; margin: -12px -14px 0; padding: 12px 14px 8px; background: var(--bg); }
.item-add-panel { position: absolute; z-index: 5; top: 100%; left: 14px; width: min(340px, calc(100% - 28px)); max-height: min(60vh, 420px); overflow: auto; padding: var(--space-2); background: #fff; border: 1px solid var(--rule-strong); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.item-add-panel ul { list-style: none; margin: 0; padding: 0; }
.item-add-panel > p { margin: var(--space-2) var(--space-2) var(--space-1); padding-top: var(--space-2); border-top: 1px solid var(--rule); }
.item-add-choice { display: flex; flex-direction: column; width: 100%; min-height: 44px; padding: 6px var(--space-2); border: 0; border-radius: 6px; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.item-add-choice > span:first-child { font-weight: 600; }
.item-add-choice:hover { background: var(--blue-tint); }
.shapes-drawer-foot { border-top: 1px solid var(--rule); padding: var(--space-2) 14px; background: #f7f9ff; }
.shapes-drawer-foot .form-error { margin: 0 0 var(--space-2); }
.shapes-foot-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.shapes-toggle.has-unsaved::after { content: "unsaved changes"; margin-left: 8px; color: var(--amber-ink); font-weight: 600; }
.editor-help { margin-bottom: var(--space-2); }
.editor-help p { margin: 0 0 var(--space-2); max-width: 70ch; }
.preview-bar .seg, .preview-bar .preview-adjust, .preview-bar .chip, .preview-bar .preview-banner, .preview-bar label, .preview-bar select { flex: none; white-space: nowrap; }
@media (min-width: 1200px) { .preview-bar { flex-wrap: nowrap; } .preview-bar > .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
.narrow-only { display: none; }
@media (max-width: 900px) { .update-banner { bottom: auto; top: calc(var(--header-h) + 8px); } }      /* clear of the drawer's save bar and the message box */
@media (max-width: 900px) { .narrow-only { display: inline-flex; } }
@media (max-width: 700px) { .item-choice { grid-template-columns: minmax(0, 1fr) auto; } .item-choice > label { grid-column: 1 / -1; } .shapes-foot-row .btn, .item-panel .btn, .item-point .btn { min-height: 44px; } }
.shapes-drawer .shape-editor-map { height: min(52vh, 460px); min-height: 280px; }
.shape-editor-pic { display: block; margin: 4px 0; }
.shape-editor-pic .btn { margin-left: 4px; }
.ws-col.chat.shapes-open { position: relative; }

/* the traced picture's fader beside the editor's map (DECISIONS #87) */
.shape-editor-stage { display: flex; gap: 8px; align-items: stretch; }
.shape-editor-stage .shape-editor-map { flex: 1; min-width: 0; }
.shape-editor-fader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 44px; }
.shape-editor-opacity { writing-mode: vertical-lr; direction: rtl; width: 24px; height: 180px; margin: 0; cursor: ns-resize; }
.shape-editor-chooser { align-items: center; flex-wrap: wrap; margin: 4px 0; }
.shape-editor-chooser select { max-width: 100%; }

/* handing a new user their temporary password (DECISIONS #102) */
.handover { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 10px; }
.handover dt { font-weight: 600; }
.handover dd { margin: 0; overflow-wrap: anywhere; }
.handover-password { font-size: 1.15em; letter-spacing: 0.04em; user-select: all; }
.handover-message { width: 100%; font: inherit; font-size: 0.9em; }

/* ---------- Interface review (24 Nov 2026) ---------- */
.app-header :focus-visible { outline-color: #fff; }
.ws-head { row-gap: var(--space-1); }
.ws-head h1 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.ws-head .title-block { flex: 0 1 auto; }
.ws-head .slug { min-width: 0; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-nav-row { flex-basis: 100%; margin-left: calc(-1 * var(--space-3)); }
.ws-nav .btn.active { background: var(--blue-tint); color: var(--accent-ink); }
.ws-switch { display: none; }
@media (max-width: 900px) { .ws-switch { display: inline-flex; } .ws-switch button { padding: 7px 18px; min-height: 36px; } }
summary { min-height: 24px; }
.tabpanel .actions + details, .review-item .actions + details { margin-top: var(--space-2); }
.parse-warning { color: var(--amber-ink); }
.privacy-hint { margin: 6px 0 0; }
.composer .actions .row { align-items: center; }
.chat.final-open .composer textarea { min-height: 42px; height: 42px; }
.chat-start { background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--space-4); }
.chat-start p { margin-bottom: 2px; }
.chat-log > .privacy-note { margin-bottom: 0; }
.more-fields { margin-bottom: var(--space-3); }
.more-fields > summary { cursor: pointer; font-size: 14px; color: var(--blue); }
.more-fields[open] > summary { margin-bottom: var(--space-2); }
.empty p { margin-bottom: var(--space-2); }
.project-list > .empty, .chart-grid > .empty { grid-column: 1 / -1; }
.project-list[aria-busy="true"] { opacity: 0.6; }
.project-card h2 a { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; }
.card-delete { color: var(--red); margin-left: -12px; }
.card-delete:hover { background: var(--red-tint); color: #7f2f15; }
.row-actions { flex-wrap: nowrap; gap: var(--space-1); align-items: center; }
.row-actions .btn { white-space: nowrap; }
.forms-item.panel-box { margin-bottom: 0; }
.forms-group { margin: var(--space-2) 0 0; }
.forms-story { margin: 0 0 var(--space-2); }
.forms-house > summary { cursor: pointer; font-weight: 600; margin: var(--space-2) 0; }
.forms-house .forms-item { margin-top: var(--space-3); }
.forms-actions { margin: var(--space-3) 0; }
.toast { display: flex; align-items: flex-start; gap: var(--space-2); justify-content: space-between; }
.toast-close { font: inherit; font-size: 18px; line-height: 1; min-width: 24px; min-height: 24px; border: 0; background: none; color: inherit; cursor: pointer; border-radius: 4px; }
.toast-close:focus-visible { outline-color: #fff; }
@media (max-width: 1100px) and (min-width: 701px) { .user-menu .name { display: none; } }
@media (max-width: 700px) {
  :root { --header-h: 92px; }
  .app-header { flex-wrap: wrap; align-content: center; row-gap: 2px; padding: 0 var(--space-3); justify-content: space-between; }
  .app-nav { order: 3; flex: 1 0 100%; }
  .user-menu .name { display: none; }
  .page { padding: var(--space-4) var(--space-3); }
  .project-list { grid-template-columns: minmax(0, 1fr); }
  .project-card { grid-template-columns: minmax(0, 1fr) 88px; }
  .thumb { width: 88px; height: 113px; }
  .preview-stage { padding: var(--space-3); }
  .privacy-note { font-size: 13px; }
  .toasts { top: calc(var(--header-h) + 8px); bottom: auto; left: var(--space-3); right: var(--space-3); max-width: none; }
  .kv, dl.kv, .handover { grid-template-columns: minmax(0, 1fr); }
  .notes-compare { grid-template-columns: 1fr; }
  .composer textarea { min-height: 44px; }
  .forms-layout { grid-template-columns: minmax(0, 1fr); }
  input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], input[type="date"], select, textarea { font-size: 16px; }   /* iOS zooms into anything smaller */
}
.reading-card { margin-bottom: var(--space-2); }
@media (max-width: 1100px) { .ws-head .slug { display: none; } }
.field label.check { display: flex; align-items: center; font-weight: 400; margin: var(--space-2) 0 0; }
.field label.check input { margin: 0; }
table.data select { min-width: 120px; }
table.data time { white-space: nowrap; }
@media (max-width: 900px) {
  .ws-nav { flex-wrap: nowrap; overflow-x: auto; min-width: 0; }
  .ws-nav .btn { flex: none; }
  .ws-nav-row { margin-left: 0; max-width: 100%; }
  .split .rule-list { max-height: 42vh; overflow-y: auto; }      /* the chosen rule's details stay within reach below the list */
}
@media (max-width: 700px) { .table-wrap > table.data:not(.compact, .dt-table) { min-width: 720px; } .md-table > table.data { min-width: 0 !important; } }
