/* Open Dashboard — dark app-screen styling.
   Tokens follow taste-skill's app-screens study (dark: #000 ground, #111 opaque surfaces,
   two greys that read apart, the accent on data only, status hues only where something is at
   risk). Text in the system sans; every figure in Geist Mono with tabular digits. */

@font-face {
  font-family: "Geist Mono";
  src: url("/web/fonts/GeistMono-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/web/fonts/GeistMono-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #000000;
  --surface: #111111;
  --raised: #1c1c1c;
  --border: #1f1f1f;
  --rule: #1d1d1d;
  --track: #262626;          /* empty part of a progress bar */
  --grid: #2b2b2b;
  --axis: #4a4a4a;
  --text: #f5f5f5;
  --muted: #b4b4b4;          /* secondary text */
  --faint: #949494;          /* meta, axis ticks (4.5:1 on #111) */
  --field: #e6eeff;          /* ambient glyphs behind the board */

  --accent: #e0892c;         /* the one data hue */
  --chart-muted: #4d4d4d;    /* non-highlighted bars, secondary series */
  --chart-2: #8a8a8a; --chart-3: #5c5c5c;
  --good: #3fc07a;  --good-bg: #172a1d;
  --warn: #e3b341;  --warn-bg: #2b2414;
  --bad: #ef5d6f;   --bad-bg: #2c1a20;
  --info: #8fa3c7;  --info-bg: #182030;
  --neutral: var(--text);

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --chart-font: 11px "Geist Mono", ui-monospace, monospace;
  --radius: 8px;
  --gap: 12px;
  --pad: 18px;
  --ease: cubic-bezier(.23, 1, .32, 1);
}
:root[data-theme="light"] {
  color-scheme: light;
  --ground: #f9fafb; --surface: #ffffff; --raised: #f4f4f5; --border: #e8e8e8; --rule: #f0f0f0; --track: #ececec;
  --grid: #e5e5e5; --axis: #c4c4c4; --text: #111111; --muted: #5f6368; --faint: #6b6b6b; --field: #2a2d36;
  --accent: #c2410c; --chart-muted: #d4d4d4; --chart-2: #8a8a8a; --chart-3: #b8b8b8;
  --good: #247b50; --good-bg: #dcfae5; --warn: #92400e; --warn-bg: #fffbeb; --bad: #c4242a; --bad-bg: #ffedea; --info: #3d5a8a; --info-bg: #eef3fb;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); scrollbar-color: var(--raised) var(--ground); scrollbar-width: thin; }
body {
  margin: 0; min-height: 100vh; color: var(--text); background: var(--ground);
  font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 4px; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
h1, h2, h3, p { margin: 0; }
:where(button, a, input, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .stat-value, .meter-value, .clock, #rev, #updated, td.num, .kv dd { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; font-variant-ligatures: none; }

/* ambient ASCII field: fixed behind everything; cards are opaque so data never sits on it */
.field { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
.top, .grid { position: relative; z-index: 1; }

/* ---------- top bar ---------- */
.top { max-width: 1600px; margin: 0 auto 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; }
.top h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
#subtitle { color: var(--muted); font-size: 14px; margin-top: 2px; }
.statusline { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--faint); }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status[data-state="open"] { color: var(--muted); }
.status[data-state="open"] i { background: var(--good); }
.status[data-state="error"] { color: var(--warn); }
.status[data-state="error"] i { background: var(--warn); }
.clock { color: var(--muted); }

/* always-on display: wake-lock toggle, tap prompt, night veil, burn-in shift */
.awake { font: inherit; color: var(--faint); background: none; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.awake[data-wanted="true"][data-state="on"] { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-bg); }
.awake[data-state="needs-tap"], .awake[data-state="error"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-bg); }
.awake[data-state="resting"] { color: var(--faint); }
.awake[data-state="unsupported"] { display: none; }
.tap-hint {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap;
  background: var(--raised); border: 1px solid var(--accent); border-radius: 999px;
  padding: 10px 20px; pointer-events: none; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.tap-hint[hidden] { display: none; }
.veil { position: fixed; inset: 0; z-index: 5; pointer-events: none; background: #000; opacity: var(--veil, 0); transition: opacity 2s linear; }
.kiosk .top, .kiosk .grid { transform: translate(var(--shift-x, 0), var(--shift-y, 0)); transition: transform 3s linear; }
.kiosk body { cursor: none; }

/* ---------- grid + card ---------- */
.grid {
  --cols: 1; max-width: 1600px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); align-items: start;
}
.block {
  grid-column: span var(--span, 1); min-width: 0; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad);
}
.block.just-updated { animation: arrive 1.2s var(--ease); }
@keyframes arrive { 0% { border-color: var(--accent); } 100% { } }
.block.is-stale > :not(.block-head) { opacity: .5; }

.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.block-title { font-size: 14px; font-weight: 600; color: var(--muted); }
.badge { font-size: 12px; white-space: nowrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.badge.fresh { color: var(--faint); }
.badge.stale { color: var(--warn); background: var(--warn-bg); padding: 1px 8px; border-radius: 999px; font-family: var(--sans); }
.caption { color: var(--faint); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.empty { color: var(--faint); font-size: 14px; }
.board-empty { grid-column: 1 / -1; text-align: center; padding: 48px 0; }

/* ---------- section ---------- */
.block-section { background: none; border: 0; padding: 14px 2px 0; }
.block-section:first-child { padding-top: 0; }
.section-title { font-size: 17px; font-weight: 650; color: var(--text); }
.section-caption { color: var(--faint); font-size: 13px; margin-top: 2px; }

/* ---------- alert: a status hue on a dark tint of itself ---------- */
.block-alert { padding: 12px var(--pad); background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.block-alert.tone-good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.block-alert.tone-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.block-alert.tone-bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.alert-text { font-size: 15px; }
.alert-text strong { font-weight: 650; }
.block-alert.tone-warn strong { color: var(--warn); } .block-alert.tone-bad strong { color: var(--bad); } .block-alert.tone-good strong { color: var(--good); }

/* ---------- stat ---------- */
.block-stat, .block-countdown { container-type: inline-size; }
.stat-label { color: var(--faint); font-size: 13px; margin-bottom: 4px; }
.stat-value { font-size: clamp(26px, 12cqi, 36px); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.affix { font-size: .5em; font-weight: 400; color: var(--faint); letter-spacing: 0; margin-right: 2px; }
.affix.unit { margin: 0 6px 0 3px; }
.countdown .affix.unit:last-child { margin-right: 0; }
.delta { font-size: 14px; font-weight: 600; margin-top: 6px; }
.delta-label { font-family: var(--sans); font-weight: 400; color: var(--faint); }

/* tone helpers: colour only where something is good or at risk */
.tone-text-good { color: var(--good); } .tone-text-warn { color: var(--warn); } .tone-text-bad { color: var(--bad); }
.tone-text-info { color: var(--info); } .tone-text-neutral { color: inherit; }
.fill-accent { background: var(--accent); } .fill-good { background: var(--good); } .fill-warn { background: var(--warn); }
.fill-bad { background: var(--bad); } .fill-info { background: var(--info); } .fill-neutral { background: var(--muted); }
.fill-series-2 { background: var(--chart-2); } .fill-series-3 { background: var(--chart-3); }

/* ---------- progress bars ---------- */
.meters { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.meter-label { font-size: 14px; color: var(--text); }
.meter-value { font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--text); }
.bar { position: relative; height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; }
.bar.fill-in .bar-fill { animation: fill .7s var(--ease) both; animation-delay: calc(var(--d, 0ms) + 150ms); }
@keyframes fill { from { width: 0; } }
.meter-foot { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-top: 6px; }
.meter-foot .caption { margin-top: 0; font-size: 12px; }
.reset { color: var(--faint); font-size: 12px; white-space: nowrap; margin-left: auto; }

/* ---------- list ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.item:first-child { border-top: 0; padding-top: 0; }
.item:last-child { padding-bottom: 0; }
.check { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 4px; border: 1.5px solid var(--faint); position: relative; }
.check.is-done { background: var(--good); border-color: var(--good); }
.check.is-done::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #0b1a10; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.ord { flex: none; color: var(--faint); min-width: 18px; }
.item.done .item-text { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--faint); }
.item-body { min-width: 0; }
.item-text { font-size: 15px; overflow-wrap: anywhere; }
.item-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--faint); font-size: 12px; margin-top: 3px; }
.pill { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill-high { color: var(--bad); background: var(--bad-bg); }
.pill-medium { color: var(--warn); background: var(--warn-bg); }
.tag { color: var(--muted); }
.due.overdue { color: var(--bad); font-weight: 600; }

/* ---------- kv ---------- */
.kv { margin: 0; display: grid; }
.kv-row { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 12px; padding: 9px 0; border-top: 1px solid var(--rule); }
.kv-row:first-child { border-top: 0; padding-top: 0; }
.kv-row:last-child { padding-bottom: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-weight: 600; font-size: 14px; text-align: right; }
.kv-caption { grid-column: 1 / -1; text-align: right; font-size: 12px; color: var(--faint); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { color: var(--faint); font-weight: 500; font-size: 12px; text-align: left; padding: 0 12px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td.missing { color: var(--faint); }
tr:last-child td { border-bottom: 0; padding-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; } th:last-child, td:last-child { padding-right: 0; }
.al-left { text-align: left; } .al-right { text-align: right; } .al-center { text-align: center; }

/* ---------- markdown ---------- */
.md { font-size: 14px; color: var(--muted); line-height: 1.65; }
.md > * + * { margin-top: 8px; }
.md strong { color: var(--text); font-weight: 600; }
.md h3, .md h4, .md h5, .md h6 { font-size: 15px; color: var(--text); }
.md ul, .md ol { padding-left: 20px; margin-bottom: 0; }
.md code { font-family: var(--mono); font-size: .9em; color: var(--text); background: var(--raised); padding: 1px 5px; border-radius: 4px; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart-svg { display: block; overflow: visible; }
.chart .tick { font: var(--chart-font); font-variant-numeric: tabular-nums; }
.chart-tip {
  position: absolute; top: 0; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
  font: 12px/1.4 var(--mono); font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap;
}
.chart-tip.on { opacity: 1; }
.chart-tip-label { color: var(--faint); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- intro (first visit only) ---------- */
.block.intro { animation: rise .45s var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- key prompt ---------- */
.key-form { grid-column: 1 / -1; max-width: 320px; margin: 14vh auto 0; display: grid; gap: 12px; text-align: center; color: var(--muted); }
.key-art { margin: 0; color: var(--text); font: 600 16px var(--sans); }
.key-form input, .key-form button { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.key-form button { background: var(--text); color: var(--ground); border: 0; font-weight: 600; cursor: pointer; }

@media (max-width: 639px) {
  body { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  :root { --pad: 16px; --gap: 10px; }
  .top { flex-direction: column; align-items: flex-start; }
  .top h1 { font-size: 20px; }
  .statusline { gap: 10px; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
