/* Paper-and-ink styling: warm neutral surfaces, near-black text, fine rules and one signal-orange accent.
   Hand-written to keep the app dependency-free. Manrope (UI) and DM Mono (metadata, labels, step numbers)
   are bundled in fonts/ so the app stays offline-capable; Inter is still the font embedded in the PDF. */

@font-face { font-family: 'Manrope'; src: url('../../fonts/Manrope-latin.woff2') format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Manrope'; src: url('../../fonts/Manrope-latin-ext.woff2') format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Mono'; src: url('../../fonts/DMMono-Regular-latin.woff2') format('woff2'); font-weight: 400; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Mono'; src: url('../../fonts/DMMono-Regular-latin-ext.woff2') format('woff2'); font-weight: 400; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Mono'; src: url('../../fonts/DMMono-Medium-latin.woff2') format('woff2'); font-weight: 500; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Mono'; src: url('../../fonts/DMMono-Medium-latin-ext.woff2') format('woff2'); font-weight: 500; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --paper: #f3f1eb;          /* page */
  --panel: #fbfaf6;          /* cards, dialogs */
  --rail: #eeece5;           /* inset boxes */
  --side: #eae8e0;           /* desktop sidebar */
  --bar: color-mix(in srgb, #fbfaf6 55%, #f3f1eb); /* desktop top bar */
  --card-dark: #20211e;      /* ink card in the section rail */
  --card-dark-line: #20211e;
  --snack-action: #ff8a6a;
  --snack-hover: rgb(255 255 255 / 0.08);
  --input: #f8f7f2;          /* text fields */
  --soft: #e8e6de;           /* hover, quiet fills */
  --ink: #20211e;
  --on-ink: #fbfaf6;
  --muted: #696a63;
  --faint: #8d8e86;
  --line: #d7d5cc;           /* rules */
  --line-strong: #b8b6ac;    /* control borders */
  --signal: #ef542f;         /* accent for marks and borders */
  --signal-fill: #d0441f;    /* accent behind white text (AA) */
  --signal-hover: #b93b18;
  --on-signal: #fff;
  --signal-text: #b93b18;    /* accent as small text (AA) */
  --signal-soft: #fbe3da;
  --moss: #365a4b;
  --moss-soft: #e1e8e2;
  --danger: #b42318;
  --danger-soft: #f8e1dc;
  --amber: #8a5a00;
  --amber-soft: #f5ead2;
  --scrim: rgb(32 33 30 / 0.34);
  --sans: 'Manrope', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --page-width: 920px;
  --radius: 2px;
  color-scheme: light;
}

/* Dark theme: follows the system unless the mode switch picked one (html[data-theme]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #111311;
    --panel: #1a1c19;
    --rail: #171916;
    --side: #151715;
    --bar: #151715;
    --input: #131512;
    --soft: #242623;
    --ink: #f0eee8;
    --on-ink: #111311;
    --muted: #a4a69e;
    --faint: #85877f;
    --line: #383b36;
    --line-strong: #4b4f49;
    --signal: #ed7251;
    --signal-fill: #ed7251;
    --signal-hover: #f2896c;
    --on-signal: #171916;
    --signal-text: #ed7251;
    --signal-soft: #3a2219;
    --moss: #7f9886;
    --moss-soft: #1f2a23;
    --danger: #ff8a7a;
    --danger-soft: #3a1d19;
    --amber: #e8b75a;
    --amber-soft: #33291a;
    --card-dark: #0b0c0b;
    --card-dark-line: #383b36;
    --snack-action: #b93b18;
    --snack-hover: rgb(0 0 0 / 0.06);
    --scrim: rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #111311;
  --panel: #1a1c19;
  --rail: #171916;
  --side: #151715;
  --bar: #151715;
  --input: #131512;
  --soft: #242623;
  --ink: #f0eee8;
  --on-ink: #111311;
  --muted: #a4a69e;
  --faint: #85877f;
  --line: #383b36;
  --line-strong: #4b4f49;
  --signal: #ed7251;
  --signal-fill: #ed7251;
  --signal-hover: #f2896c;
  --on-signal: #171916;
  --signal-text: #ed7251;
  --signal-soft: #3a2219;
  --moss: #7f9886;
  --moss-soft: #1f2a23;
  --danger: #ff8a7a;
  --danger-soft: #3a1d19;
  --amber: #e8b75a;
  --amber-soft: #33291a;
  --card-dark: #0b0c0b;
  --card-dark-line: #383b36;
  --snack-action: #b93b18;
  --snack-hover: rgb(0 0 0 / 0.06);
  --scrim: rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 21px;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--signal-soft); }
p { margin: 0 0 12px; }

/* ---- Typography ---- */
.title-large { font-size: 32px; line-height: 36px; font-weight: 700; letter-spacing: -0.05em; margin: 0; }
.title-medium { font-size: 16px; line-height: 22px; font-weight: 700; letter-spacing: -0.025em; margin: 0; }
.title-small { font-size: 14px; line-height: 20px; font-weight: 700; letter-spacing: -0.015em; margin: 0; }
.label-medium { font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: -0.005em; }
.body-small { font-size: 12px; line-height: 18px; color: var(--muted); }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--mono); font-size: 11px; line-height: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--signal-text); margin-bottom: 12px; }
.mono { font-family: var(--mono); }

/* ---- Layout ---- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.top-app-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: 60px; padding: 8px max(16px, calc((100% - var(--page-width)) / 2 + 24px));
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.top-app-bar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
/* Blueprint mark: a square with a signal-orange crosshair. */
.top-app-bar .brand img { display: none; }
.top-app-bar .brand::before {
  content: ''; width: 22px; height: 22px; flex: none; border: 1.5px solid var(--ink);
  background:
    linear-gradient(var(--signal), var(--signal)) center / 1px 12px no-repeat,
    linear-gradient(var(--signal), var(--signal)) center / 12px 1px no-repeat;
}
.top-app-bar .brand .title-large { font-size: 17px; line-height: 22px; font-weight: 800; letter-spacing: -0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-app-bar .brand .body-small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; align-items: center; gap: 4px; }

main { flex: 1; width: 100%; max-width: var(--page-width); margin: 0 auto; padding: 40px 24px 120px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 200px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.spacer { flex: 1; }

/* ---- Buttons ---- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap;
  background: transparent; color: var(--ink);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn .icon { width: 16px; height: 16px; }
.btn.filled { background: var(--signal-fill); border-color: var(--signal-fill); color: var(--on-signal); }
.btn.filled:hover:not(:disabled) { background: var(--signal-hover); border-color: var(--signal-hover); }
.btn.tonal, .btn.outlined { border-color: var(--ink); color: var(--ink); }
.btn.tonal:hover:not(:disabled), .btn.outlined:hover:not(:disabled) { background: var(--ink); color: var(--on-ink); }
.btn.text { padding: 0 8px; }
.btn.text:hover:not(:disabled) { background: var(--soft); }
.btn.danger { color: var(--danger); }
.btn.text.danger:hover:not(:disabled) { background: var(--danger-soft); }

.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid transparent; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: transparent; color: var(--muted);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--soft); color: var(--ink); }
.icon-btn[aria-expanded='true'] { border-color: var(--ink); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.small { width: 30px; height: 30px; }
.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.icon-btn.small .icon { width: 16px; height: 16px; }

.fab {
  position: fixed; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 8;
  min-height: 48px; padding: 0 20px;
}

/* ---- Panels ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.outlined { background: transparent; }
.card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-header .title-medium { flex: 1; min-width: 0; }
.card > h3.title-medium:first-child { margin-bottom: 10px; }
.card > h3.title-medium:first-child + p { margin-top: -4px; }

.section-card { position: relative; }
.section-eyebrow { font-family: var(--mono); color: var(--signal-text); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---- Text fields: label above, square field ---- */
.field { position: relative; display: flex; flex-direction: column; min-width: 0; }
.field > label {
  display: block; padding: 0 0 8px; font-size: 12px; line-height: 16px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 11px 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--input); outline: none; color: var(--ink);
  transition: border-color 0.15s, background-color 0.15s;
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field textarea { resize: vertical; line-height: 22px; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23696a63' stroke-width='1.3'%3E%3Cpath d='M3 4.5 6 7.5l3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px; }
.field select option { background: var(--panel); color: var(--ink); }
.field input:hover:not(:disabled), .field select:hover:not(:disabled), .field textarea:hover:not(:disabled) { border-color: var(--muted); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--signal); background: var(--panel); box-shadow: inset 0 0 0 1px var(--signal); }
.field input:disabled, .field select:disabled { color: var(--muted); background: var(--soft); border-style: dashed; }
.field .supporting { font-size: 12px; line-height: 16px; padding: 6px 0 0; color: var(--muted); }
.field.error input, .field.error select, .field.error textarea { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.field.error > label, .field.error .supporting { color: var(--danger); }
.field.mono textarea { font-family: var(--mono); font-size: 12px; line-height: 18px; }
.field.compact input, .field.compact select { min-height: 36px; padding-top: 7px; padding-bottom: 7px; }
.field.compact > label { padding-bottom: 6px; }

/* ---- Switch ---- */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; font-size: 13px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative; width: 34px; height: 20px; border-radius: 10px; flex: none;
  background: transparent; border: 1px solid var(--line-strong); transition: background-color 0.15s, border-color 0.15s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: transform 0.18s ease, background-color 0.15s;
}
.switch input:checked + .track { background: var(--ink); border-color: var(--ink); }
.switch input:checked + .track .thumb { transform: translateX(14px); background: var(--on-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---- Chips: square, outlined; selected = ink ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: transparent;
  font-size: 12px; font-weight: 600; color: var(--muted); transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip:has(.dot) { text-transform: capitalize; }
.label-medium.muted { color: var(--ink); }
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip .dot { width: 10px; height: 10px; border-radius: 0; background: var(--dot); flex: none; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12); }
.chip[aria-pressed='true'] .dot { box-shadow: 0 0 0 1px var(--on-ink); }

/* Metadata tags: small mono caps, no fill */
.assist-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0;
  font-family: var(--mono); font-size: 10.5px; line-height: 14px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; background: none;
}
.assist-chip + .assist-chip::before { content: '·'; margin-right: 4px; color: var(--faint); }
.assist-chip.primary { color: var(--signal-text); }
.assist-chip .icon { width: 12px; height: 12px; }

.options-list { display: flex; flex-direction: column; gap: 8px; }
.option-row { display: flex; gap: 8px; align-items: center; }
.option-row .field { flex: 1; }
.option-row .field.value { flex: 0 1 34%; }
.option-row .field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; }

.condition { border: 1px solid var(--line); background: var(--rail); padding: 14px 16px; border-radius: var(--radius); }
.condition .field input, .condition .field select { background: var(--panel); }
.condition .rule { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 8px; align-items: end; margin-top: 12px; }
@media (max-width: 600px) {
  .condition .rule { grid-template-columns: 1fr auto; }
  .condition .rule .field:nth-child(1) { grid-column: 1 / -1; }
}

.divider { height: 1px; background: var(--line); margin: 4px 0; border: 0; }

/* ---- Banners: ruled boxes with a coloured left edge ---- */
.banner { display: flex; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-left-width: 2px; border-radius: var(--radius); font-size: 13px; line-height: 20px; background: var(--panel); }
.banner > .icon { width: 18px; height: 18px; margin-top: 1px; }
.banner.error { border-left-color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); border-left-color: var(--danger); }
.banner.error > .icon { color: var(--danger); }
.banner.info { border-left-color: var(--ink); }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner code { font-family: var(--mono); font-size: 12px; opacity: 0.8; }

.hidden-note { font-family: var(--mono); font-size: 11px; color: var(--moss); display: flex; gap: 6px; align-items: center; }
.hidden-note .icon { width: 14px; height: 14px; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Dialog, menu, snackbar ---- */
dialog.dialog {
  border: 1px solid var(--ink); padding: 24px; border-radius: var(--radius); width: min(520px, calc(100vw - 32px)); max-width: min(520px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink); box-shadow: 8px 8px 0 rgb(32 33 30 / 0.08);
}
dialog.dialog[open] { animation: appear 0.18s ease-out; }
dialog.dialog::backdrop, dialog.sheet::backdrop { background: var(--scrim); }
dialog.dialog h2 { margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.035em; }
dialog.dialog .dialog-body { color: var(--muted); max-height: 55vh; overflow: auto; }
dialog.dialog .dialog-body .chip { color: var(--ink); }
dialog.dialog .dialog-body .chip[aria-pressed='true'] { color: var(--on-ink); }
dialog.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
dialog.dialog .dialog-actions .btn.text:not(.danger) { border-color: var(--line-strong); padding: 0 16px; }
dialog.dialog .dialog-actions .btn.text.danger { border-color: var(--danger); padding: 0 16px; }

.menu-anchor { position: relative; }
.menu {
  position: absolute; right: 0; top: 40px; z-index: 20; min-width: 210px; padding: 4px 0;
  background: var(--panel); border: 1px solid var(--ink); border-radius: var(--radius); box-shadow: 6px 6px 0 rgb(32 33 30 / 0.08);
  animation: appear 0.14s ease-out;
}
.menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 0 14px; border: 0; background: none;
  text-align: left; color: var(--ink); font-size: 13px; font-weight: 600;
}
.menu button:hover { background: var(--soft); }
.menu .icon { width: 16px; height: 16px; color: var(--muted); }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 4px 0; }

.snackbar {
  position: fixed; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 6px 4px 16px; max-width: min(520px, calc(100vw - 32px));
  background: var(--ink); color: var(--on-ink); border-radius: var(--radius); font-size: 13px; line-height: 18px;
  animation: appear 0.2s ease-out;
}
.snackbar .btn { color: var(--snack-action); padding: 0 10px; min-height: 32px; }
.snackbar .btn:hover { background: var(--snack-hover); }
.snackbar .icon-btn { color: inherit; opacity: 0.7; }
.snackbar .icon-btn:hover { background: var(--snack-hover); color: inherit; opacity: 1; }

/* ---- Responsive ---- */
.hide-sm { display: inline-flex; }
@media (max-width: 720px) {
  .hide-sm { display: none !important; }
  main { padding: 28px 16px 120px; }
  .card { padding: 16px; }
  .title-large { font-size: 28px; line-height: 32px; }
  .snackbar { left: 16px; right: 16px; max-width: none; }
}
@media (min-width: 721px) { .show-sm { display: none !important; } }

/* ================= Brief Builder screens ================= */
.page { width: 100%; max-width: var(--page-width); margin: 0 auto; padding: 40px 24px 120px; }
@media (max-width: 720px) { .page { padding: 28px 16px 120px; } }
.block { display: block; }
.left { text-align: left; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head { justify-content: space-between; align-items: flex-end; margin-top: 8px; }
.plain-list { margin: 8px 0; padding-left: 20px; }
.error-text { color: var(--danger); }
.subtle-flag { color: var(--amber); }
/* Step intro: heading + one line of explanation, ruled off from the content below */
.stack > div:first-child > .title-large + .muted { margin: 10px 0 0; font-size: 14px; max-width: 640px; }

/* banners */
.banner { align-items: flex-start; }
.banner.ok { border-left-color: var(--moss); background: var(--moss-soft); border-color: color-mix(in srgb, var(--moss) 25%, var(--line)); border-left-color: var(--moss); }
.banner.ok > .icon { color: var(--moss); }
.banner.warn { border-left-color: var(--amber); background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, var(--line)); border-left-color: var(--amber); }
.banner.warn > .icon { color: var(--amber); }
.banner.sticky { position: sticky; top: 64px; z-index: 9; align-items: center; }
.banner.local-warning { font-size: 12px; line-height: 18px; color: var(--muted); background: transparent; border-left-color: var(--signal); }
.banner.local-warning > .icon { color: var(--signal); }
.banner.local-warning strong { display: block; font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); margin-bottom: 2px; }
.update-banner { margin: 16px auto 0; width: calc(100% - 32px); max-width: calc(var(--page-width) - 48px); align-items: center; }
.assist-chip.warn { color: var(--amber); }

.empty-card {
  position: relative; text-align: center; padding: 56px 24px 48px; border: 1px solid var(--line); border-radius: var(--radius);
  background-color: var(--panel);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, var(--panel) 35%, color-mix(in srgb, var(--panel) 70%, transparent) 75%);
}
.empty-card > * { position: relative; }
.empty-card > .icon { width: 48px; height: 48px; padding: 11px; border: 1.5px solid var(--ink); color: var(--signal); background: var(--panel); margin-bottom: 6px; }
.empty-card h3 { font-size: 20px; line-height: 26px; letter-spacing: -0.035em; }
.empty-card p { margin: 0; max-width: 440px; }
.empty-card .row { margin-top: 12px; }

/* new brief: set up on the page, as numbered ruled rows */
.intake { display: flex; flex-direction: column; gap: 28px; margin-top: 8px; animation: appear 0.18s ease-out; }
.intake-lede { margin: 10px 0 0; font-size: 14px; }
.intake-panel { border-top: 1px solid var(--ink); }
.intake-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0 14px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.intake-num {
  width: 28px; height: 28px; display: grid; place-items: center; margin-top: -3px;
  font-family: var(--mono); font-size: 11px; color: var(--signal-text); border: 1px solid color-mix(in srgb, var(--signal) 50%, var(--line));
}
.intake-row.is-done .intake-num { color: var(--moss); border-color: var(--moss); }
.intake-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.intake-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.intake-help { margin: 4px 0 14px; }
.intake-or { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }
.intake-row .field { max-width: 520px; }
.intake-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 20px; }
.intake-actions .btn.filled { padding: 0 18px; min-height: 44px; gap: 18px; min-width: 140px; justify-content: space-between; }
@media (max-width: 560px) {
  .intake-row { grid-template-columns: 1fr; gap: 12px; }
}

/* briefs list: one ruled table */
.brief-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.brief-card { display: flex; align-items: center; gap: 4px; background: transparent; padding: 0 4px 0 0; position: relative; }
.brief-card + .brief-card { border-top: 1px solid var(--line); }
.brief-card.broken, .brief-card.cannot-open, .brief-card.future { box-shadow: inset 2px 0 0 var(--danger); }
.brief-main {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 16px 12px; color: inherit;
  display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 14px; align-items: start;
  transition: background-color 0.15s;
}
.brief-main:hover { background: var(--panel); }
.brief-main:hover .title-medium { text-decoration: underline; text-decoration-color: var(--signal); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.brief-main > .brief-num {
  grid-row: 1 / span 4; width: 28px; height: 28px; margin-top: 1px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; color: var(--signal-text); border: 1px solid color-mix(in srgb, var(--signal) 50%, var(--line));
}
.brief-main > span:not(.brief-num) { grid-column: 2; }
.brief-card .title-medium { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brief-card .body-small { margin-top: 2px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }
.brief-card .status-note { color: var(--danger); font-family: var(--sans) !important; font-size: 12px !important; }
.brief-card .menu-anchor { margin: 0; }
.backup-card { margin-top: 16px; }
.backup-card .muted { margin-bottom: 16px; }

/* workspace header: breadcrumb-like bar */
.workspace { display: flex; flex-direction: column; flex: 1; }
.workspace-head { display: flex; align-items: center; gap: 8px; padding: 0 8px 8px; max-width: var(--page-width); width: 100%; margin: 0 auto; }
.workspace-head > .icon-btn:first-child { color: var(--ink); }
.workspace-head > .grow { flex: 1; display: flex; align-items: baseline; gap: 16px; }
.workspace-head .title-medium { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.save-status { font-family: var(--mono); font-size: 10.5px; line-height: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--moss); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.save-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.save-status.dirty, .save-status.saving { color: var(--muted); }
.save-status.error, .save-status.conflict { color: var(--danger); }

/* stepper: a ruled four-column strip */
.stepper {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: calc(var(--page-width) - 48px); width: calc(100% - 48px); margin: 0 auto;
  position: sticky; top: 60px; z-index: 9; background: var(--paper);
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line);
}
.step {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px;
  border: 0; border-right: 1px solid var(--line); background: none; color: var(--faint); font-size: 12px; font-weight: 600; text-align: left;
  transition: background-color 0.15s, color 0.15s;
}
.step:last-child { border-right: 0; }
.step:hover { color: var(--ink); background: var(--panel); }
.step-num {
  width: 22px; height: 22px; display: grid; place-items: center; flex: none;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; border: 1px solid var(--line-strong); color: inherit;
}
.step.done { color: var(--moss); }
.step.done .step-num { border-color: var(--moss); }
.step[aria-current='step'] { color: var(--ink); background: var(--panel); box-shadow: inset 0 2px 0 var(--signal); }
.step[aria-current='step'] .step-num { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .stepper { width: calc(100% - 32px); } }
@media (max-width: 560px) {
  .step { flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 8px 8px; font-size: 11px; min-height: 58px; }
}
.step-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; }
.step-footer .btn.filled { flex-direction: row-reverse; padding: 0 18px; min-height: 44px; gap: 18px; }

/* sections step */
.section-head > .grow { flex: 1; min-width: 0; }
.section-card { padding: 0 20px; }
.section-head { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 0; border: 0; background: none; color: inherit; text-align: left; }
.section-head > .icon { color: var(--muted); }
.section-card.open .section-head { border-bottom: 1px solid var(--line); }
.section-number {
  width: 28px; height: 28px; display: grid; place-items: center; flex: none;
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--signal-text);
  border: 1px solid color-mix(in srgb, var(--signal) 50%, var(--line));
}
/* the section's chosen PDF colour, shown as a small square swatch */
.section-head .title-medium::after {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 10px; vertical-align: 2px; background: var(--section-accent);
}
.section-head .meta, .question-main .meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.section-body { padding: 20px 0 20px; animation: appear 0.18s ease-out; }
.section-body > div:has(> .chips) { padding: 14px 16px; background: var(--rail); border: 1px solid var(--line); }
.section-body > div:has(> .chips) > .label-medium { color: var(--ink) !important; }
.question-list { display: flex; flex-direction: column; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.question-row { display: flex; align-items: center; position: relative; padding-right: 2px; }
.question-row + .question-row { border-top: 1px solid var(--line); }
.question-row.focus { box-shadow: inset 2px 0 0 var(--signal); background: var(--panel); }
.question-list > p.body-small { padding: 14px 0; margin: 0 !important; }
.question-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 4px 12px 0; border: 0; background: none; color: inherit; text-align: left; min-height: 60px; }
.question-main:hover .label { text-decoration: underline; text-decoration-color: var(--signal); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.question-main .label { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.type-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 1px solid var(--line-strong); color: var(--ink); background: var(--panel); }
.type-icon .icon { width: 16px; height: 16px; }

/* bottom sheet */
dialog.sheet {
  border: 1px solid var(--ink); padding: 0; background: var(--panel); color: var(--ink); box-shadow: 8px 8px 0 rgb(32 33 30 / 0.08);
  width: min(640px, 100vw); max-width: 100vw; max-height: min(92vh, 900px); margin: auto; border-radius: var(--radius); overflow: hidden;
}
dialog.sheet[open] { animation: appear 0.18s ease-out; }
.sheet-inner { display: flex; flex-direction: column; max-height: min(92vh, 900px); }
.sheet-header { display: flex; align-items: center; gap: 8px; padding: 16px 12px 14px 22px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { flex: 1; font-size: 18px; line-height: 24px; font-weight: 700; letter-spacing: -0.03em; }
.sheet-body { padding: 18px 22px 22px; overflow-y: auto; flex: 1; }
.sheet-footer, .sheet-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.sheet-footer { padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.sheet-actions .btn.text { border-color: var(--line-strong); padding: 0 16px; }
@media (max-width: 720px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; border-width: 1px 0 0; box-shadow: none; }
}
.template-list { display: flex; flex-direction: column; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.template { display: flex; align-items: center; gap: 14px; padding: 12px 6px 12px 0; border: 0; background: none; color: inherit; text-align: left; transition: background-color 0.15s, padding 0.15s; }
.template + .template { border-top: 1px solid var(--line); }
.template:hover { background: var(--paper); padding-left: 8px; }
.template:hover .title-small { text-decoration: underline; text-decoration-color: var(--signal); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.template-icon { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border: 1px solid var(--line-strong); color: var(--ink); background: var(--panel); position: relative; }
.template-icon::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 7px; height: 7px; background: var(--tint); }
.template-icon .icon { width: 18px; height: 18px; }
.template > .icon { color: var(--faint); width: 18px; height: 18px; }

/* dialogs and lists */
.radio-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.radio { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; color: var(--ink); }
.radio input { margin-top: 3px; accent-color: var(--ink); }
.check-row { display: flex; gap: 12px; align-items: flex-start; margin: 8px 0 16px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--ink); flex: none; }
.summary-list, .restore-list, .overview-list, .issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.summary-list { gap: 0; border-top: 1px solid var(--ink); }
.summary-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.summary-list li:first-child { border-top: 0; }
.summary-list li.out { color: var(--faint); text-decoration: line-through; text-decoration-color: color-mix(in srgb, currentColor 60%, transparent); }
.summary-list li.out .body-small { text-decoration: none; }
.summary-list li.in .icon { color: var(--moss); }
.summary-list li .icon { width: 18px; height: 18px; }
.summary-list li .body-small { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.restore-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); background: var(--paper); }
.restore-list li.ready .icon { color: var(--moss); }
.restore-list li.skipped .icon { color: var(--danger); }
.issues { gap: 0; border-top: 1px solid var(--ink); }
.issue { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.issue:first-child { border-top: 0; }
.issue.error .icon { color: var(--danger); }
.issue.warn .icon { color: var(--amber); }
.overview .row { align-items: center; }
.overview-list { margin-top: 10px; padding-left: 42px; gap: 6px; }
.overview-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.overview-list li .label { font-weight: 600; }
.scenario-q { display: flex; flex-direction: column; gap: 8px; }
.app.in-brief .top-app-bar { display: none; }
.app.in-brief .workspace-head {
  position: sticky; top: 0; z-index: 11; max-width: none; min-height: 60px; box-sizing: border-box;
  padding: max(8px, env(safe-area-inset-top)) max(12px, calc((100% - var(--page-width)) / 2 + 18px)) 8px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.app.in-brief .stepper { top: calc(60px + env(safe-area-inset-top)); margin-top: 32px; }
.app.in-brief .banner.sticky { top: calc(118px + env(safe-area-inset-top)); }

/* Understated "show more" link at the end of the section picker */
.link-button.show-all {
  display: block; margin: 14px auto 0; padding: 8px 12px; background: none; border: 0;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--signal-text);
  min-height: 40px;
}
.link-button.show-all:hover { text-decoration: underline; text-underline-offset: 4px; }

/* Light/dark mode switch in the top bar */
.mode-switch {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 30px; padding: 0 10px; margin: 0 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: transparent; color: var(--ink);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; cursor: pointer;
}
.mode-switch .icon { width: 14px; height: 14px; }
.mode-switch:hover { border-color: var(--ink); }
@media (max-width: 560px) { .mode-switch { width: 36px; height: 36px; padding: 0; justify-content: center; } .mode-label { display: none; } }

/* ================= Desktop: sidebar, breadcrumb bar and section rail ================= */
.sidebar, .top-app-bar .crumb, .crumb-link, .crumb-sep { display: none; }
.app-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.workspace-head .crumb { min-width: 0; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 66px minmax(0, 1fr); align-items: start; }
  .app-main { min-height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 22px 10px 16px; background: var(--side); border-right: 1px solid var(--line);
  }
  .side-brand { display: flex; align-items: center; gap: 11px; padding: 6px 12px 30px; color: var(--ink); text-decoration: none; }
  .side-brand::before {
    content: ''; width: 22px; height: 22px; flex: none; border: 1.5px solid var(--ink);
    background:
      linear-gradient(var(--signal), var(--signal)) center / 1px 12px no-repeat,
      linear-gradient(var(--signal), var(--signal)) center / 12px 1px no-repeat;
  }
  .brandword { font-size: 17px; line-height: 22px; font-weight: 800; letter-spacing: -0.04em; white-space: nowrap; }
  .navlabel { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding: 0 12px 9px; }
  .navlabel ~ .navlabel { margin-top: 24px; }
  .side-nav { display: grid; gap: 3px; }
  .side-item {
    display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 0 12px;
    border: 0; border-radius: var(--radius); background: transparent; color: var(--muted);
    font: inherit; font-size: 13px; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer;
  }
  .side-item .icon { width: 18px; height: 18px; flex: none; }
  .side-item:hover { background: var(--panel); color: var(--ink); }
  .side-item:disabled { opacity: 0.5; cursor: default; background: transparent; }
  .side-item.active { background: var(--panel); color: var(--ink); box-shadow: inset 2px 0 var(--signal); font-weight: 600; }
  .side-bottom { margin-top: auto; padding: 16px 12px 4px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.6; }
  .side-bottom strong { display: block; color: var(--ink); font-size: 12px; margin-bottom: 2px; }
  /* Narrow desktop: the sidebar keeps only its icons. */
  .brandword, .navlabel, .side-item > span, .side-bottom { display: none; }
  .side-brand { justify-content: center; padding: 6px 0 28px; }
  .side-item { justify-content: center; padding: 0; min-height: 44px; }

  /* Breadcrumb bar replaces the brand bar; the brand lives in the sidebar. */
  .top-app-bar { min-height: 62px; padding: 0 34px; background: var(--bar); }
  .top-app-bar .brand { display: none; }
  .top-app-bar .crumb { display: block; flex: 1; font-size: 12px; color: var(--muted); }
  .top-app-bar .crumb strong, .crumb .title-medium { color: var(--ink); font-weight: 700; }
  .app.in-brief .workspace-head { min-height: 62px; padding: 0 26px 0 34px; background: var(--bar); }
  .app.in-brief .workspace-head > .icon-btn:first-child { display: none; }
  .workspace-head > .grow { justify-content: space-between; align-items: center; }
  .crumb { font-size: 12px; color: var(--muted); }
  .crumb .title-medium { font-size: 12px; }
  .crumb-link, .crumb-sep { display: inline; }
  .crumb-link { border: 0; background: none; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
  .crumb-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
  .crumb-sep { white-space: pre; }
  .app.in-brief .stepper { top: 62px; margin-top: 44px; }
  .app.in-brief .banner.sticky { top: 124px; }

  .page { max-width: 1260px; padding: 44px 46px 120px; }
  .stepper { max-width: calc(1260px - 92px); width: calc(100% - 92px); }
  .app.in-brief .page { padding-top: 30px; }
}

@media (min-width: 1100px) {
  .app { grid-template-columns: 232px minmax(0, 1fr); }
  .sidebar { padding: 25px 16px 16px; }
  .brandword, .navlabel { display: block; }
  .side-item > span { display: inline; }
  .side-bottom { display: block; }
  .side-brand { justify-content: flex-start; padding: 6px 12px 30px; }
  .side-item { justify-content: flex-start; padding: 0 12px; min-height: 40px; }
}

/* Sections step on wide screens: list on the left, settings for the open section on the right */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.editor-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.editor-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.editor-head .mono { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.rail { display: grid; gap: 13px; padding-top: 38px; }
.railbox { border: 1px solid var(--line); background: var(--rail); padding: 16px; }
.railbox h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: -0.005em; }
.railbox > p { margin: 0 0 14px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.railbox > p:last-child { margin-bottom: 0; }
.railbox .condition { border: 0; background: none; padding: 0; }
.railbox .condition .field input, .railbox .condition .field select { background: var(--panel); }
.railbox .condition .rule { grid-template-columns: minmax(0, 1fr) auto; }
.railbox .condition .rule .field:nth-child(1) { grid-column: 1 / -1; }
.railbox .hidden-note { font-size: 12px; }
.rail-card {
  position: relative; overflow: hidden; min-height: 147px; padding: 18px;
  background: var(--card-dark); color: #f5f2e9; border: 1px solid var(--card-dark-line);
}
.rail-card::after {
  content: ''; position: absolute; right: -26px; bottom: -45px; width: 150px; height: 150px;
  border: 1px solid #5f615a; transform: rotate(45deg);
  box-shadow: 0 0 0 12px var(--card-dark), 0 0 0 13px #5f615a, 0 0 0 25px var(--card-dark), 0 0 0 26px #5f615a;
}
.rail-card small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: #d2d0c5; }
.rail-card h3 { position: relative; z-index: 1; max-width: 180px; margin: 22px 0 6px; font-size: 19px; line-height: 1.2; letter-spacing: -0.03em; font-weight: 700; overflow-wrap: anywhere; }
.rail-card .dot-mark { color: #ff7551; }
.rail-card p { position: relative; z-index: 1; margin: 0; font-family: var(--mono); font-size: 10.5px; color: #d2d0c5; }

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