/* Inter (SIL OFL, see fonts/Inter-OFL.txt), bundled so the demo stays offline-safe */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/inter-latin-wght-normal.woff2) format("woff2");
  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: "Inter";
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/inter-latin-wght-italic.woff2) format("woff2-variations"), url(fonts/inter-latin-wght-italic.woff2) format("woff2");
  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;
}

:root {
  /* Brand: Variation Capture navy + paper (see brand/variation-capture-brand-pack). Amber means waiting or in progress,
     green means approved/done, red means a problem. Nothing else. */
  --ink: #0B1D39;
  --ink-2: #13284A;
  --ink-3: #2A3F5F;
  --on-ink-muted: #C9D1DC;
  --hivis: #E0A100;
  --hivis-hover: #F0B416;
  --hivis-soft: #FBF1D6;
  --hivis-text: #8A6200;
  --bg: #F3F0EA;
  --card: #ffffff;
  --line: #E2DED5;
  --line-2: #F1EEE8;
  --text: #0B1D39;
  --muted: #4B5A70;
  --brand: var(--ink);
  --brand-soft: #EEF1F5;
  --ok: #1E7A4F;
  --ok-soft: #E3F1EA;
  --warn: #C4202A;
  --warn-soft: #F8E1E2;
  --chat-bg: #EEEBE4;
  --bubble-in: #ffffff;
  --bubble-out: #E3E9F2;

  /* Type scale: six sizes only */
  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.strong { font-weight: 650; }
.ico { display: inline-block; vertical-align: -2px; flex: none; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -0.01em; }
.money-xl { font-size: var(--fs-xl); line-height: 1.1; }
.money-md { font-size: var(--fs-lg); }
.money.bump { animation: bump .7s ease; transform-origin: left center; }
@keyframes bump { 30% { transform: scale(1.08); } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--ink);
  color: #fff;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-logo { height: 22px; width: auto; display: block; flex: none; }
.workspace {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto;
  padding-left: 16px; border-left: 1px solid var(--ink-3);
}
.ws-mark {
  width: 30px; height: 30px; border-radius: var(--radius-sm); flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm);
  background: var(--ink-2); color: #fff; border: 1px solid var(--ink-3);
}
.ws-text { min-width: 0; }
.ws-name { font-weight: 650; font-size: var(--fs-sm); line-height: 1.25; }
.ws-sub { font-size: var(--fs-xs); color: var(--on-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; align-items: center; gap: 8px; flex: none; }
.mode-toggle { display: flex; background: var(--ink-2); border-radius: var(--radius-sm); padding: 3px; }
.mode-toggle button {
  border: 0; background: transparent; color: #c6d0dc;
  padding: 6px 12px; border-radius: 6px; font-size: var(--fs-sm); font-weight: 600;
}
.mode-toggle button[aria-checked="true"] { background: #fff; color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 650;
  font-size: var(--fs-sm);
  line-height: 1.1;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ink-2); }
.topbar .btn-primary { background: #fff; color: var(--ink); min-width: 118px; }
.topbar .btn-primary:hover:not(:disabled) { background: var(--brand-soft); }
.topbar .btn-primary[aria-busy="true"] { opacity: 1; background: var(--ink-2); color: #fff; box-shadow: inset 0 0 0 1px var(--ink-3); }
.topbar .btn-primary[aria-busy="true"] .run-icon {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--ink-3); border-top-color: var(--hivis);
  animation: spin .8s linear infinite;
}
.topbar .btn-primary[aria-busy="true"] .run-icon svg { display: none; }
.run-icon { display: inline-grid; place-items: center; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--line-2); }
.topbar .btn-ghost { color: #dbe2ea; border-color: var(--ink-3); }
.topbar .btn-ghost:hover { background: var(--ink-2); }
.btn-approve { background: var(--ok); color: #fff; }
.btn-approve:hover:not(:disabled) { background: #18663F; }
.btn.pulse { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(29, 128, 73, .55); }
  70% { box-shadow: 0 0 0 12px rgba(29, 128, 73, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 128, 73, 0); }
}

/* ---------- Stepper ---------- */
.stepper { background: var(--card); border-bottom: 1px solid var(--line); padding: 0 20px; }
.stepper ol { list-style: none; margin: 0 auto; padding: 0; display: flex; max-width: 1500px; }
.stepper li {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 10px 0; color: var(--muted); font-size: var(--fs-sm); font-weight: 600;
  position: relative;
}
.stepper li::after {
  content: ""; position: absolute; left: 0; right: 8px; bottom: 0; height: 3px; border-radius: 2px;
  background: transparent; transition: background .3s;
}
.stepper .num {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: var(--fs-xs);
  border: 1.5px solid var(--line); background: var(--card);
}
.stepper li.active { color: var(--text); }
.stepper li.active .num { border-color: var(--hivis); background: var(--hivis); color: var(--ink); }
.stepper li.active::after { background: var(--hivis); }
.stepper li.done { color: var(--text); }
.stepper li.done .num { border-color: var(--ink); background: var(--ink); color: #fff; }
.stepper li.done::after { background: var(--ink); }

.tabs { display: none; }

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 380px) minmax(420px, 1.25fr) minmax(360px, 1fr);
  gap: 16px;
  padding: 16px 20px;
  max-width: 1540px;
  width: 100%;
  margin: 0 auto;
}
.col { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-bottom: 8px; scrollbar-width: thin; }
.col > .card, .col > .toast, .col > .col-head { flex-shrink: 0; }
.col-head { display: flex; align-items: baseline; gap: 8px; padding: 0 2px; position: sticky; top: 0; background: var(--bg); z-index: 2; padding-bottom: 2px; }
.col-kicker { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
.col-title { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.col.focus .col-kicker::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hivis); margin-right: 6px; vertical-align: 1px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.appear { animation: appear .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes appear { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Office: opening pitch (before the demo runs) ---------- */
.intro-card { padding: 22px 22px 20px; }
.intro-card > img { display: block; margin-bottom: 14px; }
.intro-title { margin: 0; font-size: var(--fs-lg); line-height: 1.25; letter-spacing: -0.015em; max-width: 30ch; }
.intro-lede { margin: 8px 0 18px; color: var(--muted); max-width: 52ch; }
.intro-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.intro-steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.intro-steps b { display: block; font-weight: 650; }
.intro-steps span:not(.intro-num) { display: block; color: var(--muted); font-size: var(--fs-sm); }
.intro-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--ink); font-weight: 700; font-size: var(--fs-sm);
}
.intro-hint { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: var(--fs-sm); color: var(--muted); }
.intro-hint kbd {
  font: inherit; font-weight: 650; color: var(--ink); background: var(--line-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px;
}
body:not([data-step="0"]) .intro-card { display: none; }
body[data-mode="demo"] .intro-hint[data-hint="live"],
body[data-mode="live"] .intro-hint[data-hint="demo"] { display: none; }
body[data-step="0"] .agent-steps:empty { display: none; }

/* ---------- Phone ---------- */
.phone {
  flex: 1;
  min-height: 560px;
  max-height: 780px;
  display: flex; flex-direction: column;
  border-radius: 38px;
  background: #0d1117;
  padding: 10px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.phone-notch { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 92px; height: 22px; background: #0d1117; border-radius: 12px; z-index: 3; }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 36px 14px 10px;
  background: var(--ink); color: #fff;
  border-radius: 30px 30px 0 0;
}
.chat-name { font-weight: 650; font-size: var(--fs-base); }
.chat-status { font-size: var(--fs-xs); color: var(--on-ink-muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex: none; }
img.avatar { border-radius: var(--radius-sm); }
.avatar-brand { background: var(--ink); color: #fff; border-radius: var(--radius-sm); }
.chat {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--chat-bg);
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 6px;
  scroll-behavior: smooth;
}
.chat-day { align-self: center; font-size: var(--fs-xs); background: #fff; color: var(--muted); padding: 3px 10px; border-radius: var(--radius-sm); margin-bottom: 4px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: var(--fs-sm); max-width: 220px; }
.bubble {
  max-width: 86%;
  padding: 7px 10px 5px;
  border-radius: var(--radius);
  font-size: var(--fs-base);
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
  animation: appear .3s ease both;
  position: relative;
}
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.bubble .meta .ticks { color: var(--muted); display: inline-flex; }
.chat-ok { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--ok); color: #fff; margin-right: 6px; vertical-align: -3px; }
.chat-ok .ico { width: 11px; height: 11px; vertical-align: 0; }
.bubble-photo { padding: 4px; }
.bubble-photo img { display: block; width: 230px; max-width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); }
.bubble-photo .caption { padding: 4px 4px 0; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 210px; padding: 2px 0; }
.voice-play { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.wave { display: flex; align-items: center; gap: 2px; height: 26px; flex: 1; }
.wave i { display: block; width: 3px; border-radius: 2px; background: #8593A8; }
.voice-time { font-size: var(--fs-xs); color: var(--muted); }
.transcript { font-size: var(--fs-sm); color: #33424e; border-top: 1px solid rgba(0,0,0,.08); margin-top: 5px; padding-top: 5px; font-style: italic; }
.transcript .label { font-style: normal; font-weight: 650; color: var(--hivis-text); font-size: var(--fs-xs); display: block; }
.typing { display: inline-flex; gap: 3px; padding: 4px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #9aa6af; animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 50% { transform: translateY(-3px); opacity: .5; } }

.composer { background: #f0f2f5; border-radius: 0 0 30px 30px; padding: 8px 10px 14px; display: none; }
body[data-mode="live"] .composer { display: block; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea {
  flex: 1; resize: none; border: 0; border-radius: 18px; padding: 9px 12px; background: #fff;
  font-size: var(--fs-base); max-height: 120px; outline: none;
}
.icon-btn, .send-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 0; cursor: pointer; }
.icon-btn { color: var(--muted); }
.icon-btn:hover { background: #e2e6ea; }
.send-btn { background: var(--ink); color: #fff; }
.send-btn:disabled { opacity: .5; }
.composer-photo { position: relative; width: 84px; margin: 0 0 8px 44px; }
.composer-photo img { width: 84px; height: 63px; object-fit: cover; border-radius: var(--radius-sm); display: block; }
.chip-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: var(--fs-sm); line-height: 1; }
.link-btn { background: none; border: 0; color: var(--ink); font-size: var(--fs-sm); padding: 6px 0 0 46px; text-decoration: underline; }

/* ---------- Office: agent ---------- */
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--ink); color: #fff; border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow);
  animation: appear .4s ease both;
}
.toast-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--hivis); margin-top: 5px; flex: none; box-shadow: 0 0 0 4px rgba(224, 161, 0, .25); }
.agent-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.agent-pulse { width: 9px; height: 9px; border-radius: 50%; background: #b6c0cb; }
.agent-pulse.on { background: var(--hivis); animation: blink 1s infinite; }
.agent-pulse.done { background: var(--ok); }
@keyframes blink { 50% { opacity: .3; } }
.agent-steps { list-style: none; margin: 0; padding: 6px 16px 10px; }
.agent-steps:empty::before { content: "The agent watches the site channel and starts as soon as a message lands."; display: block; color: var(--muted); font-size: var(--fs-sm); padding: 8px 0 4px; }
.agent-step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 7px 0; animation: appear .3s ease both; }
.agent-step + .agent-step { border-top: 1px dashed var(--line-2); }
.step-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; margin-top: 1px; }
.step-icon .ico { width: 12px; height: 12px; vertical-align: 0; }
.agent-step.running .step-icon { border: 2px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }
.agent-step.done .step-icon { background: var(--ok); color: #fff; }
.agent-step.failed .step-icon { background: var(--warn); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.step-label { font-weight: 600; }
.step-detail { font-size: var(--fs-sm); color: var(--muted); }
.step-flag { display: inline-block; margin-top: 4px; font-size: var(--fs-sm); font-weight: 650; padding: 2px 8px; border-radius: 6px; background: var(--hivis-soft); color: var(--hivis-text); border: 1px solid #EED48A; }
.step-flag.bad { background: var(--warn-soft); color: var(--warn); border-color: #EDB8BB; }

/* ---------- Office: draft ---------- */
.draft-card { padding: 16px; animation: appear .45s ease both; }
.draft-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.draft-ref { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.draft-title { margin: 4px 0 0; font-size: var(--fs-lg); line-height: 1.25; letter-spacing: -0.01em; }
.draft-total { text-align: right; flex: none; }
.badge { display: inline-block; font-size: var(--fs-xs); font-weight: 650; padding: 1px 9px; border-radius: 99px; background: var(--line-2); color: var(--muted); }
.badge-draft { background: var(--line-2); color: var(--muted); }
.badge-submitted { background: var(--hivis-soft); color: var(--hivis-text); }
.badge-approved { background: var(--ok-soft); color: var(--ok); }
.badge-queried { background: var(--warn-soft); color: var(--warn); }
.badge-invoiced { background: var(--brand-soft); color: var(--ink); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0 10px; padding: 12px; background: var(--line-2); border-radius: var(--radius-sm); }
.facts div { min-width: 0; }
.facts dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.facts dd { margin: 1px 0 0; font-size: var(--fs-sm); font-weight: 550; }
.facts .warn-text { color: var(--warn); font-weight: 650; }
.draft-desc { margin: 8px 0 12px; }

.lines { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.lines th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.lines td { padding: 7px 4px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.lines .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .code { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }
.lines .group td { font-weight: 700; color: var(--ink); padding-top: 12px; border-bottom: 0; }
.lines tfoot td { border: 0; padding: 4px; }
.lines tfoot .grand td { font-size: var(--fs-md); font-weight: 750; padding-top: 8px; border-top: 2px solid var(--text); }
.lines input {
  width: 72px; text-align: right; padding: 3px 6px; border: 1px solid var(--hivis); border-radius: 6px;
  background: var(--hivis-soft); font-variant-numeric: tabular-nums;
}
.lines tr.row-in { animation: appear .35s ease both; }
.lines tr.changed td { background: var(--hivis-soft); transition: background 1.2s; }

.draft-extra { display: grid; grid-template-columns: 150px 1fr; gap: 14px; margin-top: 14px; }
.draft-photo { margin: 0; }
.draft-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); display: block; border: 1px solid var(--line); }
.draft-photo figcaption { font-size: var(--fs-xs); color: var(--muted); margin-top: 3px; }
.draft-notes p, .draft-notes ul { margin: 2px 0 8px; }
.draft-notes ul { padding-left: 18px; }

.approve-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 14px -16px -16px; padding: 12px 16px;
  border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  background: var(--card); position: sticky; bottom: -8px; z-index: 1;
  box-shadow: 0 -6px 12px -8px rgba(16, 24, 40, .18);
}
.approve-actions { display: flex; gap: 8px; justify-content: flex-end; }
.sent-note .ico { margin-right: 4px; }
.sent-note { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 650; }
body:not([data-step="4"]) .approve-bar .btn { pointer-events: none; opacity: .45; }

/* ---------- Builder ---------- */
.builder-card { overflow: hidden; animation: appear .45s ease both; }
.builder-from { display: flex; gap: 10px; align-items: center; padding: 12px 16px; background: var(--line-2); }
.builder-body { padding: 14px 16px 4px; }
.builder-title { margin: 4px 0 8px; font-size: var(--fs-lg); line-height: 1.25; letter-spacing: -0.01em; }
.builder-body p { margin: 10px 0 6px; }
.builder-actions { display: flex; gap: 8px; padding: 12px 16px 16px; }
.builder-actions .btn { flex: 1; padding: 12px; font-size: var(--fs-base); }
.query-form { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.query-form textarea { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; resize: vertical; }
.builder-result { display: flex; gap: 8px; align-items: flex-start; margin: 0 16px 16px; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 650; }
.builder-result .ico { margin-top: 3px; }
.builder-result.ok { background: var(--ok-soft); color: var(--ok); }
.builder-result.query { background: var(--warn-soft); color: var(--warn); }

/* ---------- Tracker ---------- */
.tracker-kpis { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; padding: 12px 16px 4px; }
.kpi { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--line-2); }
.kpi-hero { background: var(--ink); color: #fff; }
.kpi-hero .money { color: #8FE0B5; }
.kpi-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--muted); }
.kpi-hero .kpi-label { color: var(--on-ink-muted); }
.tracker-filters { display: flex; gap: 6px; padding: 10px 16px 4px; flex-wrap: wrap; }
.tracker-filters span { font-size: var(--fs-xs); font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--line-2); color: var(--muted); }
.tracker-filters b { color: var(--text); }
.tracker { list-style: none; margin: 0; padding: 4px 8px 10px; }
.tracker li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 8px; border-radius: var(--radius-sm); }
.tracker li + li { border-top: 1px solid var(--line-2); }
.tracker li.new { animation: highlight 2.4s ease both; }
@keyframes highlight { 0% { background: var(--hivis-soft); } 100% { background: transparent; } }
.t-title { font-size: var(--fs-sm); font-weight: 600; min-width: 0; }
.t-ref { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); margin-right: 6px; font-weight: 500; }
.t-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-meta { font-size: var(--fs-xs); color: var(--muted); }
.t-status { text-align: right; }

/* ---------- Footer & banners ---------- */
.footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 20px; font-size: var(--fs-xs); color: #8994a1; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.werket { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.werket img { display: block; }
.werket b { color: var(--ink); font-weight: 800; letter-spacing: .02em; }
.werket a { color: inherit; }
.live-banner {
  position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-width: min(560px, calc(100% - 32px)); z-index: 20;
  animation: appear .3s ease both;
}
.live-banner.error { background: var(--warn); }

/* ---------- Narrower screens: tabs, one view at a time ---------- */
@media (max-width: 1180px) {
  .ws-desc { display: none; }
  .tabs { display: flex; gap: 4px; padding: 10px 16px 0; max-width: 760px; width: 100%; margin: 0 auto; }
  .tabs button { flex: 1; border: 1px solid var(--line); background: var(--card); padding: 9px; border-radius: var(--radius-sm); font-weight: 650; color: var(--muted); position: relative; }
  .tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
  .tabs button.ping::after { content: ""; position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--hivis); }
  .stage { display: block; max-width: 760px; padding: 12px 16px; overflow-y: auto; }
  .col { display: none; overflow: visible; }
  .col.tab-active { display: flex; }
  .col-head { position: static; }
  .col-kicker { display: none; } /* the tab already names the view */
  .phone { max-width: 400px; width: 100%; margin: 0 auto; min-height: 620px; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px 12px; padding: 8px 16px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand-logo { height: 20px; }
  .workspace { padding-left: 12px; flex: 1 1 0; }
  .ws-mark { display: none; }
  .ws-sub { display: none; }
  .ws-name { font-size: var(--fs-xs); color: var(--on-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .controls { width: 100%; }
  .controls .btn-primary { flex: 1; }
  .stepper { padding: 0 16px; overflow-x: auto; }
  .stepper .lbl { display: none; }
  .stepper li.active .lbl,
  body[data-step="0"] .stepper li:first-child .lbl { display: inline; }
  .stepper li { flex: none; padding-right: 14px; }
  .stepper li.active,
  body[data-step="0"] .stepper li:first-child { flex: 1; }
  .phone { border-radius: 0; padding: 0; background: none; box-shadow: none; min-height: 70vh; max-height: none; }
  .phone-notch { display: none; }
  .chat-head { padding-top: 10px; border-radius: var(--radius) var(--radius) 0 0; }
  .composer { border-radius: 0 0 var(--radius) var(--radius); }
  .money-xl { font-size: 24px; }
  .intro-card { padding: 18px 16px 16px; }
  .draft-head { flex-direction: column; gap: 8px; }
  .draft-total { text-align: left; }
  .facts { grid-template-columns: 1fr; }
  .draft-extra { grid-template-columns: 1fr; }
  .draft-photo img { max-width: 240px; }
  .lines .code { display: none; }
  .footer { flex-direction: column; align-items: flex-start; gap: 4px; padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* Keep scrolled-to cards clear of the sticky column heading */
.toast, .draft-card, .builder-card { scroll-margin-top: 30px; }

/* Agent log folds away once the draft is up; click the header to reopen */
.agent-card .card-head { cursor: default; }
.agent-card.collapsible .card-head { cursor: pointer; }
.agent-card.collapsible .card-head:hover { background: var(--line-2); }
.agent-card.collapsed .agent-steps { display: none; }
.agent-card.collapsed .card-head { border-bottom: 0; }
.agent-toggle { font-size: var(--fs-sm); color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; margin-left: 6px; }

/* ---------- Builder inbox: the variation arrives as an email with a secure link ---------- */
.mail-card { overflow: hidden; animation: appear .45s ease both; scroll-margin-top: 30px; }
.mail-chrome { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--ink); color: #c6d0dc; }
.mail-chrome .muted { color: #9fb0c2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-app { font-weight: 700; color: #fff; font-size: 13px; }
.mail-state { margin-left: auto; color: var(--hivis); font-weight: 650; white-space: nowrap; }
.mail-head { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px 6px; }
.mail-meta { min-width: 0; font-size: 14px; }
.mail-subject { font-weight: 650; margin-top: 2px; line-height: 1.3; }
.mail-body { padding: 0 16px 16px 60px; font-size: 14px; }
.mail-body p { margin: 6px 0 10px; }
.mail-summary { display: grid; grid-template-columns: repeat(3, auto); gap: 10px 16px; justify-content: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.mail-summary div { display: flex; flex-direction: column; min-width: 0; }
.mail-summary b { font-size: 14px; }
.mail-cta { margin-top: 12px; padding: 11px 18px; font-size: 15px; }
.mail-cta.pulse { animation: pulse-blue 1.6s ease-out infinite; }
@keyframes pulse-blue {
  0% { box-shadow: 0 0 0 0 rgba(29, 95, 168, .5); }
  70% { box-shadow: 0 0 0 12px rgba(29, 95, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 95, 168, 0); }
}
.mail-fine { font-size: 12px; color: var(--muted); margin: 6px 0 10px !important; }
.mail-attach { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
.pdf-chip { font-size: 10px; font-weight: 800; color: #fff; background: #c2410c; border-radius: 3px; padding: 2px 4px; }
.mail-card.opened .mail-body { display: none; }
.mail-card.opened .mail-state { color: #9fb0c2; }

.browser-bar { display: flex; align-items: center; gap: 6px; padding: 7px 12px; background: #e7ebf0; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); font-family: var(--mono); }
.browser-bar svg { color: var(--ok); flex: none; }
.browser-bar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-photo { display: block; width: 160px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); margin: 8px 0; }

@media (max-width: 760px) {
  .mail-body { padding-left: 16px; }
  .mail-summary { grid-template-columns: 1fr 1fr; }
}

/* Demo mode hides the composer, so the chat itself ends the phone screen: round its bottom corners */
body:not([data-mode="live"]) .chat { border-radius: 0 0 30px 30px; }
@media (max-width: 760px) {
  body:not([data-mode="live"]) .chat { border-radius: 0 0 var(--radius) var(--radius); }
}
