/* Layout: a flight-plan board — goal meters and a dated phase rail on top, then tabbed working views (Today, Plan, Review, Tracker, Rules). */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --sunk: #e4e9f0;
  --ink: #111a26;
  --muted: #586579;
  --line: #d5dce6;
  --accent: #2a52d6;
  --accent-ink: #ffffff;
  --accent-soft: #e2e8fb;
  --pace: #b06c0c;
  --pace-soft: #f6ead6;
  --good: #19805a;
  --good-soft: #dcf1e7;
  --warn: #b3461b;
  --warn-soft: #f8e3d9;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219; --surface: #151c26; --sunk: #1b2431; --ink: #e6ebf2; --muted: #94a1b4; --line: #273244;
    --accent: #7f9cff; --accent-ink: #0d1219; --accent-soft: #1c2849; --pace: #e2a443; --pace-soft: #33270f;
    --good: #52c58f; --good-soft: #12301f; --warn: #ef8f5c; --warn-soft: #3a1d10; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1219; --surface: #151c26; --sunk: #1b2431; --ink: #e6ebf2; --muted: #94a1b4; --line: #273244;
  --accent: #7f9cff; --accent-ink: #0d1219; --accent-soft: #1c2849; --pace: #e2a443; --pace-soft: #33270f;
  --good: #52c58f; --good-soft: #12301f; --warn: #ef8f5c; --warn-soft: #3a1d10; color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.wrap { max-width: 1160px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; line-height: 1.02; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Masthead */
.mast { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; padding-block: 32px 20px; }
.mast .sub { margin-top: 10px; color: var(--muted); max-width: 60ch; }
.mast .sub b { color: var(--ink); font-weight: 600; }
.clock { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 260px; display: grid; gap: 8px; }
.clock-row { display: flex; gap: 18px; }
.clock-row div { display: grid; }
.clock-time { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.1; }
.block-now { font-size: 0.88rem; border-top: 1px solid var(--line); padding-top: 8px; }
.block-now b { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.live { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }

/* Goal strip */
.goals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.goal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 6px; min-width: 0; }
.goal .big { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.goal .big small { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 400; color: var(--muted); margin-left: 4px; }
.bar { position: relative; height: 8px; background: var(--sunk); border-radius: 4px; overflow: visible; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; }
.bar > em { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--pace); border-radius: 1px; }
.goal .note { font-size: 0.8rem; color: var(--muted); }
.goal .note .pace { color: var(--pace); font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.pace { background: var(--pace-soft); color: var(--pace); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

/* Timeline */
.rail-wrap { margin-top: 18px; overflow-x: auto; padding-bottom: 6px; }
.rail { min-width: 760px; position: relative; padding-top: 22px; }
.rail-segs { display: flex; gap: 3px; }
.seg { border: 0; background: var(--sunk); border-radius: 6px; padding: 8px 8px 7px; text-align: left; min-width: 0; display: grid; gap: 1px; position: relative; }
.seg:hover { background: var(--accent-soft); }
.seg .s-name { font-weight: 600; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg .s-date { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.seg.current { background: var(--accent); color: var(--accent-ink); }
.seg.current .s-date { color: var(--accent-ink); opacity: 0.8; }
.seg.past .s-name { color: var(--muted); }
.seg .s-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 0 0 6px 6px; background: var(--good); transform-origin: left; }
.today-pin { position: absolute; top: 0; transform: translateX(-50%); font-family: var(--font-mono); font-size: 0.68rem; color: var(--accent); white-space: nowrap; pointer-events: none; }
.today-pin::after { content: ""; position: absolute; left: 50%; top: 16px; width: 2px; height: 46px; background: var(--accent); transform: translateX(-50%); }
.milestones { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 0.78rem; color: var(--muted); }
.milestones span b { color: var(--ink); font-weight: 600; }

/* Tabs */
.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; gap: 4px; margin-top: 22px; padding-block: 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--sunk); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.save-state { margin-left: auto; align-self: center; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; padding-left: 12px; }
.view { padding-top: 22px; }

/* Panels */
.cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 20px; }

/* Day navigator */
.daynav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.daynav .navbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; font-size: 1.1rem; }
.daynav .navbtn:hover { border-color: var(--accent); color: var(--accent); }
.daynav .ghost { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; font-size: 0.85rem; }
.daynav h2 { font-size: 1.5rem; }
.daynav .ctx { flex-basis: 100%; color: var(--muted); }

/* Task rows */
.tasks { display: grid; gap: 2px; }
.task { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 8px; border-radius: 8px; }
.task:hover { background: var(--sunk); }
.task input { appearance: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--muted); border-radius: 5px; display: grid; place-items: center; cursor: pointer; background: var(--surface); }
.task input:checked { background: var(--good); border-color: var(--good); }
.task input:checked::after { content: ""; width: 10px; height: 6px; border-left: 2px solid var(--surface); border-bottom: 2px solid var(--surface); transform: rotate(-45deg) translate(1px, -1px); }
.task label { cursor: pointer; min-width: 0; }
.task .t { font-weight: 500; }
.task .d { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.task.done .t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.task .time { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); display: block; margin-bottom: 1px; }

/* Counters */
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.counter { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.counter .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.counter .n { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.counter .n small { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 400; color: var(--muted); }
.step { display: flex; gap: 4px; }
.step button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 1.1rem; line-height: 1; }
.step button:hover { border-color: var(--accent); color: var(--accent); }

/* Boost timer */
.boost { border-radius: 8px; padding: 12px 14px; background: var(--accent-soft); display: grid; gap: 8px; }
.boost .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.boost .left { font-family: var(--font-mono); font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.btn { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 0.88rem; }
.btn:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--warn); }

/* Week card */
.targets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.targets div { background: var(--sunk); border-radius: 8px; padding: 8px 10px; display: grid; }
.targets b { font-family: var(--font-display); font-size: 1.15rem; }
.targets span { font-size: 0.75rem; color: var(--muted); }
.goalline { font-size: 0.9rem; border-left: 3px solid var(--pace); padding-left: 10px; }

/* Plan */
.phase { scroll-margin-top: 80px; }
.phase-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.phase-num { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1; color: var(--accent); min-width: 34px; }
.phase-head .goal-txt { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.ring { width: 46px; height: 46px; }
.week { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.week-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.due { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; padding-top: 3px; }
.due.over { color: var(--warn); }
.due.today { color: var(--accent); font-weight: 500; }

/* Review */
.weeks-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.wp { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-family: var(--font-mono); font-size: 0.78rem; }
.wp[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.wp.complete::before { content: "✓ "; color: var(--good); }
.wp[aria-pressed="true"].complete::before { color: var(--bg); }
textarea, input[type="number"], input[type="date"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 120px; resize: vertical; }
textarea:focus, input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* Tracker */
.logform { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 0.78rem; color: var(--muted); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; }
th:first-child, td:first-child { text-align: left; }
td .linkbtn { border: 0; background: transparent; color: var(--muted); font-size: 0.8rem; padding: 2px 6px; border-radius: 6px; }
td .linkbtn:hover { color: var(--warn); background: var(--warn-soft); }
td .linkbtn.armed { color: var(--surface); background: var(--warn); }
.empty { border: 1px dashed var(--line); border-radius: 8px; padding: 18px; color: var(--muted); text-align: center; font-size: 0.9rem; }

/* Rules */
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; counter-reset: r; }
.rule { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule::before { counter-increment: r; content: counter(r, decimal-leading-zero); font-family: var(--font-mono); font-size: 0.78rem; color: var(--warn); padding-top: 2px; }
.rule b { font-weight: 600; display: block; }
.rule span { font-size: 0.85rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fact { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: grid; gap: 4px; align-content: start; }
.fact b { font-family: var(--font-display); font-size: 1.4rem; color: var(--accent); line-height: 1.1; }
.fact span { font-size: 0.85rem; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 0.88rem; z-index: 20; }

@media (max-width: 900px) {
  .goals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols, .charts { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .mast { grid-template-columns: minmax(0, 1fr); padding-top: 22px; }
  .clock { min-width: 0; }
  .rules, .facts { grid-template-columns: minmax(0, 1fr); }
  .logform { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .targets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .goal .big { font-size: 1.5rem; }
  .save-state { display: none; }
}
@media (max-width: 420px) {
  .goals { grid-template-columns: minmax(0, 1fr); }
  .counters { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .bar > i, .s-fill { transition: transform .4s ease, width .4s ease; }
}

/* ---------- base (own hosting) ---------- */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent); }
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--sunk); padding: 1px 5px; border-radius: 4px; }

/* ---------- account bar ---------- */
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 14px; }
.topline-msg { font-size: 0.85rem; color: var(--good); background: var(--good-soft); padding: 4px 10px; border-radius: 999px; }
.userbar { display: flex; align-items: center; gap: 16px; margin-left: auto; font-size: 0.88rem; flex-wrap: wrap; }
.userbar b { color: var(--ink); font-weight: 600; }
.userbar a, .linklike { color: var(--ink); text-decoration: none; font-weight: 500; border-bottom: 1px solid var(--line); padding: 0; background: none; border-top: 0; border-left: 0; border-right: 0; font-size: inherit; line-height: 1.4; }
.userbar a:hover, .linklike:hover { color: var(--accent); border-bottom-color: var(--accent); }
.userbar form { margin: 0; display: inline; }
.mast { padding-top: 18px; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form .field { display: grid; gap: 5px; }
.form label, .field > label { font-size: 0.85rem; font-weight: 500; color: var(--ink); }
input[type="text"], input[type="password"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; }
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 0.8rem; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.btn.wide { width: 100%; padding: 11px 16px; font-size: 0.95rem; }
.btn.as-link { display: inline-block; text-decoration: none; justify-self: start; }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; border: 1px solid transparent; }
.notice.ok { background: var(--good-soft); color: var(--good); }
.notice.error { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- sign-in and setup ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: clamp(28px, 6vw, 80px); align-items: center; max-width: 1040px; margin: 0 auto; padding-block: 40px; }
.auth-aside { display: grid; gap: 14px; align-content: start; }
.auth-aside h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.auth-aside > p { max-width: 44ch; }
.auth-milestones { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 0; border-left: 2px solid var(--line); }
.auth-milestones li { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 10px; padding: 8px 0 8px 16px; position: relative; font-size: 0.92rem; }
.auth-milestones li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.auth-milestones li:last-child::before { background: var(--accent); }
.auth-milestones span { color: var(--muted); font-size: 0.82rem; padding-top: 1px; }
.auth-milestones b { font-weight: 500; }
.auth-targets { display: flex; gap: 12px; flex-wrap: wrap; }
.auth-targets div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; display: grid; min-width: 140px; }
.auth-targets b { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; }
.auth-targets span { font-size: 0.8rem; color: var(--muted); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(20px, 4vw, 30px); display: grid; gap: 18px; box-shadow: 0 1px 2px rgba(17, 26, 38, 0.04), 0 12px 32px -18px rgba(17, 26, 38, 0.25); }
.auth-card h2 { font-size: 1.6rem; margin-top: 2px; }
.auth-card p.muted { margin-top: 6px; font-size: 0.9rem; }

/* ---------- admin ---------- */
.admin-top { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; padding-block: 28px 18px; }
.admin-title { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 14px; }
.admin-grid > .panel:first-child { max-width: 520px; }
.facts-list { margin: 0; display: grid; gap: 0; }
.facts-list div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.facts-list div:last-child { border-bottom: 0; }
.facts-list dt { color: var(--muted); }
.facts-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.inline-form { margin: 0; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; }
.danger-zone summary { cursor: pointer; color: var(--warn); font-weight: 500; font-size: 0.92rem; }
.danger-zone .form { margin-top: 12px; }
#notice-anchor { scroll-margin-top: 20px; }

@media (max-width: 820px) {
  .auth { grid-template-columns: minmax(0, 1fr); align-items: start; padding-block: 24px; min-height: 0; }
  .auth-card { order: -1; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-grid > .panel:first-child { max-width: none; }
}
@media (max-width: 480px) {
  .facts-list div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .userbar { gap: 12px; margin-left: 0; }
}
