@font-face {
  font-family: "Archivo";
  src: url("assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Besley";
  src: url("assets/fonts/besley-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --navy: #0A2035;
  --navy-raised: #12304B;
  --navy-line: #1D3A55;
  --navy-text: #B4C2D3;
  --gold: #C28C24;
  --gold-soft: #F7EEDB;
  --ink: #172B3D;
  --muted: #5E7084;
  --subtle: #8595A6;
  --canvas: #ECEFF3;
  --surface: #FFFFFF;
  --surface-alt: #F7F9FB;
  --line: #DDE4EA;
  --line-soft: #E9EDF2;
  --ok: #26754C;
  --warn: #A05A0B;
  --down: #B04141;
  --unknown: #8595A6;
  --ok-soft: #E3F1E9;
  --warn-soft: #F8EBD9;
  --down-soft: #F6E1E1;
  --unknown-soft: #EEF1F4;
  --bar: #356F9C;
  --bar-hover: #24557D;
  /* Flow step kinds: always shown with their word, never colour alone. */
  --k-entry: #356F9C;
  --k-account: #C28C24;
  --k-question: #7A5BA6;
  --k-action: #26754C;
  --k-payment: #A05A0B;
  --k-external: #8595A6;
  --k-finish: #1C7C7D;
  --text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Besley", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E3E9F0;
    --muted: #A4B3C3;
    --subtle: #7F91A4;
    --canvas: #08172A;
    --surface: #0F2438;
    --surface-alt: #13293F;
    --line: #23405C;
    --line-soft: #1B3550;
    --ok: #5CC28A;
    --warn: #E5A048;
    --down: #EE7D7D;
    --unknown: #8EA0B3;
    --ok-soft: #12352A;
    --warn-soft: #3A2A12;
    --down-soft: #3D1C22;
    --unknown-soft: #1A2F45;
    --gold-soft: #3A2F18;
    --bar: #6FA6D2;
    --bar-hover: #A3C8E6;
    --k-entry: #6FA6D2;
    --k-account: #E0B154;
    --k-question: #B39BDB;
    --k-action: #5CC28A;
    --k-payment: #E5A048;
    --k-external: #8EA0B3;
    --k-finish: #5CC6C6;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 13.5px/1.45 var(--text);
  font-feature-settings: "tnum";
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.2px; }
a { color: var(--bar); }

/* Bar ---------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--navy); color: #fff;
  border-bottom: 1px solid var(--navy-line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font: 700 16px var(--display); }
.brand-sub { color: var(--navy-text); font-weight: 500; }
.env {
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.7px;
  background: var(--navy-raised); color: var(--navy-text); border: 1px solid var(--navy-line);
}
.env[data-env="prod"] { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 6px 12px; border-radius: 8px;
  color: var(--navy-text); text-decoration: none; font-weight: 600;
}
.tabs a:hover { color: #fff; background: var(--navy-raised); }
.tabs a[aria-current="page"] { color: #fff; background: var(--navy-raised); box-shadow: inset 0 -2px 0 var(--gold); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--gold); color: var(--navy);
  font-size: 11px; font-weight: 700; text-align: center;
}
.session { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--navy-text); font-size: 12.5px; }
.who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overall { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #fff; }

button.ghost {
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
  background: transparent; color: #fff; border: 1px solid var(--navy-line);
}
button.ghost:hover { background: var(--navy-raised); }
button.primary {
  padding: 9px 18px; border-radius: 8px; cursor: pointer;
  background: var(--gold); color: var(--navy); border: 0; font-weight: 700;
}
button.primary:hover { filter: brightness(1.06); }
button.secondary {
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 600;
}
button.secondary:hover { background: var(--surface-alt); }
.link { font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
button.link { background: none; border: 0; padding: 0; color: var(--bar); cursor: pointer; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Layout -------------------------------------------------------------- */
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 64px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 26px 0 10px; flex-wrap: wrap; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.meta { margin: 0; color: var(--muted); font-size: 12.5px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.panel-head h3 { font-size: 13.5px; font-weight: 700; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.empty { padding: 18px 16px; color: var(--muted); }

/* Gate ---------------------------------------------------------------- */
.gate {
  max-width: 420px; margin: 12vh auto 0; padding: 36px 32px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.gate h1 { font: 700 22px var(--display); margin: 14px 0 8px; }
.gate p { color: var(--muted); margin: 0 0 20px; }
.emulator-form { display: grid; gap: 8px; margin-top: 8px; }
.emulator-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); }
.hint { font-size: 12px; }

/* Health -------------------------------------------------------------- */
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.check {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: start;
  padding: 11px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.check[data-status="down"] { border-color: var(--down); background: var(--down-soft); }
.check[data-status="warn"] { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.check-label { font-weight: 700; overflow-wrap: anywhere; }
.check-group { color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.check-detail { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.check-latency { color: var(--subtle); font-size: 11.5px; white-space: nowrap; }

.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.status svg { width: 14px; height: 14px; flex: none; }
.status[data-status="ok"] { color: var(--ok); }
.status[data-status="warn"] { color: var(--warn); }
.status[data-status="down"] { color: var(--down); }
.status[data-status="unknown"] { color: var(--unknown); }
.overall .status { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface); }

/* Tiles --------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.tile-value { font-size: 26px; font-weight: 750; letter-spacing: -0.6px; margin-top: 2px; }
.tile-note { color: var(--subtle); font-size: 12px; }

/* Chart --------------------------------------------------------------- */
.chart-panel { margin-top: 10px; }
.chart { position: relative; padding: 8px 16px 14px; }
.chart svg { display: block; width: 100%; height: 160px; overflow: visible; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-label { fill: var(--subtle); font-size: 10.5px; }
.chart .bar { fill: var(--bar); pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.active { fill: var(--bar-hover); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 2;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap;
  background: var(--navy); color: #fff; font-size: 12px;
  transform: translate(-50%, calc(-100% - 8px));
}
.tooltip strong { font-size: 13px; }
#signup-table { padding: 0 16px 14px; }

/* Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font-size: 11.5px; font-weight: 600; background: var(--surface-alt); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.sub { display: block; color: var(--subtle); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; white-space: nowrap;
}
.chip[data-tone="gold"] { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.chip[data-tone="warn"] { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
.chip[data-tone="down"] { background: var(--down-soft); border-color: var(--down); color: var(--ink); }
.chip[data-tone="ok"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ink); }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 150px 140px 1fr; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); }
.log li:last-child { border-bottom: 0; }
.log time, .log .svc { color: var(--muted); font-size: 12px; }
.log .msg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Inbox --------------------------------------------------------------- */
.inbox-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 14px; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.segmented button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.segmented button[aria-pressed="true"] { background: var(--navy); color: #fff; }
#filter-text, #flows-filter { flex: 1 1 220px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }

.inbox { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 14px; align-items: start; }
.inbox-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; max-height: calc(100vh - 190px); overflow-y: auto; }
.inbox-list li + li { border-top: 1px solid var(--line-soft); }
.inbox-list button { display: block; width: 100%; text-align: left; padding: 11px 14px; background: none; border: 0; cursor: pointer; }
.inbox-list button:hover { background: var(--surface-alt); }
.inbox-list button[aria-current="true"] { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
.item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-from { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-when { color: var(--subtle); font-size: 11.5px; white-space: nowrap; }
.item-snippet { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 5px; }
.item-new .item-from::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: 1px; }

.inbox-detail { padding: 18px 20px; min-height: 240px; position: sticky; top: 66px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.detail-head h3 { font-size: 16px; }
.detail-from { color: var(--muted); margin-top: 3px; }
.detail-message { white-space: pre-wrap; overflow-wrap: anywhere; margin: 16px 0; padding: 14px 16px; background: var(--surface-alt); border: 1px solid var(--line-soft); border-radius: 10px; font-size: 14px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.note label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.note textarea { width: 100%; min-height: 72px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); resize: vertical; }
.note .actions { margin-top: 8px; }

/* Flows -------------------------------------------------------------- */
.flows-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 14px; }
.size-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.size-control input { width: 110px; accent-color: var(--gold); }
.size-control span { min-width: 48px; color: var(--ink); }

.flows { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 14px; align-items: start; }
.flows:has(.flows-nav[hidden]) { grid-template-columns: minmax(0, 1fr); }
.flows-nav { position: sticky; top: 66px; max-height: calc(100vh - 86px); overflow-y: auto; padding: 10px 0; }
.flows-nav-head { padding: 0 14px 6px; color: var(--subtle); font-size: 11.5px; }
.flows-group h3 { padding: 10px 14px 4px; color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.flows-group ul { list-style: none; margin: 0; padding: 0; }
.flows-group a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 6px 14px; color: var(--ink); text-decoration: none;
}
.flows-group a:hover { background: var(--surface-alt); }
.flows-group a[aria-current="true"] { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); font-weight: 600; }
.flows-nav-count { flex: none; color: var(--subtle); font-size: 11.5px; }

.flows-main { --thumb: 260px; --frame-w: 1280; --frame-h: 860; min-width: 0; }
.flows-main[data-size="small"] { --thumb: 180px; }
.flows-main[data-size="large"] { --thumb: 380px; }
.flows-empty { padding: 28px 24px; text-align: center; }
.flows-empty h2 { font: 700 18px var(--display); margin-bottom: 6px; }
.flows-empty p { margin: 0; color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-alt); border: 1px solid var(--line-soft); overflow-wrap: anywhere; }

.flow { margin-bottom: 14px; padding-top: 14px; scroll-margin-top: 72px; }
.flow-head { padding: 0 16px; }
.flow-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow-title h2 { font-size: 16px; font-weight: 700; margin-right: 4px; }
.flow-who { margin: 4px 0 0; color: var(--muted); max-width: 820px; }
.flow-entry { margin: 4px 0 0; color: var(--subtle); font-size: 12.5px; }

.strip {
  list-style: none; margin: 0; padding: 14px 16px 16px;
  display: flex; align-items: flex-start; overflow-x: auto;
  scroll-snap-type: x proximity; scroll-padding: 0 16px;
}
.step { flex: none; display: flex; align-items: flex-start; }
.step + .step::before {
  content: "\2192"; content: "\2192" / "";
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 34px; height: calc(var(--thumb) * var(--frame-h) / var(--frame-w));
  color: var(--subtle); font-size: 18px;
}
.step-card { width: var(--thumb); scroll-snap-align: start; }
.frame {
  position: relative; display: block; overflow: hidden; text-decoration: none;
  aspect-ratio: var(--frame-w) / var(--frame-h);
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 1px 2px rgb(10 32 53 / 0.08);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.frame:hover { border-color: var(--gold); box-shadow: 0 4px 14px rgb(10 32 53 / 0.16); }
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.has-phone {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 999px;
  background: var(--navy); color: #fff; font-size: 10.5px; font-weight: 600;
}
.placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 100%; height: 100%; padding: 12px; text-align: center;
  color: var(--muted); font-size: 12px; overflow-wrap: anywhere;
  background: repeating-linear-gradient(135deg, var(--surface-alt) 0 10px, var(--surface) 10px 20px);
  border: 2px dashed var(--line); border-radius: 7px;
}
.placeholder strong { color: var(--ink); font-size: 13px; }
.step-meta { display: flex; gap: 7px; align-items: baseline; margin-top: 8px; }
.step-num {
  flex: none; min-width: 20px; padding: 0 5px; border-radius: 999px; text-align: center;
  background: var(--navy); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
}
.step-title { font-weight: 700; line-height: 1.3; }
.step-card .kind { margin-top: 5px; }
.step-note { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }
.same { display: inline-block; margin-top: 5px; font-size: 12px; font-weight: 600; text-decoration: none; }
.same:hover { text-decoration: underline; }
.step[data-match="true"] .step-title { background: var(--gold-soft); box-shadow: 0 0 0 2px var(--gold-soft); border-radius: 3px; }
.skip-marker {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  width: max-content; max-width: 130px; height: calc(var(--thumb) * var(--frame-h) / var(--frame-w));
  padding: 6px 10px; border: 1.5px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 11.5px; line-height: 1.3;
}
.skip-marker strong { color: var(--subtle); font-size: 10.5px; letter-spacing: 0.5px; text-transform: uppercase; }
.step.skipped[data-match="true"] .skip-marker { border-color: var(--gold); }
.flows-foot { margin-top: 10px; display: grid; gap: 2px; }
.foot-line[data-source="planning"] { color: var(--warn); }

/* Planning designs: mock screens for the next design, not app captures. */
.chip[data-tone="plan"] { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); font-weight: 700; }
.chip[data-tone="captured"] { color: var(--muted); }
a.chip { text-decoration: none; }
a.chip:hover { border-color: var(--gold); }
.flow[data-source="planning"] { border-left: 3px solid var(--warn); }
.flows-group[data-source="planning"] h3 { color: var(--warn); }
.flow-status { margin: 6px 0 0; padding: 5px 9px; border-radius: 6px; background: var(--surface-alt); border: 1px solid var(--line-soft); color: var(--muted); font-size: 12.5px; max-width: 820px; }
.step-open { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.step-open li { padding: 4px 7px; border: 1.5px dashed color-mix(in srgb, var(--warn) 65%, var(--line)); border-radius: 6px; color: var(--ink); font-size: 11.5px; line-height: 1.35; }
.step-open strong, .req-open strong { color: var(--warn); font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; }
.step-via { margin: 6px 0 0; font-size: 12px; font-weight: 700; color: var(--gold); }
.skip-marker span { color: var(--subtle); font-size: 11px; }
.checklist .req-list { list-style: none; margin: 0; padding: 10px 16px 16px; display: grid; gap: 8px; }
.checklist .req-list > li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface-alt); }
.req-id { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; }
.req-text { margin: 0; font-weight: 600; line-height: 1.4; }
.req-screens { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.req-screens a { font-weight: 600; text-decoration: none; }
.req-screens a:hover { text-decoration: underline; }
.req-screens .skipped-ref { font-weight: 500; font-style: italic; }
.req-screens .missing-ref { color: var(--warn); }
.req-open { margin: 5px 0 0; font-size: 12px; color: var(--ink); }
.viewer-via { font-weight: 700; color: var(--gold); }
.viewer-note .step-open { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; vertical-align: middle; }
.viewer-flow .chip { margin-left: 4px; }

.kind {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--k) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--k) 55%, var(--line));
  color: var(--ink); font-size: 11px; font-weight: 600; white-space: nowrap; vertical-align: middle;
}
.kind::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--k); }
[data-kind="entry"] { --k: var(--k-entry); }
[data-kind="account"] { --k: var(--k-account); }
[data-kind="question"] { --k: var(--k-question); }
[data-kind="action"] { --k: var(--k-action); }
[data-kind="payment"] { --k: var(--k-payment); }
[data-kind="external"] { --k: var(--k-external); }
[data-kind="skipped"] { --k: var(--k-external); }
[data-kind="finish"] { --k: var(--k-finish); }

/* Viewer -------------------------------------------------------------- */
body:has(.viewer[open]) { overflow: hidden; }
.viewer {
  width: calc(100vw - 32px); height: calc(100dvh - 32px); max-width: none; max-height: none;
  margin: auto; padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--canvas); color: var(--ink); overflow: hidden;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgb(4 12 22 / 0.72); }
.viewer-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.viewer-heading { flex: 1 1 260px; min-width: 0; }
.viewer-flow { margin: 0; color: var(--muted); font-size: 12px; }
.viewer-heading h2 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.viewer-stage {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr);
  align-items: center; gap: 12px; padding: 14px;
}
.viewer-figure { margin: 0; height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer-figure img {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 30px rgb(0 0 0 / 0.18);
}
.viewer-figure[data-device="phone"] { overflow-y: auto; align-items: flex-start; }
.viewer-figure[data-device="phone"] img { width: min(100%, 390px); max-height: none; }
.viewer-figure .placeholder { width: min(100%, 720px); height: auto; aspect-ratio: 1280 / 860; max-height: 100%; }
.viewer-figure[data-device="phone"] .placeholder { width: auto; height: 100%; aspect-ratio: 390 / 844; }
.viewer-nav {
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-size: 18px; font-weight: 700;
}
.viewer-nav:hover:not(:disabled) { border-color: var(--gold); }
.viewer-nav:disabled { opacity: 0.35; }
.viewer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 18px; flex-wrap: wrap;
  padding: 10px 16px 12px; background: var(--surface); border-top: 1px solid var(--line);
}
.viewer-note { margin: 0; flex: 1 1 320px; color: var(--muted); }
.viewer-note .same { margin: 0; }
.viewer-dots { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.dot {
  display: block; width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; position: relative;
}
.dot::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%;
  background: color-mix(in srgb, var(--k) 45%, var(--line));
}
.dot:hover::after { inset: 6px; background: var(--k); }
.dot[aria-current="step"]::after { inset: 4px; background: var(--k); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--gold); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 10px 16px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 600;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}
.toast[data-tone="error"] { background: var(--down); }

@media (max-width: 820px) {
  .bar { padding: 10px 14px; gap: 10px; }
  .session { margin-left: 0; width: 100%; flex-wrap: wrap; }
  main { padding: 14px 14px 48px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-detail { position: static; }
  .log li { grid-template-columns: 1fr; gap: 2px; }
  .flows { grid-template-columns: 1fr; }
  .flows-nav { position: static; max-height: 240px; }
  .flows-main[data-size="large"] { --thumb: min(300px, 78vw); }
  .viewer { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .viewer-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding: 10px; gap: 8px; }
  .viewer-figure { grid-column: 1; }
  .viewer-nav { grid-row: 2; grid-column: 1; }
  #viewer-prev { justify-self: start; }
  #viewer-next { justify-self: end; grid-row: 2; grid-column: 1; }
}
