:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #fff;
  --text: #1a2923;
  --muted: #54635b;
  --rule: #dce3dc;
  --accent: #286044;
  --accent-strong: #1d4d36;
  --mint: #e0ebe0;
  --mint-ink: #1d3d2b;
  --hero: #dceadd;
  --hero-line: #86a48a;
  --sidebar: #172c24;
  --sidebar-muted: #adbbb1;
  --nav-current: #314b3f;
  --sidebar-ink: #f0f6f0;
  --plum-bg: #f0ebf1;
  --plum-ink: #44364c;
  --plum-button: #55435e;
  --danger: #943b3f;
  --warning: #f9eeee;
  --study: #a891b1;
  --work: #497f60;
  --focus: #8653a5;
  --shadow: 0 12px 44px #1a292329;
  --radius: 17px;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 100%;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141c18;
  --surface: #1c2822;
  --text: #ebf3ed;
  --muted: #b4c4b9;
  --rule: #35483d;
  --accent: #a6d1b3;
  --accent-strong: #c0e7ca;
  --mint: #293e31;
  --mint-ink: #e4f5e6;
  --hero: #294432;
  --hero-line: #59846a;
  --sidebar: #111e18;
  --nav-current: #314b3f;
  --plum-bg: #312a38;
  --plum-ink: #f0e4f5;
  --plum-button: #6c5579;
  --danger: #ffb4b5;
  --warning: #3b272a;
  --work: #87be99;
  --study: #c8a9d3;
  --focus: #e0b6f5;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #141c18;
    --surface: #1c2822;
    --text: #ebf3ed;
    --muted: #b4c4b9;
    --rule: #35483d;
    --accent: #a6d1b3;
    --accent-strong: #c0e7ca;
    --mint: #293e31;
    --mint-ink: #e4f5e6;
    --hero: #294432;
    --hero-line: #59846a;
    --sidebar: #111e18;
    --nav-current: #314b3f;
    --plum-bg: #312a38;
    --plum-ink: #f0e4f5;
    --plum-button: #6c5579;
    --danger: #ffb4b5;
    --warning: #3b272a;
    --work: #87be99;
    --study: #c8a9d3;
    --focus: #e0b6f5;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 280px; line-height: 1.48; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, input[type="checkbox"], input[type="radio"] { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main:focus, #dialog-title:focus { outline: none; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.16; }
p, li, .record-text { overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; letter-spacing: -.022em; font-weight: 670; }
h3 { font-size: 1rem; letter-spacing: -.012em; }
svg { flex: none; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; z-index: 10; top: 8px; left: 8px; background: var(--surface); padding: 10px 16px; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.mobile-header, .scrim { display: none; }

.sidebar { width: 246px; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 33px 20px 24px; background: var(--sidebar); color: var(--sidebar-ink); overflow: auto; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--sidebar-ink); text-decoration: none; font-size: 1.45rem; font-weight: 665; letter-spacing: -.055em; }
.desktop-brand { margin: 0 8px 31px; }
.brand-mark { width: 37px; height: 37px; flex: none; background: url("./mark.svg") center / contain no-repeat; }
.nav-group { margin-bottom: 26px; }
.nav-group > p { color: var(--sidebar-muted); margin: 0 11px 8px; font-size: .78rem; letter-spacing: .11em; text-transform: uppercase; font-weight: 590; }
.nav-link { min-height: 43px; margin: 3px 0; border-radius: 8px; display: flex; align-items: center; gap: 11px; padding: 8px 11px; text-decoration: none; color: var(--sidebar-ink); font-size: .91rem; white-space: nowrap; }
.nav-link svg { color: #b7c9be; }
.nav-link:hover, .nav-link[aria-current="page"] { background: var(--nav-current); }
.nav-link[aria-current="page"] { font-weight: 640; }
.nav-link[aria-current="page"] svg { color: #def0e3; }
.nav-footer { margin-top: auto; border-top: 1px solid #ffffff22; padding-top: 10px; }
.device-note { display: flex; align-items: center; gap: 8px; padding: 14px 10px 0; color: var(--sidebar-muted); font-size: .79rem; }
.device-note span { width: 7px; height: 7px; background: #a0ccab; border-radius: 50%; }
.workspace { margin-left: 246px; }
main, .update-banner { width: min(100%, 1310px); margin: auto; }
main { padding: 38px 46px 46px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 25px; }
.page-heading h1 { font-size: clamp(2.2rem, 4vw, 3.0rem); font-weight: 665; letter-spacing: -.062em; }
.page-heading p { color: var(--muted); font-size: 1rem; margin-top: 7px; }
.date-pill { color: var(--muted); display: inline-flex; align-items: center; gap: 9px; padding: 8px 13px; border: 1px solid var(--rule); border-radius: 9px; white-space: nowrap; font-size: .89rem; background: var(--surface); }
.card { min-width: 0; border: 1px solid var(--rule); background: var(--surface); border-radius: var(--radius); padding: 22px; }
main > .card, main > .two-up { margin-bottom: 16px; }
.section-heading { display: flex; min-height: 30px; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.card > p + .actions, .card > p + .button { margin-top: 13px; }
.dashboard-top, .dashboard-main, .dashboard-bottom, .two-up { display: grid; gap: 16px; }
.dashboard-top { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); margin-bottom: 16px; }
.dashboard-main { grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr); margin-bottom: 16px; }
.dashboard-bottom, .two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-compact { display: grid; gap: 12px; margin-bottom: 12px; }
.program-hero { position: relative; isolation: isolate; overflow: hidden; min-width: 0; border-radius: var(--radius); background: var(--hero); color: var(--mint-ink); padding: 24px 26px; min-height: 245px; }
.program-content { position: relative; max-width: 74%; z-index: 1; }
.program-kicker { display: flex; align-items: center; gap: 7px; font-size: .85rem; font-weight: 650; }
.program-day { margin: 17px 0 7px; font-size: .83rem; font-weight: 620; }
.program-content h2 { max-width: 25ch; font-size: clamp(1.58rem, 2.45vw, 2.15rem); line-height: 1.11; margin-bottom: 9px; letter-spacing: -.052em; }
.program-content > p:not([class]) { max-width: 50ch; font-size: .95rem; }
.program-content .button { margin-top: 18px; }
.program-etch { position: absolute; top: -2px; bottom: -2px; right: -7%; width: 56%; opacity: .63; transform: rotate(-23deg); transform-origin: center; pointer-events: none; }
.program-etch i { display: block; position: absolute; width: 86%; height: 63%; transform: rotate(-18deg); right: -8%; bottom: -6%; border: 1px solid var(--hero-line); border-radius: 48%; }
.program-etch i:nth-child(2) { right: 0; bottom: 0; }
.program-etch i:nth-child(3) { right: 8%; bottom: 6%; }
.program-etch i:nth-child(4) { right: 16%; bottom: 12%; }
.program-etch i:nth-child(5) { right: 24%; bottom: 18%; }
.program-etch b { position: absolute; top: 33%; right: 47%; border: 1px solid var(--hero-line); border-radius: 50%; width: 8px; height: 8px; }
.stuck-card { display: flex; align-items: flex-start; flex-direction: column; justify-content: center; padding: 24px 25px; background: var(--plum-bg); color: var(--plum-ink); border-color: transparent; }
.stuck-card h2 { font-size: 1.52rem; margin: 12px 0 8px; }
.stuck-card p { font-size: .96rem; max-width: 33ch; }
.stuck-card > .button { margin-top: 17px; }
.icon-badge { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--mint); color: var(--mint-ink); flex: none; }
.icon-badge.study { background: var(--plum-bg); color: var(--plum-ink); }
.icon-badge.stuck { background: var(--surface); color: var(--plum-ink); border: 1px solid var(--rule); }
.fast-work { display: flex; align-items: center; gap: 11px; min-height: 64px; }
.fast-work > div { flex: 1; min-width: 0; }
.fast-work p { color: var(--muted); font-size: .83rem; margin-top: 3px; }
.fast-work .button { white-space: nowrap; }
.mini-clock, .clock, .clock-inline { font-variant-numeric: tabular-nums; }
.action-divider { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 12px; padding-top: 13px; border-top: 1px solid var(--rule); }
.action-divider .button { font-size: .84rem; }
.small-card .section-heading { margin-bottom: 3px; }
.small-card { padding-block: 15px; }
.mini-description { color: var(--muted); white-space: pre-wrap; }
.goal-list { display: grid; gap: 8px; }
.goal-list > div { display: grid; gap: 3px; }
.goal-list span { line-height: 1.15; }

.button, .icon-button { display: inline-flex; justify-content: center; align-items: center; border: 1px solid var(--rule); border-radius: 8px; color: var(--text); background: var(--surface); text-decoration: none; gap: 7px; font-size: .88rem; font-weight: 630; line-height: 1.24; min-height: 42px; padding: 7px 12px; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: var(--mint); }
.icon-button { min-width: 42px; padding: 5px; background: transparent; }
.button.primary { background: #286044; color: #fff; border-color: #286044; }
.button.primary:hover:not(:disabled) { background: #1d4d36; }
.button.plum-button { background: var(--plum-button); color: #fff; border-color: var(--plum-button); }
.button.plum-button:hover { filter: brightness(1.1); background: var(--plum-button); }
.button.hero-button { background: var(--surface); color: var(--text); border-color: transparent; }
.button.hero-button:hover { border-color: var(--hero-line); background: var(--surface); }
.button.danger { color: var(--danger); }
.button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.button.ghost.danger { color: var(--danger); }
.button.small { min-height: 38px; font-size: .83rem; }
.section-heading > .button.small { flex-shrink: 0; }
.actions, .form-end { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.form-end { justify-content: flex-end; margin-top: 17px; }
.form-end.spread :first-child { margin-right: auto; }
.note { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); background: var(--bg); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 12px; font-size: .88rem; margin: 12px 0; }
.note svg { margin-top: 2px; }
.muted, .empty { color: var(--muted); font-size: .9rem; }
.empty { padding: 10px 0; }
.activity-grid, .stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
.activity-card, .stat { background: var(--surface); padding: 16px; border: 1px solid var(--rule); border-radius: var(--radius); }
.activity-card h3 { margin: 10px 0 9px; }
.activity-card p, .stat p, .stat small { color: var(--muted); font-size: .87rem; }
.clock, .stat strong { font-size: clamp(1.26rem, 2.2vw, 1.8rem); letter-spacing: -.03em; line-height: 1.18; }
.activity-card .actions { margin-top: 12px; }
.stat strong { display: block; margin: 6px 0; }
.record { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--rule); min-height: 58px; }
.record-text { flex: 1; min-width: 0; }
.record-text p { color: var(--muted); margin-top: 4px; font-size: .89rem; white-space: pre-wrap; }
.record .button, .record .icon-button { flex-shrink: 0; }
.record .actions { justify-content: flex-end; }
.record .icon-button { min-height: 38px; min-width: 38px; }
.chart-area { position: relative; min-width: 0; }
.chart { width: 100%; max-width: 100%; display: block; overflow: visible; }
.chart text { font-family: inherit; font-size: 13px; fill: var(--muted); }
.chart-grid { stroke: var(--rule); }
.bar-work { fill: var(--work); background: var(--work); }
.bar-study { fill: var(--study); background: var(--study); }
.bar-zero { fill: var(--muted); }
.chart-empty { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); min-width: max-content; font-size: .86rem; background: var(--surface); border: 1px solid var(--rule); color: var(--muted); padding: 5px 9px; border-radius: 7px; }
.legend { display: flex; gap: 16px; justify-content: center; margin: 10px 0 0; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.legend i { width: 9px; height: 9px; border-radius: 2px; }
.sleep-range { stroke: var(--study); stroke-width: 6; stroke-linecap: round; }
.sleep-threshold { fill: var(--study); }
.data-summary { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 0; }
.tag { font-size: .81rem; border: 1px solid var(--rule); border-radius: 6px; padding: 4px 8px; }
.counts { margin: 0; }
.counts > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.counts dd { margin: 0; font-weight: 630; }
.segmented { display: flex; gap: 3px; flex-wrap: wrap; padding: 4px; border: 1px solid var(--rule); border-radius: 9px; width: fit-content; background: var(--bg); }
.segmented button { min-height: 35px; border: 0; border-radius: 6px; background: transparent; padding: 4px 12px; }
.segmented button[aria-pressed="true"] { background: var(--mint); color: var(--mint-ink); font-weight: 640; }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); }
th { color: var(--muted); }
.range { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.range .fields { margin: 0; }

progress { width: min(100%, 20rem); height: 12px; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 9px 0; font-size: .89rem; font-weight: 580; }
.field input, select, textarea { width: 100%; min-width: 0; min-height: 42px; padding: 8px 10px; border: 1px solid var(--rule); background: var(--bg); border-radius: 7px; font-size: 1rem; font-weight: 400; }
.field input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 13px; }
.fields.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.fields.inline .field { margin: 0; }
fieldset { padding: 0; border: 0; margin: 13px 0; min-width: 0; }
legend { font-weight: 630; margin-bottom: 6px; }
.checkbox { display: flex; align-items: center; gap: 8px; min-height: 38px; font-size: .91rem; }
.checkbox input, .choice input { width: 1.1em; height: 1.1em; accent-color: var(--accent); flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.option-grid > .button { justify-content: flex-start; text-align: left; }
.option-grid fieldset { grid-column: 1 / -1; }
.choice { display: inline-flex; align-items: center; gap: 6px; margin: 0 5px 6px 0; padding: 5px 8px; min-height: 42px; border: 1px solid var(--rule); border-radius: 8px; font-size: .9rem; cursor: pointer; }
.choice:has(input:checked) { color: var(--mint-ink); background: var(--mint); }
details { border-top: 1px solid var(--rule); margin-top: 10px; padding: 6px 0; }
summary { padding: 7px 0; font-weight: 630; font-size: .91rem; }
details p, details li { margin: 6px 0; }
ol { padding-inline-start: 23px; }
.steps li { margin: 7px 0; }
.report-preview { width: 100%; }

dialog { background: var(--surface); color: var(--text); width: min(600px, calc(100% - 28px)); max-height: min(90dvh, 740px); border: 1px solid var(--rule); padding: 19px 22px 22px; border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
dialog::backdrop { background: #102018a3; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 11px; }
.dialog-head h2 { font-size: 1.4rem; }
.dialog-head .icon-button { border-color: transparent; }
.form-error { background: var(--warning); color: var(--danger); padding: 9px; margin-bottom: 10px; border-radius: 8px; }
.modal-date { margin-bottom: 10px; }
.update-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 20px; color: var(--mint-ink); background: var(--mint); }
.toast { position: fixed; z-index: 4; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); max-width: min(360px, 95vw); background: var(--sidebar); color: var(--sidebar-ink); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 14px; box-shadow: var(--shadow); }
.toast[data-error="true"] { background: var(--warning); color: var(--danger); }

@media (max-width: 1120px) {
  .sidebar { width: 214px; padding-inline: 15px; }
  .workspace { margin-left: 214px; }
  main { padding-inline: 26px; }
  .card { padding-inline: 17px; }
  .fast-work .button svg { display: none; }
  .activity-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .dashboard-main { grid-template-columns: minmax(0, 1fr); }
  .overview-card .chart-area { max-width: 570px; margin-inline: auto; }
}

@media (max-width: 760px) {
  .mobile-header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 4; min-height: 59px; padding: max(8px, env(safe-area-inset-top)) 15px 8px; background: var(--sidebar); color: var(--sidebar-ink); }
  .mobile-header .brand { font-size: 1.24rem; }
  .mobile-header .brand-mark { width: 32px; height: 32px; }
  .mobile-header .icon-button { color: var(--sidebar-ink); border-color: #ffffff38; }
  .mobile-header .icon-button:hover { background: var(--nav-current); }
  .sidebar { display: none; z-index: 3; inset: 59px auto 0 0; width: min(290px, 82vw); padding-top: 19px; }
  .sidebar.is-open { display: flex; }
  .desktop-brand { display: none; }
  .scrim { display: block; z-index: 2; position: fixed; inset: 59px 0 0; background: #10201891; }
  .workspace { margin: 0; }
  main { padding: 23px 17px 30px; }
  .page-heading { align-items: flex-start; }
  .page-heading .date-pill { margin-top: 5px; }
  .button, .icon-button, .button.small, .record .icon-button { min-height: 44px; }
  .icon-button { min-width: 44px; }
  .field input, select { min-height: 44px; }
}

@media (max-width: 520px) {
  .page-heading { flex-wrap: wrap; gap: 11px; margin-bottom: 17px; }
  .page-heading > div { flex-basis: 100%; }
  .page-heading .date-pill { margin: 0; }
  .dashboard-top, .dashboard-bottom, .two-up { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .dashboard-top, .dashboard-main { margin-bottom: 12px; gap: 12px; }
  .program-hero { padding: 20px; min-height: 212px; }
  .program-content { max-width: 87%; }
  .program-etch { opacity: .39; }
  .stuck-card { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 6px 9px; padding: 16px; }
  .stuck-card h2 { margin: 0; }
  .stuck-card p, .stuck-card .button { grid-column: 2; }
  .stuck-card > .button { margin-top: 4px; justify-self: start; }
  .fast-work { gap: 8px; }
  .fast-work .button { padding-inline: 8px; font-size: .81rem; white-space: normal; }
  .fast-work .icon-badge { width: 34px; height: 34px; }
  .fast-work .icon-button { min-width: 34px; }
  .field input[type="date"], .field input[type="datetime-local"], .field input[type="time"] { min-height: 44px; }
  .record .icon-badge { display: none; }
  dialog { padding: 14px 15px 17px; }
  .check-grid { grid-template-columns: 1fr; }
}
