/* OCTO WEB KIT — shared base. Tokens, chips, sheet, toast, buttons.
   Distilled from octo-lab-log / octo_note / octo_science_landing (2026-10-17).
   Dark mode: <html data-mode="dark"> (kit.js sets it). Fonts are NOT loaded here:
   declare Host Grotesk / JetBrains Mono (or ~/web_fonts) in the app stylesheet. */
:root {
  --bg: #f4f1ec; --card: #fffdf9; --ink: #1f1a17; --dim: #5d544e;
  --line: rgba(31,26,23,.12); --line2: rgba(31,26,23,.24);
  --sunk: #efe9e1; --hover: rgba(31,26,23,.06); --scrim: rgba(31,26,23,.35);
  --accent: #2560c0; --accent-bg: #dde8fb; --on-c: #fff;
  --r: 14px; --ease: cubic-bezier(.2,.7,.2,1); --sh: 31,26,23;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --pad: 16px; --gap: 12px; --maxw: 1100px;   /* one gutter: header, chips, content share it */
  color-scheme: light;
}
@media (max-width: 560px) { :root { --pad: 14px; } }
[data-mode="dark"] {
  --bg: #141110; --card: #1d1916; --ink: #efe7dc; --dim: #a89c90;
  --line: rgba(239,231,220,.11); --line2: rgba(239,231,220,.24);
  --sunk: #2a2521; --hover: rgba(239,231,220,.07); --scrim: rgba(0,0,0,.55);
  --accent: #8db6ff; --accent-bg: #1b2944; --on-c: #14110f; --sh: 0,0,0;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 'Host Grotesk', system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; letter-spacing: .01em; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }

/* buttons: 40px+ hit area, labels >= 13px */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 0 16px; border-radius: 4px; border: 1px solid var(--line2); background: var(--card); font-size: 14px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.icon { width: 40px; padding: 0; }

/* chips: toggle (re-tap untoggles), tone via --c/--cb */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 4px; }
.chips.wrapped { flex-wrap: wrap; overflow: visible; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border-radius: 3px; border: 1px solid var(--line2); background: var(--card); white-space: nowrap;
  font-size: 14px; transition: background .12s, border-color .12s; }
.chip .n { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--dim); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--dim)); }
.chip.on { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: var(--on-c, var(--card)); }
.chip.on .n { color: inherit; opacity: .72; }
.chip.on .dot { background: var(--on-c); }
.chip:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select.chip-select { height: 40px; padding: 0 12px; border-radius: 3px; border: 1px solid var(--line2);
  background: var(--card); font-size: 14px; max-width: 100%; }

/* sheet: bottom sheet on phone, centred modal >= 900px. Toggle with [hidden]. */
.sheet-bg { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(640px, 100%); max-height: 92dvh; overflow-y: auto; background: var(--bg);
  border-radius: 4px 20px 0 0; padding: 14px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(var(--sh),.18); animation: kit-up .22s var(--ease); }
.sheet.tall { max-height: 96dvh; }
.sheet[hidden], .sheet-bg[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--dim); }
@media (min-width: 900px) { .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%);
  border-radius: 4px; animation: none; } }
@keyframes kit-up { from { transform: translate(-50%, 30px); opacity: 0 } }

/* toast: one pill in the lower third. Kit.js creates #toast if missing. */
#toast { position: fixed; left: 50%; bottom: calc(112px + var(--safe-b)); transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 3px; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }
@media (prefers-reduced-motion: reduce) { .sheet, #toast, .chip { animation: none; transition: none; } }
