/* Genesen OS web shell — shared styles.
   Layout follows docs/web-layout-spec.md:
   - wide  (≥ 1100 px): left nav 220 px full height | content
   - mid   (900–1099 px): nav collapses to 72 px icons + labels, columns become two
   - phone (< 900 px): status strip on top, cards stacked, bottom tab bar
   Dark by default, light via prefers-color-scheme or data-theme. */

@font-face {
  font-family: 'Lexend';
  src: url('/static/fonts/Lexend-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/static/fonts/AtkinsonHyperlegible-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --font: 'Lexend', 'Atkinson Hyperlegible', Verdana, sans-serif;
  --size: 18px;
  --lh: 1.5;
  --measure: 42rem;      /* ~75 characters at 18 px */

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --radius: 4px;
  --radius-sm: 3px;
  /* figures, times, counts and file paths: never reading text (rule 4) */
  --num: 'Cascadia Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  --label-size: 16px;
  --label-track: 0.01em;
  --tap: 44px;

  --nav-w: 220px;
  --nav-w-mid: 72px;
  --tabbar-h: 64px;
  --strip-h: 44px;

  --bg: #0a0b0d;
  --surface: #101216;
  --surface-2: #181b21;
  --line: #2c313b;
  --line-soft: #1d2128;
  --text: #ebe8e1;
  --muted: #9097a3;
  --accent: #ffa028;
  --accent-text: #0a0b0d;
  --accent-soft: rgba(255, 160, 40, 0.12);
  --danger: #ff5f56;
  --danger-soft: rgba(255, 95, 86, 0.13);
  --ok: #3ecf8e;
  --warn: #f2d45c;
  --ward: #ffa028;
  --pepijn: #4cc2ff;
  --focus: #4cc2ff;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  /* native parts (date picker, select popup, spinners, scrollbars) follow the theme */
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5f1;
    --surface: #ffffff;
    --surface-2: #efede7;
    --line: #cdc8bd;
    --line-soft: #e5e1d8;
    --text: #14161a;
    --muted: #575d68;
    --accent: #a85400;
    --accent-text: #ffffff;
    --accent-soft: rgba(168, 84, 0, 0.10);
    --danger: #b8322a;
    --danger-soft: rgba(184, 50, 42, 0.09);
    --ok: #1c7a4f;
    --warn: #856100;
    --ward: #a85400;
    --pepijn: #0b6fa8;
    --focus: #0b6fa8;
    --shadow: 0 10px 28px rgba(20, 20, 20, 0.16);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --line: #cdc8bd;
  --line-soft: #e5e1d8;
  --text: #14161a;
  --muted: #575d68;
  --accent: #a85400;
  --accent-text: #ffffff;
  --accent-soft: rgba(168, 84, 0, 0.10);
  --danger: #b8322a;
  --danger-soft: rgba(184, 50, 42, 0.09);
  --ok: #1c7a4f;
  --warn: #856100;
  --ward: #a85400;
  --pepijn: #0b6fa8;
  --focus: #0b6fa8;
  --shadow: 0 10px 28px rgba(20, 20, 20, 0.16);
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--size);
  line-height: var(--lh);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0 0 var(--s3); line-height: 1.3; font-weight: 400; }
h1 { font-size: 1.5em; }
h2 { font-size: 20px; font-weight: 600; }
::selection { background: var(--accent); color: var(--accent-text); }
h3 { font-size: 1em; color: var(--muted); }
p { margin: 0 0 var(--s3); max-width: var(--measure); }
a { color: var(--accent); }
ul { margin: 0; padding-left: 1.2em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.9em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
[hidden] { display: none !important; }

/* ---------- app shell: phone first ---------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "main";
}

/* phone status strip: time · ● vault ok · user / sign out */
.topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: var(--strip-h);
  padding: var(--s1) var(--s4);
  padding-top: calc(var(--s1) + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 0.85em;
  color: var(--muted);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
/* a full strip wraps on the left (time · vault · sync), never splits "Sign out" */
.topbar-left { flex-wrap: wrap; row-gap: 0; }
.topbar-right { flex: none; white-space: nowrap; }
@media (max-width: 400px) {
  .topbar, .topbar-left, .topbar-right { column-gap: 6px; }
}
.topbar-brand { color: var(--accent); text-transform: uppercase; letter-spacing: var(--label-track); }
.topbar-time { color: var(--text); font-family: var(--num); }
.topbar-status { color: var(--warn); }
.topbar-status:empty { display: none; }
.topbar a { color: var(--muted); text-decoration: none; min-height: 36px; display: inline-flex; align-items: center; }
.topbar a:hover { color: var(--text); }
.topbar .topbar-user { color: var(--text); }

/* vault dot */
.vault-dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.vault-dot::before { content: ""; width: 8px; height: 8px; border-radius: 1px; background: var(--muted); flex: none; }
.vault-dot.ok::before { background: var(--ok); }
.vault-dot.bad::before { background: var(--danger); }
.vault-dot.bad { color: var(--danger); }

/* Syncthing dot (admin): a button, tap shows the detail line, hover shows it as a title */
.sync-dot {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  min-height: 36px; padding: 0; margin: 0;
  background: none; border: 0; border-radius: 4px;
  color: inherit; font: inherit; line-height: inherit; text-align: left; cursor: pointer;
}
.sync-dot::before { content: ""; width: 8px; height: 8px; border-radius: 1px; background: var(--muted); flex: none; }
.sync-dot.ok::before { background: var(--ok); }
.sync-dot.warn::before { background: var(--warn); }
.sync-dot.warn { color: var(--warn); }
.sync-dot.bad::before { background: var(--danger); }
.sync-dot.bad { color: var(--danger); }
.sync-dot:hover { color: var(--text); }
.sync-dot.warn:hover { color: var(--warn); }
.sync-dot.bad:hover { color: var(--danger); }

.main {
  grid-area: main;
  width: 100%;
  min-width: 0;
  padding: var(--s4) var(--s4) calc(var(--tabbar-h) + var(--s6) + env(safe-area-inset-bottom));
}
.no-nav .main { padding-bottom: var(--s6); }

/* page header: title left, user + sign out right (wide only) */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
  margin-bottom: var(--s4);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}
.page-head h1 { margin: 0; font-size: 1.5em; line-height: 1.2; font-weight: 500; letter-spacing: -0.01em; }
.page-head .page-sub { color: var(--muted); margin: var(--s1) 0 0; }
.page-title { min-width: 0; }
.page-user { display: none; align-items: center; gap: var(--s3); margin-left: auto; white-space: nowrap; color: var(--muted); }
.page-user a { color: var(--muted); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 var(--s2); }
.page-user a:hover { color: var(--text); }
.page-user a.page-user-name { color: var(--text); }
.page-user .sep { color: var(--line); }
.no-nav .page-user { display: none !important; }   /* athlete: the status strip already shows name · sign out */

/* login */
.login-main { max-width: 480px; margin: 0 auto; }

/* ---------- left nav (wide) ---------- */
.sidenav { display: none; }
.sidenav .nav-brand {
  display: block;
  padding: var(--s3) var(--s3) var(--s4);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.sidenav a.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  border-radius: 0;
  color: var(--muted);
  text-decoration: none;
}
.sidenav a.nav-item:hover { background: var(--surface-2); color: var(--text); }
.sidenav a.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.sidenav a.nav-item .ico { width: 1.4em; text-align: center; flex: none; }
.sidenav .nav-plus {
  margin-top: var(--s4);
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-text);
  text-decoration: none;
}
.sidenav .nav-foot {
  margin-top: auto;
  padding: var(--s3) var(--s3) 0;
  font-size: 0.8em;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-top: 1px solid var(--line-soft);
}
.sidenav .nav-foot .sync-dot { min-height: 32px; }

/* ---------- bottom tab bar (phone) ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tap);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72em;
}
.tabbar a .ico { font-size: 1.4em; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.tabbar a.tab-plus .ico {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
}
.no-nav .tabbar, .no-nav .sidenav { display: none; }

/* ---------- mid (900–1099): icon nav 72 px ---------- */
@media (min-width: 900px) {
  .app {
    grid-template-columns: var(--nav-w-mid) minmax(0, 1fr);
    grid-template-rows: 1fr;
    grid-template-areas: "nav main";
  }
  .app.no-nav {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "top" "main";
  }
  .topbar { display: none; }
  .no-nav .topbar { display: flex; }
  .sidenav {
    grid-area: nav;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    padding: var(--s4) var(--s2) var(--s4);
    border-right: 1px solid var(--line);
    background: var(--bg);
    overflow-x: hidden;
    overflow-y: auto;   /* short landscape screens: scroll to + Capture and the vault status */
    scrollbar-width: thin;
  }
  .sidenav .nav-brand { padding: var(--s2) 0 var(--s4); text-align: center; font-size: 0.8em; }
  .sidenav .nav-brand .brand-long { display: none; }
  .sidenav a.nav-item { flex-direction: column; gap: 2px; padding: var(--s2) var(--s1); font-size: 0.68em; border-radius: 0; }
  .sidenav a.nav-item .ico { font-size: 1.6em; width: auto; }
  .sidenav .nav-plus .lbl { display: none; }
  .sidenav .nav-foot { text-align: center; padding: var(--s3) 0 0; align-items: center; }
  .sidenav .nav-foot .vault-text, .sidenav .nav-foot .sync-text { display: none; }
  .sidenav .nav-foot .sync-dot { min-width: 32px; justify-content: center; }
  .tabbar { display: none; }
  .page-user { display: flex; }
  .main { padding: var(--s5) var(--s5) var(--s6); }
}

/* ---------- wide (≥ 1100): full nav 220 px ---------- */
@media (min-width: 1100px) {
  .app { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .sidenav { padding: var(--s4) 0 var(--s4); }
  .sidenav .nav-plus { margin-left: var(--s3); margin-right: var(--s3); }
  .sidenav .nav-brand { text-align: left; font-size: 0.8em; padding: var(--s3) var(--s3) var(--s4); }
  .sidenav .nav-brand .brand-long { display: inline; }
  .sidenav .nav-brand .brand-short { display: none; }
  .sidenav a.nav-item { flex-direction: row; gap: var(--s3); padding: var(--s2) var(--s3); font-size: 1em; border-radius: 0; }
  .sidenav a.nav-item .ico { font-size: 1em; width: 1.4em; }
  .sidenav .nav-plus .lbl { display: inline; }
  .sidenav .nav-foot { text-align: left; padding: var(--s3) var(--s3) 0; align-items: flex-start; }
  .sidenav .nav-foot .vault-text, .sidenav .nav-foot .sync-text { display: inline; }
  .sidenav .nav-foot .sync-dot { min-width: 0; justify-content: flex-start; }
  .main { padding: var(--s5) var(--s6) var(--s6); }
}

/* ---------- content columns ---------- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-items: start; }
.cols > .col { min-width: 0; display: flex; flex-direction: column; gap: var(--s4); }
.cols > .col > .card { margin-bottom: 0; }
.cols > .col.col-fill { align-self: stretch; }
.cols > .col.col-fill > .card:last-child { flex: 1; }
@media (min-width: 900px) {
  .cols-3, .cols-2, .cols-md { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-md { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
}
@media (min-width: 1100px) {
  .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-md { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
}

/* ---------- cards, rows ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s4) var(--s5);
  margin-bottom: var(--s4);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.card > h2:first-child { margin-top: 0; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s3);
}
.card-head h2 { margin: 0; }
/* panel titles: the accent, normal case (no capitals: rule 4), a hairline under the head */
.card-head h2, .card > h2:first-child {
  font-size: var(--label-size);
  font-weight: 600;
  letter-spacing: var(--label-track);
  color: var(--accent);
}
.card-head h2 a, .card > h2:first-child a { color: inherit; text-decoration: none; }
.card-head { padding-bottom: var(--s2); border-bottom: 1px solid var(--line-soft); }
.card-head .card-meta { color: var(--muted); font-size: 0.8em; font-family: var(--num); margin-left: auto; text-align: right; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.card-head .card-meta .btn { font-size: 1em; }
.card-sub { color: var(--muted); margin: -4px 0 var(--s3); max-width: var(--measure); }
.card-body { flex: 1; min-width: 0; }
.source {
  margin-top: auto;
  padding-top: var(--s3);
  font-size: 12px;
  font-family: var(--num);
  line-height: 1.5;
  color: var(--muted);
  opacity: 0.75;
  overflow-wrap: anywhere;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s2) 0;
  border-top: 1px solid var(--line-soft);
  min-width: 0;
}
.row:first-of-type { border-top: 0; }
.row-main { flex: 1; min-width: 0; max-width: var(--measure); }
.row-when { color: var(--muted); font-size: 0.9em; }
.row-title { margin: 2px 0; overflow-wrap: anywhere; }
.row-items { color: var(--muted); font-size: 0.95em; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); align-items: center; }
.row.done .row-title { text-decoration: line-through; color: var(--muted); }
.row.today { box-shadow: inset 2px 0 0 var(--accent); padding-left: var(--s3); }
.row-end { flex: none; margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s1); }
.row-tag { font-size: 0.8em; color: var(--muted); white-space: nowrap; }
.row-age { color: var(--muted); font-size: 0.85em; font-family: var(--num); white-space: nowrap; }
.bullet::before { content: "•"; color: var(--muted); margin-right: var(--s2); }

/* actions revealed on hover / focus; always visible on touch */
.hover-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s1); }
@media (hover: hover) {
  .row .hover-actions { opacity: 0; transition: opacity 0.12s; }
  .row:hover .hover-actions, .row:focus-within .hover-actions { opacity: 1; }
}

.badge {
  display: inline-block;
  font-size: 0.75em;
  padding: 1px 7px;
  border-radius: 2px;
  font-family: var(--num);
  border: 1px solid var(--line);
  color: var(--muted);
  vertical-align: middle;
}
.badge-ward { border-color: var(--ward); color: var(--ward); }
.badge-pepijn { border-color: var(--pepijn); color: var(--pepijn); }
.badge-today { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--s2) var(--s4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary:hover { color: var(--accent-text); filter: brightness(1.08); }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: transparent; }
.btn-sm { min-height: 36px; padding: var(--s1) var(--s3); font-size: 0.85em; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; min-width: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: inherit; }
.btn-link.muted { color: var(--muted); }

/* big checkbox */
.check {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: transparent;
  font-size: 1.4em;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.check:disabled { opacity: 0.5; cursor: default; }
.check:hover:not(:disabled):not(.on) { border-color: var(--accent); }
.check.check-sm { width: 32px; height: 32px; font-size: 1.1em; border-radius: var(--radius-sm); }

/* ---------- inputs ---------- */
.field { display: block; margin-bottom: var(--s4); max-width: var(--measure); }
.field > span { display: block; color: var(--muted); margin-bottom: var(--s1); font-size: 0.9em; }
.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
.textarea { resize: vertical; min-height: 120px; line-height: var(--lh); }
.select { appearance: none; -webkit-appearance: none; padding-right: 2.2em;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.select-inline { width: auto; display: inline-block; }
.form-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.form-row > .btn { flex: none; }
.form-row > .input, .form-row > .select { flex: 1 1 200px; width: auto; }
.form-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--s3); margin: var(--s2) 0; }

/* ---------- tabs (people tabs, week tabs) ---------- */
.tabs { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); align-items: center; }
.tabs button {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; line-height: 1.2;
  color: var(--muted);
}
.tabs button:hover { color: var(--text); border-color: var(--muted); }
.tabs button small { font-size: 0.65em; color: var(--accent); }
.tabs button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tabs .tabs-end { margin-left: auto; }

/* ---------- table ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
.table th, .table td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line-soft); vertical-align: top; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 14px; border-bottom-color: var(--line); }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.empty { color: var(--line); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: min(92vw, 520px);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: var(--ok); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.no-nav .toast { bottom: var(--s5); }
@media (min-width: 900px) { .toast { bottom: var(--s5); } }

/* ---------- sheet (bottom sheet on phone, dialog on wide) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  z-index: 30;
}
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  padding: var(--s3) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 0.2s ease-out;
  z-index: 31;
}
.sheet.open { transform: translateY(0); }
.sheet:not(.open) { pointer-events: none; visibility: hidden; }
.sheet-handle { width: 40px; height: 3px; border-radius: 0; background: var(--line); margin: 0 auto var(--s3); }
.sheet-title { margin-bottom: var(--s3); }
.sheet-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.sheet-menu { list-style: none; padding: 0; margin: 0; }
.sheet-menu button { width: 100%; text-align: left; justify-content: flex-start; margin-bottom: var(--s2); }
@media (min-width: 900px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(560px, 92vw);
    border-radius: var(--radius);
    transform: translate(-50%, -50%) scale(0.98);
    opacity: 0;
    transition: opacity 0.15s;
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-handle { display: none; }
}
/* full-screen capture sheet on phone (frame 3g) */
@media (max-width: 899px) {
  .sheet.sheet-full { top: 0; max-height: none; border-radius: 0; padding-top: calc(var(--s3) + env(safe-area-inset-top)); }
}

/* ---------- skeleton, empty, error ---------- */
.skeleton {
  height: 1.2em; border-radius: 2px; margin: var(--s2) 0;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
.skeleton.w-50 { width: 50%; }
.skeleton.w-75 { width: 75%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { color: var(--muted); padding: var(--s4) 0; }
.banner-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  max-width: var(--measure);
}
.banner-error:empty { display: none; }

/* ---------- capture ---------- */
.capture-text { min-height: 140px; font-size: var(--size); }
.capture-help { margin: var(--s2) 0 var(--s3); color: var(--muted); font-size: 0.9em; }
.capture-help summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }
.capture-help ul { list-style: none; padding: 0; }
.capture-help li { padding: 2px 0; }
.capture-help code { font-family: inherit; color: var(--text); }
.capture-queue { margin-top: var(--s4); }
.capture-queue .row { align-items: center; flex-wrap: wrap; }
.capture-queue .row-main { white-space: pre-wrap; overflow-wrap: anywhere; }

/* the capture bar on Today: one row when empty, grows with its text (capture-sheet.js fit()),
   at most ~10 lines, then it scrolls; the button stays at the bottom, by the last line */
.capture-bar { margin-bottom: var(--s4); position: relative; }
.capture-bar .capture-form { display: flex; gap: var(--s2); align-items: flex-end; }
.capture-bar .capture-input {
  flex: 1; min-width: 0; min-height: var(--tap);
  display: block; resize: none; overflow-y: hidden; line-height: var(--lh);
  max-height: min(calc(var(--lh) * 10em + 2 * var(--s2) + 2px), 50vh);
}
.capture-bar .capture-input::placeholder { color: var(--muted); opacity: 1; }
.capture-bar .capture-twin {
  position: absolute; top: 0; left: 0; visibility: hidden; pointer-events: none;
  border: 0; white-space: pre-wrap; overflow-wrap: break-word;
  max-width: calc(var(--measure) + 2 * var(--s3));   /* text at the reading measure (rule 4) */
}
.capture-bar .btn { flex: none; min-height: calc(var(--lh) * 1em + 2 * var(--s2) + 2px); }
.capture-bar .capture-hint { margin: var(--s1) 0 0; font-size: 13px; color: var(--muted); min-height: 1.4em; max-width: none; }
.capture-bar .capture-hint.ok { color: var(--ok); }
.capture-bar .capture-hint.bad { color: var(--danger); }
.capture-bar .capture-hint .btn-link { margin-left: var(--s2); }
@media (max-width: 480px) {
  .capture-bar .capture-form { flex-wrap: wrap; }
  .capture-bar .capture-input { flex-basis: 100%; }
  .capture-bar .btn { flex: 1; }
}

/* ---------- misc ---------- */
.stack > * + * { margin-top: var(--s3); }
.hr { border: 0; border-top: 1px solid var(--line-soft); margin: var(--s4) 0; }
.log-list { list-style: none; padding: 0; }
.log-list li { padding: var(--s2) 0; border-top: 1px solid var(--line-soft); max-width: var(--measure); overflow-wrap: anywhere; }
.log-list li:first-child { border-top: 0; }
.log-when { color: var(--muted); font-size: 0.8em; font-family: var(--num); display: block; }
.progress { height: 6px; border-radius: 0; background: var(--surface-2); overflow: hidden; margin-top: var(--s1); max-width: 360px; }
.progress > div { height: 100%; background: var(--accent); }
.progress.pepijn > div { background: var(--pepijn); }
