/* Do For Self CRM. Colors from the Do For Self flyers: royal blue, deep red, white, with gold accents.
   One family (Archivo): condensed and heavy for display, normal width for reading. */
:root {
  --brand: #1c46c6;        /* royal blue: links, primary buttons */
  --brand-solid: #1c46c6;  /* button fill */
  --brand-2: #2f5de6;
  --navy: #0b1e5b;         /* deep blue: sidebar, page headers */
  --navy-2: #163196;
  --red: #d7182a;          /* calls to action */
  --red-2: #b0101f;
  --gold: #e7b528;         /* accents */
  --gold-ink: #8a6200;     /* gold that reads on white */
  --paper: #f3f5fb;
  --surface: #ffffff;
  --ink: #0d1530;
  --muted: #56607a;
  --line: #d8ddeb;
  --line-strong: #b6bfd6;
  --good: #1f7a45; --good-bg: #e2f3e8;
  --warn: #8a5a00; --warn-bg: #fdf0cf;
  --bad: #b42318;  --bad-bg: #fde4e1;
  --info: #1c46c6; --info-bg: #e3eafc;
  --mute-bg: #eaedf5;
  --focus: #0b1e5b;
  --radius: 6px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #080e22; --surface: #101a38; --ink: #e8ecf8; --muted: #a3adc8; --line: #233059; --line-strong: #3a4878;
    --brand: #7d9bff; --brand-solid: #2448d0; --brand-2: #5c84ff; --navy: #060c26; --navy-2: #12245f;
    --red: #ff4d5a; --red-2: #e0303f; --gold: #f2c94c; --gold-ink: #f2c94c;
    --good: #7ad19c; --good-bg: #12301f; --warn: #f2c94c; --warn-bg: #3a2c0a; --bad: #ff8a80; --bad-bg: #3d1414;
    --info: #9fb6ff; --info-bg: #17285c; --mute-bg: #1a2448; --focus: #f2c94c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #080e22; --surface: #101a38; --ink: #e8ecf8; --muted: #a3adc8; --line: #233059; --line-strong: #3a4878;
  --brand: #7d9bff; --brand-solid: #2448d0; --brand-2: #5c84ff; --navy: #060c26; --navy-2: #12245f;
  --red: #ff4d5a; --red-2: #e0303f; --gold: #f2c94c; --gold-ink: #f2c94c;
  --good: #7ad19c; --good-bg: #12301f; --warn: #f2c94c; --warn-bg: #3a2c0a; --bad: #ff8a80; --bad-bg: #3d1414;
  --info: #9fb6ff; --info-bg: #17285c; --mute-bg: #1a2448; --focus: #f2c94c; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--font); color: var(--ink); background: var(--paper); font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-stretch: 112%; line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--brand-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sub { color: var(--muted); font-size: 0.875rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.loading { color: var(--muted); }
.note { max-width: 70ch; color: var(--muted); }

/* ---------- buttons ---------- */
.btn { font: 600 0.9rem var(--font); border-radius: var(--radius); padding: 0.55rem 1rem; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--brand-solid); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.cta { background: var(--red); color: #fff; box-shadow: 0 2px 0 var(--red-2); }
.btn.cta:hover { background: var(--red-2); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--mute-bg); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: currentColor; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn.block { width: 100%; margin-top: 0.5rem; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-2); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link.light { color: #cdd8ff; }

/* ---------- shell ---------- */
#app { min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
#app:has(> .center) { display: block; }
.side { background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #e6ebff; border-top: 4px solid var(--red); padding: 1.25rem 0.75rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .org { padding: 0 0.5rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,.14); display: grid; gap: 0.5rem; }
.side .org img { max-width: 140px; max-height: 96px; object-fit: contain; border-radius: 8px; }
.side .org-name { font-stretch: 80%; font-weight: 850; font-size: 1.3rem; letter-spacing: 0.02em; text-transform: uppercase; color: #fff; }
.side .org-subtitle { color: #e7b528; text-transform: uppercase; font-weight: 750; font-size: .71rem; letter-spacing: .14em; margin-top: -.25rem; }
.side .org-name::after { content: ""; display: block; width: 44px; height: 3px; margin-top: 0.35rem; background: linear-gradient(90deg, var(--red) 0 60%, var(--gold) 60%); border-radius: 2px; }
.org-switch { font: inherit; font-size: 0.8rem; background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.25); border-radius: var(--radius); padding: 0.2rem; }
.side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side ul.admin { padding-top: 0.75rem; border-top: 1px solid rgba(255,255,255,.14); }
.side :focus-visible { outline-color: var(--gold); }
.side a { display: block; color: #cdd8ff; text-decoration: none; padding: 0.45rem 0.6rem; border-radius: var(--radius); font-weight: 500; }
.side a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side a[aria-current] { background: rgba(255,255,255,.13); color: #fff; font-weight: 650; box-shadow: inset 4px 0 0 var(--gold); }
.side .me { margin-top: auto; padding: 0.75rem 0.5rem 0; border-top: 1px solid rgba(255,255,255,.14); display: grid; gap: 0.3rem; font-size: 0.82rem; justify-items: start; }
.me-email { color: #fff; word-break: break-all; }
.me-role { color: var(--gold); font-weight: 600; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; gap: 0.75rem; align-items: center; padding: 0.75rem 2rem; border-bottom: 3px solid var(--brand-solid); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top input[type=search] { flex: 1; max-width: 520px; }
.menu-btn { display: none; }
main#view { padding: 1.75rem 2rem 4rem; max-width: 1280px; width: 100%; }
main#view:focus { outline: none; }
.page-head h1, .person-head h1 { font-stretch: 85%; font-weight: 850; text-transform: uppercase; letter-spacing: 0.01em; color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .page-head h1, :root:not([data-theme="light"]) .person-head h1 { color: var(--ink); } }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- inputs ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.5rem 0.65rem; width: 100%; min-height: 40px; }
textarea { resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand-2); margin: 0; }
input[type=color] { padding: 2px; height: 40px; }
[aria-invalid="true"] { border-color: var(--bad); }
.field { display: grid; gap: 0.3rem; align-content: start; }
.field > label, .field .lbl, .field legend { font-weight: 600; font-size: 0.85rem; }
.field small { color: var(--muted); }
.field-error, .form-error { color: var(--bad); font-size: 0.85rem; }
.form-error:empty, .field-error:empty { display: none; }
.form-note { color: var(--good); font-size: 0.875rem; }
.req { color: var(--bad); }
.check { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.9rem; cursor: pointer; }
.check input { margin-top: 2px; flex: none; }
.form-grid { display: grid; gap: 1.25rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.group > legend { font-stretch: 112%; font-weight: 700; font-size: 0.95rem; margin-bottom: 0.6rem; padding: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem 1rem; }
.grid .wide, .field.wide { grid-column: 1 / -1; }
.field.readonly span:last-child { color: var(--muted); font-size: 0.85rem; white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.chip span { display: inline-block; padding: 0.3rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.85rem; }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; gap: 0.75rem; justify-content: space-between; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---------- filters, tables ---------- */
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.filters input { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 200px; }
.count { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.5rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--muted); padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--paper); }
.row-link { all: unset; font-weight: 600; cursor: pointer; }
.row-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; background: var(--mute-bg); color: var(--muted); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: 0.5rem 0.8rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.9rem; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-selected="true"] { color: var(--ink); border-color: var(--red); }

/* ---------- owner back office ---------- */
.owner-home { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1.5rem; overflow: hidden; box-shadow: 0 4px 20px rgba(12, 26, 70, .05); }
.owner-home-intro { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; padding: 1.5rem 1.6rem; color: #fff; background: linear-gradient(115deg, #0a1a52, #1c46c6); }
.owner-home-intro h2 { font-size: clamp(1.3rem, 2.3vw, 1.85rem); }
.owner-home-intro p:last-child { max-width: 64ch; margin: .5rem 0 0; color: #e5ecff; }
.owner-eyebrow { font-size: .72rem; margin: 0 0 .35rem; letter-spacing: .13em; font-weight: 800; color: #e7b528; }
.owner-home-intro > .btn { border: 1px solid rgba(255,255,255,.6); background: #fff; color: #0a1a52; }
.owner-home-intro > .btn:hover { background: #f0f3ff; }
.owner-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.owner-tool { position: relative; display: flex; flex-direction: column; gap: .35rem; min-height: 135px; padding: 1.15rem 1.1rem 2rem; background: var(--surface); color: var(--ink); text-decoration: none; }
.owner-tool:hover { background: var(--paper); color: var(--ink); }
.owner-tool-title { font-size: .95rem; font-weight: 750; }
.owner-tool-desc { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.owner-tool-arrow { position: absolute; bottom: .75rem; right: 1rem; color: var(--brand-2); font-size: 1.15rem; font-weight: 800; }
.owner-public { display: flex; gap: .75rem 1.5rem; flex-wrap: wrap; align-items: center; padding: 1rem 1.5rem; }
.owner-public > strong { font-size: .88rem; }
.owner-public-links { display: flex; flex-wrap: wrap; gap: .6rem 1rem; }
.owner-public-links a { font-weight: 650; font-size: .83rem; text-underline-offset: 3px; }
@media (max-width: 1100px) { .owner-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .owner-tools { grid-template-columns: 1fr; } .owner-home-intro { padding: 1.1rem; } .owner-public { padding: 1rem; } .owner-tool { min-height: 94px; } }

/* ---------- overview ---------- */
.stats { overflow: hidden; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 2rem; }
.stat { padding: 1.1rem 1.2rem; text-decoration: none; color: var(--ink); display: grid; gap: 0.2rem; border-right: 1px solid var(--line); border-top: 4px solid var(--brand-solid); }
.stat:nth-child(3n+2) { border-top-color: var(--red); }
.stat:nth-child(3n+3) { border-top-color: var(--gold); }
.stat:last-child { border-right: 0; }
.stat:hover { background: var(--paper); }
.stat .n { font-stretch: 85%; font-weight: 850; font-size: 2.1rem; line-height: 1.1; color: var(--brand); }
.stat .t { color: var(--muted); font-size: 0.85rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; }
.split h2 { margin: 1.5rem 0 0.5rem; }
.split > div > h2:first-child { margin-top: 0; }
.todo { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.35rem; }
.todo .quiet { color: var(--muted); list-style: none; margin-left: -1.1rem; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.bars a { display: grid; grid-template-columns: 7rem 1fr 2rem; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); font-size: 0.9rem; }
.bar { height: 12px; background: var(--brand-2); border-radius: 0 3px 3px 0; min-width: 3px; }
.bar-n { text-align: right; font-weight: 600; }
.pipeline-mini { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pipeline-mini a { display: grid; padding: 0.6rem 0.7rem; background: var(--surface); text-decoration: none; color: var(--muted); font-size: 0.78rem; height: 100%; }
.pipeline-mini .n { font-stretch: 120%; font-weight: 800; font-size: 1.35rem; color: var(--ink); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }

/* ---------- person ---------- */
.person-head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-end; flex-wrap: wrap; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.crumb { margin: 0 0 0.25rem; font-size: 0.85rem; }
.person-head h1 { font-size: 2.1rem; font-stretch: 118%; }
.contact-line { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0.4rem 0; }
.tags { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin: 0.25rem 0 0; }
.tag { font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.55rem; border: 1px solid var(--line-strong); border-radius: 999px; }
.consent { font-size: 0.78rem; padding: 0.15rem 0.5rem; border-radius: 999px; }
.consent.yes { color: var(--good); background: var(--good-bg); }
.consent.no { color: var(--muted); background: var(--mute-bg); text-decoration: line-through; }
.head-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.person-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 2rem; align-items: start; }
.person-main { display: grid; gap: 1.75rem; min-width: 0; }
.membership-box { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: grid; gap: 0.6rem; justify-items: start; }
.mb-top { display: flex; gap: 0.75rem; align-items: center; }
.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.related { display: grid; gap: 0.6rem; }
main#view > .related, main#view > form.details + .related { margin-top: 2.25rem; }
form.details > fieldset.group + fieldset.group { margin-top: 1.5rem; }
.rel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.related > .rel-head:only-child { color: var(--muted); }
.details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.timeline { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.timeline h2 { margin-bottom: 0.75rem; }
.timeline ol { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); display: grid; gap: 1rem; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.timeline li.call::before, .timeline li.sms::before, .timeline li.meeting::before, .timeline li.email::before { border-color: var(--brand-2); background: var(--brand-2); }
.timeline li.note::before { border-color: var(--gold); background: var(--gold); }
.timeline .kind { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.timeline p { margin: 0.1rem 0; white-space: pre-wrap; font-size: 0.9rem; }
.timeline .when { font-size: 0.75rem; color: var(--muted); }

/* Punch card: one hole per request this month. Filled = used. */
.punch { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; }
.punch .holes { display: flex; gap: 6px; }
.punch .holes span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--brand-2); background: transparent; }
.punch .holes span.used { background: var(--red); border-color: var(--red); box-shadow: inset 0 0 0 3px var(--surface); }
.punch.large .holes span { width: 26px; height: 26px; }
.punch-text { font-size: 0.9rem; }
.punch-text strong { font-stretch: 112%; }
.punch-text .sub { display: block; }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 0.75rem; overflow-x: auto; padding-bottom: 1rem; }
.board .col { background: var(--mute-bg); border-radius: var(--radius); padding: 0.75rem; display: grid; gap: 0.5rem; align-content: start; min-height: 140px; }
.board h2 { font-size: 0.85rem; display: flex; justify-content: space-between; }
.board h2 .n { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.65rem 0.75rem; display: grid; gap: 0.3rem; }
.card-name { font-weight: 700; text-decoration: none; color: var(--ink); }
.card .sub { margin: 0; font-size: 0.8rem; }
.card-actions { display: flex; gap: 0.5rem; align-items: center; }
.card-actions select { min-height: 32px; padding: 0.2rem 0.4rem; font-size: 0.8rem; }

/* ---------- modal, toast ---------- */
dialog.modal { border: 0; border-radius: 10px; padding: 1.5rem; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(6, 12, 38, 0.35); }
dialog.modal.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(6, 12, 38, 0.6); }
dialog h2 { margin-bottom: 1rem; font-size: 1.35rem; font-stretch: 85%; font-weight: 850; text-transform: uppercase; color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) dialog h2 { color: var(--ink); } }
dialog.modal { border-top: 5px solid var(--brand-solid); }
.modal-body { display: grid; gap: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; padding-top: 0.5rem; position: sticky; bottom: -1.5rem; background: var(--surface); padding-bottom: 0.25rem; }
#toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translate(-50%, 150%); background: var(--ink); color: var(--paper); padding: 0.7rem 1.1rem; border-radius: var(--radius); font-weight: 500; transition: transform 0.2s ease; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); color: #fff; }
#toast.warn { background: var(--warn); color: #fff; }
pre.code { background: var(--mute-bg); padding: 0.75rem 1rem; border-radius: var(--radius); overflow-x: auto; font-size: 0.85rem; white-space: pre-wrap; word-break: break-all; }

/* ---------- sign-in ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-page { background: radial-gradient(circle at 20% 10%, var(--navy-2), var(--navy) 60%); border-top: 6px solid var(--red); }
.auth-card { background: var(--surface); border-radius: 10px; padding: 2rem; width: min(420px, 100%); }
.auth h1 { font-size: 1.6rem; margin-bottom: 0.4rem; }
.auth .lede { color: var(--muted); margin: 0 0 1.25rem; }
.auth form { display: grid; gap: 0.9rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: 0.9rem; }
.dev-note { background: var(--warn-bg); color: var(--warn); padding: 0.6rem 0.75rem; border-radius: var(--radius); font-size: 0.85rem; margin: 0; }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .person-grid { grid-template-columns: 1fr; }
  .timeline { position: static; max-height: none; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-btn { display: inline-block; font: 600 0.85rem var(--font); background: none; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.45rem 0.7rem; color: var(--ink); }
  .top { padding: 0.6rem 16px; }
  .top .btn { display: none; }
  main#view { padding: 1.25rem 16px 4rem; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .person-head h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tag-row { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
td .link { white-space: nowrap; }
.item-name { display: inline-flex; align-items: center; gap: 0.6rem; }
.thumb { width: 44px; height: 33px; object-fit: cover; border-radius: 4px; background: var(--navy); }
.tag.shop { border-color: var(--red); color: var(--red); }

/* ---------- Website editor (#/website): full-screen workspace ---------- */
body.web-focus #app { grid-template-columns: 1fr; }
body.web-focus .side, body.web-focus .top { display: none; }
main#view.web-view { max-width: none; padding: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
main#view.web-view > .web-layout { flex: 1; }

.web-topbar { display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0.75rem; background: var(--surface); border-bottom: 3px solid var(--brand-solid); min-width: 0; }
.web-back { font-weight: 650; text-decoration: none; color: var(--ink); padding: 0.35rem 0.6rem; border-radius: var(--radius); white-space: nowrap; }
.web-back:hover { background: var(--mute-bg); }
.web-title { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.web-title strong { font-stretch: 85%; font-weight: 850; text-transform: uppercase; color: var(--navy); font-size: 1.05rem; letter-spacing: 0.02em; }
.web-pill { font-size: 0.75rem; font-weight: 650; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--good-bg); color: var(--good); }
.web-pill.draft { background: var(--warn-bg); color: var(--warn); }
.web-viewctl { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; min-width: 0; }
.web-select { width: auto; max-width: 220px; min-height: 34px; padding: 0.25rem 0.5rem; }
.web-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; flex: none; }
.web-seg button { font: 600 0.82rem var(--font); padding: 0.35rem 0.65rem; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.web-seg button + button { border-left: 1px solid var(--line-strong); }
.web-seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.web-actions { display: flex; align-items: center; gap: 0.4rem; flex: none; }
.web-actions .btn.cta { padding: 0.5rem 1.1rem; }
.web-menu { position: relative; }
.web-menu-btn { font-size: 1.1rem; line-height: 1; padding: 0.3rem 0.6rem; }
.web-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; display: grid; padding: 0.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 30px rgba(6, 12, 38, 0.18); }
.web-menu-list[hidden] { display: none; }
.web-menu-list button { text-align: left; font: 500 0.9rem var(--font); padding: 0.5rem 0.7rem; border: 0; border-radius: 6px; background: none; color: var(--ink); cursor: pointer; }
.web-menu-list button:hover, .web-menu-list button:focus-visible { background: var(--mute-bg); }
.web-menu-list button.danger { color: var(--bad); }
.web-panes { display: none; }

.web-layout { min-height: 0; display: grid; grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); }
.web-chat { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.web-preview { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--paper); }
.web-preview-note { margin: 0; padding: 0.35rem 0.75rem; background: var(--warn-bg); color: var(--warn); font-size: 0.8rem; font-weight: 600; }
.web-frame-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; overflow: hidden; }
.web-frame { width: 100%; height: 100%; border: 0; background: #fff; flex: none; transform-origin: top left; }
.web-frame-wrap.scaled { display: block; position: relative; }
.web-frame-wrap.scaled .web-frame { position: absolute; top: 0; left: 0; }
.web-frame-wrap.phone { padding: 0.75rem 0; background: repeating-linear-gradient(45deg, var(--paper) 0 12px, var(--mute-bg) 12px 24px); }
.web-frame-wrap.phone .web-frame { width: 390px; max-width: 100%; border-radius: 18px; box-shadow: 0 0 0 8px var(--navy), 0 18px 40px rgba(6, 12, 38, 0.25); }

.web-meter { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.web-bar { flex: 1; min-width: 80px; height: 6px; border-radius: 999px; background: var(--mute-bg); overflow: hidden; }
.web-bar span { display: block; height: 100%; border-radius: inherit; background: var(--good); transition: width 0.4s ease; }
.web-bar.warn span { background: var(--gold); }
.web-bar.bad span { background: var(--bad); }
.web-meter-text { white-space: nowrap; }
.web-limit { flex-basis: 100%; margin: 0; font-weight: 650; }
.web-limit.bad { color: var(--bad); }
.web-limit.warn { color: var(--warn); }

.web-platform { border-bottom: 1px solid var(--line); padding: 0.4rem 0.9rem; font-size: 0.8rem; background: var(--warn-bg); }
.web-platform summary { cursor: pointer; font-weight: 650; }
.web-platform[open] { display: grid; gap: 0.5rem; max-height: 40vh; overflow-y: auto; }
.web-platform-form { display: grid; gap: 0.4rem; }
.web-platform .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.web-platform input[type=number] { padding: 0.2rem 0.4rem; font-size: 0.8rem; min-height: 0; width: 100%; }
.web-platform .field > label { font-size: 0.72rem; }
.web-platform-form > .btn, .web-platform .web-grant .btn { justify-self: start; width: auto; }
.web-grant { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.web-platform .web-grant input { width: 5.5rem; flex: none; }
.web-requests { margin: 0.3rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.3rem; }

.web-log { flex: 1; min-height: 0; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.75rem; }
.web-welcome { display: grid; gap: 0.6rem; margin: auto 0; }
.web-welcome h2 { font-stretch: 90%; text-transform: uppercase; color: var(--navy); }
.web-welcome p { margin: 0; color: var(--muted); }
.web-welcome .web-starters { padding: 0; flex-wrap: wrap; overflow: visible; }
.web-fine { font-size: 0.78rem; }
.msg { display: grid; gap: 0.2rem; max-width: 94%; }
.msg.me { align-self: flex-end; justify-items: end; }
.msg.ai { align-self: flex-start; }
.msg-body { padding: 0.55rem 0.75rem; border-radius: 12px; background: var(--mute-bg); display: grid; gap: 0.35rem; font-size: 0.92rem; }
.msg.me .msg-body { background: var(--brand-solid); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .msg-body { border-bottom-left-radius: 4px; }
.msg.error .msg-body { background: var(--bad-bg); color: var(--bad); }
.msg-body p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-changes { margin: 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--muted); }
.msg-show { justify-self: start; font-size: 0.85rem; font-weight: 650; }
.msg-meta { font-size: 0.7rem; color: var(--muted); }
.msg-cost { font-size: 0.7rem; color: var(--warn); }
.msg-files { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.msg.me .web-chip.static { background: rgba(255,255,255,.18); color: #fff; border-color: transparent; }
.msg.working .dots { display: inline-block; animation: web-blink 1.2s infinite; }
@keyframes web-blink { 50% { opacity: 0.2; } }

.web-starters { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.web-starters[hidden] { display: none; }
.web-chip { font: 600 0.8rem var(--font); padding: 0.3rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); white-space: nowrap; cursor: pointer; }
.web-chip:hover { border-color: var(--brand); color: var(--brand); }
.web-chip.static { cursor: default; font-weight: 500; }

.web-composer { padding: 0.6rem 0.75rem 0.75rem; display: grid; gap: 0.45rem; border-top: 1px solid var(--line); }
.web-compose { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); padding: 0.45rem 0.5rem 0.35rem 0.65rem; display: grid; gap: 0.25rem; }
.web-compose:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--info-bg); }
.web-input { width: 100%; min-height: 1.6rem; max-height: 160px; resize: none; border: 0; padding: 0.2rem 0; background: transparent; font: inherit; color: var(--ink); outline: none; box-shadow: none; }
.web-compose-tools { display: flex; align-items: center; gap: 0.15rem; }
.web-spacer { flex: 1; }
.web-ib { border: 0; background: none; font-size: 1.05rem; line-height: 1; padding: 0.35rem 0.4rem; border-radius: 8px; cursor: pointer; color: var(--muted); }
.web-ib:hover { background: var(--mute-bg); }
.web-ib.listening { background: var(--bad-bg); animation: web-blink 1.2s infinite; }
.web-send { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--brand-solid); color: #fff; font-size: 1.1rem; font-weight: 800; cursor: pointer; }
.web-send:disabled { opacity: 0.45; cursor: not-allowed; }
.web-tray { display: flex; flex-direction: column; gap: 0.3rem; }
.web-tray:empty { display: none; }
.web-tray .file { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 0.5rem; align-items: center; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.8rem; }
.web-tray .file img, .file-icon { width: 40px; height: 30px; object-fit: cover; border-radius: 4px; background: var(--mute-bg); display: grid; place-items: center; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.web-tray .file.ready .file-state { color: var(--good); font-weight: 600; }
.web-tray .file.failed .file-state { color: var(--bad); }
.file-x { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 0 0.3rem; }

.web-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; max-height: 60vh; overflow-y: auto; }
.web-history li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); }
.web-history li p { margin: 0.15rem 0 0; }
.web-history .pill { margin-left: 0.5rem; }
.web-history-actions { display: flex; gap: 0.4rem; }
.web-media { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.75rem; max-height: 60vh; overflow-y: auto; }
.web-media li { display: grid; gap: 0.3rem; font-size: 0.82rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem; }
.web-media img, .web-media .file-icon { width: 100%; height: 110px; object-fit: cover; border-radius: 4px; }
.web-guide { display: grid; gap: 0.2rem 0; margin: 0; }
.web-guide dt { font-weight: 700; margin-top: 0.6rem; }
.web-guide dd { margin: 0; color: var(--muted); }

/* Narrower screens: the page picker and toggles move under the title row. */
@media (max-width: 1100px) {
  .web-topbar { flex-wrap: wrap; row-gap: 0.4rem; }
  .web-viewctl { order: 3; flex-basis: 100%; margin-left: 0; }
  .web-actions { margin-left: auto; }
  .web-layout { grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); }
}
/* Phones: chat or preview, one at a time. */
@media (max-width: 820px) {
  .web-back { padding: 0.35rem 0.3rem; }
  .web-title strong { display: none; }
  .web-device { display: none; }
  .web-select { flex: 1; max-width: none; }
  .web-actions .btn.ghost.small:not(.web-menu-btn) { display: none; }
  .web-panes { display: flex; margin: 0.4rem 0.75rem; }
  .web-panes button { flex: 1; padding: 0.4rem; }
  .web-layout { grid-template-columns: 1fr; }
  .web-layout.pane-chat .web-preview, .web-layout.pane-preview .web-chat { display: none; }
  .web-chat { border-right: 0; }
}
