/* promptcloak — strictly monochrome. Composer-first.
   Type does the branding: Geist Sans for voice, Geist Mono for machinery.
   The scrambled `o` is the only brand device; hierarchy comes from weight,
   opacity, spacing and hairlines — never from color. */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --input: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --invert-bg: #18181b;
  --invert-text: #fafafa;
  --state: #18181b;           /* functional state, monochrome */
  --state-soft: rgba(0, 0, 0, 0.07);
  --danger: #c2453a;
  --danger-soft: rgba(194, 69, 58, 0.09);
  --warn: #a3722a;
  --selection: rgba(0, 0, 0, 0.14);
  --bubble-ai: #ffffff;
  --bubble-ai-text: #17171a;
  --bubble-ai-accent: #17171a;
  --silver-hi: #2e2e33;
  --silver-lo: #6b6b74;
  --silver-mid: #6f6f78;
  --silver-dim: #a4a4ad;
  --pipe-pending: #b0b0b8;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Geist", "Inter", system-ui, -apple-system, sans-serif;
  --r-major: 14px;            /* composer, cards */
  --r-ctl: 8px;               /* normal controls */
  --r-send: 10px;             /* send button: near-square */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 16px 40px rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] {
  --bg: #080809;
  --surface: #111113;
  --input: #161618;
  --border: #29292d;
  --border-strong: #3a3a40;
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #68686f;
  --silver-hi: #fafafb;
  --silver-lo: #b4b4bf;
  --silver-mid: #9d9da8;
  --silver-dim: #74747e;
  --pipe-pending: #62626b;
  --invert-bg: #f4f4f5;
  --invert-text: #0a0a0b;
  --state: #f4f4f5;
  --state-soft: rgba(255, 255, 255, 0.10);
  --danger: #e0715c;
  --danger-soft: rgba(224, 113, 92, 0.12);
  --warn: #d9a03f;
  --selection: rgba(255, 255, 255, 0.28);
  --bubble-ai: #e9e9ee;
  --bubble-ai-text: #17171a;
  --bubble-ai-accent: #17171a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 16px 48px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080809;
    --surface: #111113;
    --input: #161618;
    --border: #29292d;
    --border-strong: #3a3a40;
    --text: #f4f4f5;
    --text-2: #a1a1aa;
    --text-3: #68686f;
    --silver-hi: #fafafb;
    --silver-lo: #b4b4bf;
    --silver-mid: #9d9da8;
    --silver-dim: #74747e;
    --pipe-pending: #62626b;
    --invert-bg: #f4f4f5;
    --invert-text: #0a0a0b;
    --state: #f4f4f5;
    --state-soft: rgba(255, 255, 255, 0.10);
    --danger: #e0715c;
    --danger-soft: rgba(224, 113, 92, 0.12);
    --warn: #d9a03f;
    --selection: rgba(255, 255, 255, 0.28);
    --bubble-ai: #e9e9ee;
    --bubble-ai-text: #17171a;
    --bubble-ai-accent: #17171a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 16px 48px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--selection); }

/* film grain: kills gradient banding on the dark ground; imperceptible as texture */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* slim brand scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); }

#globe {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 0;
}
.wrap {
  max-width: 720px; margin: 0 auto; padding: 0 24px;
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  width: 100%;
}

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 0;
}
.logo {
  display: flex; align-items: center;
  font-weight: 600; font-size: 17px; letter-spacing: -0.015em;
}
.wordmark { display: inline-flex; align-items: baseline; }
/* pro edition tag — visible only when /api/health reports edition: pro */
.pro-tag {
  display: none;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.14em; color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: 4px;
  padding: 2px 5px; margin-left: 8px; align-self: center;
}
body.pro .pro-tag { display: inline-flex; }
.glyph-o {
  width: 0.82em; height: 0.64em; color: var(--text);
  margin: 0 0.06em; transform: translateY(0.02em);
  align-self: center; flex: none;
}
.header-right { display: flex; align-items: center; gap: 8px; }

.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--state); flex: none;
  animation: badge-blink 2.4s ease-in-out infinite;
}
@keyframes badge-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@media (prefers-reduced-motion: reduce) {
  .badge::before { animation: none; }
}
.badge.warn { color: var(--danger); }
.badge.warn::before { background: var(--danger); }

.pill-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: 99px;
  padding: 6px 13px; height: 30px;
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  color: var(--text-2);
}
.pill-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }

.icon-btn {
  background: none; border: none; color: var(--text-3);
  border-radius: var(--r-ctl); width: 34px; height: 34px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }

/* ---------- hero: message, then the machine ----------
   Silver-gradient two-tone: line 1 bright metallic, line 2 quieter but
   instantly readable (~55%), revealed once on load — the cloak motif. */
.hero { margin: 72px 0 22px; text-align: left; }
.hero .glyph { display: none; }
.hero .eyebrow {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 12px;
}
.hero.compact .eyebrow { display: none; }
.hero h1 {
  font-weight: 600; font-size: 38px; letter-spacing: -0.03em;
  margin: 0 0 10px; line-height: 1.12;
  background: linear-gradient(135deg, var(--silver-hi) 20%, var(--silver-lo) 90%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
/* the ciphered word on line 1 carries its own copy of the line-1 gradient so
   background-clip survives the inline-block width lock */
.hero h1 #cipher-prompt {
  background: linear-gradient(135deg, var(--silver-hi) 20%, var(--silver-lo) 90%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero h1 .quiet {
  background: linear-gradient(135deg, var(--silver-mid) 10%, var(--silver-dim) 90%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  display: inline-block;
  animation: unveil 0.9s cubic-bezier(0.25, 1, 0.4, 1) 0.15s both;
}
@keyframes unveil {
  from { clip-path: inset(0 100% 0 0); opacity: 0.4; }
  to { clip-path: inset(0 0 0 0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .hero h1 .quiet { animation: none; }
}
.hero p {
  color: var(--text-2); margin: 0; font-size: 14.5px; max-width: 48ch;
  line-height: 1.55;
}
.hero.compact { margin: 30px 0 16px; }
.hero.compact h1 { font-size: 17px; letter-spacing: -0.015em; margin-bottom: 0; }
.hero.compact p { display: none; }

/* ---------- pipeline: typography only ---------- */
.stepper {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 14px; padding: 0; flex-wrap: wrap;
}
.step {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--pipe-pending);
  transition: color 0.25s ease;
  position: relative;
}
.step + .step::before {
  content: "→"; color: var(--pipe-pending); opacity: 0.6;
  margin-right: 10px; letter-spacing: 0;
}
.step.done { color: var(--text-2); }
.step.active { color: var(--text); font-weight: 600; }
.step.active.working { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-major);
  margin-bottom: 18px; overflow: hidden;
  display: none;
}
.card.enabled { display: block; animation: rise 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 0;
}
.card-title {
  font-family: var(--mono); font-weight: 500; font-size: 10.5px;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.14em;
}
.card-title .num { display: none; }
.card-title .hint { font-family: var(--sans); text-transform: none; letter-spacing: 0; font-weight: 400; }
.card-body { padding: 12px 20px 18px; }
.card-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- composer: the hero object ---------- */
#card-1 {
  background: var(--input);
  background: linear-gradient(180deg, var(--input), color-mix(in srgb, var(--input) 82%, var(--bg)));
  border-color: var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow);
}
#card-1 { transition: border-color 0.2s ease; }
#card-1:focus-within {
  border-color: var(--border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), var(--shadow);
}
#card-1 .card-head { display: none; }
#card-1 .card-body { padding: 0; }

textarea {
  width: 100%; min-height: 132px; resize: vertical;
  background: transparent; color: var(--text);
  border: none;
  padding: 18px 18px 10px; font-family: var(--sans); font-size: 15.5px; line-height: 1.6;
  display: block;
}
textarea::placeholder { color: var(--text-3); }
textarea:focus { outline: none; }

/* distinct lower control bar */
#card-1 .chips { padding: 0 14px 8px; }
#card-1 .row {
  margin: 0; padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 12px; align-items: center;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.spacer { flex: 1; }
.hint { color: var(--text-3); font-size: 12.5px; }
#char-count { font-family: var(--mono); font-size: 11px; }

.scrub-status {
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.scrub-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--state); flex: none;
}
.scrub-status.warn::before { background: var(--danger); }

select {
  background: transparent; color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--r-ctl); padding: 7px 26px 7px 10px;
  min-width: 138px;   /* the selected frontier model must stay legible */
  font-size: 12px; font-weight: 500;
  font-family: var(--mono); cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 10px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
select:hover { border-color: var(--border-strong); }
select:focus { outline: 1px solid var(--text-3); }

button.primary {
  background: linear-gradient(180deg, var(--silver-hi), var(--silver-lo));
  color: var(--invert-text);
  border: none; border-radius: var(--r-ctl);
  padding: 9px 18px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: var(--sans);
  display: inline-flex; align-items: center; gap: 7px;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
button.primary:hover { opacity: 0.85; }
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.4; cursor: default; }

button.circle {
  /* send: near-square, not a capsule */
  width: 38px; height: 38px; padding: 0; border-radius: var(--r-send);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
}

button.ghost {
  background: none; border: none; color: var(--text-3);
  border-radius: var(--r-ctl); padding: 6px 11px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; font-family: var(--sans);
}
button.ghost:hover { color: var(--text); background: var(--input); }
#card-1 button.ghost:hover { background: var(--surface); }

/* ---------- lower nav: about / privacy accordions ---------- */
.nowrap { white-space: nowrap; }
/* sticky footer: pinned to the window bottom on short pages, flows after
   content on long ones */
.lower-nav { margin-top: auto; padding-top: 40px; }
.nav-row {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-2); text-decoration: none;
  padding: 12px 2px;
  border-top: 1px solid var(--border);
}
.nav-row:hover { color: var(--text); }
.nav-arrow { font-size: 13px; letter-spacing: 0; }
/* camera capture is a mobile affordance; desktop uses Attach */
#camera-btn { display: none; align-items: center; }
@media (max-width: 640px) {
  #camera-btn { display: inline-flex; padding: 7px 8px; }
}

/* ---------- mapping table ---------- */
table.mapping { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mapping th {
  text-align: left; color: var(--text-3); font-family: var(--mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  padding: 8px 8px 9px 0; font-weight: 500;
  border-bottom: 1px solid var(--border);
}
table.mapping td {
  padding: 2px 8px 2px 0; vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
table.mapping tr:last-child td { border-bottom: none; }
table.mapping input {
  width: 100%; background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: var(--r-ctl);
  padding: 7px 10px; font-family: var(--mono); font-size: 12px;
}
table.mapping input:hover { background: var(--input); }
table.mapping input:focus { outline: none; background: var(--input); border-color: var(--border-strong); }
.chip {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--text-3);
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.08em;
}
.arrow { color: var(--text-3); font-size: 12px; }
.del-btn {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 12px; padding: 5px 8px; border-radius: var(--r-ctl); opacity: 0.35;
}
tr:hover .del-btn { opacity: 1; }
.del-btn:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- output panes ---------- */
.pane {
  background: var(--input); border: 1px solid var(--border);
  border-radius: var(--r-ctl); padding: 15px 17px;
  font-size: 14.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  min-height: 52px; max-height: 440px; overflow-y: auto;
}
#scrambled-pane { font-family: var(--mono); font-size: 12.5px; }
.pane mark, .bubble mark {
  background: var(--border); color: var(--text);
  border-radius: 4px; padding: 0.5px 5px; font-family: var(--mono);
  font-size: 0.92em;
}
.pane mark.restored, .bubble mark.restored {
  background: transparent; color: var(--text); font-family: inherit;
  font-size: inherit; border-bottom: 1px solid color-mix(in srgb, var(--text) 45%, transparent);
  border-radius: 0; padding: 0 1px; font-weight: 550;
}

.cursor {
  display: inline-block; width: 7px; height: 15px; background: var(--text-2);
  vertical-align: text-bottom; animation: blink 1.1s steps(1) infinite;
  border-radius: 1px; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- toggle ---------- */
.toggle {
  display: inline-flex; background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl); padding: 2px; gap: 2px;
}
.toggle button {
  background: none; border: none; padding: 4px 11px; font-size: 11px;
  font-family: var(--mono); font-weight: 500; color: var(--text-3); cursor: pointer;
  border-radius: 6px;
}
.toggle button.on { background: var(--invert-bg); color: var(--invert-text); }

/* ---------- toast + modal ---------- */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(6px);
  background: var(--invert-bg); color: var(--invert-text);
  padding: 11px 20px; border-radius: var(--r-ctl);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  width: max-content; /* left:50% halves shrink-to-fit width; size to content instead */
  transition: opacity 0.25s ease, transform 0.25s ease; max-width: 80vw; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast.ok { background: var(--invert-bg); color: var(--invert-text); }
.toast-act {
  display: inline-block; vertical-align: middle; margin-left: 12px;
  appearance: none; cursor: pointer;
  background: transparent; color: inherit;
  border: 1px solid color-mix(in srgb, currentColor 45%, transparent);
  border-radius: 7px; padding: 5px 12px;
  font: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em; white-space: nowrap;
}
.toast-act:hover { border-color: currentColor; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 40;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-major); padding: 28px;
  width: min(380px, 90vw); box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.modal p { color: var(--text-2); font-size: 13px; margin: 0 0 16px; }
.modal input {
  width: 100%; background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 10px 14px;
  font-size: 13px; margin-bottom: 12px; font-family: var(--mono);
}
.modal input:focus { outline: 1px solid var(--text-3); }
.modal button.primary { width: 100%; justify-content: center; }

/* ---------- settings ---------- */
.settings-wrap { position: relative; }
.settings-panel {
  position: absolute; top: 42px; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-major); box-shadow: var(--shadow);
  padding: 8px; width: 250px; display: none;
}
.settings-panel.open { display: block; animation: rise 0.2s ease; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 12px; border-radius: var(--r-ctl);
  font-size: 13px; font-weight: 500;
}
.setting-row:hover { background: var(--input); }
.setting-row span { display: flex; flex-direction: column; gap: 1px; }
.setting-row small {
  font-weight: 400; font-size: 11px; color: var(--text-3);
}
.switch {
  width: 34px; height: 20px; border-radius: 99px; flex: none;
  background: var(--border-strong); border: none; cursor: pointer;
  position: relative; transition: background 0.15s ease;
  padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.switch.on { background: var(--state); }
.switch.on::after { transform: translateX(14px); }

/* ---------- chat mode ---------- */
#chat-log { display: none; }
#chat-log.active { display: block; margin-bottom: 18px; }
/* section rule with the `+` alignment device: ──── + ──── */
#chat-log.active::before {
  content: "+"; display: flex; align-items: center; justify-content: center;
  margin: 2px 0 18px; height: 14px;
  font-family: var(--mono); font-size: 11px; line-height: 1; color: var(--text-3);
  background:
    linear-gradient(90deg, transparent, var(--border-strong) 18%, var(--border-strong) calc(50% - 14px), transparent calc(50% - 14px)) left center / 100% 1px no-repeat,
    linear-gradient(90deg, transparent calc(50% + 14px), var(--border-strong) calc(50% + 14px), var(--border-strong) 82%, transparent) left center / 100% 1px no-repeat;
}
.msg { margin: 0 0 18px; animation: rise 0.3s ease; }
/* cap the wrapper, not the bubble: a % max-width on the bubble resolves
   against this content-sized wrapper and squeezes short messages */
.msg .msg-inner { max-width: 85%; min-width: 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--input); border: 1px solid var(--border);
  border-radius: var(--r-major); border-bottom-right-radius: 4px;
  padding: 10px 15px; width: fit-content; margin-left: auto;
  font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.assistant { display: flex; justify-content: flex-start; }
.msg.assistant .bubble {
  background: var(--bubble-ai); color: var(--bubble-ai-text);
  border: 1px solid var(--border);
  border-radius: var(--r-major); border-bottom-left-radius: 4px;
  font-size: 14.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  padding: 10px 15px; width: fit-content;
}
/* mark colors are tuned for the page ground; rescope them on the light bubble */
.msg.assistant .bubble mark {
  background: rgba(0, 0, 0, 0.08); color: inherit;
}
.msg.assistant .bubble mark.restored {
  background: transparent; color: inherit;
  border-bottom-color: rgba(23, 23, 26, 0.4);
}
.msg.assistant .bubble .msg-status { color: inherit; opacity: 0.75; }
/* edited-document card inside an assistant bubble */
.doc-card {
  background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px; margin: 8px 0; overflow: hidden;
}
.doc-card-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.doc-card-icon { font-size: 18px; flex: none; }
.doc-card-info { min-width: 0; flex: 1; }
.doc-card-title {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-card-sub { font-family: var(--mono); font-size: 10px; color: rgba(23, 23, 26, 0.55); }
.doc-card-actions { display: flex; gap: 6px; flex: none; }
.doc-btn {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
  /* the card is always light (it sits on the silver AI bubble in both themes) */
  background: #17171a; color: #f5f5f7;
  border: 1px solid transparent;
}
.doc-btn:hover { opacity: 0.85; }
.doc-btn:disabled { opacity: 0.5; cursor: default; }
.doc-preview { border-top: 1px solid rgba(0, 0, 0, 0.1); }
.doc-preview summary {
  cursor: pointer; list-style: none; user-select: none;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(23, 23, 26, 0.55); padding: 8px 12px;
}
.doc-preview summary::-webkit-details-marker { display: none; }
.doc-preview summary::after { content: " +"; }
.doc-preview[open] summary::after { content: " –"; }
.doc-preview-body {
  padding: 0 12px 12px; max-height: 320px; overflow-y: auto;
  font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.assistant .bubble .cursor { background: var(--bubble-ai-text); }
/* per-message actions: quiet mono controls under the assistant meta */
.msg-actions { display: flex; gap: 14px; margin-top: 5px; }
.msg-act {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; padding: 4px 0; cursor: pointer;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
}
.msg-act:hover { color: var(--text); }
.msg-act .act-glyph { font-size: 12px; letter-spacing: 0; }
@media (max-width: 640px) {
  .msg-act { padding: 8px 2px; }
}

.msg .msg-meta {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  letter-spacing: 0.05em; margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
}
.msg.user .msg-meta { justify-content: flex-end; }
.msg .msg-meta .cloaked-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--state);
  display: inline-block;
}
.msg .msg-status {
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.msg .msg-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--state); animation: pulse 1.2s ease-in-out infinite;
}

/* send morph: the mark performing its meaning (dash -> plane -> dots) */
#scrub-morph { display: inline-flex; align-items: center; }
/* glyph fragments scatter in horizontally and settle — the anonymization
   gesture. Deterministic offsets, mechanical easing, ~420ms total. */
#scrub-morph .g1  { animation: g-in-l 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
#scrub-morph .g2  { animation: g-in-l 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.05s both; }
#scrub-morph .g2b { animation: g-in-r 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.05s both; }
#scrub-morph .g3  { animation: g-in-l 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.1s both; }
#scrub-morph .g3b { animation: g-in-r 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.1s both; }
#scrub-morph .g4  { animation: g-in-l 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.15s both; }
#scrub-morph .g4b { animation: g-in-r 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.15s both; }
#scrub-morph .g5  { animation: g-in-r 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) 0.2s both; }
@keyframes g-in-l { from { transform: translateX(-7px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes g-in-r { from { transform: translateX(7px); opacity: 0; } to { transform: none; opacity: 1; } }

/* busy: three horizontal fragments in a slow, quiet drift */
.glitch-loader { display: inline-flex; flex-direction: column; gap: 2.5px; }
.glitch-loader i {
  display: block; width: 13px; height: 2.5px; background: currentColor; border-radius: 0.5px;
}
.glitch-loader i:nth-child(1) { animation: gl-a 1.5s ease-in-out infinite; }
.glitch-loader i:nth-child(2) { animation: gl-b 1.5s ease-in-out infinite 0.2s; width: 10px; }
.glitch-loader i:nth-child(3) { animation: gl-a 1.5s ease-in-out infinite 0.4s; width: 11px; }
@keyframes gl-a { 0%, 100% { transform: translateX(-2px); opacity: 0.5; } 50% { transform: translateX(2px); opacity: 1; } }
@keyframes gl-b { 0%, 100% { transform: translateX(2px); opacity: 1; } 50% { transform: translateX(-2px); opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  #scrub-morph svg rect { animation: none; }
  .glitch-loader i { animation: none; opacity: 0.7; }
}

/* typing-indicator dots: status line and busy send button */
.tdots { display: inline-flex; align-items: center; gap: 3px; }
.tdots i {
  width: 3.5px; height: 3.5px; border-radius: 50%;
  background: currentColor; display: inline-block;
  animation: tdot 1.1s ease-in-out infinite;
}
.tdots i:nth-child(2) { animation-delay: 0.18s; }
.tdots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes tdot { 0%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-1.5px); } }
.stream-cursor { margin-left: 5px; vertical-align: baseline; }
.stream-cursor i { width: 4px; height: 4px; }
@media (prefers-reduced-motion: reduce) { .tdots i { animation: none; opacity: 0.7; } }
.msg .msg-thumbs { display: flex; gap: 8px; margin-top: 6px; justify-content: flex-end; }
.msg .msg-thumbs img { height: 72px; border-radius: var(--r-ctl); border: 1px solid var(--border); }

body.chat-mode .stepper { display: none; }
body.chat-mode #card-2, body.chat-mode #card-3,
body.chat-mode #card-4, body.chat-mode #card-5 { display: none !important; }

/* ---------- history drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px); display: none; z-index: 45;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 320px; max-width: 100vw;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 46; display: flex; flex-direction: column;
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 18px; font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
/* ---------- pro: receipt + strict review sheets ---------- */
.pro-only { display: none; }
body.pro .pro-only { display: flex; }
.pro-inline { display: none !important; }
body.pro .pro-inline { display: inline-flex !important; }
#client-btn.active { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
#client-label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-back { margin: 10px 12px 0; }
.client-rule {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 18px; font-size: 13px; border-bottom: 1px solid var(--border);
}
.client-rule span { flex: 1; min-width: 0; word-break: break-word; }
.client-ledger-note {
  padding: 4px 18px 10px; font-size: 12px; color: var(--text-2); line-height: 1.5;
}
.client-manage {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
}
.client-danger { margin: 6px 12px; color: var(--danger); }
.client-danger:hover { background: var(--danger-soft); color: var(--danger); }
.meta-btn { cursor: pointer; }
.meta-btn:hover { color: var(--text-2); }

.receipt-stats {
  margin: 0; padding: 14px 18px;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px;
}
.receipt-stats dt {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3); align-self: baseline;
}
.receipt-stats dd { margin: 0; font-size: 12.5px; color: var(--text); }
.receipt-caption {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
  padding: 12px 18px 6px; border-top: 1px solid var(--border);
}
.receipt-table-wrap { overflow-x: auto; padding: 0 18px 8px; }
.receipt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.receipt-table th {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3); font-weight: 500;
  text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border);
}
.receipt-table td {
  padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border);
  vertical-align: top; word-break: break-word;
}
.receipt-table td:nth-child(2) { font-family: var(--mono); font-size: 11px; }
.receipt-table td:nth-child(3) { font-family: var(--mono); font-size: 10px; color: var(--text-3); white-space: nowrap; }
.receipt-transcript { border-top: 1px solid var(--border); margin-top: 6px; }
.receipt-transcript summary {
  cursor: pointer; list-style: none; user-select: none;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3); padding: 12px 18px;
}
.receipt-transcript summary::-webkit-details-marker { display: none; }
.receipt-transcript summary::after { content: " +"; }
.receipt-transcript[open] summary::after { content: " –"; }
.receipt-role {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em;
  color: var(--text-3); padding: 8px 18px 2px;
}
.receipt-msg {
  margin: 0; padding: 0 18px 6px; font-family: var(--mono); font-size: 11px;
  color: var(--text-2); white-space: pre-wrap; word-break: break-word; line-height: 1.55;
}
.receipt-dl { margin: 16px 18px 20px; padding: 10px 16px; border-radius: var(--r-ctl);
  border: none; cursor: pointer; background: var(--invert-bg); color: var(--invert-text);
  font-family: var(--sans); font-size: 13px; font-weight: 600; }
.receipt-dl:disabled { opacity: 0.5; }

.strict-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--border);
}
.strict-row.locked { opacity: 0.55; }
.strict-row.excluded .strict-pair { text-decoration: line-through; color: var(--text-3); }
.strict-row-main { flex: 1; min-width: 0; }
.strict-pair { font-size: 13px; word-break: break-word; }
.strict-sub {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  margin-top: 2px; padding: 0;
}
.strict-add { display: flex; gap: 8px; padding: 14px 18px; flex-wrap: wrap; }
.strict-add input {
  flex: 1; min-width: 130px; background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 8px 11px; font-size: 13px; font-family: var(--sans);
}
.strict-add input:focus { outline: none; border-color: var(--border-strong); }
.strict-foot {
  display: flex; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.strict-foot .primary {
  flex: 1; border: none; cursor: pointer; border-radius: var(--r-ctl);
  background: var(--invert-bg); color: var(--invert-text);
  padding: 11px 16px; font-family: var(--sans); font-size: 13.5px; font-weight: 600;
}

#history-close, #receipt-close, #strict-close {
  width: 40px; height: 40px; padding: 0; margin: -8px -6px; /* big target, optically aligned */
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: 50%;
}
#history-close:hover, #receipt-close:hover, #strict-close:hover { color: var(--text); border-color: var(--text-3); }
.drawer-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--r-ctl); cursor: pointer;
}
.conv-row.current { background: var(--input); }
@media (hover: hover) {
  .conv-row:hover { background: var(--input); }
  .conv-row:hover .conv-del { opacity: 1; }
}
.conv-row:active { background: var(--input); }
.conv-main { flex: 1; min-width: 0; }
.conv-title {
  font-size: 13.5px; font-weight: 500; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-branch { color: var(--text-3); }
.conv-meta {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  margin-top: 2px; letter-spacing: 0.03em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-del {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 12px; padding: 4px 7px; border-radius: 50%; opacity: 0.35; flex: none;
}
.conv-del:hover { color: var(--danger); background: var(--danger-soft); }
.drawer-empty {
  padding: 64px 18px 26px; color: var(--text-3); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.drawer-empty svg { width: 40px; height: 31px; opacity: 0.25; }
.drawer-empty div { color: var(--text-2); font-weight: 500; }
.drawer-empty small { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em; }
/* background-job rows pinned above conversations */
.drawer-section {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 12px 4px;
}
.job-row { cursor: default; }
.job-row.job-done { cursor: pointer; }
.job-status {
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  flex: none; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-status.err { color: var(--danger); }
.drawer-note {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em;
  color: var(--text-3); padding: 2px 12px 10px;
  border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
#jobs-cue { color: var(--text-2); }
.drawer-foot {
  padding: 12px 18px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.05em; color: var(--text-3); border-top: 1px solid var(--border);
}
@media (max-width: 640px) {
  .drawer { width: 100vw; border-left: none; }
  /* fixed to top:0, so clear the status bar / notch and breathe a little */
  .drawer-head {
    padding: calc(26px + env(safe-area-inset-top)) 18px 15px;
    font-size: 17px;
  }
  .drawer-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); font-size: 10.5px; }
  /* comfortable touch scale: nothing tiny, rows ~56px tall */
  .drawer-list { padding: 10px; }
  .conv-row { padding: 14px 6px 14px 14px; gap: 6px; }
  .conv-title { font-size: 16px; font-weight: 500; }
  .conv-meta { font-size: 11px; margin-top: 3px; }
  .conv-del {
    width: 40px; height: 40px; font-size: 14px; opacity: 0.5;
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
  }
  .drawer-section { font-size: 11px; padding: 14px 14px 6px; }
  .job-status { font-size: 11px; }
  .drawer-note { font-size: 10.5px; padding: 4px 14px 12px; }
  .drawer-empty { padding-top: 90px; font-size: 15px; }
  .drawer-empty svg { width: 52px; height: 41px; }
  .drawer-empty small { font-size: 11.5px; }
}

footer {
  text-align: center; color: var(--text-2); font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 0.04em; margin-top: 48px; opacity: 0.85;
}
footer a { color: inherit; }
footer .dot { margin: 0 8px; opacity: 0.5; }

/* ---------- attachments ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 6px; }
.chips:empty { display: none; }
.chip-file {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 5px 10px; font-size: 12px; font-weight: 500;
  background: var(--surface); max-width: 100%;
}
.chip-file .kind { font-size: 12px; }
/* document-edit toggle: cyan dot = active (functional color only) */
.chip-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px dashed var(--border-strong); border-radius: var(--r-ctl);
  padding: 5px 11px; font-size: 12px; font-weight: 500;
  background: none; color: var(--text-2); cursor: pointer;
  font-family: var(--sans);
}
.chip-toggle .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3); opacity: 0.5;
}
.chip-toggle:hover { color: var(--text); border-color: var(--text-3); }
.chip-toggle.on {
  border-style: solid; color: var(--text); background: var(--surface);
}
.chip-toggle.on .dot { background: var(--state); opacity: 1; }
.chip-file .fname {
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-file .meta { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; }
.chip-file .warn-ic { color: var(--warn); font-size: 12px; }
.chip-file .chip-x {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 11px; padding: 2px 3px; border-radius: 4px;
}
.chip-file .chip-x:hover { color: var(--danger); }
.chip-file.loading { opacity: 0.55; }

.warn-banner {
  border: 1px solid var(--border); border-left: 3px solid var(--warn);
  background: var(--input);
  color: var(--text-2); border-radius: var(--r-ctl); padding: 9px 13px;
  font-size: 12.5px; margin-bottom: 12px;
}

/* image region review */
.img-review { margin-bottom: 16px; }
.img-review .review-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  font-size: 12px; color: var(--text-3); flex-wrap: wrap;
}
.img-stage { position: relative; display: inline-block; max-width: 100%; }
.img-stage img { max-width: 100%; display: block; border-radius: var(--r-ctl); }
.img-stage .draw-layer { position: absolute; inset: 0; cursor: crosshair; display: none; }
.img-stage.drawing .draw-layer { display: block; }
.region-box {
  position: absolute; border: 1.5px solid var(--invert-bg); border-radius: 3px;
  cursor: pointer; background: rgba(127, 127, 127, 0.15);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.region-box.off { opacity: 0.35; border-style: dashed; background: transparent; }
.region-box .tag {
  position: absolute; top: -20px; left: -1px;
  background: var(--invert-bg); color: var(--invert-text);
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.05em;
  padding: 1px 7px; border-radius: 4px; white-space: nowrap;
}
.region-names { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.region-name-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.region-name-row .alias-lbl {
  min-width: 84px; color: var(--text-2); font-family: var(--mono);
  font-size: 11px; font-weight: 500;
}
.region-name-row input {
  background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 5px 11px; font-size: 12px; width: 230px; font-family: var(--sans);
}
.region-name-row input:focus { outline: 1px solid var(--text-3); }

#blurred-thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
#blurred-thumbs:empty { display: none; }
#blurred-thumbs img {
  height: 104px; border-radius: var(--r-ctl); border: 1px solid var(--border);
}

/* ---------- mobile: denser, flatter, one strict gutter ---------- */
@media (max-width: 640px) {
  /* one page gutter; composer interior aligns to its own consistent inset */
  .wrap { padding: 0 18px env(safe-area-inset-bottom); }
  header { padding-top: calc(12px + env(safe-area-inset-top)); }

  /* header: infrastructure chrome, not a hero */
  .logo { font-size: 15px; gap: 8px; }
  .logo svg { width: 18px; height: 18px; }
  .badge { padding: 3px 8px; font-size: 9.5px; gap: 5px; }
  .icon-btn { width: 34px; height: 34px; color: var(--text-3); }
  .pill-btn { padding: 6px 9px; }
  .pill-btn span { display: none; }
  #settings-btn svg { width: 14px; height: 14px; stroke-width: 1.5; }

  /* hero: compact rhythm — headline → body → breathing room → composer */
  .hero { margin: 26px 0 20px; }
  .hero h1 { font-size: 26px; line-height: 1.14; margin-bottom: 10px; }
  .hero p { font-size: 12.5px; line-height: 1.5; max-width: none; }
  .hero.compact { margin: 16px 0 14px; }
  .stepper { gap: 6px; margin: 0 0 12px; }
  .step { font-size: 9px; letter-spacing: 0.09em; }
  .step + .step::before { margin-right: 6px; }

  /* chat mode: composer pinned to the bottom like a native chat app */
  body.chat-mode #card-1 {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
  }
  body.chat-mode #chat-log.active { margin-bottom: 12px; }
  /* iOS-glass composer while chatting (solid var(--input) is the fallback) */
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    body.chat-mode #card-1 {
      background: color-mix(in srgb, var(--input) 72%, transparent);
      -webkit-backdrop-filter: blur(16px) saturate(1.15);
      backdrop-filter: blur(16px) saturate(1.15);
    }
  }
  /* during an active conversation the composer owns the bottom edge:
     nav rows disappear and the card snaps down even when the chat is short */
  body.chat-mode #chat-log.active ~ .lower-nav { display: none; }
  body.chat-mode #chat-log.active ~ #card-1 { margin-top: auto; margin-bottom: 0; }
  .msg { margin-bottom: 14px; }
  .msg .msg-inner { max-width: 90%; }
  .msg.user .bubble { font-size: 14.5px; padding: 8px 13px; }
  .msg.assistant .bubble { font-size: 14.5px; }

  /* composer: an instrument, not a card */
  #card-1 { border-radius: 12px; }
  textarea {
    min-height: 64px; padding: 12px 14px 4px;
    font-size: 16px; /* 16px minimum or iOS zoom-jumps on focus */
  }
  #card-1 .chips { padding: 0 12px 6px; }
  /* the toolbar must survive ANY effective width (page zoom, font scale):
     everything except the send button may shrink, and as a last resort the
     row wraps — the send button is never pushed off-screen */
  #card-1 .row { padding: 6px 8px 6px 10px; gap: 7px; flex-wrap: wrap; }
  /* short functional label on the status dot */
  .scrub-status { font-size: 0; gap: 5px; flex: none; }
  .scrub-status::after {
    content: attr(data-short); font-family: var(--mono);
    font-size: 10px; color: var(--text-2); letter-spacing: 0.02em;
  }
  /* icon-only on mobile so the send button always stays on-screen */
  #new-chat-btn { white-space: nowrap; padding: 8px; flex: none; }
  #new-chat-btn .nc-txt { display: none; }
  .attach-txt { display: none; }
  #char-count { display: none; }
  select {
    flex: 0 1 auto; min-width: 0; max-width: 40vw;
    overflow: hidden; text-overflow: ellipsis;
    font-size: 11.5px; padding: 6px 22px 6px 8px;
  }
  /* send: flat, decisive, modest radius — pinned right, never shrinks */
  button.circle {
    width: 40px; height: 40px; border-radius: 10px; font-size: 15px;
    flex: none; margin-left: auto;
  }
  button.primary { background: var(--invert-bg); }
  button.ghost { padding: 7px 9px; }

  /* lower nav pins to the screen bottom */
  .lower-nav { padding-top: 18px; }

  /* idle chat state: hero + composer centered in the viewport */
  body.centered-idle .hero { margin-top: auto; }
  body.centered-idle #card-1 { margin-bottom: auto; }
  body.centered-idle .lower-nav { margin-top: 0; }

  .card-head { flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
  .card-body { padding: 10px 14px 14px; }
  /* mapping table scrolls sideways instead of breaking the page */
  #card-2 .card-body { overflow-x: auto; }
  table.mapping { min-width: 480px; }
  .region-name-row input { width: 100%; }
  .settings-panel { width: 228px; }
}

/* very narrow effective widths (page zoom / large font scale): drop the
   status label to its dot so one toolbar row still fits */
@media (max-width: 360px) {
  .scrub-status::after { display: none; }
  #card-1 .row { gap: 5px; }
}

/* ---------- pro workspace: sidebar + conv bar + status strip (desktop) ----------
   All hidden by default; the grid activates only on body.pro at >=900px, so the
   simple edition and pro mobile are untouched. */
#sidebar, #conv-bar, #status-strip { display: none; }

@media (min-width: 900px) {
  body.pro { display: grid; grid-template-columns: 264px minmax(0, 1fr); }
  body.pro #sidebar {
    display: flex; flex-direction: column;
    grid-column: 1; position: sticky; top: 0; height: 100vh; height: 100dvh;
    overflow-y: auto; padding: 18px 12px 14px;
    border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 60%, var(--bg));
    z-index: 2;
  }
  body.pro .wrap { grid-column: 2; max-width: none; padding: 0 44px; }
  body.pro .hero, body.pro .lower-nav { display: none; }
  body.pro .logo, body.pro #history-btn, body.pro #new-chat-top { display: none; }
  /* sidebar owns clients on desktop; the header pill's show rule uses
     !important (pro-inline), so the hide must too */
  body.pro #client-btn { display: none !important; }
  /* idle: center the composer in the main pane (hero is hidden here) */
  body.pro.centered-idle #card-1 { margin-top: auto; }
  body.pro.centered-idle #status-strip { margin-bottom: auto; }
  body.pro #conv-bar { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding-right: 16px; }
  body.pro.chat-mode #card-1 { position: sticky; bottom: 12px; z-index: 5; }
  /* the log absorbs spare height so the composer docks even on short chats */
  body.pro #chat-log.active { flex: 1; margin-bottom: 10px; }
  body.pro #status-strip { display: block; }
  /* the docked composer gets the glass treatment on desktop too */
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    body.pro.chat-mode #card-1 {
      background: color-mix(in srgb, var(--input) 72%, transparent);
      -webkit-backdrop-filter: blur(16px) saturate(1.15);
      backdrop-filter: blur(16px) saturate(1.15);
    }
  }
}

.sb-brand {
  display: flex; align-items: center; padding: 4px 8px 16px;
  font-weight: 600; font-size: 16px; letter-spacing: -0.015em;
}
#sb-new-chat {
  margin: 0 4px 14px; padding: 9px 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
  background: none; color: var(--text);
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
}
#sb-new-chat:hover { background: var(--input); }
#sb-clients { margin-bottom: 6px; }
.sb-client {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-ctl); cursor: pointer;
  font-size: 12.5px; color: var(--text-2);
}
.sb-client:hover { background: var(--input); color: var(--text); }
.sb-client.active { color: var(--text); font-weight: 500; }
.sb-client-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: none; }
.sb-client.active .sb-client-dot { background: var(--state); }
.sb-client-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-manage {
  background: none; border: none; cursor: pointer; padding: 7px 10px;
  color: var(--text-3); font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
}
.sb-manage:hover { color: var(--text); }
#sb-list { flex: 1; }
#sb-list .conv-title { font-size: 13px; }
#sidebar .drawer-section { padding: 12px 10px 4px; }

#conv-bar { color: var(--text); }
#cb-title {
  font-weight: 600; font-size: 14px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#cb-client {
  flex: none; font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 99px;
  padding: 3px 10px; color: var(--text-2);
}
#cb-receipt { flex: none; }

#status-strip {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em;
  color: var(--text-3); padding: 8px 6px 14px;
}
