:root {
    --bg: #f6f5f2;
    --card: #ffffff;
    --ink: #1c1d1f;
    --muted: #6b6e74;
    --line: #e2e0db;
    --accent: #1f6f5c;
    --accent-ink: #ffffff;
    --accent-soft: #dcefe8;
    --warn-bg: #fff3d6;
    --warn-ink: #6b4b00;
    --lower: #6d4bb3;
    --danger: #b3261e;
    --radius: 14px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121315;
        --card: #1c1e21;
        --ink: #ecebe8;
        --muted: #9a9ea6;
        --line: #2d3034;
        --accent: #4fbf9f;
        --accent-ink: #0c1f19;
        --accent-soft: #1d3a31;
        --warn-bg: #3a2f12;
        --warn-ink: #f3d68a;
        --lower: #b39ae8;
        --danger: #f2867f;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0.2rem 0 0.4rem; }
h1:focus { outline: none; }
h1 small { font-size: 0.95rem; font-weight: 500; color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }

.page {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

.dev-banner {
    background: var(--warn-bg);
    color: var(--warn-ink);
    text-align: center;
    font-size: 0.8rem;
    padding: 4px 16px;
}

.tabs {
    position: fixed;
    inset: auto 0 0 0;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
    flex: 1;
    text-align: center;
    padding: 14px 0;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}
.tabs a.active { color: var(--accent); }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 0;
}

.label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.today-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.today-head .date { font-size: 1.1rem; font-weight: 700; }
.chip { font-size: 0.8rem; background: var(--accent-soft); color: var(--ink); padding: 4px 10px; border-radius: 999px; }
.chip-lower { background: color-mix(in srgb, var(--lower) 20%, transparent); }

.anchor {
    display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
    margin: 12px 0; padding: 14px 16px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.anchor small { display: block; color: var(--muted); }
.anchor .tick {
    flex: none; width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800;
}
.anchor.on .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.questions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.questions .q { font-weight: 600; flex: 1 1 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 8px 18px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.link { background: none; border: 0; color: var(--accent); padding: 8px 4px; }
.link.on { color: var(--warn-ink); }
.link.danger { color: var(--danger); display: block; margin: 8px auto 0; }

.answer h1 { font-size: 1.7rem; }
.answer .dose { font-weight: 600; margin: 0 0 8px; }
.items { padding-left: 0; list-style: none; margin: 8px 0; }
.items li { padding: 6px 0; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; }
.items .muted { display: block; font-size: 0.88rem; }
.cue { font-style: italic; color: var(--muted); margin: 8px 0 12px; }
.why summary { color: var(--muted); cursor: pointer; margin-top: 8px; }
.why ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; }
.verdict-anchoronly h1, .verdict-rest h1, .verdict-done h1 { color: var(--accent); }

.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-size: 0.92rem; }

.primary, .secondary, .toggle {
    border-radius: 12px; padding: 12px 18px; font-weight: 700; border: 1px solid transparent;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary, .toggle { background: var(--card); border-color: var(--line); }
.toggle.on { background: var(--accent-soft); border-color: var(--accent); }
.primary.big { padding: 18px 22px; font-size: 1.1rem; flex: 1; }
.wide, .answer .primary { width: 100%; }

.meter { display: grid; grid-template-columns: 7.5rem 1fr auto; align-items: center; gap: 8px; margin: 8px 0; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.dots.big { margin-top: 12px; justify-content: center; }
.dots.big i { width: 18px; height: 18px; }

.other summary { font-weight: 600; cursor: pointer; }
.grid-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.grid-buttons small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }

.log-head h1 { margin-top: 4px; }
.item-head { display: flex; flex-direction: column; margin-bottom: 8px; }
.item-head .muted { font-size: 0.88rem; }
.trip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.trip-label { font-size: 0.8rem; color: var(--muted); width: 3.5rem; }
.set { background: var(--accent-soft); border-radius: 8px; padding: 2px 10px; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.stepper > button:not(.primary) {
    width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 1.4rem;
}
.stepper .value { min-width: 3.5rem; text-align: center; font-size: 1.6rem; font-weight: 800; }
.stepper .primary { flex: 1; padding: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.weight { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 0.9rem; }
.weight input { width: 5rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }

.rpe { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 8px 0 12px; }
.rpe button { padding: 10px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.rpe button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
textarea {
    width: 100%; min-height: 64px; padding: 10px; margin-bottom: 12px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit;
}

.page-title { margin-top: 4px; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); text-transform: none; letter-spacing: 0; }
.history-session { margin-top: 10px; }
.history-session ul { margin: 4px 0; padding-left: 18px; font-size: 0.9rem; }

#blazor-error-ui {
    background: var(--warn-bg); color: var(--warn-ink);
    bottom: 0; display: none; left: 0; padding: 0.6rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.loading-progress { position: relative; display: block; width: 6rem; height: 6rem; margin: 20vh auto 1rem auto; }
.loading-progress circle { fill: none; stroke: var(--line); stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto 0.2rem; color: var(--muted); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

.vault-preview summary { font-size: 0.82rem; color: var(--muted); cursor: pointer; margin-top: 6px; }
.vault-preview pre {
    font-size: 0.72rem; line-height: 1.4; background: var(--bg); border: 1px solid var(--line);
    border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre; margin: 6px 0 0;
}

/* ── 7-minute anchor timer ─────────────────────────────────────────────────────────── */
:root { --work: #c2410c; --work-soft: #fde4d3; --rest: #1a7f45; --rest-soft: #d8f0e2; --on-phase: #ffffff; }
@media (prefers-color-scheme: dark) {
    :root { --work: #ff8a3d; --work-soft: #3d2312; --rest: #3ecf7a; --rest-soft: #143222; --on-phase: #111214; }
}

.anchor-row { display: flex; gap: 8px; align-items: stretch; margin: 12px 0; }
.anchor-row .anchor { margin: 0; flex: 1; }
.anchor-row .timer-btn {
    flex: none; min-width: 84px; border-radius: var(--radius); border: 1px solid var(--work);
    background: var(--work-soft); color: var(--ink); font-weight: 700; padding: 0 12px;
}
.anchor-row .timer-btn span { display: block; font-size: 1.4rem; color: var(--work); line-height: 1; }

.timer-head { display: flex; justify-content: space-between; align-items: center; }
.timer, .timer-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding-top: 4px; }
.phase-label {
    font-weight: 800; letter-spacing: 0.18em; font-size: 1rem; padding: 6px 18px; border-radius: 999px;
    color: var(--on-phase);
}
.phase-label.work { background: var(--work); }
.phase-label.rest { background: var(--rest); }

.ring-wrap { position: relative; width: min(82vw, 360px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.ring .bar.work { stroke: var(--work); }
.ring .bar.rest { stroke: var(--rest); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ring-text .total { font-size: 1.05rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ring-text .big { font-size: clamp(4.5rem, 26vw, 7.5rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.timer-work .ring-text .big { color: var(--work); }
.timer-rest .ring-text .big, .timer-done .ring-text .big { color: var(--rest); }
.ring-text .name { font-size: 1.05rem; font-weight: 600; max-width: 70%; }

.timer-info { min-height: 4.2rem; }
.timer-info .next { font-size: 1.1rem; }
.timer-info .swap { color: var(--muted); }

.timer-controls { display: flex; gap: 20px; align-items: center; justify-content: center; margin-top: 4px; }
.ctl {
    width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--card); font-size: 1.5rem;
}
.ctl.main { width: 96px; height: 96px; font-size: 2rem; color: #fff; border: 0; }
.ctl.main.work { background: var(--work); }
.ctl.main.rest { background: var(--rest); }

@media (prefers-reduced-motion: reduce) {
    .ring .bar { transition: none; }
}
