/* Layout: sticky top bar with section nav; one centered working column; home is a short stack of
   "this week" first, then scoreboard, then what's next. Dark by design (TGV brand). */
:root {
  --bg: #07080F;
  --surface: #10132A;
  --surface-2: #171B38;
  --line: #262C47;
  --fg: #EEF0F7;
  --muted: #A9AFC6;
  --dim: #868DA8;
  --accent: #8FB3FF;
  --accent-ink: #07080F;
  --warm: #FFB65C;
  --good: #6FD9A8;
  --warn: #F2C46D;
  --bad: #FF8A9B;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: #C9DAFF; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 16px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(7, 8, 15, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px 20px; padding: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; color: var(--muted); padding: 9px 12px; font-size: 14px; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--warm); }
.save-state { font-family: var(--mono); font-size: 11px; color: var(--dim); white-space: nowrap; }
.save-state.ok { color: var(--good); }
.save-state.err { color: var(--bad); }
@media (max-width: 760px) {
  .topbar { padding: 8px 16px 0; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 8px; }
  .save-state { margin-left: auto; }
}

/* ---------- page ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 16px; padding-block: 28px 80px; display: flex; flex-direction: column; gap: 28px; outline: none; }
.page-head { display: flex; flex-direction: column; gap: 6px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--warm); }
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: clamp(24px, 4.5vw, 34px); line-height: 1.1; letter-spacing: -0.01em; }
h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 18px; line-height: 1.25; }
h3 { margin: 0; font-size: 16px; font-weight: 600; }
.lede { margin: 0; color: var(--muted); max-width: 66ch; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
p { margin: 0; }

.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }

.panel { background: var(--surface); border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel.tight { padding: 16px; gap: 10px; }
.panel.focus { border-color: rgba(255, 182, 92, 0.55); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--line); min-width: 0; }
.tile:last-child { border-right: 0; }
.tile .v { font-family: var(--display); font-weight: 500; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .v small { font-family: var(--body); font-size: 14px; color: var(--muted); font-weight: 400; }
.tile .sub { font-size: 12.5px; color: var(--muted); }
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(2) { border-right: 0; }
  .tile:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
.tiles.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) {
  .tiles.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles.six .tile { border-bottom: 1px solid var(--line); }
  .tiles.six .tile:nth-child(2) { border-right: 1px solid var(--line); }
  .tiles.six .tile:nth-child(3n) { border-right: 0; }
  .tiles.three { grid-template-columns: minmax(0, 1fr); }
  .tiles.three .tile { border-right: 0; border-bottom: 1px solid var(--line); }
}
.bar { height: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--warm); }

/* ---------- checklist ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.check { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--warm); cursor: pointer; }
.check label { cursor: pointer; }
.check .why { grid-column: 2 / 4; font-size: 13px; color: var(--dim); }
.check.done label { color: var(--dim); text-decoration: line-through; }
.tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 2px 6px; white-space: nowrap; }
.tag.warm { color: var(--warm); border-color: rgba(255, 182, 92, 0.45); }
.tag.good { color: var(--good); border-color: rgba(111, 217, 168, 0.45); }
.tag.bad { color: var(--bad); border-color: rgba(255, 138, 155, 0.45); }
.tag.accent { color: var(--accent); border-color: rgba(143, 179, 255, 0.45); }

/* ---------- lists ---------- */
.rows { display: flex; flex-direction: column; }
.row { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row:last-child { border-bottom: 0; }
.row .main { min-width: 0; flex: 1 1 260px; display: flex; flex-direction: column; gap: 2px; }
.alert { display: flex; gap: 10px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.alert:last-child { border-bottom: 0; }
.alert .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.empty { color: var(--dim); font-size: 14px; padding: 6px 0; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--fg); }
.btn.primary { background: var(--warm); color: #1D1203; border-color: var(--warm); font-weight: 600; }
.btn.primary:hover { background: #FFC67E; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(255, 138, 155, 0.4); background: transparent; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
input[type="text"], input[type="number"], input[type="url"], input[type="date"], input[type="search"], input[type="password"], select, textarea {
  background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; min-height: 38px; font-size: 14px; width: 100%; border-radius: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgba(143, 179, 255, 0.25); }
textarea { min-height: 64px; resize: vertical; }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.field .hint { font-size: 12px; color: var(--dim); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- tabs & chips ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 6px 11px; font-size: 13px; cursor: pointer; min-height: 34px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); font-weight: 500; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tr.current td { background: rgba(255, 182, 92, 0.06); }

/* ---------- plan ---------- */
.phase { border: 1px solid var(--line); background: var(--surface); }
.phase > summary { list-style: none; cursor: pointer; padding: 16px 20px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: baseline; }
.phase > summary::-webkit-details-marker { display: none; }
.phase-n { font-family: var(--display); font-size: 22px; color: var(--warm); }
.phase .body { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.phase.now { border-color: rgba(255, 182, 92, 0.55); }
.week-block { display: flex; flex-direction: column; gap: 4px; }
.week-h { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.06em; padding-top: 6px; }
.targets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); }
.targets div { padding: 10px 12px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.targets div:last-child { border-right: 0; }
.targets b { font-family: var(--mono); font-weight: 500; font-size: 16px; }
@media (max-width: 760px) { .targets { grid-template-columns: repeat(2, minmax(0, 1fr)); } .targets div { border-bottom: 1px solid var(--line); } }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 6px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
@media (max-width: 640px) { .rule { grid-template-columns: 1fr; } }

/* ---------- content bank ---------- */
.post { border-bottom: 1px solid var(--line); }
.post-row { width: 100%; display: grid; grid-template-columns: 72px 82px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 8px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--fg); }
.post-row:hover, .post.open .post-row { background: var(--surface); }
.post.done .post-title { color: var(--dim); text-decoration: line-through; }
.post-date { font-family: var(--mono); font-size: 12.5px; color: var(--warm); }
.post-title { font-weight: 500; min-width: 0; }
.post-meta { font-size: 12px; color: var(--dim); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.lane { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lane.space { background: var(--s1); } .lane.nature { background: var(--s3); } .lane.tech { background: var(--s5); }
.post-detail { padding: 6px 8px 20px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.headline { font-family: var(--display); font-weight: 500; font-size: 17px; line-height: 1.25; background: var(--surface-2); padding: 10px 14px; border-left: 3px solid var(--warm); }
.slides { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.slides li { counter-increment: s; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.slides li::before { content: counter(s); font-family: var(--mono); color: var(--warm); text-align: center; }
.slides a { display: block; font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.slides .credit { font-size: 12px; color: var(--dim); }
.caption-box { background: var(--surface-2); padding: 10px 12px; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.flag { font-size: 13px; color: var(--warn); border-left: 2px solid var(--warn); padding-left: 10px; }
@media (max-width: 680px) {
  .post-row { grid-template-columns: 64px minmax(0, 1fr); }
  .post-row .post-type { display: none; }
  .post-row .post-meta { grid-column: 2; }
}

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--dim); font-family: var(--mono); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; display: inline-block; }
.tip { position: fixed; z-index: 50; background: #1E2346; border: 1px solid var(--line); padding: 8px 10px; font-size: 12.5px; pointer-events: none; max-width: 240px; }
.tip b { font-family: var(--mono); font-weight: 500; }

/* ---------- misc ---------- */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--warm); color: #1D1203; padding: 9px 16px; font-weight: 600; font-size: 13px; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 60; }
.toast.on { opacity: 1; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--dim); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts { list-style: none; margin: 0; padding: 0; }
.facts li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.facts li:last-child { border-bottom: 0; }
.template-body { white-space: pre-wrap; font-size: 13.5px; background: var(--bg); border: 1px solid var(--line); padding: 12px; max-height: 260px; overflow: auto; }
details.plain > summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; }
.status-sel { min-width: 140px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

#logCharts { display: flex; flex-direction: column; gap: 28px; }

/* ---------- live page stats ---------- */
.live-card { gap: 8px; }
.live-card.stale { opacity: 0.7; }
.live-big { display: flex; align-items: baseline; gap: 10px; }
.live-big .v { font-family: var(--display); font-weight: 500; font-size: 26px; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.live-line { display: flex; gap: 16px; font-family: var(--mono); font-size: 13px; }
.live-last { text-decoration: none; color: var(--fg); border-top: 1px solid var(--line); padding-top: 8px; }
.live-last:hover { color: var(--accent); }
.thumb { width: 44px; height: 44px; object-fit: cover; display: block; background: var(--surface-2); }
.thumb.lg { width: 72px; height: 72px; flex: none; }
td.wrap-cell { white-space: normal; min-width: 220px; max-width: 360px; }
.best-row { border: 0; padding: 4px 0 0; align-items: center; flex-wrap: nowrap; }
@media (max-width: 760px) {
  .live-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 14px; }
  .live-card > .section-head { grid-column: 1; grid-row: 1; justify-content: flex-start; gap: 10px; }
  .live-card > .live-big { grid-column: 1; grid-row: 2; }
  .live-card > .live-line { grid-column: 2; grid-row: 1 / 3; flex-direction: column; gap: 2px; align-items: flex-end; justify-content: center; }
  .live-card > .live-last, .live-card > .small.dim, .live-card > p { grid-column: 1 / -1; grid-row: 3; margin-top: 6px; }
  .live-big .v { font-size: 22px; }
  .grid-3:has(.live-card) { gap: 10px; }
}
