/* hopper-dashboard — control-room identity: neutral slate ground, one accent,
   Okabe–Ito state colours (colour-blind safe) always paired with text + glyph.
   No webfonts (CSP self-only); system sans + mono. Theme-aware via tokens. */

:root {
  --ground: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --ink: #1c2127;
  --muted: #5f6b7a;
  --rule: #d9dee5;
  --accent: #0b6e99;
  --link: #0b6e99;

  --ok: #009e73;        /* bluish green */
  --late: #e69f00;      /* orange */
  --fail: #d55e00;      /* vermillion */
  --stale: #cc79a7;     /* reddish purple */
  --behind: #0072b2;    /* blue */
  --unknown: #8a94a3;   /* grey */
  --skipped: #56b4e9;   /* sky blue */
  --on-state: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121519; --panel: #1a1f26; --panel-2: #222932; --ink: #e6e9ee;
    --muted: #9aa5b4; --rule: #2e3742; --accent: #5ab4dd; --link: #7cc4e6;
    --ok: #1fc29a; --late: #f2b134; --fail: #ff7a3d; --stale: #e09ac2;
    --behind: #4aa3e0; --unknown: #6f7a89; --skipped: #6cc3f0;
    --on-state: #0f1317;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --ground: #121519; --panel: #1a1f26; --panel-2: #222932; --ink: #e6e9ee;
  --muted: #9aa5b4; --rule: #2e3742; --accent: #5ab4dd; --link: #7cc4e6;
  --ok: #1fc29a; --late: #f2b134; --fail: #ff7a3d; --stale: #e09ac2;
  --behind: #4aa3e0; --unknown: #6f7a89; --skipped: #6cc3f0;
  --on-state: #0f1317;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
/* `hidden` always wins. inbox.js shows and hides pre-rendered elements by flipping the
   attribute, and one whose class sets `display` (a badge, an action group, the Reviewed
   pill) would otherwise stay on screen with it set. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
        "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}
code, .strip title, table.kv td code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .92em;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1120px; margin: 0 auto; padding: 1rem .9rem 2rem; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em;
     color: var(--muted); font-weight: 600; display: flex; gap: .6rem; align-items: baseline; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.bad { color: var(--fail); font-weight: 600; }

/* nav */
/* One row at 390px with no horizontal scroll: brand, two EQUAL tabs that share
   the free width, then a short Sign out link. Every link is >= 44px tall. */
nav.top {
  display: flex; align-items: center; gap: .6rem; padding: 0 .9rem;
  background: var(--panel); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 2; min-height: 52px;
}
nav.top a { color: var(--muted); min-height: 44px; display: flex; align-items: center; }
nav.top .brand { color: var(--ink); font-weight: 700; gap: .45rem; flex: 0 0 auto; white-space: nowrap; }
nav.top .brand .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--accent); display: inline-block; }
nav.top .env { font-size: .7rem; padding: .05rem .4rem; border-radius: 3px; background: var(--late); color: var(--on-state); text-transform: uppercase; }
nav.top .tabs { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem;
                max-width: 20rem; margin: 0 auto; min-width: 0; }
nav.top .tab { justify-content: center; padding: 0 .4rem; border-radius: 8px; font-weight: 600;
               font-size: .95rem; white-space: nowrap; border-bottom: 3px solid transparent; }
nav.top .tab:hover { background: var(--panel-2); text-decoration: none; }
nav.top .tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent);
                                    border-radius: 8px 8px 0 0; }
nav.top .signout { flex: 0 0 auto; font-size: .88rem; white-space: nowrap; padding: 0 .1rem; }

/* summary tiles */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: .4rem 0 1.2rem; }
@media (min-width: 640px) { .summary { grid-template-columns: repeat(6, 1fr) 2fr; } }
.tile { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: .55rem .7rem;
        display: flex; flex-direction: column; box-shadow: var(--shadow); border-top: 3px solid var(--rule); }
.tile .n { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.tile .l { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile.zero .n { color: var(--muted); }
.tile-ok { border-top-color: var(--ok); } .tile-late { border-top-color: var(--late); }
.tile-fail { border-top-color: var(--fail); } .tile-stale_dest { border-top-color: var(--stale); }
.tile-behind { border-top-color: var(--behind); } .tile-unknown { border-top-color: var(--unknown); }
.tile.meta { grid-column: 1 / -1; justify-content: center; gap: .15rem; }
.tile.meta .l { text-transform: none; letter-spacing: 0; }
@media (min-width: 640px) { .tile.meta { grid-column: auto; } }

.banner { padding: .7rem .9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid var(--rule); background: var(--panel); }
.banner.warn { border-color: var(--late); }
.banner.bad { border-color: var(--fail); color: var(--fail); }

/* groups & cards */
.group { margin: 1.4rem 0; }
.group h2 .machine { color: var(--ink); }
.cards { display: grid; grid-template-columns: 1fr; gap: .8rem; margin-top: .6rem; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 10px;
  padding: .85rem .95rem .7rem; box-shadow: var(--shadow); display: flex; flex-direction: column;
  border-left: 5px solid var(--unknown); min-width: 0;
}
.card.state-ok { border-left-color: var(--ok); }
.card.state-late { border-left-color: var(--late); }
.card.state-fail { border-left-color: var(--fail); }
.card.state-stale_dest { border-left-color: var(--stale); }
.card.state-behind { border-left-color: var(--behind); }
.card header { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .6rem; margin-bottom: .5rem; }
.card header h3 { font-size: 1.02rem; font-weight: 650; flex: 1 1 auto; min-width: 0; }
.card header h3 a { color: var(--ink); }
.card .kind { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.card .hint { margin: 0 0 .5rem; padding: .4rem .6rem; border-radius: 6px; background: var(--panel-2); font-size: .9rem; }
.card .hint.never-run { border-left: 3px solid var(--unknown); }
.card dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .7rem; margin: 0; font-size: .9rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; min-width: 0; }
.card dd.names code { display: inline-block; margin: 0 .25rem .25rem 0; padding: 0 .3rem; border-radius: 4px; background: var(--panel-2); }
.card dd.names code.missing { background: var(--fail); color: var(--on-state); }
.card footer { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .7rem; padding-top: .55rem; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.card.detail { padding: 1.1rem 1.2rem .9rem; }
.card.detail h1 { font-size: 1.4rem; flex: 1 1 auto; }

/* state chip */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem;
  border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .04em;
  color: var(--on-state); background: var(--unknown); white-space: nowrap;
}
.chip .glyph { font-size: .8em; }
.chip-ok { background: var(--ok); } .chip-late { background: var(--late); }
.chip-fail { background: var(--fail); } .chip-stale_dest { background: var(--stale); }
.chip-behind { background: var(--behind); } .chip-unknown { background: var(--unknown); }

.pill { display: inline-block; padding: 0 .45rem; border-radius: 4px; font-size: .74rem; font-weight: 600;
        background: var(--panel-2); color: var(--ink); vertical-align: middle; }
.pill-ok { background: var(--ok); color: var(--on-state); }
.pill-fail { background: var(--fail); color: var(--on-state); }
.pill-skipped { background: var(--skipped); color: var(--on-state); }

/* disk capacity gauge (kind: disk) */
.gauge { display: flex; flex-direction: column; gap: .25rem; }
.gauge-head { display: flex; flex-wrap: wrap; gap: .15rem .5rem; align-items: baseline; }
.gauge .gaugebar { display: block; width: 100%; height: .5rem; }
.gauge .gaugebar .track { fill: var(--panel-2); stroke: var(--rule); stroke-width: .5; }
.gauge .gaugebar .fill { fill: var(--ok); }
.gauge .gaugebar .mark { fill: var(--muted); }
.gauge-low .gaugebar .fill { fill: var(--behind); }
.gauge-foot { line-height: 1.35; }

/* run history strip */
.strip { display: block; max-width: 100%; }
.strip .bar { fill: var(--unknown); }
.strip .bar-ok { fill: var(--ok); } .strip .bar-fail { fill: var(--fail); } .strip .bar-skipped { fill: var(--skipped); }

/* panels & tables */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: .9rem 1rem; margin: 1rem 0; box-shadow: var(--shadow); }
.panel h2 { margin-bottom: .6rem; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: .4rem .55rem; border-bottom: 1px solid var(--rule); vertical-align: top; white-space: nowrap; }
td.note { white-space: normal; min-width: 14rem; }
thead th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
table.kv th { color: var(--muted); font-weight: 500; width: 30%; }
.crumbs { margin: .2rem 0 .8rem; }

/* login */
.login { max-width: 420px; margin: 2.5rem auto; }
.login h1 { font-size: 1.4rem; margin-bottom: .2rem; }
.login form { display: flex; flex-direction: column; gap: .5rem; margin-top: .8rem; }
label { font-size: .9rem; color: var(--muted); }
input[type=password] {
  font: inherit; font-size: 16px; padding: .6rem .7rem; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--ground); color: var(--ink); width: 100%;
}
button { font: inherit; font-size: 16px; padding: .65rem 1rem; border: 0; border-radius: 6px;
         background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; min-height: 44px; }
button:hover { filter: brightness(1.08); }

.foot { color: var(--muted); font-size: .8rem; text-align: center; padding: 1rem .9rem 2rem; }

@media (max-width: 480px) {
  nav.top { gap: .4rem; padding: 0 .75rem; }
  .card dl { grid-template-columns: 1fr; gap: .05rem; }
  .card dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; margin-top: .35rem; }
}

/* ------------------------------------------------------------------ inbox -- */
/* Mobile-first, because this page is used on a phone first and a desktop
   second. Three rules are load-bearing rather than cosmetic:
   - every form control is font-size 16px on mobile. iOS Safari auto-zooms the
     viewport when a focused input is under 16px, which throws the page sideways
     mid-sentence. Do NOT "tidy" these to a smaller size.
   - item rows STACK on a phone and go inline at 640px. A `min-w-0` title beside
     a `shrink-0` control cluster on one line is what collapsed km-tracker's
     titles to "Cl…" on a 390px screen.
   - titles and transcripts `overflow-wrap: anywhere` (inherited from body) and
     are never truncated: a wrapped sentence is readable, a clipped one is not.
   Tap targets are >= 44px. */

.inbox-summary { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .inbox-summary { grid-template-columns: 1fr 1fr 2fr; } }


.capture-form { display: flex; flex-direction: column; gap: .6rem; }
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
.field.grow { flex: 1 1 12rem; min-width: 0; }
.capture-row, .filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.capture-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.capture-actions .spacer { flex: 1; }

textarea, input[type=text], input[type=search], select {
  font: inherit; font-size: 16px; padding: .6rem .7rem; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--ground); color: var(--ink);
  width: 100%; min-width: 0; color-scheme: light dark;
}
textarea { resize: vertical; min-height: 4.5rem; }
button.record {
  background: var(--fail); color: #fff; min-height: 44px; min-width: 7rem;
}
button.record[disabled] { background: var(--unknown); cursor: not-allowed; }
button.record.recording { background: var(--late); }
/* How full this take is against the per-note cap — the recorder auto-stops at
   the end of it, so this is a countdown, not a decoration. Deliberately small
   and quiet: the clock next to it carries the minutes-remaining in words. */
progress.record-level {
  width: 6rem; height: .45rem; flex: 0 0 auto; align-self: center;
  accent-color: var(--late); border: 0;
}
.filters button, .capture-actions button, .filters select { min-height: 44px; }
.filters .clear { align-self: flex-end; display: inline-flex; align-items: center;
                  min-height: 44px; padding: 0 .4rem; }
/* The two long capture notes live in one collapsed block, so the list is not a
   screen further down on a phone. */
details.about-recordings summary { min-height: 44px; display: flex; align-items: center;
  width: fit-content; cursor: pointer; color: var(--link); font-size: .9rem; }

.items { list-style: none; margin: .6rem 0 0; padding: 0; display: flex;
         flex-direction: column; gap: .6rem;
         scroll-margin-top: 64px; }  /* #items is a link target; clear the sticky nav */
.item {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 10px;
  border-left: 5px solid var(--unknown); box-shadow: var(--shadow);
  padding: .8rem .9rem; display: flex; flex-direction: column; gap: .6rem;
  min-width: 0; scroll-margin-top: 64px;   /* #item-<id> links clear the sticky nav */
}
/* One column at EVERY width (designed for the phone): badges, draft, transcript,
   player, then one action row, then the meta line. */
.item-filing { border-left-color: var(--late); }
.item-review { border-left-color: var(--behind); }
.item.state-closed { border-left-color: var(--ok); opacity: .75; }
.item-main { min-width: 0; flex: 1 1 auto; }
.item-head { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .35rem; }
.item-title { font-size: 1rem; font-weight: 650; overflow-wrap: anywhere; }
.item-body { margin: .3rem 0 0; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-meta { margin: .35rem 0 0; }
.item-issues { margin: .35rem 0 0; }
.item .player { display: block; width: 100%; height: 40px; margin-top: .5rem; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
                margin-top: .6rem; }
.row-error { margin: .4rem 0 0; }

/* Two groups, each kept together; the second (Close/Reopen + Delete) is right-aligned and
   wraps as a unit, so the row never splits a pair at 390 px. */
.item-actions .action-group { display: inline-flex; flex-wrap: nowrap; align-items: center;
  gap: .5rem; }
.item-actions .action-end { margin-left: auto; }
/* A closed note's [Edit draft][Reviewed]: the slot stays, nothing in it shows or takes a tap
   or focus, so Close and Reopen sit at the same x AND y (no 52 px jump at 390 px). */
.item-actions .action-start.dormant { visibility: hidden; }
.item-actions .edit-draft { min-height: 44px; padding: 0 1rem; }
/* The same width for Close and Reopen: flipping a note's state never reflows its row. */
.item-actions .toggle-state { min-height: 44px; min-width: 6.25rem; padding: 0 1rem; }
/* Reviewed reads as a TOGGLE: a pill that fills in when ticked. The whole pill is
   the 44px tap target; the checkbox inside it stays a real checkbox. */
.item-actions .review { display: inline-flex; align-items: center; gap: .45rem;
  min-height: 44px; padding: 0 .9rem; border: 1px solid var(--rule); border-radius: 999px;
  font-size: .95rem; font-weight: 600; color: var(--ink); cursor: pointer;
  white-space: nowrap; background: var(--panel); }
.item-actions .review input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--ok); }
.item-actions .review:has(input:checked) { border-color: var(--ok); background: var(--panel-2); }
/* Delete is deliberately QUIET: a small danger-coloured text button at the end of
   the row, never a primary-looking block — but still a 44px tap target. */
.item-actions button.delete-item { min-height: 44px; padding: 0 .5rem;
  background: transparent; color: var(--fail); border: 0; font-size: .88rem;
  font-weight: 500; }
.item-actions button.delete-item:hover { text-decoration: underline; filter: none; }

.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px;
         font-size: .72rem; font-weight: 600; background: var(--panel-2);
         color: var(--ink); white-space: nowrap; }
.badge-voice { background: var(--behind); color: var(--on-state); }
.badge-typed { background: var(--unknown); color: var(--on-state); }
.badge-github { background: var(--stale); color: var(--on-state); }
.badge-backlog { background: var(--skipped); color: var(--on-state); }
.badge-filing { background: var(--late); color: var(--on-state); }
.badge-review { background: var(--behind); color: var(--on-state); }
.badge-closed, .badge-archived { background: var(--panel-2); color: var(--muted); }
.ts { font-weight: 600; }
.ts-pending, .ts-live { color: var(--late); }
.ts-whisper, .ts-typed { color: var(--ok); }
.ts-failed { color: var(--fail); }
.issue { font-weight: 600; }
.issue-closed { color: var(--muted); text-decoration: line-through; }

/* -------------------------------------------------------------------- hub -- */
/* The landing page. Mobile-first: cards stack, Inbox first; at 640px they sit
   side by side at EQUAL width. The Record button is the one loud thing on the
   page and is >= 56px tall; every other tap target is >= 44px. */
.hub { display: grid; grid-template-columns: 1fr; gap: .9rem; margin: .4rem 0 1rem; }
@media (min-width: 640px) { .hub { grid-template-columns: 1fr 1fr; align-items: stretch; } }
.hub-card {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: var(--shadow); padding: 1rem 1rem .9rem; display: flex;
  flex-direction: column; gap: .75rem; min-width: 0; border-top: 4px solid var(--accent);
}
.hub-dashboard { border-top-color: var(--ok); }
.hub-card h2 { color: var(--ink); }
.hub-stat {
  display: flex; align-items: baseline; gap: .6rem; color: var(--ink);
  padding: .5rem .7rem; border-radius: 8px; background: var(--panel-2); min-height: 44px;
}
.hub-stat:hover { text-decoration: none; filter: brightness(.98); }
.hub-stat .n { font-size: 2.4rem; font-weight: 750; line-height: 1; color: var(--behind); }
.hub-stat .l { font-size: 1rem; font-weight: 600; }
.hub-stat.zero .n { color: var(--muted); }
a.hub-record {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 56px; width: 100%; border-radius: 10px; background: var(--fail);
  color: #fff; font-size: 1.1rem; font-weight: 700; letter-spacing: .01em;
}
a.hub-record:hover { text-decoration: none; filter: brightness(1.08); }
a.hub-record:focus-visible, a.hub-open:focus-visible, .hub-stat:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.hub-meta { margin: 0; font-size: .9rem; }
a.hub-open {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; border-radius: 8px; border: 1px solid var(--rule);
  font-weight: 600; margin-top: auto;
}
a.hub-open:hover { background: var(--panel-2); text-decoration: none; }
.health { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .45rem;
          font-size: 1.05rem; font-weight: 650; padding: .55rem .7rem; border-radius: 8px;
          background: var(--panel-2); min-height: 44px; }
.health .sep { color: var(--muted); font-weight: 400; }
.health .hs { white-space: nowrap; }
.health .hs.zero { color: var(--muted); font-weight: 500; }
.hs-ok .glyph { color: var(--ok); }
.hs-behind:not(.zero) { color: var(--behind); }
.hs-failing:not(.zero) { color: var(--fail); }
.hs-unknown { color: var(--muted); }
.hub-warn { margin: 0; padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--late);
            font-size: .9rem; }

/* Drafts (voice notes). The draft body keeps the model's line breaks
   (pre-line) and is autoescaped like everything else. */
.draft-body { white-space: pre-line; }
.draft-state { margin: .3rem 0 0; font-weight: 600; }
.draft-pending { color: var(--late); }
.draft-failed { color: var(--fail); }
details.transcript { margin: .45rem 0 0; font-size: .9rem; }
details.transcript summary { cursor: pointer; color: var(--link); min-height: 44px;
                             display: flex; align-items: center; width: fit-content; }
details.transcript .item-body { color: var(--muted); margin-top: 0; }
.draft-edit { display: flex; flex-direction: column; gap: .5rem; margin-top: .6rem;
              padding: .7rem; border-radius: 8px; background: var(--panel-2); }
.edit-actions { display: flex; gap: .5rem; }
.edit-actions button { flex: 1 1 0; }
button.secondary { background: transparent; color: var(--link); border: 1px solid var(--rule); }
button.secondary:hover { background: var(--panel-2); filter: none; }

label.check { display: flex; align-items: center; gap: .45rem; min-height: 44px;
              font-size: .95rem; color: var(--ink); cursor: pointer; }
label.check input { width: 1.2rem; height: 1.2rem; }
a.tile-link { color: inherit; }
a.tile-link:hover { text-decoration: none; filter: brightness(.98); }
