/* TimeStamper styles. Layout: one phone-width column, scrolling screen above a
   fixed three-tab bar. Palettes are token sets (docs/spec.md#palettes).
   "Match phone" = Graphite E-Ink when the phone is light, Amber Instrument when dark. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("fonts/atkinson-hyperlegible-mono.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
}

/* Graphite E-Ink: glare-resistant, monochrome. Only danger has a hue. */
:root, :root[data-palette="graphite"] {
  --bg: #e8e8e4; --surface: #dadad5; --ink: #111111; --ink-soft: #3a3a38;
  --line: rgba(17, 17, 17, .35); --field: #f4f4f0; --field-line: #111111;
  --primary-bg: #111111; --primary-fg: #ffffff; --hl-bg: #ffffff; --hl-fg: #111111;
  --band-bg: #111111; --band-fg: #ffffff; --danger: #b00000; --danger-style: solid; --scrim: rgba(17, 17, 17, .55);
  color-scheme: light;
  --font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --nav-h: 70px;
}
/* Amber Instrument: dim cab at night, unaided eyes. */
@media (prefers-color-scheme: dark) {
  :root:not([data-palette]) {
    --bg: #120e08; --surface: #1f180c; --ink: #ffb000; --ink-soft: #d99a10;
    --line: rgba(255, 176, 0, .3); --field: #1a140a; --field-line: #d99a10;
    --primary-bg: #ffb000; --primary-fg: #120e08; --hl-bg: #ffb000; --hl-fg: #120e08;
    --band-bg: #0a0703; --band-fg: #ffb000; --danger: #ff7a5c; --danger-style: solid; --scrim: rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-palette="amber"] {
  --bg: #120e08; --surface: #1f180c; --ink: #ffb000; --ink-soft: #d99a10;
  --line: rgba(255, 176, 0, .3); --field: #1a140a; --field-line: #d99a10;
  --primary-bg: #ffb000; --primary-fg: #120e08; --hl-bg: #ffb000; --hl-fg: #120e08;
  --band-bg: #0a0703; --band-fg: #ffb000; --danger: #ff7a5c; --danger-style: solid; --scrim: rgba(0, 0, 0, .7);
  color-scheme: dark;
}
/* Sunlight: maximum contrast for ramps, helipads, bright cabs. Yellow only on black. */
:root[data-palette="sunlight"] {
  --bg: #ffffff; --surface: #f0f0f0; --ink: #000000; --ink-soft: #262626;
  --line: rgba(0, 0, 0, .4); --field: #ffffff; --field-line: #000000;
  --primary-bg: #000000; --primary-fg: #fffd30; --hl-bg: #000000; --hl-fg: #fffd30;
  --band-bg: #000000; --band-fg: #ffffff; --danger: #a30000; --danger-style: solid; --scrim: rgba(0, 0, 0, .6);
  color-scheme: light;
}
/* Night: deep red on black for unaided eyes. Never under NVGs. */
:root[data-palette="night"] {
  --bg: #000000; --surface: #140000; --ink: #e0392b; --ink-soft: #b02a1f;
  --line: rgba(224, 57, 43, .35); --field: #070000; --field-line: #b02a1f;
  --primary-bg: #3d0000; --primary-fg: #ff5040; --hl-bg: #520000; --hl-fg: #ff6a5c;
  --band-bg: #000000; --band-fg: #e0392b; --danger: #ff5040; --danger-style: dashed; --scrim: rgba(0, 0, 0, .8);
  color-scheme: dark;
}
/* NVG: dim green on true black, for use under goggles at minimum brightness. */
:root[data-palette="nvg"] {
  --bg: #000000; --surface: #000a02; --ink: #3b9a48; --ink-soft: #276b31;
  --line: rgba(59, 154, 72, .32); --field: #000000; --field-line: #276b31;
  --primary-bg: #062b0c; --primary-fg: #5cc96b; --hl-bg: #0b3a12; --hl-fg: #6fd87d;
  --band-bg: #000000; --band-fg: #3b9a48; --danger: #5cc96b; --danger-style: dashed; --scrim: rgba(0, 0, 0, .85);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.4; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
::placeholder { color: var(--ink-soft); opacity: 1; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 460px; margin: 0 auto; height: 100%; display: flex; flex-direction: column; position: relative; }
.screen { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

.label { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.field { width: 100%; background: var(--field); border: 2px solid var(--field-line); border-radius: 10px; padding: 14px; font-size: 19px; min-height: 58px; }
textarea.field { resize: none; min-height: 76px; display: block; }
/* iOS gives date/time inputs a native width that ignores width: 100% and overflows the row. */
input[type="date"].field, input[type="time"].field { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left; }
input[type="date"].field::-webkit-date-and-time-value, input[type="time"].field::-webkit-date-and-time-value { text-align: left; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 48px; font-weight: 600; }
.select-wrap::after { content: ""; position: absolute; right: 20px; top: 50%; width: 11px; height: 11px; border-right: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.btn { border: 2px solid var(--ink); background: transparent; border-radius: 10px; min-height: 48px; padding: 10px 16px; font-weight: 700; font-size: 16px; }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: 15px; }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-fg); }
.btn.danger { border-color: var(--danger); border-style: var(--danger-style); color: var(--danger); }
.btn.link { border: 0; padding-inline: 4px; text-decoration: underline; text-underline-offset: 3px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border: 1.5px solid currentColor; border-radius: 6px; padding: 1px 6px; vertical-align: 2px; color: var(--ink-soft); }
.err { color: var(--danger); font-weight: 700; min-height: 1.4em; margin: 0; }
.install { display: flex; gap: 12px; align-items: center; border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.install p { margin: 0; flex: 1; min-width: 0; }
.notice { border: 2px dashed var(--ink-soft); border-radius: 10px; padding: 10px 12px; font-size: 15px; color: var(--ink-soft); margin: 0; }

/* Log: case line + "Save is the clock" */
.log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-block: 12px 14px; }
.caseline { display: flex; align-items: center; gap: 10px; justify-content: space-between; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.caseline p { margin: 0; font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.caseline .btn { flex: none; border-width: 2.5px; }
.inputs { display: grid; gap: 10px; }
.save { flex: 1; min-height: 240px; width: 100%; border: 3px solid var(--primary-fg); border-radius: 18px; background: var(--primary-bg); color: var(--primary-fg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 8px; touch-action: manipulation; }
.save:active { transform: scale(.985); }
.save .t { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: clamp(64px, 22vw, 92px); line-height: 1; font-weight: 700; }
.save .z { font-size: 22px; font-weight: 700; }
.save .sub { font-size: 14px; font-weight: 600; opacity: .85; text-align: center; padding-inline: 12px; }
.save .cta { font-size: 22px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; border-top: 3px solid currentColor; padding-top: 10px; margin-top: 6px; }

/* Review */
.rv { display: grid; gap: 16px; padding-block: 14px 24px; }
.rv-head h1 { font-size: 26px; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.rv-head .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 15px; }
.tzchip { border: 2px solid var(--ink); border-radius: 999px; padding: 6px 12px; min-height: 40px; background: none; font-weight: 700; font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.day { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.segtabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface); border-radius: 12px; padding: 4px; border: 1px solid var(--line); }
.segtabs button { border: 0; background: none; color: var(--ink); min-height: 44px; border-radius: 9px; font-weight: 700; font-size: 16px; }
.segtabs button[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); }
.cases { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cases button { width: 100%; text-align: left; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 2px; }
.cases .nm { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.cases .sm { color: var(--ink-soft); font-size: 14px; }
.empty { margin: 0; color: var(--ink-soft); }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 87px; top: 8px; bottom: 8px; width: 3px; background: var(--line); }
.tl li button { width: 100%; background: none; border: 0; text-align: left; display: grid; grid-template-columns: 72px 30px 1fr; align-items: start; padding: 10px 0; color: var(--ink); }
.tl .t { font-size: 22px; font-weight: 700; text-align: right; }
.tl .dot { width: 15px; height: 15px; border-radius: 50%; background: var(--bg); border: 3px solid var(--ink); justify-self: center; margin-top: 6px; position: relative; }
.tl li:last-child .dot { background: var(--ink); }
.tl .op { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.tl .note { display: block; color: var(--ink-soft); font-size: 15px; overflow-wrap: anywhere; white-space: pre-wrap; }
.tl li.dayrow { padding: 10px 0 2px 104px; }

/* Settings */
.st { display: grid; gap: 22px; padding-block: 14px 28px; }
.st h1 { font-size: 26px; margin: 0; }
.st .version { font-size: 15px; color: var(--ink-soft); margin-top: -14px; }
.st section { display: grid; gap: 10px; }
.st h2 { margin: 0; }
.st p { margin: 0; }
.pal { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pal button { width: 100%; text-align: left; background: none; color: var(--ink); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; }
.pal button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.pal .nm { font-weight: 700; }
.pal .ds { display: block; font-size: 14px; color: var(--ink-soft); }
.sw { width: 52px; height: 52px; border-radius: 10px; display: grid; place-items: center; font: 700 15px/1 var(--font-mono); border: 1px solid var(--line); overflow: hidden; }
.sw.split { grid-template-columns: 1fr 1fr; place-items: stretch; }
.sw.split span { display: grid; place-items: center; font-size: 11px; }
.ops { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ops li { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; }
.ops .field { min-height: 48px; font-size: 17px; padding: 8px 10px; }
.ops .btn { min-width: 44px; padding-inline: 8px; }
.addrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
[data-act="op-reset"] { margin-top: 12px; }
.warn { border: 2px solid var(--ink); border-radius: 10px; padding: 12px 14px; font-size: 16px; }
.warn strong { display: block; margin-bottom: 4px; }
.fine { font-size: 14px; color: var(--ink-soft); }

/* Nav: the whole tab fills when active */
nav.tabs { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-top: 6px; padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); background: var(--band-bg); border-top: 1px solid var(--line); }
nav.tabs button { background: none; border: 2px solid transparent; color: var(--band-fg); border-radius: 12px; min-height: 58px; margin-bottom: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 13px; font-weight: 700; opacity: .8; }
nav.tabs button[aria-current="page"] { background: var(--hl-bg); color: var(--hl-fg); border-color: var(--hl-fg); opacity: 1; }
nav.tabs svg { width: 26px; height: 26px; }

/* Sheets and toast */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet { width: 100%; max-width: 460px; background: var(--bg); color: var(--ink); border: 2px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding-block: 20px calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; max-height: 92%; overflow-y: auto; }
.sheet h2 { margin: 0; font-size: 22px; text-wrap: balance; }
.sheet h2:focus { outline: none; }
.sheet .row { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet .row > * { flex: 1; min-width: 120px; }
.sheet p { margin: 0; overflow-wrap: anywhere; }
.sheet .stack { display: grid; gap: 10px; }
.sheet pre { margin: 0; white-space: pre-wrap; font: 15px/1.5 var(--font-mono); background: var(--field); border: 2px solid var(--field-line); border-radius: 10px; padding: 12px; user-select: text; -webkit-user-select: text; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); background: var(--primary-bg); color: var(--primary-fg); border: 2px solid var(--primary-fg); font-weight: 700; padding: 12px 18px; border-radius: 999px; z-index: 40; font-size: 17px; white-space: nowrap; max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
