/* Patch on the web. Paper and ink, one hairline, status green only for live / needs you / running, clay only on Patch, red only for errors.
   Same roles and values as the phone app (android ui/theme/Color.kt). Plex Sans for words, Plex Mono for machine values. */
@font-face { font-family: "IBM Plex Sans"; font-weight: 100 700; font-display: swap; src: url("fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 100 700; font-display: swap; src: url("fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  color-scheme: light;
  --paper: #f6f5f1; --card: #fbfaf7; --ground: #ecebe5; --ink: #1b1b18; --muted: #5f5e56; --hair: #e6e3da;
  --green: #1c9a60; --ok: #126f47; --warn: #835608; --warn-dot: #c0801c; --clay: #9a4711;
  --err: #b3261e; --err-soft: #f6e1de; --on-err: #fff;
  --stage: #000; --on-stage: #fff; --on-stage-muted: #c9c7bf;
  --shadow: 0 1px 2px rgb(27 27 24 / .06), 0 8px 24px -12px rgb(27 27 24 / .18);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px; --rail: 288px; --col: 46rem;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151513; --card: #1b1b19; --ground: #222220; --ink: #ecebe5; --muted: #a6a49a; --hair: #2d2c28;
  --ok: #3fbc82; --warn: #e0a63c; --err: #f0a79d; --err-soft: #3b1f1b; --on-err: #2a0e0b;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -12px rgb(0 0 0 / .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #151513; --card: #1b1b19; --ground: #222220; --ink: #ecebe5; --muted: #a6a49a; --hair: #2d2c28;
    --ok: #3fbc82; --warn: #e0a63c; --err: #f0a79d; --err-soft: #3b1f1b; --on-err: #2a0e0b;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -12px rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1rem/1.5 var(--sans); min-height: 100dvh; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: color-mix(in srgb, var(--green) 28%, transparent); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.mono, .tech { font-family: var(--mono); font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.strong { font-weight: 500; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 14px; }
.error { color: var(--err); font-size: .95rem; }
.note { color: var(--muted); font-size: .9rem; }
.lead { color: var(--muted); font-size: 1.0625rem; }
.tech { display: none; color: var(--muted); }
body.details .tech { display: inline; }
body.details div.tech, body.details pre.tech { display: block; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); display: inline-block; flex: none; }
.dot.off { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.dot.warn { background: var(--warn-dot); }

/* Buttons: 44px tall at least, ink fill for the one main action, hairline outline for the rest */
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--hair); background: var(--card); cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background-color .15s, border-color .15s, transform .15s var(--ease); }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 40%, var(--hair)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--paper)); }
.btn.big { min-height: 52px; font-size: 1.0625rem; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); padding: 0 12px; }
.btn.quiet:hover { color: var(--ink); background: var(--ground); }
.btn.danger { background: var(--err); color: var(--on-err); border-color: var(--err); }
.btn.icon-btn { padding: 0; width: 44px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 500; }
input[type="email"], input[type="password"], input:not([type]), textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--ink) 28%, var(--hair)); background: var(--card); caret-color: var(--green);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); width: 22px; height: 22px; flex: none; margin: 0; }

/* Sign-in */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card { width: min(100%, 27rem); display: grid; gap: 18px; }
.signin-patch { border-radius: 18px; }
:root[data-theme="dark"] .signin-patch, :root[data-theme="dark"] #rail-face { background: #ecebe5; border-radius: 50%; padding: 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .signin-patch, :root:not([data-theme="light"]) #rail-face { background: #ecebe5; border-radius: 50%; padding: 4px; } }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.1; font-weight: 600; letter-spacing: -.02em; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--ground); padding: 4px; border-radius: 14px; }
.tab { min-height: 44px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(27 27 24 / .12); }
.qr-sketch { width: 200px; height: 200px; border-radius: 20px; border: 2px dashed var(--hair); display: grid; place-items: center; margin-inline: auto;
  background: repeating-linear-gradient(0deg, transparent 0 11px, var(--hair) 11px 12px), repeating-linear-gradient(90deg, transparent 0 11px, var(--hair) 11px 12px); }
.qr-sketch img { background: var(--paper); padding: 8px; border-radius: 14px; }
:root[data-theme="dark"] .qr-sketch img { background: #ecebe5; }

/* App shell: rail and one conversation column */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
.topbar { display: none; }
.rail { grid-row: 1 / -1; border-right: 1px solid var(--hair); background: var(--card); display: flex; flex-direction: column; gap: 20px; padding: 24px 16px 16px; overflow-y: auto; }
.rail-patch { display: flex; gap: 14px; align-items: center; padding: 0 8px; }
.rail-name { font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; }
.rail-state { color: var(--muted); font-size: .9375rem; }
.rail.needs .rail-state { color: var(--ok); font-weight: 500; }
.rail-sections { display: grid; gap: 20px; flex: 1; align-content: start; }
.rail h2 { font-size: .8125rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; padding: 0 8px 6px; }
.rail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail-item { display: flex; gap: 10px; align-items: center; width: 100%; min-height: 44px; text-align: left; background: transparent; border: 0; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.rail-item:hover { background: var(--ground); }
.rail-item .t { flex: 1; min-width: 0; display: grid; }
.rail-item .t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .t small { color: var(--muted); font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot { display: grid; gap: 8px; border-top: 1px solid var(--hair); padding-top: 12px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--ground); border: 1px solid var(--hair); position: relative; cursor: pointer; flex: none; transition: background-color .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(18px); background: var(--paper); }
.rail-foot .small { padding: 0 8px; overflow-wrap: anywhere; white-space: pre-line; }

.stage { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.thread-wrap { overflow-y: auto; padding: 32px 24px 8px; scroll-behavior: smooth; }
.thread { max-width: var(--col); margin-inline: auto; display: grid; gap: 14px; align-content: start; }
.empty { color: var(--muted); font-size: 1.125rem; padding: 64px 0; text-align: center; }

/* Messages */
.msg { display: grid; gap: 8px; max-width: 100%; animation: arrive .35s var(--ease); }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
.msg.you { justify-self: end; max-width: min(85%, 34rem); }
.bubble { border-radius: 18px; padding: 12px 16px; overflow-wrap: anywhere; white-space: pre-line; }
.you .bubble { background: var(--ink); color: var(--paper); border-bottom-right-radius: 6px; }
.patch .bubble { background: var(--card); border: 1px solid var(--hair); border-bottom-left-radius: 6px; }
.patch { grid-template-columns: 36px minmax(0, 1fr); gap: 4px 12px; align-items: start; }
.patch > .face { width: 36px; height: 36px; border-radius: 50%; }
:root[data-theme="dark"] .patch > .face { background: #ecebe5; padding: 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .patch > .face { background: #ecebe5; padding: 2px; } }
.patch .body { display: grid; gap: 8px; min-width: 0; }
.when { color: var(--muted); font-size: .8125rem; }
.assure { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 0 4px; font-size: .875rem; color: var(--muted); }
.label { font-weight: 600; color: var(--muted); }
.label.ok { color: var(--ok); }
.label.warn { color: var(--warn); }
.label.ok::before { content: ""; display: inline-block; width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(-45deg); margin-right: 8px; }
details.fold { padding: 0 4px; font-size: .9rem; }
details.fold summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--muted); }
details.fold summary:hover { color: var(--ink); }
details.fold ul { margin: 6px 0 4px; padding-left: 20px; color: var(--muted); }
.reads { display: grid; gap: 8px; margin: 6px 0; }
.reads pre { margin: 0; padding: 10px 12px; background: var(--ground); border-radius: 10px; overflow-x: auto; font: 400 .8125rem/1.5 var(--mono); }
.actions { display: flex; gap: 6px; padding: 0 2px; }

/* Cards in the thread */
.card { background: var(--card); border: 1px solid var(--hair); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 10px; }
.card h3 { font-size: 1rem; font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 8px 16px; margin: 0; }
.facts div { display: grid; }
.facts dt { color: var(--muted); font-size: .8125rem; }
.facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.machine-head { display: flex; gap: 10px; align-items: center; }
.machine-head h3 { flex: 1; }

.task { gap: 12px; }
.task-head { display: flex; gap: 10px; align-items: center; }
.task-head h3 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.status { color: var(--muted); }
.status.live { color: var(--ok); font-weight: 500; }
.bar { height: 6px; border-radius: 3px; background: var(--ground); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 3px; transition: width .6s var(--ease); }
.task.done { padding: 12px 16px; }
.outcome { color: var(--muted); }

.ask { border-color: color-mix(in srgb, var(--green) 55%, var(--hair)); }
.ask .sentence { font-size: 1.125rem; font-weight: 500; }
.ask .row .btn { flex: 1 1 8rem; }
.consequence { color: var(--muted); }
.typed { display: grid; gap: 6px; }

/* The live screen */
.screen { display: grid; gap: 10px; }
.screen-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.screen-head h3 { flex: 1 1 12rem; font-size: .9375rem; font-weight: 500; color: var(--muted); }
.livepill { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.stage-box { position: relative; aspect-ratio: 16 / 9; background: var(--stage); border-radius: var(--r); overflow: hidden; display: grid; place-items: center; outline-offset: 3px; }
.stage-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage-box video[hidden] { display: none; }
.stage-box.controlling { cursor: crosshair; box-shadow: 0 0 0 3px var(--green); }
.stage-box:focus-visible { outline: 3px solid var(--ink); }
.stage-words { position: relative; z-index: 1; color: var(--on-stage); text-align: center; padding: 16px 24px; display: grid; gap: 6px; justify-items: center; }
.stage-words .detail { color: var(--on-stage-muted); font-size: .9rem; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--on-stage-muted); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.controls .spacer { flex: 1; }
.waiting { background: var(--ground); border-radius: 12px; padding: 12px; display: grid; gap: 10px; justify-items: start; }
.hint { color: var(--muted); font-size: .875rem; }
.stopask { background: var(--ground); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.still img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: var(--r); display: block; }

/* Composer */
.composer { max-width: calc(var(--col) + 48px); width: 100%; margin-inline: auto; padding: 8px 24px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; background: var(--card); border: 1px solid color-mix(in srgb, var(--ink) 25%, var(--hair)); border-radius: 20px; padding: 6px 6px 6px 6px; box-shadow: var(--shadow); }
.composer-row:focus-within { border-color: var(--ink); }
.composer-row textarea { border: 0; background: transparent; resize: none; min-height: 44px; max-height: 9rem; padding: 10px 12px; outline: none; }
.composer-row .send { border-radius: 14px; }
.composer-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.chip { display: flex; gap: 8px; align-items: center; justify-content: space-between; background: var(--ground); border-radius: 12px; padding: 6px 6px 6px 14px; }
.chip-title { font-weight: 600; font-size: .9375rem; }
.chip-sub { color: var(--muted); font-size: .875rem; }

/* Sheets (computer choice) and the expanded screen */
dialog { color: var(--ink); background: var(--paper); border: 1px solid var(--hair); padding: 0; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.sheet { width: min(100% - 32px, 34rem); max-height: min(92dvh, 52rem); border-radius: 24px; box-shadow: var(--shadow); margin: auto; }
.sheet-body { padding: 24px; display: grid; gap: 14px; overflow-y: auto; max-height: min(92dvh, 52rem); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 2px; }
.choices legend { font-weight: 600; padding: 4px 0 6px; }
.choice { display: flex; gap: 12px; align-items: center; min-height: 52px; padding: 6px 10px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.choice:hover { background: var(--ground); }
.choice:has(input:checked) { background: var(--card); border-color: var(--ink); }
.choice:has(input:disabled) { cursor: default; }
.choice .t { display: grid; flex: 1; min-width: 0; }
.choice .t span { color: var(--muted); font-size: .9rem; }
.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; padding: 8px 4px; cursor: pointer; }
.check:has(input:disabled) { cursor: default; opacity: .6; }
.notes { display: grid; gap: 6px; padding: 0 4px; color: var(--muted); font-size: .9rem; }
.notes b { font-family: var(--mono); font-weight: 400; color: var(--ink); font-size: .85rem; }
.sheet-actions { display: grid; gap: 8px; position: sticky; bottom: -24px; background: var(--paper); padding: 12px 0 24px; margin-bottom: -24px; border-top: 1px solid var(--hair); }
.expand { width: min(100% - 24px, 90rem); max-height: 96dvh; border-radius: 20px; margin: auto; }
.expand-body { padding: 16px; display: grid; gap: 12px; }
.expand-body h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.expand .stage-box { width: min(100%, calc((96dvh - 250px) * 16 / 9)); margin-inline: auto; }
.expand .screen { border: 0; padding: 0; background: transparent; }
.scrim { display: none; }

@media (max-width: 1100px) { :root { --rail: 248px; } .thread-wrap { padding-inline: 16px; } .composer { padding-inline: 16px; } }
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--hair); background: var(--card); }
  .who { display: grid; }
  .who-name { font-weight: 600; line-height: 1.2; }
  .who-state { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: .875rem; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); z-index: 30; transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow); visibility: hidden; }
  .rail.open { transform: none; visibility: visible; }
  .scrim.on { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 20; }
  .thread-wrap { padding: 16px 12px 4px; }
  .composer { padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .composer-tools .small { display: none; }
  .msg.you { max-width: 92%; }
  .sheet { margin-block: auto 0; width: 100%; border-radius: 24px 24px 0 0; max-height: 94dvh; }
  .expand { width: 100%; max-height: 100dvh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
