/* Kalamo Bhala mobile. Quiet by design: the page is the interface; everything else slides in only when asked for.
   Colours follow the desktop's Sand (light) and Walnut (dark) schemes. */
:root, :root[data-theme="light"] {
  --bg: #f6f0e5; --page: #fbf7f0; --raised: #fffdf8; --line: #e3d7c4; --line-strong: #cdbb9f;
  --text: #2c2117; --muted: #7a6650; --faint: #a8957d; --accent: #8a5a2b; --accent-ink: #fff8ec; --accent-soft: #8a5a2b1a;
  --danger: #a3402a; --ok: #4f6a24; --shade: #2c211759; --shadow: 0 10px 40px #4a33191f, 0 2px 8px #4a33190f;
  --sel: #8a5a2b2e;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d1712; --page: #221b15; --raised: #2b221a; --line: #3d3125; --line-strong: #56442f;
  --text: #ecdfcb; --muted: #b5a084; --faint: #7f6d58; --accent: #d4ab69; --accent-ink: #22180e; --accent-soft: #d4ab6922;
  --danger: #e8a08a; --ok: #b9c98a; --shade: #0a07058c; --shadow: 0 10px 40px #00000066, 0 2px 8px #00000040;
  --sel: #d4ab6938;
  color-scheme: dark;
}
:root { --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Charter, "Noto Serif", Georgia, ui-serif, serif;
  --text-size: 1.1875rem; --top: env(safe-area-inset-top, 0px); --bottom: env(safe-area-inset-bottom, 0px); }
:root[data-size="small"] { --text-size: 1.0625rem; }
:root[data-size="large"] { --text-size: 1.375rem; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 var(--ui); }
/* no pull-down-to-refresh (test round 17 Nov 2026): Chrome reads this from html (the page), not from body */
html { overscroll-behavior-y: none; }
body { overscroll-behavior-y: none; overflow-x: hidden; }
#app, .screen { max-width: 100vw; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; font: 500 1.4rem var(--serif); color: var(--faint); letter-spacing: .02em; }

/* ---------- screens ---------- */
#app { min-height: 100%; }
.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-top: var(--top); }
.bar { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 0 6px; position: sticky; top: 0; z-index: 5; background: var(--bg); }
.bar h1 { flex: 1; min-width: 0; margin: 0; font: 600 1.0625rem var(--ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 22px; background: none; color: var(--muted); }
.icon-btn:active { background: var(--accent-soft); color: var(--text); }
.content { flex: 1; padding: 8px 20px calc(96px + var(--bottom)); }

/* ---------- buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 23px;
  border: 1px solid var(--line-strong); background: var(--raised); color: var(--text); font-weight: 550; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.field-label { display: block; margin: 14px 0 6px; font-size: .8125rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field-input, .field-area, select.field-input { width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--raised); outline: none; }
.field-area { min-height: 140px; resize: vertical; font: .9375rem/1.45 ui-monospace, "Cascadia Mono", Menlo, monospace; }
.field-input:focus, .field-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- projects ---------- */
.brand { padding: 18px 22px 6px; }
.brand h1 { margin: 0; font: 600 2rem/1.1 var(--serif); letter-spacing: -.01em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: .9375rem; }
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--raised); color: var(--text); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.card:active { transform: scale(.99); }
.card .ic { color: var(--accent); width: 26px; height: 26px; }
.card .t { flex: 1; min-width: 0; }
.card .t b { display: block; font: 600 1.0625rem/1.3 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .t span { font-size: .8125rem; color: var(--muted); }
.card.remote { border-style: dashed; background: none; }
.card.remote .ic { color: var(--faint); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.empty b { display: block; font: 600 1.25rem var(--serif); color: var(--text); margin-bottom: 6px; }
.fab { position: fixed; right: 20px; bottom: calc(22px + var(--bottom)); width: 60px; height: 60px; border-radius: 30px; border: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); z-index: 6; }
.fab .ic { width: 28px; height: 28px; stroke-width: 2; }

/* sync chip */
.sync { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 15px; border: 0; background: none; color: var(--faint); font-size: .75rem; }
.sync .dot { width: 8px; height: 8px; border-radius: 4px; background: var(--ok); }
.sync[data-state="syncing"] .dot { background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.sync[data-state="offline"] .dot { background: var(--faint); }
.sync[data-state="signin"] .dot, .sync[data-state="error"] .dot { background: var(--danger); }
.sync[data-state="signin"], .sync[data-state="error"] { color: var(--danger); }
.sync[data-state="phone"] .dot { display: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- writing ---------- */
.write { background: var(--page); }
.write .bar { background: var(--page); transition: opacity .25s; }
.write .bar h1 { font: 500 1rem var(--serif); color: var(--muted); text-align: center; }
.page { flex: 1; display: flex; flex-direction: column; padding: 4px 22px calc(40vh + var(--bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
.pm-surface { flex: 1; outline: none; font: var(--text-size)/1.68 var(--serif); color: var(--text); caret-color: var(--accent); white-space: pre-wrap; word-wrap: break-word;
  min-height: 60vh; -webkit-user-select: text; user-select: text; }
.pm-surface ::selection { background: var(--sel); }
.pm-surface p { margin: 0 0 .85em; }
.pm-surface h1, .pm-surface h2, .pm-surface h3 { font-family: var(--serif); line-height: 1.25; margin: 1.2em 0 .5em; }
.pm-surface h1 { font-size: 1.6em; font-weight: 600; }
.pm-surface h2 { font-size: 1.3em; font-weight: 600; }
.pm-surface h3 { font-size: 1.1em; font-weight: 650; }
.pm-surface blockquote { margin: 0 0 .85em; padding-left: 1em; border-left: 3px solid var(--line-strong); color: var(--muted); }
.pm-surface hr { border: 0; text-align: center; margin: 1.4em 0; }
.pm-surface hr::after { content: "* * *"; color: var(--faint); letter-spacing: .5em; }
.pm-surface ul, .pm-surface ol { padding-left: 1.4em; margin: 0 0 .85em; }
.pm-surface img { max-width: 100%; height: auto; border-radius: 8px; }
.pm-surface table { border-collapse: collapse; width: 100%; font-size: .85em; margin-bottom: 1em; }
.pm-surface td, .pm-surface th { border: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
.pm-surface code { font-size: .85em; background: var(--accent-soft); padding: 0 .25em; border-radius: 4px; }
.pm-surface .find-hit { background: var(--sel); }
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-gapcursor { display: none; }
.doc-empty { color: var(--faint); font: italic var(--text-size)/1.6 var(--serif); pointer-events: none; position: absolute; }
.wordcount { position: fixed; left: 0; right: 0; bottom: calc(10px + var(--bottom)); text-align: center; font-size: .75rem; color: var(--faint); pointer-events: none; transition: opacity .3s; }
.typing .wordcount { opacity: 0; }
.typing .write .bar { opacity: .3; }
.no-doc { margin: auto; text-align: center; color: var(--muted); padding: 40px 20px; }

/* selection bar: small, floating, below the selection (Android puts its own copy/paste bar above it) */
.selbar { position: fixed; z-index: 20; display: flex; gap: 2px; padding: 4px; border-radius: 16px; background: var(--raised); border: 1px solid var(--line);
  box-shadow: var(--shadow); transform: translateX(-50%); transition: opacity .12s; }
.selbar button { min-width: 44px; height: 40px; padding: 0 10px; border: 0; border-radius: 12px; background: none; color: var(--text); font: 600 1rem var(--serif); }
.selbar button.on { background: var(--accent-soft); color: var(--accent); }
.selbar button.ai { display: flex; align-items: center; gap: 6px; color: var(--accent); font: 600 .9375rem var(--ui); }
.selbar button.ai .ic { width: 18px; height: 18px; }
.selbar i { font-style: italic; }

/* "/" list: docked above the keyboard */
.slash { position: fixed; left: 8px; right: 8px; z-index: 21; max-height: 46vh; overflow-y: auto; padding: 6px; border-radius: 18px; background: var(--raised);
  border: 1px solid var(--line); box-shadow: var(--shadow); overscroll-behavior: contain; }
.slash h3 { margin: 8px 12px 4px; font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.slash button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 6px 12px; border: 0; border-radius: 12px; background: none; text-align: left; }
.slash button.active, .slash button:active { background: var(--accent-soft); }
.slash button .k { width: 28px; text-align: center; color: var(--muted); font: 600 .9375rem var(--serif); flex: none; }
.slash button .k .ic { width: 18px; height: 18px; }
.slash button span { flex: 1; min-width: 0; }
.slash button small { display: block; color: var(--faint); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slash .none { padding: 14px; color: var(--muted); font-size: .875rem; }

/* ---------- binder drawer (swipe from the left edge) ---------- */
.drawer-shade { position: fixed; inset: 0; background: var(--shade); opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 30; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 360px); z-index: 31; background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); padding-top: var(--top); box-shadow: var(--shadow); }
.drawer.open { transform: none; }
.drawer-shade.open { opacity: 1; pointer-events: auto; }
.drawer.dragging, .drawer-shade.dragging { transition: none; }
.drawer-head { display: flex; align-items: center; gap: 4px; padding: 8px 6px 8px 16px; }
.drawer-head button.title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; border: 0; background: none; padding: 6px 0; text-align: left; }
.drawer-head .title b { font: 600 1.1875rem/1.2 var(--serif); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head .title span { font-size: .75rem; color: var(--muted); }
.tree { flex: 1; overflow-y: auto; padding: 4px 8px 12px; overscroll-behavior: contain; }
.node { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 10px; border: 0; border-radius: 12px; background: none; text-align: left;
  color: var(--text); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.node:active { background: var(--accent-soft); }
.node.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.node .ic { width: 19px; height: 19px; color: var(--faint); }
.node.current .ic { color: var(--accent); }
.node .chev { width: 16px; height: 16px; transition: transform .15s; }
.node.open .chev { transform: rotate(90deg); }
.node .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .w { font-size: .6875rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.node .on { width: 6px; height: 6px; border-radius: 3px; background: var(--accent); flex: none; }
.kids { padding-left: 16px; }
.drawer-foot { display: flex; gap: 8px; padding: 10px 12px calc(12px + var(--bottom)); border-top: 1px solid var(--line); }
.drawer-foot .btn { flex: 1; min-height: 42px; padding: 0 10px; font-size: .875rem; }
.drawer-hint { padding: 0 18px 10px; font-size: .75rem; color: var(--faint); }

/* ---------- sheets ---------- */
.shade { position: fixed; inset: 0; background: var(--shade); opacity: 0; transition: opacity .2s; z-index: 40; }
.shade.in { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88vh; display: flex; flex-direction: column; background: var(--raised);
  border-radius: 24px 24px 0 0; box-shadow: var(--shadow); transform: translateY(105%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--bottom); max-width: 720px; margin: 0 auto; }
.sheet.in { transform: none; }
.sheet.tall { height: 88vh; }
.grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 10px auto 2px; flex: none; }
.sheet-head h2 { margin: 6px 22px 4px; font: 600 1.1875rem var(--serif); }
.sheet-body { flex: 1; overflow-y: auto; padding: 6px 22px 14px; overscroll-behavior: contain; }
.sheet-body p { margin: .4em 0 .8em; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 10px 18px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-foot .btn { flex: 1; max-width: 220px; }
.action-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0 -10px; }
.action { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 12px; border: 0; border-radius: 12px; background: none; text-align: left; font-size: 1rem; }
.action:active { background: var(--accent-soft); }
.action .ic { color: var(--muted); }
.action.danger, .action.danger .ic { color: var(--danger); }
.choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; margin-bottom: 10px; border-radius: 16px; border: 1px solid var(--line-strong);
  background: var(--raised); text-align: left; }
.choice .ic { width: 28px; height: 28px; color: var(--accent); }
.choice b { display: block; font: 600 1.0625rem var(--serif); }
.choice span { font-size: .875rem; color: var(--muted); }
.choice.picked { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* AI reply */
.reply-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .75rem; color: var(--muted); margin-bottom: 10px; }
.reply-meta b { color: var(--text); font-weight: 600; }
.reply-text { font: var(--text-size)/1.6 var(--serif); word-wrap: break-word; min-height: 4em; }
.reply-text p { margin: 0 0 .7em; }
.reply-text h1, .reply-text h2, .reply-text h3 { font-size: 1.15em; margin: .8em 0 .4em; }
.reply-text img { display: none; }
.reply-text.waiting::after { content: "▍"; color: var(--accent); animation: pulse .9s infinite; }
.reply-warn { font-size: .8125rem; color: var(--danger); margin: 8px 0 0; }
.reply-cost { font-size: .8125rem; color: var(--muted); margin-top: 12px; }

/* lists in settings */
.group { margin: 18px 0 6px; font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.list { border-radius: 16px; border: 1px solid var(--line); background: var(--raised); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; }
.item:first-child { border-top: 0; }
.item:active { background: var(--accent-soft); }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 550; }
.item .t span { display: block; font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .ic { color: var(--faint); }
.item .tag { font-size: .6875rem; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; border: 0; background: none; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.note { font-size: .8125rem; color: var(--muted); margin: 8px 2px; }
.model-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.model-row:first-child { border-top: 0; }
.model-row .t { flex: 1; min-width: 0; }
.model-row .t b { display: block; font-size: .9375rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-row .t span { font-size: .75rem; color: var(--muted); }
.model-row .def { font-size: .6875rem; color: var(--accent); font-weight: 650; }

/* setup */
.setup { padding: calc(32px + var(--top)) 24px calc(24px + var(--bottom)); min-height: 100dvh; display: flex; flex-direction: column; }
.setup h1 { font: 600 2.1rem/1.15 var(--serif); margin: 12px 0 8px; letter-spacing: -.01em; }
.setup .lead { color: var(--muted); font-size: 1.0625rem; margin: 0 0 24px; }
.setup .steps { display: flex; gap: 6px; }
.setup .steps i { height: 4px; flex: 1; border-radius: 2px; background: var(--line); }
.setup .steps i.on { background: var(--accent); }
.setup .grow { flex: 1; }
.setup .foot { display: grid; gap: 10px; margin-top: 20px; }
.logo { width: 64px; height: 64px; border-radius: 16px; }
.crumbs { font-size: .8125rem; color: var(--muted); margin: 0 0 8px; word-break: break-word; }

/* toasts and the update banner */
#toasts { position: fixed; left: 16px; right: 16px; top: calc(12px + var(--top)); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.toast { justify-self: center; max-width: 520px; padding: 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: .9375rem; box-shadow: var(--shadow);
  transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); color: var(--accent-ink); }
.toast.out { opacity: 0; transform: translateY(-8px); }
.banner { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--bottom)); z-index: 55; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px;
  border-radius: 18px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); max-width: 560px; margin: 0 auto; }
.banner span { flex: 1; font-size: .9375rem; }
.banner .btn { min-height: 40px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- round 2 (DECISIONS 55): small buttons, chips, picked files ---------- */
.btn.small { min-height: 36px; padding: 0 14px; font-size: .875rem; border-radius: 18px; }
.ic.tiny { width: 14px; height: 14px; }
.action.picked { color: var(--accent); font-weight: 600; }
.action.picked .ic { color: var(--accent); }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; align-items: center; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.cost-line { font-size: .9375rem; }
.file-list { margin: 4px 0 12px; padding-left: 1.2em; word-break: break-word; }
.file-list li { margin: 2px 0; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check small { display: block; font-size: .8125rem; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line-strong); background: none; color: var(--muted); font-size: .875rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* imports running in the background: small cards under the top bar */
.bg-tasks { position: fixed; right: 10px; top: calc(60px + var(--top)); z-index: 25; display: grid; gap: 8px; width: min(320px, calc(100vw - 20px)); }
.bg-task { padding: 10px 12px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); }
.bg-row { display: flex; align-items: center; gap: 8px; }
.bg-name { flex: 1; min-width: 0; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-msg { font-size: .75rem; color: var(--muted); margin: 4px 0 6px; }
.bg-task progress { width: 100%; height: 4px; accent-color: var(--accent); }
.bg-stop { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 15px; border: 0; background: var(--accent-soft); color: var(--danger); font-size: .75rem; font-weight: 600; }
.bg-stop .ic { width: 14px; height: 14px; }
.bg-stop:disabled { opacity: .5; }

/* Kalamo's camera: the picture fills the whole screen; the top bar and the controls lie over it (DECISIONS 59) */
.camera { position: fixed; inset: 0; z-index: 45; background: #000; color: #fff; overflow: hidden; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: var(--top) 8px 8px; background: linear-gradient(rgba(0, 0, 0, .6), rgba(0, 0, 0, 0)); }
.cam-top b { flex: 1; font-weight: 600; }
.cam-top .icon-btn { color: #fff; }
.cam-top .icon-btn.on { background: rgba(255, 255, 255, .25); }
.cam-count { font-size: .8125rem; opacity: .85; padding-right: 4px; }
/* the video stays inside the screen: a phone camera gives a tall picture; touch here zooms (pinch) and focuses (tap) */
.cam-view { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; transform-origin: 50% 50%; }
.cam-msg { z-index: 1; position: absolute; left: 24px; right: 24px; top: 40%; text-align: center; font-size: .9375rem; line-height: 1.5; }
.cam-grid { position: absolute; inset: 0; pointer-events: none; }
.cam-grid i { position: absolute; background: rgba(255, 255, 255, .35); }
.cam-grid i:nth-child(1) { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.cam-grid i:nth-child(2) { left: 66.67%; top: 0; bottom: 0; width: 1px; }
.cam-grid i:nth-child(3) { top: 33.33%; left: 0; right: 0; height: 1px; }
.cam-grid i:nth-child(4) { top: 66.67%; left: 0; right: 0; height: 1px; }
.cam-level { position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 38px;
  border: 2px solid rgba(255, 255, 255, .7); pointer-events: none; display: grid; place-items: center; }
.cam-level b { width: 14px; height: 14px; border-radius: 7px; background: #fff; }
.cam-level.flat { border-color: #3ddc84; }
.cam-level.flat b { background: #3ddc84; }
.cam-focus { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 2px solid #ffd54f; border-radius: 8px;
  pointer-events: none; animation: cam-focus .9s ease-out forwards; }
@keyframes cam-focus { from { transform: scale(1.4); opacity: 1; } 60% { transform: scale(1); opacity: 1; } to { opacity: 0; } }
.cam-controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding-bottom: var(--bottom);
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .65) 40%); }
.cam-zoom { display: flex; justify-content: center; gap: 10px; padding: 14px 0 2px; }
.cam-zoom button { min-width: 46px; height: 34px; padding: 0 8px; border-radius: 17px; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-weight: 600; font-size: .8125rem; }
.cam-zoom button.on { background: #fff; color: #000; }
/* the last picture and the light on the left, shutter in the middle, Done on the right */
.cam-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 16px 16px; }
.cam-left { justify-self: start; display: flex; align-items: center; gap: 10px; }
.cam-right { justify-self: end; }
.cam-light { color: #fff; background: rgba(0, 0, 0, .45); }
.cam-light.on { background: #fff; color: #000; }
.cam-thumb { position: relative; width: 50px; height: 50px; padding: 0; border: 2px solid rgba(255, 255, 255, .85); border-radius: 10px; background: #222; flex: none; }
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.cam-badge { position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #fff; color: #000; font-size: .75rem; font-weight: 700; line-height: 20px; }
/* the "new version" banner never covers the camera's shutter (it waits until the camera closes) or the chat's
   Send button (it moves to the top while the chat is open) */
.camera-on .banner { display: none; }
.chat-on .banner { top: calc(64px + var(--top)); bottom: auto; }
/* phone on its side: the controls stand in a column on the right (as in the phone's own camera), the zoom buttons
   in a column next to them, so the picture stays free (DECISIONS 59) */
@media (orientation: landscape) and (max-height: 560px) {
  .cam-controls { top: 0; left: auto; width: 136px; padding: 0 env(safe-area-inset-right, 0px) 0 0; display: flex; align-items: center;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .65) 35%); }
  .cam-bottom { height: 100%; width: 100%; grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr; justify-items: center;
    gap: 10px; padding: 60px 8px 14px; }
  .cam-left { align-self: end; justify-self: center; }
  .cam-right { align-self: start; justify-self: center; }
  .cam-done { padding: 0 14px; }
  .cam-zoom { position: absolute; right: 100%; top: 50%; transform: translateY(-50%); flex-direction: column; padding: 0 6px 0 0; gap: 8px; }
  .cam-top { padding-right: 144px; }
}
/* looking at the pictures taken */
.cam-review { position: absolute; inset: 0; z-index: 5; background: #000; display: flex; flex-direction: column; }
.cam-review .cam-top { position: static; background: none; }
.cam-review-view { flex: 1; position: relative; min-height: 0; }
.cam-review-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-nav { position: absolute; top: 50%; margin-top: -22px; color: #fff; background: rgba(0, 0, 0, .5); }
.cam-nav:disabled { opacity: .25; }
.cam-prev { left: 6px; }
.cam-next { right: 6px; }
.cam-review-bar { display: flex; justify-content: center; gap: 10px; padding: 12px 12px calc(16px + var(--bottom)); }
.cam-review-bar .btn:not(.danger) { color: #fff; background: none; border-color: rgba(255, 255, 255, .6); }
.cam-shutter { width: 74px; height: 74px; border-radius: 37px; border: 5px solid #fff; background: rgba(255, 255, 255, .25); flex: none; transition: transform .1s; }
.cam-shutter:active, .cam-shutter.flash { transform: scale(.9); background: #fff; }
.cam-shutter.busy { opacity: .45; }

/* settings pages that save by themselves: the line under the title */
.save-line { margin: 0 0 6px; font-size: .8125rem; color: var(--muted); min-height: 1.2em; }
.save-line.bad { color: var(--danger); }

/* the / list without internet */
.slash .no-signal { display: flex; align-items: center; gap: 8px; margin: 4px 6px 6px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--muted); font-size: .8125rem; }
.slash .no-signal .ic { flex: none; width: 18px; height: 18px; }

/* {{ suggestions above a text box */
.var-hints { position: fixed; z-index: 70; max-height: 40vh; overflow-y: auto; padding: 6px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); }
.var-hints button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 10px; background: none; }
.var-hints button:active { background: var(--accent-soft); }
.var-hints b { font: 600 .875rem var(--ui); color: var(--accent); }
.var-hints small { display: block; color: var(--muted); font-size: .75rem; }

/* choosing a model: collections that open and close, and search */
.pick-group { border-bottom: 1px solid var(--line); }
.pick-group summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 12px 6px; cursor: pointer; }
.pick-group summary::-webkit-details-marker { display: none; }
.pick-group summary b { flex: 1; }
.pick-group summary small { color: var(--muted); font-size: .75rem; }
.pick-group .chev { width: 16px; height: 16px; transition: transform .15s; }
.pick-group[open] .chev { transform: rotate(90deg); }
.pick-group .pick-row { padding-left: 22px; }
.pick-row .pick-t { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.pick-row .pick-t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .pick-t small { color: var(--muted); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-done { flex: none; }.cam-app { color: #fff; border-color: rgba(255, 255, 255, .6); background: none; }

/* the chat: full screen over the document */
.chat-screen { position: fixed; inset: 0; z-index: 35; background: var(--bg); display: flex; flex-direction: column; padding-top: var(--top); }
.chat-screen .bar h1 { font: 600 1.0625rem var(--ui); }
.chat-model { display: inline-flex; align-items: center; gap: 4px; max-width: 46vw; height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line-strong); background: none; color: var(--muted); font-size: .8125rem; }
.chat-model span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 14px 16px; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 300px; font-size: .9375rem; }
.chat-empty b { display: block; font: 600 1.25rem var(--serif); color: var(--text); margin-bottom: 6px; }
.chat-msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; }
.chat-msg.user { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 6px; }
.chat-msg.assistant { align-self: flex-start; background: var(--raised); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.chat-meta { font-size: .6875rem; color: var(--faint); margin-bottom: 4px; }
.chat-body { font: 1rem/1.55 var(--serif); word-wrap: break-word; user-select: text; -webkit-user-select: text; }
.chat-body p { margin: 0 0 .6em; }
.chat-body p:last-child { margin-bottom: 0; }
.chat-body h1, .chat-body h2, .chat-body h3 { font-size: 1.1em; margin: .6em 0 .3em; }
.chat-body ul, .chat-body ol { padding-left: 1.3em; margin: 0 0 .6em; }
.chat-body img { display: none; }
.chat-picture { display: block; max-width: 100%; border-radius: 12px; margin: 4px 0 8px; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-foot { border-top: 1px solid var(--line); padding: 6px 10px calc(8px + var(--bottom)); background: var(--bg); position: relative; }
.chat-status { margin: 2px 6px 6px; font-size: .75rem; color: var(--muted); min-height: 1em; }
.chat-status.note { color: var(--danger); }
.chat-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input { flex: 1; min-height: 46px; max-height: 160px; padding: 11px 14px; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--raised); resize: none; outline: none; line-height: 1.4; }
.chat-input:focus { border-color: var(--accent); }
.chat-send { width: 46px; height: 46px; border-radius: 23px; border: 0; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.chat-send.stop { background: var(--danger); }
.chat-cmds { position: absolute; left: 8px; right: 8px; bottom: 100%; margin-bottom: 6px; max-height: 44vh; overflow-y: auto; padding: 6px; border-radius: 16px; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); }
.chat-cmds button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 10px; background: none; }
.chat-cmds button:active { background: var(--accent-soft); }
.chat-cmds b { font-size: .9375rem; }
.chat-cmds small { display: block; color: var(--muted); font-size: .75rem; }
.chat-insert-pop { position: fixed; z-index: 50; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: .875rem; box-shadow: var(--shadow); }
.chat-insert-pop .ic { width: 18px; height: 18px; }
