/* Vibration Apps — the shared look (2 Oct 2026, chosen with Tore over
   several rounds of mockups): paper by day, charcoal by night, and his
   lecture-pen colours for the lines, so a quantity drawn in blue in the
   notes is blue on the phone too.

   Line roles are fixed across every app: blue the main trace, orange the
   second one (peak hold, a second series), green a third, hot pink for
   what is highlighted or dragged (markers, handles, the live point), gold
   for flags only (never a data line: to the 1 in 12 men with red-green
   colour blindness it is the same colour as the orange). The orange,
   green and dark-mode pink are his pens tuned so that blue, orange and
   green stay apart under deuteranopia and protanopia, and every line has
   at least 3:1 contrast with its ground (measured: docs/specs/2026-10-02-look.md).

   Every colour the apps use is a token here; app CSS and canvas code read
   tokens, never literals, so both themes stay complete. */

@import url('fonts.css');

:root {
  /* the pens */
  --ink-blue: #8ec0f6; --ink-orange: #f08a4b; --ink-green: #1f9e78; --ink-pink: #f5528a; --ink-gold: #e5b445;

  --bg-page: #211f1e;         /* charcoal, like Tore's tablet at night */
  --bg-panel: #211f1e;
  --bg-raised: #2b2927;       /* cards, controls */
  --bg-inset: #242220;        /* plots */
  --line: rgba(238, 234, 230, 0.1);
  --line-strong: rgba(238, 234, 230, 0.2);
  --text: #eeeae6;
  --text-dim: #a29d98;
  --text-faint: #77726d;
  --accent: var(--ink-blue);  /* the main trace and primary actions */
  --accent-dim: rgba(142, 192, 246, 0.12);
  --accent-border: rgba(142, 192, 246, 0.4);
  --on-accent: #13233d;       /* text on a filled accent button */
  --amber: var(--ink-orange); /* (the old name: secondary traces, peak hold, warnings) */
  --gold: var(--ink-gold);
  /* Flat gold reads as mustard on paper (Tore, 5 Oct): a metal shows itself
     by its sheen, dark to bright to dark, and OneNote's textured ink adds a
     fine sparkle. --gold-ink fills a draft pill; --gold-on is the text on it;
     --gold-sheen edges a gold outline; --gold-text is gold lettering. Flags
     only, never data. */
  --gold-sheen: linear-gradient(160deg, #7a5410 0%, #b8862a 22%, #f1d27c 46%, #fff0b8 52%, #d6a63c 64%, #8f6616 100%);
  --gold-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='1' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 0.97  0 0 0 0 0.82  0 0 0 14 -9.4'/%3E%3C/filter%3E%3Crect width='48' height='48' filter='url(%23n)'/%3E%3C/svg%3E"), var(--gold-sheen);
  --gold-on: #3d2a05;
  --gold-text: linear-gradient(100deg, #e9c262 0%, #ffe7a0 45%, #d9a83c 100%);
  --gold-deep: #e5b445;
  --danger: #ff6b6b;
  --font-ui: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  --radius: 10px;
  --radius-sm: 6px;

  /* surfaces that float over the plot (phone pills, sheet, scrim) */
  --pill: rgba(43, 41, 39, 0.9);
  --sheet: #2b2927;
  --sheet-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  --scrim: rgba(10, 9, 8, 0.5);
  --btn-hover: #34312f;
  --thumb-glow: transparent;
  --seg-shadow: rgba(0, 0, 0, 0.4);
  --toast-border: rgba(255, 107, 107, 0.5);
  --overlay-shadow: rgba(0, 0, 0, 0.45);

  /* plot colours, read by the canvas renderers via plotTheme() */
  --plot-grid: rgba(238, 234, 230, 0.05);
  --plot-grid-strong: rgba(238, 234, 230, 0.1);
  --plot-frame: rgba(238, 234, 230, 0.24);
  --plot-label: #a29d98;
  --plot-title: #77726d;
  --plot-text: #eeeae6;
  --plot-crosshair: rgba(238, 234, 230, 0.25);
  --trace-main: var(--ink-blue);
  --trace-ghost: rgba(142, 192, 246, 0.28);
  --trace-peak: var(--ink-orange);
  --trace-third: var(--ink-green);
  --trace-hot: var(--ink-pink);
  /* More lines than three (Transfer function's kept measurements; Tore,
     5 Oct: "not dashed: whatever matplotlib does after my own palette"):
     matplotlib's tab10 order after blue, orange and green, without its pink
     (hot pink is for highlights) or its grey (the grid's), lifted a little for
     the charcoal ground. Colour then never needs a dash to tell lines apart. */
  --trace-4: #e8615f;
  --trace-5: #b39ddb;
  --trace-6: #c49a8a;
  --trace-7: #d4d64a;
  --trace-8: #4fd3e0;
  --plot-tag-bg: rgba(36, 34, 32, 0.9);
  --plot-tag-border: rgba(238, 234, 230, 0.22);
  --plot-persist-color: rgba(142, 192, 246, 0.06);
  --plot-persist-comp: lighter;
  --plot-rubber: rgba(142, 192, 246, 0.08);
  --plot-rubber-line: rgba(142, 192, 246, 0.45);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --ink-blue: #234e8a; --ink-orange: #e8702a; --ink-green: #0b6e57; --ink-pink: #ea3168; --ink-gold: #b8860b;
  --gold-text: linear-gradient(100deg, #6e4c0c 0%, #9c7216 35%, #c8962a 55%, #8a6212 100%);
  --trace-4: #d62728; --trace-5: #9467bd; --trace-6: #8c564b; --trace-7: #bcbd22; --trace-8: #17becf;
  --gold-deep: #8a6212;

  --bg-page: #fbfcfe;         /* paper */
  --bg-panel: #fbfcfe;
  --bg-raised: #ffffff;
  --bg-inset: #ffffff;
  --line: rgba(21, 35, 58, 0.12);
  --line-strong: rgba(21, 35, 58, 0.22);
  --text: #15233a;            /* ink navy */
  --text-dim: #56657c;
  --text-faint: #8a96a8;
  --accent-dim: rgba(35, 78, 138, 0.08);
  --accent-border: rgba(35, 78, 138, 0.35);
  --on-accent: #ffffff;
  --danger: #d1373f;

  --pill: rgba(255, 255, 255, 0.9);
  --sheet: #ffffff;
  --sheet-shadow: 0 -12px 40px rgba(21, 35, 58, 0.14);
  --scrim: rgba(21, 35, 58, 0.28);
  --btn-hover: #f1f4f8;
  --seg-shadow: rgba(21, 35, 58, 0.12);
  --toast-border: rgba(209, 55, 63, 0.45);
  --overlay-shadow: rgba(21, 35, 58, 0.18);

  --plot-grid: rgba(21, 35, 58, 0.06);
  --plot-grid-strong: rgba(21, 35, 58, 0.12);
  --plot-frame: rgba(21, 35, 58, 0.3);
  --plot-label: #56657c;
  --plot-title: #8a96a8;
  --plot-text: #15233a;
  --plot-crosshair: rgba(21, 35, 58, 0.35);
  --trace-ghost: rgba(35, 78, 138, 0.28);
  --plot-tag-bg: rgba(255, 255, 255, 0.92);
  --plot-tag-border: rgba(21, 35, 58, 0.22);
  --plot-persist-color: rgba(35, 78, 138, 0.05);
  --plot-persist-comp: source-over;
  --plot-rubber: rgba(35, 78, 138, 0.08);
  --plot-rubber-line: rgba(35, 78, 138, 0.45);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ---------- Panel primitives ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.group {
  padding: 0.65rem 0.9rem 0.8rem;
}

.group + .group { border-top: 1px solid var(--line); }

.group-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-faint);
  margin: 0 0 0.45rem;
  user-select: none;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2rem;
}

.row + .row { margin-top: 0.35rem; }

.row > label {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------- Controls ---------- */

select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-raised)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%238391ab'/%3E%3C/svg%3E")
    no-repeat right 0.55rem center;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.32rem 1.5rem 0.32rem 0.55rem;
  max-width: 11rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

select:hover, select:focus-visible { border-color: var(--line-strong); outline: none; }

.btn {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.btn:hover { border-color: var(--line-strong); background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-border); outline-offset: 1px; }

.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}
.btn.primary:hover { filter: brightness(1.15); }

.btn.solid {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn.solid:hover { filter: brightness(1.08); background: var(--accent); }

.btn.small { font-size: 0.72rem; padding: 0.22rem 0.55rem; }

/* borderless icon/text button: header actions, sheet title row */
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn.ghost:hover { background: var(--accent-dim); color: var(--accent); border-color: transparent; }

.btn.icon {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
}

/* Segmented control: a radio group in a pill */
.seg {
  display: inline-flex;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.seg input { position: absolute; opacity: 0; pointer-events: none; }

.seg label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 0.22rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  user-select: none;
}

.seg input:checked + label {
  background: var(--bg-raised);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--line-strong), 0 1px 4px var(--seg-shadow);
}

.seg input:focus-visible + label { outline: 2px solid var(--accent-border); outline-offset: 1px; }

/* Flat variant: no box, the active item is accent text with an underline */
.seg.flat { background: transparent; border-color: transparent; padding: 0; gap: 0; }
.seg.flat label { padding: 0.35rem 0.7rem; border-radius: 0; position: relative; }
.seg.flat input:checked + label { background: transparent; box-shadow: none; }
.seg.flat input:checked + label::after {
  content: '';
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 0;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

/* Toggle switch */
.switch {
  position: relative;
  width: 34px;
  height: 19px;
  flex: none;
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--bg-inset);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  transition: background 0.18s, border-color 0.18s;
  pointer-events: none;
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.18s, background 0.18s;
}

.switch input:checked ~ .track {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.switch input:checked ~ .track::after {
  transform: translateX(15px);
  background: var(--accent);
}

/* Range slider */
input[type='range'] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line-strong);
  border-radius: 2px;
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5px;
}

input[type='range']::-moz-range-track {
  height: 3px;
  background: var(--line-strong);
  border-radius: 2px;
}

input[type='range']::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

input[type='number'], input[type='text'] {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.3rem 0.45rem;
  width: 5.2rem;
}

input[type='number']:focus, input[type='text']:focus { border-color: var(--accent); outline: none; }

/* ---------- Readouts & lamps ---------- */

.readout {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.readout b {
  color: var(--text);
  font-weight: 500;
}

.readout .unit { color: var(--text-faint); }

.lamp {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  user-select: none;
}

.lamp::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.1s, box-shadow 0.1s;
}

.lamp.on { color: var(--danger); }
.lamp.on::before {
  background: var(--danger);
}

.lamp.ok.on { color: var(--accent); }
.lamp.ok.on::before {
  background: var(--accent);
}

/* ---------- Tooltips ---------- */
/* Add data-tip="..." to a control label. On hover devices a shared,
   fixed-position #tip element (positioned by JS, see livefft ui.js) shows
   the text, so the tip is never clipped by a scrolling panel. */

[data-tip] { cursor: help; }

.tip {
  position: fixed;
  z-index: 70;
  width: 14rem;
  max-width: 70vw;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px var(--overlay-shadow);
  pointer-events: none;
}

/* ---------- Touch sizes (phones and small tablets) ---------- */
/* 16 px on form controls stops iOS zooming on focus; 44 px targets. */

@media (max-width: 860px) {
  select, input[type='number'], input[type='text'] { font-size: 16px; }
  select { padding: 0.5rem 1.7rem 0.5rem 0.7rem; max-width: 13rem; }
  input[type='number'], input[type='text'] { padding: 0.45rem 0.55rem; width: 5.6rem; }
  .row { min-height: 44px; }
  .row + .row { margin-top: 0.15rem; }
  .row > label { font-size: 0.95rem; }
  .seg label { padding: 0.5rem 0.8rem; font-size: 0.9rem; }
  .btn { font-size: 0.9rem; padding: 0.55rem 1rem; }
  .btn.small { font-size: 0.8rem; padding: 0.4rem 0.7rem; }
  .btn.icon { width: 2.6rem; height: 2.6rem; font-size: 1.1rem; }
  .switch { width: 44px; height: 24px; }
  .switch .track::after { width: 18px; height: 18px; }
  .switch input:checked ~ .track::after { transform: translateX(20px); }
  input[type='range'] { height: 28px; }
  input[type='range']::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -7.5px; }
  input[type='range']::-moz-range-thumb { width: 18px; height: 18px; }
}

/* A finger, not a mouse: thumbs big enough to land on first time (IA's are
   28 px), and site.js moves a slider straight to where it is touched. */
/* no double-tap zoom on any page (Tore, 5 Oct: Membranes zoomed on a double
   tap and was hard to get back); pinching still zooms */
html, body { touch-action: manipulation; }

@media (pointer: coarse) {
  input[type='range'] { height: 36px; touch-action: none; }
  input[type='range']::-webkit-slider-runnable-track { height: 4px; }
  input[type='range']::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -11px; border: 3px solid var(--bg-raised); }
  input[type='range']::-moz-range-thumb { width: 26px; height: 26px; border: 3px solid var(--bg-raised); }
}

/* Subtle scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
