/* Savinet Console — Chat widget v2 (dsg-795fb5d807d8, Direction A "Structured Console").
   Tokens lifted directly from the approved design-as-code screens at
   /srv/savinet/_platform/assets/designs/dsg-795fb5d807d8/r1/A/*.html, which themselves match
   the tokens already shipped in Savinet.Api/wwwroot/app.css ("Direction A, approved rev 1").
   Scaled from the design's 1080x2340 fixed mockup canvas to real responsive breakpoints. */

:root {
  --canvas: #f6f6f5;
  --surface: #ffffff;
  --sunken: #eeeeec;
  --nav-bg: #1d2126;
  --line: #e0e0dd;
  --line-strong: #bfbfba;
  --ink: #16181b;
  --dim: #666b6e;
  --faint: #8c8c87;
  --accent: #2563eb;
  --accent-bg: #e6ecfe;
  --ok: #168b47;
  --ok-bg: #e0f2e5;
  --warn: #b57a08;
  --warn-bg: #fef1d8;
  --bad: #c82828;
  --bad-bg: #fce6e5;
  --radius: 20px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* FocusOnNavigate (Routes.razor) programmatically focuses the page's h1 on every navigation for
   screen readers; without this it also paints a visible focus ring that reads as a stray box. */
h1:focus { outline: none; }

#blazor-error-ui {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  background: var(--bad-bg); color: #8f1f1f; padding: .9rem 1.1rem; text-align: center;
}
#blazor-error-ui .reload { text-decoration: underline; margin-left: .5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ── Screen shell — full-height, chat fills the viewport on phone, centered column on desktop ── */

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.screen.canvas { background: var(--canvas); }

@media (min-width: 900px) {
  .screen { max-width: 640px; margin: 0 auto; border-inline: 1px solid var(--line); }
}

/* ── Chat header (shared by Welcome / Statement / Decision / Window) ── */

header.chat {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex: none; background: none; border: 0; cursor: pointer; color: var(--ink);
}
.icon-btn:active { background: var(--sunken); }
.who-avatar {
  width: 42px; height: 42px; border-radius: 13px; background: var(--nav-bg);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.who { flex: 1; min-width: 0; }
.who .name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.who .status-line { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.hicon {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-family: var(--mono); font-size: 14px; font-weight: 700; flex: none;
}

/* ── Launcher (00) ── */

.launcher-top {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 16px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line);
}
.ham span { display: block; width: 20px; height: 2px; background: var(--ink); margin: 4px 0; border-radius: 2px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.proj-chip {
  margin-left: auto; display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 999px; padding: 7px 14px 7px 10px;
  font-size: 14px; font-weight: 600;
}
.proj-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

main.launcher-body { flex: 1; position: relative; padding: 20px 16px 120px; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 6px;
}
h1.pagehead { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.sub { color: var(--dim); font-size: 15px; margin-bottom: 20px; }

.story {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: 0 2px 4px rgba(20,20,20,.03);
}
.story .k {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 8px;
}
.story h3 { margin: 0 0 8px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.story p.charter { color: var(--dim); font-size: 14.5px; line-height: 1.55; margin: 0 0 14px; }
.story ul { margin: 0; padding-left: 0; list-style: none; }
.story li {
  display: flex; gap: 10px; font-size: 14.5px; color: var(--ink); padding: 9px 0;
  border-top: 1px solid var(--line); align-items: flex-start;
}
.story li:first-child { border-top: 0; }
.tick { flex: none; width: 18px; height: 18px; margin-top: 2px; }

.decision-teaser {
  margin-top: 14px; background: var(--accent-bg); border: 1px solid #b9caf7;
  border-radius: 16px; padding: 14px 16px;
}
.decision-teaser .q { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.decision-teaser .m { font-size: 13px; color: var(--dim); }

.peek {
  display: block; position: absolute; right: 16px; bottom: 132px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px 18px 4px 18px; padding: 14px 16px;
  box-shadow: 0 12px 28px rgba(15,17,20,.16);
}
.peek .who-row { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.peek .avatar { width: 22px; height: 22px; border-radius: 7px; background: var(--nav-bg); display: flex; align-items: center; justify-content: center; }
.peek p { margin: 0; font-size: 14.5px; line-height: 1.4; color: var(--ink); }
.peek .arrow { color: var(--accent); font-weight: 700; }

.fab {
  position: fixed; right: 20px; bottom: 24px; width: 60px; height: 60px; border-radius: 20px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 28px rgba(37,99,235,.38); border: 0; cursor: pointer;
}
@media (min-width: 900px) { .fab { right: calc((100vw - 640px) / 2 + 20px); } }
.fab-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--bad); color: #fff; font: 800 11px/20px var(--mono); text-align: center;
  border: 3px solid var(--canvas); padding: 0 4px;
}

/* ── Conversation body (Welcome / Statement / Decision) ── */

main.convo { flex: 1; padding: 16px 16px 140px; position: relative; }
.day {
  text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 18px;
}
.row { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-end; }
.row.mine { justify-content: flex-end; }
.row .av {
  width: 30px; height: 30px; border-radius: 10px; background: var(--nav-bg); flex: none;
  display: flex; align-items: center; justify-content: center;
}
.bubble {
  max-width: 78%; border-radius: 18px 18px 18px 5px; padding: 12px 15px;
  font-size: 15px; line-height: 1.48; background: var(--sunken);
}
.bubble.mine {
  background: var(--ink); color: #fff; border-radius: 18px 18px 5px 18px; max-width: 82%;
}
.bubble strong { font-weight: 700; }
.meta { font-size: 12px; color: var(--faint); margin: 4px 0 14px 40px; }
.meta.mine { text-align: right; margin: 4px 0 14px; }

.suggested {
  font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); margin: 4px 0 10px 40px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px 40px; }
.chip {
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 999px;
  padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.chip:active { border-color: var(--accent); color: var(--accent); }

.artifact {
  display: block; margin: 0 0 18px 40px; background: var(--ok-bg); border: 1px solid #a9d9b7;
  border-radius: 14px; padding: 14px 16px; max-width: 82%;
}
.artifact .head {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12.5px;
  color: #106437; margin-bottom: 6px; letter-spacing: .02em;
}
.artifact p { margin: 0; font-size: 14.5px; line-height: 1.5; color: #1c3d28; }
.artifact a.view { display: inline-block; margin-top: 8px; font-size: 13.5px; font-weight: 700; color: var(--accent); }

.status-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--warn-bg);
  border: 1px solid #e6cb87; border-radius: 999px; padding: 7px 14px 7px 10px; font-size: 13px;
  font-weight: 700; color: #7a5405; margin: 0 0 22px 40px; cursor: pointer;
}
.status-chip .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }

/* ── Composer (bottom bar) ── */

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center;
}
@media (min-width: 900px) {
  .composer { max-width: 640px; margin: 0 auto; left: 0; right: 0; }
}
.composer .input {
  flex: 1; background: var(--sunken); border: 1px solid var(--line); border-radius: 22px;
  padding: 12px 16px; font-size: 15px; color: var(--faint);
}
.sendbtn {
  width: 44px; height: 44px; border-radius: 14px; background: var(--accent); flex: none; border: 0;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 14px rgba(37,99,235,.3);
  cursor: pointer;
}

/* ── Decision card (7-field, HumanInterface.md §5) ── */

.dcard {
  margin: 4px 0 18px 40px; max-width: 82%; background: var(--surface); border: 2px solid var(--accent);
  border-radius: 20px; overflow: hidden; box-shadow: 0 10px 28px rgba(37,99,235,.12);
}
.dcard .hdr { background: var(--accent-bg); padding: 14px 18px; border-bottom: 1px solid #b9caf7; }
.dcard .hdr .k {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.dcard .hdr .q { font-size: 17.5px; font-weight: 700; line-height: 1.3; }
.dcard .body { padding: 4px 18px 4px; }
.field { padding: 12px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field .fk {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; margin-bottom: 4px;
}
.field .fv { font-size: 14.5px; line-height: 1.45; color: var(--ink); }
.field.risk .fv { color: #8a4c05; }
.field.safe { background: var(--sunken); margin: 0 -18px; padding: 12px 18px; }
.deadline {
  display: flex; align-items: center; gap: 8px; background: var(--bad-bg); color: #8f1f1f;
  font-size: 13px; font-weight: 700; padding: 12px 18px; margin-top: 2px;
}
.actions { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 18px; }
.actions .action-btn {
  display: block; text-align: center; padding: 13px; border-radius: 14px; font-size: 15px;
  font-weight: 700; border: 0; cursor: pointer; width: 100%;
}
.a-approve { background: var(--accent); color: #fff; }
.a-keep { background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--ink); }
.a-evidence { background: none; color: var(--dim); font-weight: 600; padding: 6px; }

/* ── Owner window digest (04) ── */

.digest {
  margin: 4px 0 18px 40px; max-width: 82%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 20px; overflow: hidden; box-shadow: 0 10px 28px rgba(20,20,20,.08);
}
.digest .hdr { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.digest .hdr .k {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; margin-bottom: 2px;
}
.digest .hdr .t { font-size: 17px; font-weight: 700; }
.ditem { display: flex; gap: 12px; align-items: flex-start; padding: 13px 18px; border-top: 1px solid var(--line); }
.ditem:first-child { border-top: 0; }
.dicon {
  width: 26px; height: 26px; border-radius: 9px; flex: none; display: flex; align-items: center;
  justify-content: center; margin-top: 1px; background: var(--accent-bg);
}
.dtext .dt { font-size: 14.5px; font-weight: 700; line-height: 1.35; }
.dtext .dm { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.digest .foot { padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.digest .foot a {
  display: block; text-align: center; background: var(--sunken); border-radius: 12px;
  padding: 12px; font-size: 14px; font-weight: 700; color: var(--ink);
}

.donebar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
@media (min-width: 900px) { .donebar { max-width: 640px; margin: 0 auto; left: 0; right: 0; } }
.donebar a {
  display: block; text-align: center; background: var(--ink); color: #fff; border-radius: 16px;
  padding: 15px; font-size: 15px; font-weight: 700;
}

/* ── Type specimen (05) ── */

main.specimen { padding: 20px 16px 60px; }
.spec { padding: 18px 0; border-top: 1px solid var(--line); }
.spec:first-child { border-top: 0; }
.spec .label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px;
}
.spec .sample.h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.spec .sample.h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.spec .sample.body { font-size: 15px; line-height: 1.5; max-width: 60ch; }
.spec .sample.caption { font-size: 12.5px; color: var(--faint); }
.spec .sample.mono { font-family: var(--mono); font-size: 13px; color: var(--dim); }
.spec .sample.btn {
  display: inline-block; background: var(--accent); color: #fff; font-size: 14.5px;
  font-weight: 700; padding: 12px 20px; border-radius: 14px;
}
.swrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.sw { width: 68px; }
.sw .chip-sw { height: 40px; border-radius: 10px; border: 1px solid var(--line); }
.sw .name { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 6px; text-align: center; }
