/* Responsive layout: stable timer sizing and natural card flow. */
:root {
  --shell-max: 1920px;
  --shell-pad: clamp(12px, 2vw, 32px);
  --aux-width: clamp(200px, calc((min(100vw, var(--shell-max)) - 2 * var(--shell-pad) - 2 * var(--layout-gap)) * .225), 410px);
  --layout-gap: clamp(14px, 1.4vw, 24px);
  --timer-size: 320px;
  --shadow: 0 12px 32px -16px rgba(32, 54, 44, .24), 0 2px 6px rgba(32, 54, 44, .04);
  --shadow-soft: 0 5px 16px -10px rgba(32, 54, 44, .2);
}
html[data-theme="dark"] {
  --shadow: 0 12px 32px -16px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .15);
  --shadow-soft: 0 5px 16px -10px rgba(0, 0, 0, .4);
}
body { overflow-x: clip; }
.site-header, .app-shell, .site-footer { width: min(100%, var(--shell-max)); margin-inline: auto; }
.site-header { padding: 16px max(var(--shell-pad), env(safe-area-inset-right)) 8px max(var(--shell-pad), env(safe-area-inset-left)); }
.app-shell { padding-inline: max(var(--shell-pad), env(safe-area-inset-left)) max(var(--shell-pad), env(safe-area-inset-right)); }
.site-footer { padding: 16px var(--shell-pad) max(20px, env(safe-area-inset-bottom)); }
.vertical-note, .ambient-orb, .rail-quote { display: none; }
.mode-bar { gap: 16px; margin: 4px 0 16px; }
.mode-note { max-width: 32ch; font-size: 12px; }
.segment { min-width: 0; min-height: 44px; padding: 8px 14px; }
.segment-copy small, .phase-tab span, .primary-action kbd, .preset span { opacity: 1; }
.history-empty span, .split-empty, .footer-quote, .plan-library-label small, .record-btn.is-active small { opacity: 1; }
.plan-chip.is-done { opacity: 1; border-style: dashed; }
.week-chart.is-empty::before { opacity: 1; }
.segment-copy b { letter-spacing: .04em; }
.segment-copy small { font-size: 12px; letter-spacing: 0; }
.segment-copy small, .segment-copy b { white-space: normal; }
.page-grid { display: grid; grid-template-columns: var(--aux-width) minmax(0, 1fr); gap: var(--layout-gap); align-items: start; }
.insight-rail { display: grid; gap: var(--layout-gap); min-width: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) var(--aux-width); gap: var(--layout-gap); align-items: start; }
.side-stack { display: grid; gap: var(--layout-gap); min-width: 0; max-height: none; overflow: visible; padding: 0; }
.sheet { overflow: visible; }
.timer-sheet { padding: 20px clamp(16px, 2vw, 30px) 16px; min-height: var(--timer-sheet-min-height, 0px); gap: 10px; }
.timer-sheet::after { display: none; }
.sheet-title h1 { font-size: clamp(22px, 2vw, 28px); }
.sheet-top { gap: 8px; align-items: center; }
.status-pill { padding: 6px 9px; margin: 0; font-size: 12px; letter-spacing: 0; }
.eyebrow { font-size: 12px; letter-spacing: .12em; }
.practice-band { margin: 0; padding: 6px 10px; gap: 8px; }
.practice-band-item { font-size: 12px; }
.practice-band-item:last-child { display: none; }
.question-target { width: min(100%, clamp(240px, 65%, 380px)); display: grid; grid-template-columns: auto minmax(50px, 1fr) auto; gap: 8px; margin: 0 auto; padding: 0; background: none; border: 0; }
.question-target-label { font-size: 12px; }
.question-target-field input { height: 44px; font-size: 16px; }
.question-target-set { min-height: 44px; font-size: 12px; padding-inline: 12px; }
.timer-wrap { width: min(100%, var(--timer-size)); flex: 0 0 auto; aspect-ratio: 1; margin: auto; }
.timer-center { width: 74%; padding: 10px; aspect-ratio: 1; }
.timer-digits { font-size: clamp(28px, calc(var(--timer-size) * .12), 60px); font-weight: 400; line-height: 1.15; margin-top: 8px; letter-spacing: 0; }
.timer-kicker, .timer-sub { font-size: 12px; letter-spacing: .03em; }
.timer-sub { margin-top: 8px; line-height: 1.4; max-width: 100%; overflow-wrap: anywhere; }
.control-deck { gap: 10px; margin: 0; }
.primary-action { width: clamp(144px, 16vw, 192px); height: 48px; padding-inline: 12px; font-size: 15px; }
.primary-action:not(.is-running) { color: var(--action-text); background: var(--action-bg); box-shadow: 0 8px 20px -8px rgba(199, 53, 44, .55); }
.primary-action:not(.is-running):not(:disabled):hover { background: var(--action-hover); box-shadow: 0 10px 24px -8px rgba(199, 53, 44, .65); }
.primary-action:not(.is-running):not(:disabled):active { background: var(--action-active); box-shadow: 0 3px 10px -5px rgba(199, 53, 44, .5); }
.primary-action:not(.is-running):focus-visible { outline: 3px solid var(--cinnabar); outline-offset: 4px; }
.round-btn, .record-btn { width: 48px; height: 48px; border-radius: 14px; }
.record-btn { width: 76px; }
.record-btn small { font-size: 12px; white-space: nowrap; letter-spacing: 0; }
.under-controls, .pomo-sheet .under-controls { margin: 0; padding: 0; gap: 8px; min-height: 44px; }
.control-hint { font-size: 12px; line-height: 1.5; }
.control-hint kbd { font-size: 12px; }
.under-controls > .control-hint { text-align: right; }
.text-btn, .link-btn { min-height: 44px; min-width: 44px; padding: 8px; font-size: 12px; }
.chrome-btn, .icon-close, .countdown-remove { min-width: 44px; min-height: 44px; }
.plan-row-actions button { min-width: 44px; min-height: 44px; }
.phase-switch { margin: 0; padding: 3px; gap: 3px; }
.phase-tab { min-height: 44px; padding: 4px 6px; }
.phase-tab span { font-size: 12px; }
.primary-action.is-running, .primary-action.is-running:hover { color: var(--action-text); background: var(--action-paused); }
.pomo-sheet[data-phase="short"] .primary-action.is-running { color: var(--action-text); background: #24634f; }
.pomo-sheet[data-phase="long"] .primary-action.is-running { color: var(--action-text); background: #74541d; }
.glance-sheet, .countdown-sheet, .progress-sheet, .practice-log-sheet, .history-sheet, .today-sheet, .rhythm-sheet { padding: 18px; }
.sheet-heading { gap: 8px; flex-wrap: wrap; }
.sheet-heading h2, .insight-rail h2 { font-size: 20px; }
.metric-grid { margin-top: 14px; }
.metric-grid > div { padding: 10px; }
.metric-grid dt, .metric-grid dd small, .glance-grid dt, .glance-grid dd small { font-size: 12px; }
.metric-grid dd { font-size: 20px; overflow-wrap: anywhere; }
.question-hint, .question-target-hint, .practice-splits-head, .pace-note p, .practice-note p { font-size: 12px; line-height: 1.6; }
.question-count { max-width: 100%; white-space: normal; font-size: 12px; }
.history-copy b, .history-copy span, .countdown-item-copy b, .countdown-item-copy small { overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }
.history-item { min-height: 64px; }
.history-copy { min-width: 0; }
.history-badge, .history-mark { font-size: 12px; }
.countdown-item { padding: 10px 0; gap: 8px; }
.countdown-item-days span, .countdown-date, .countdown-name, .countdown-count { font-size: 12px; }
.countdown-item-days strong { font-size: 22px; }
.countdown-item-copy { min-width: 0; }
.countdown-actions { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.glance-caption, .site-footer p { font-size: 12px; }
.glance-hero strong { font-size: 44px; }
.glance-grid > div { padding: 9px; }
.exam-plan-bar { margin: 0; padding: 8px 10px; }
.plan-bar-top { gap: 8px; flex-wrap: wrap; }
.plan-current { flex: 1 1 160px; }
.plan-current strong, #examPlanName { max-width: 100%; white-space: normal; overflow: visible; text-overflow: clip; font-size: 14px; line-height: 1.5; }
.plan-current span { font-size: 12px; }
.plan-edit { min-height: 44px; font-size: 12px; }
.exam-sections { padding: 16px; }
.exam-sections summary { cursor: pointer; min-height: 44px; padding: 10px 0; font-size: 14px; font-weight: 600; }
.plan-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px; overflow: visible; margin-top: 10px; }
.plan-chip { min-width: 0; display: flex; flex-wrap: wrap; white-space: normal; padding: 10px; }
.plan-chip b, .plan-chip small, .plan-chip em { font-size: 12px; overflow-wrap: anywhere; }
.plan-chip b { flex-basis: 100%; }
body[data-mode="stats"] .page-grid { display: block; }
body[data-mode="stats"] .insight-rail { display: none; }
.stats-page { width: min(100%, 1200px); margin-inline: auto; }
.stats-chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(2px, .6vw, 8px); height: 240px; overflow: visible; padding: 12px 0 0; }
.stats-chart[data-range="30"] { display: grid; grid-auto-flow: initial; grid-auto-columns: auto; grid-template-columns: repeat(30, minmax(0, 1fr)); }
.stats-day { position: relative; display: flex; height: 100%; min-width: 0; width: 100%; padding: 0 0 24px; gap: 0; border: 0; background: none; color: inherit; }
.stats-day:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 1px; border-radius: 4px; }
.stats-day[aria-pressed="true"] .stats-bar { box-shadow: 0 0 0 2px var(--cinnabar); }
.stats-bar-slot { flex: 1; height: auto; min-height: 0; }
.stats-bar { width: min(28px, 75%); }
.stats-label, .stats-chart[data-range="30"] .stats-label { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-size: 12px; line-height: 1.4; }
.stats-day:first-child .stats-label { left: 0; transform: none; }
.stats-day:last-child .stats-label { left: auto; right: 0; transform: none; }
.stats-day-detail { margin-top: 16px; min-height: 44px; font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.stats-data { margin-top: 8px; }
.stats-data summary { min-height: 44px; padding-block: 10px; cursor: pointer; font-size: 13px; }
.stats-data table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.stats-data th, .stats-data td { padding: 10px 4px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.stats-card-note, .stats-period-caption, .stats-chart-legend, .stats-footnote { font-size: 12px; }
.stats-period button { min-height: 44px; font-size: 13px; }
.stats-mode-row small, .stats-legend dt, .stats-donut-hole span { font-size: 12px; }
/* A dialog owns its shadow. Only its content body may scroll. */
dialog { width: min(780px, calc(100% - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: var(--card-solid); box-shadow: 0 20px 64px -20px rgba(0, 0, 0, .4); }
dialog[open] { display: flex; flex-direction: column; }
dialog:not([open]) { display: none; }
#settingsForm, #planForm { width: 100%; min-height: 0; max-height: inherit; border: 0; border-radius: 0; background: none; box-shadow: none; overflow: hidden; }
.dialog-head, .dialog-actions { flex-shrink: 0; padding: 16px 20px; }
.dialog-head h2 { font-size: 24px; }
.dialog-head p { font-size: 12px; line-height: 1.6; }
.settings-body, .plan-dialog-body { min-height: 0; padding: 16px 20px; overflow-y: auto; overscroll-behavior: contain; }
.plan-dialog { width: min(1040px, calc(100% - 24px)); }
.plan-dialog-body { align-items: start; }
.plan-section-list { max-height: none; overflow: visible; }
.field input, .field select, .plan-search input, .plan-name-field input, .plan-row input, #planNameInput { font-size: 16px; }
.countdown-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; }
.field-error { color: var(--cinnabar-deep); font-size: 13px; padding-block: 8px; line-height: 1.6; }
[aria-invalid="true"] { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
.dialog-action-group .ghost-btn, .dialog-action-group .small-primary, .finish-actions button, .restore-actions button { min-height: 44px; }
.finish-dialog, .restore-dialog { width: min(520px, calc(100% - 24px)); padding: 0; }
.finish-body, .restore-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px; }
.finish-actions, .restore-actions { flex: 0 0 auto; margin: 0; padding: 14px 20px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.finish-dialog h2, .restore-dialog h2 { font-size: 24px; }
.restore-copy, .restore-item b, .restore-item small, .restore-saved, .finish-summary, .finish-question-hint { font-size: 12px; }
.restore-item { flex-wrap: wrap; gap: 4px 12px; }
.restore-item em { font-size: 14px; }
.finish-stats { flex-wrap: wrap; }
.finish-stats strong { font-size: 22px; }
.fallback-backdrop { position: fixed; inset: 0; z-index: 999; background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog.is-fallback-open { position: fixed; z-index: 1000; left: 50%; top: 50%; margin: 0; transform: translate(-50%, -50%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); animation: none; }
dialog.is-fallback-open::before { content: none; }
body.has-fallback-dialog > :not(dialog):not(.fallback-backdrop) { pointer-events: none; }
body.is-focus-mode .page-grid { max-width: none; }
body.is-focus-mode .workspace { max-width: 820px; }
body.is-focus-mode .timer-sheet { max-width: 820px; }
.focus-exit { min-height: 44px; }
@media (min-width: 1000px) and (max-width: 1399px) {
  .side-stack .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-stack .metric-grid > div { padding: 6px; }
  .side-stack .metric-grid dd { font-size: 16px; }
  .side-stack .pace-note, .side-stack .practice-note { padding: 10px; }
  .side-stack .question-actions { flex-wrap: wrap; }
  .side-stack .question-actions > button { flex: 1 1 100%; }
}
@media (max-width: 999px) {
  .page-grid { display: flex; flex-direction: column; gap: 20px; }
  .view-area { order: 1; width: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .timer-sheet { width: min(100%, 760px); margin-inline: auto; }
  .side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight-rail { order: 2; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-top-grid, .stats-bottom-grid { grid-template-columns: 1fr; }
  .mode-note { display: none; }
  .plan-dialog-body { grid-template-columns: 1fr; }
  .plan-editor { order: -1; }
}
@media (max-width: 700px) {
  .site-header { padding-block: 8px 4px; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; font-size: 22px; border-radius: 12px; }
  .brand-copy strong { font-size: 20px; }
  .brand-copy span, .live-clock, .chrome-btn > span, .segment-icon, .segment-copy small { display: none; }
  .brand { gap: 8px; }
  .header-tools { gap: 6px; }
  .chrome-btn { width: 44px; height: 44px; padding: 0; }
  .mode-bar { margin: 4px 0 10px; }
  .segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; padding: 3px; gap: 2px; }
  .segment { padding: 6px 2px; justify-content: center; }
  .segment-copy b { font-size: 12px; letter-spacing: 0; white-space: nowrap; }
  .timer-sheet { padding: 14px; gap: 8px; }
  .sheet-title .eyebrow, .practice-band { display: none; }
  .sheet-title h1 { font-size: 23px; }
  .status-pill { padding: 5px 8px; }
  .under-controls > .control-hint, .pomo-sheet .under-controls > .control-hint:first-child { display: none; }
  .pomo-sheet .under-controls { display: none; }
  .under-controls { justify-content: center; }
  .primary-action { width: 146px; font-size: 15px; }
  .control-deck { gap: 8px; }
  .phase-tab { padding: 3px 2px; }
  .phase-tab b, .phase-tab span { font-size: 12px; }
  .side-stack, .insight-rail { grid-template-columns: 1fr; }
  .stats-page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .stats-period { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .stats-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-mini-grid > div { padding: 12px; border: 0; border-bottom: 1px solid var(--line); }
  .stats-mini-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .stats-mini-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
  .stats-overview, .stats-split-card, .stats-chart-card, .stats-countdown-card, .stats-mode-card-wrap { padding: 18px; }
  .stats-split-body { flex-wrap: wrap; gap: 20px; }
  .stats-legend { flex: 1 1 160px; }
  .stats-chart-legend { flex-wrap: wrap; gap: 8px; }
  .stats-total strong { font-size: 40px; }
  .stats-chart { height: 220px; }
  .plan-current { flex-basis: 130px; }
  .plan-current strong { font-size: 13px; }
  .plan-current .plan-label { display: none; }
  #examPlanMeta { display: none; }
  .plan-edit { padding-inline: 8px; }
  .field-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dialog-head, .dialog-actions { padding: 12px 14px; gap: 8px; }
  .dialog-head .eyebrow { display: none; }
  .dialog-head h2 { font-size: 22px; }
  .dialog-head p { margin-top: 3px; }
  .settings-body, .plan-dialog-body { padding: 14px; }
  .countdown-row { grid-template-columns: minmax(0,1fr) 44px; }
  .countdown-row .field { grid-column: 1; }
  .countdown-remove { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-action-group { flex: 1; justify-content: flex-end; gap: 8px; }
  .dialog-action-group button { min-width: 80px; }
  .plan-row { grid-template-columns: 22px minmax(0,1fr) minmax(0,1fr) 44px; }
  .plan-row-name { grid-column: 2 / span 2; }
  .plan-num { grid-row: 2; }
  .plan-min { grid-column: 2; }
  .plan-q { grid-column: 3; }
  .plan-row-actions { grid-column: 4; grid-row: 1; }
  .plan-row-actions button { min-width: 44px; min-height: 44px; }
  .finish-body, .restore-body { padding: 18px; }
  .finish-actions, .restore-actions { padding: 10px; gap: 8px; }
  .finish-actions button, .restore-actions button { flex: 1; min-width: 0; padding-inline: 10px; }
  .finish-stats { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .finish-stats > div { display: flex; justify-content: space-between; gap: 8px; }
  .site-footer { display: block; }
  .footer-quote { display: none; }
}
@media (max-height: 850px) {
  .practice-band, .sheet-title .eyebrow { display: none; }
  .segment-copy small { display: none; }
  .timer-sheet { gap: 8px; padding-top: 14px; padding-bottom: 12px; }
  .brand-copy span { display: none; }
  .site-header { padding-top: max(8px, env(safe-area-inset-top)); }
  .mode-bar { margin-bottom: 10px; }
}
/* At very low heights the ring and controls form one centered horizontal unit. */
@media (min-width: 600px) and (max-height: 520px) {
  .mode-note, .brand-copy span, .live-clock { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .site-header { padding-block: 4px; }
  .chrome-btn { height: 44px; }
  .mode-bar { margin: 0 0 8px; }
  .segment { min-height: 44px; padding-block: 4px; }
  .page-grid { display: flex; flex-direction: column; }
  .view-area { order: 1; width: 100%; }
  .insight-rail { order: 2; width: 100%; grid-template-columns: repeat(3,minmax(0,1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .timer-sheet { width: min(100%, 820px); display: grid; grid-template-columns: minmax(220px,1fr) minmax(200px,1fr); grid-template-rows: auto auto auto 1fr; column-gap: 16px; row-gap: 4px; min-height: 0; padding: 12px 16px; }
  .timer-sheet .sheet-top { grid-column: 1 / -1; grid-row: 1; }
  .timer-wrap { grid-column: 1; grid-row: 2 / span 3; width: 220px; margin: auto; }
  .question-target, .exam-plan-bar, .phase-switch { grid-column: 2; grid-row: 2; align-self: center; }
  .control-deck { grid-column: 2; grid-row: 3; }
  .under-controls { grid-column: 2; grid-row: 4; justify-content: center; }
  .under-controls > .control-hint { display: none; }
  .pomo-sheet .under-controls { display: none; }
  .timer-sheet .primary-action { width: 140px; }
  .timer-sheet .round-btn, .timer-sheet .record-btn { width: 44px; height: 44px; }
  .timer-sheet .record-btn { width: 76px; }
  .control-deck { gap: 6px; }
  .question-target-label { grid-column: 1 / -1; }
  .question-target { grid-template-columns: minmax(0,1fr) auto; gap: 4px; }
  .phase-tab span { display: none; }
  .plan-current { flex-basis: 100%; }
  .exam-plan-bar { display: flex; padding: 4px 8px; }
  .plan-bar-top { gap: 0 8px; }
  #examPlanMeta { display: none; }
  .plan-edit { min-height: 36px; }
  body.is-focus-mode .app-shell { padding-block: 12px; }
  .restore-icon, .finish-seal { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media (forced-colors: active) {
  .sheet, dialog, button, input, select { border: 1px solid CanvasText; }
  .stats-bar { forced-color-adjust: none; }
}
@media print {
  body { background: #fff; }
  .site-header, .mode-bar, .site-footer, .control-deck, .under-controls, dialog, .toast, .focus-exit { display: none !important; }
  .sheet { box-shadow: none; backdrop-filter: none; }
  .page-grid, .workspace { display: block; }
}

/* Study dashboard: real activity, clear hierarchy, and a compact habit calendar. */
.stats-overview { position: relative; background: linear-gradient(125deg, var(--jade-soft), transparent 75%), var(--card); border-top: 3px solid var(--jade); }
.stats-comparison { display: inline-block; margin-top: 14px; padding: 6px 10px; border-radius: 8px; color: var(--jade); background: var(--jade-soft); font-size: 12px; }
.stats-comparison[data-trend="down"] { color: var(--cinnabar); background: var(--cinnabar-soft); }
.stats-insights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stats-insight { display: flex; align-items: flex-start; gap: 12px; padding: 20px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); }
.stats-insight-icon { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 10px; color: var(--jade); background: var(--jade-soft); font-size: 21px; }
.stats-insight:nth-child(2) .stats-insight-icon { color: var(--cinnabar); background: var(--cinnabar-soft); }
.stats-insight:nth-child(3) .stats-insight-icon { color: var(--gold); background: var(--gold-soft); }
.stats-insight > div { min-width: 0; }
.stats-insight div > span { font-size: 12px; color: var(--ink-soft); }
.stats-insight strong { display: block; margin: 5px 0 6px; font-size: clamp(18px, 2vw, 25px); font-family: var(--font-num); font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.stats-insight small { display: block; color: var(--muted); font-size: 12px; }
.stats-chart { background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%); }
.stats-habit-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.stats-calendar-card, .stats-reflection-card { min-width: 0; padding: 22px 23px; }
.stats-calendar-scroll { overflow-x: auto; padding: 4px 4px 10px; margin: 18px -4px 0; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.stats-calendar { min-width: 760px; --heat-empty: #ebedf0; --heat-1: #9be9a8; --heat-2: #40c463; --heat-3: #30a14e; --heat-4: #216e39; }
html[data-theme="dark"] .stats-calendar { --heat-empty: #202b25; --heat-1: #0e4429; --heat-2: #006d32; --heat-3: #26a641; --heat-4: #39d353; }
.stats-calendar-months, .stats-calendar-body { display: grid; grid-template-columns: 24px repeat(var(--calendar-weeks), minmax(10px, 1fr)); gap: 4px; }
.stats-calendar-months { margin-bottom: 8px; color: var(--muted); font-size: 12px; line-height: 18px; }
.stats-calendar-months span { white-space: nowrap; }
.stats-calendar-body { grid-template-rows: repeat(7, auto); }
.stats-calendar-weekday { grid-column: 1; align-self: center; color: var(--muted); font-size: 11px; line-height: 1; }
.stats-heat-cell, .stats-heat-key i { border: 1px solid var(--line); border-radius: 3px; background: var(--heat-empty, #ebedf0); }
.stats-heat-cell { min-width: 0; width: 100%; aspect-ratio: 1; padding: 0; cursor: pointer; }
.stats-heat-cell:hover { outline: 2px solid var(--ink-soft); outline-offset: 1px; }
.stats-heat-cell.is-today { box-shadow: inset 0 0 0 1px var(--ink-soft); }
.stats-heat-cell[aria-pressed="true"], .stats-heat-cell:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
.stats-heat-cell[data-level="1"], .stats-heat-key i[data-level="1"] { background: var(--heat-1, #9be9a8); }
.stats-heat-cell[data-level="2"], .stats-heat-key i[data-level="2"] { background: var(--heat-2, #40c463); }
.stats-heat-cell[data-level="3"], .stats-heat-key i[data-level="3"] { background: var(--heat-3, #30a14e); }
.stats-heat-cell[data-level="4"], .stats-heat-key i[data-level="4"] { background: var(--heat-4, #216e39); }
html[data-theme="dark"] .stats-heat-key { --heat-empty: #202b25; --heat-1: #0e4429; --heat-2: #006d32; --heat-3: #26a641; --heat-4: #39d353; }
.stats-calendar-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.stats-heat-key { display: inline-flex; align-items: center; gap: 4px; }
.stats-heat-key i { width: 12px; height: 12px; }
.stats-calendar-detail { min-height: 20px; margin-top: 12px; color: var(--ink-soft); font-size: 12px; }
.stats-reflection-card { background: linear-gradient(145deg, var(--gold-soft), transparent), var(--card); display: flex; flex-direction: column; justify-content: center; }
.stats-reflection-card h2 { margin-top: 6px; font-family: var(--font-display); font-size: 22px; }
.stats-reflection-card p { margin: 14px 0 20px; color: var(--ink-soft); font-size: 13px; line-height: 1.9; }
.stats-rhythm-track { height: 6px; margin-bottom: 10px; overflow: hidden; border-radius: 20px; background: var(--soft-strong); }
.stats-rhythm-track span { display: block; height: 100%; border-radius: inherit; background: var(--gold); transition: width .25s ease; }
@media (max-width: 1000px) {
  .stats-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-habit-grid { grid-template-columns: 1fr; }
}
@media (max-width: 599px) {
  .stats-page { gap: 14px; }
  .stats-insights { gap: 10px; }
  .stats-insight { padding: 14px 12px; gap: 8px; }
  .stats-insight-icon { flex-basis: 26px; height: 28px; font-size: 17px; }
  .stats-insight strong { font-size: 18px; }
  .stats-calendar-card, .stats-reflection-card { padding: 18px; }
  .stats-calendar-card .sheet-heading { flex-wrap: wrap; gap: 8px; }
}
@media (forced-colors: active) {
  .stats-heat-cell { forced-color-adjust: none; }
}

/* Weighted question pace is a primary study metric. */
.stats-pace-card { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr); align-items: center; gap: 32px; padding: 24px; border-left: 3px solid var(--cinnabar); background: linear-gradient(110deg, var(--cinnabar-soft), transparent 65%), var(--card); }
.stats-pace-main h2 { margin-top: 5px; font-family: var(--font-display); font-size: 21px; }
.stats-pace-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-top: 12px; }
.stats-pace-value strong { color: var(--cinnabar); font-family: var(--font-num); font-weight: 500; font-size: clamp(28px, 3vw, 40px); line-height: 1.3; }
.stats-pace-value > span { color: var(--muted); font-size: 13px; }
.stats-pace-context { border-left: 1px solid var(--line); padding-left: 28px; min-width: 0; }
.stats-pace-samples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; }
.stats-pace-samples dt { color: var(--muted); font-size: 12px; }
.stats-pace-samples dd { margin: 6px 0 0; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.stats-pace-samples b { font-family: var(--font-num); font-size: 22px; font-weight: 500; }
.stats-pace-context p { margin-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.stats-pace-context .stats-pace-missing { color: var(--cinnabar); margin-top: 6px; }
@media (max-width: 700px) {
  .stats-pace-card { grid-template-columns: 1fr; gap: 18px; padding: 20px 18px; }
  .stats-pace-context { border-left: 0; border-top: 1px solid var(--line); padding: 18px 0 0; }
  .stats-pace-samples { gap: 10px; }
}

/* The harvest lives beside the title, keeping the clock clear. */
.timer-heading { display: grid; justify-items: start; gap: 7px; min-width: 0; }
.timer-heading .status-pill { padding: 3px 8px; font-size: 11px; }
.pomo-sheet .sheet-top { align-items: flex-start; }
.pomo-sheet .cycle-block { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 7px; width: auto; margin: 0; padding: 3px 0 0; border: 0; border-radius: 0; background: none; }
.pomo-sheet .cycle-label { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; font-size: 11px; letter-spacing: .04em; color: var(--muted); }
.pomo-sheet .cycle-label span:last-child { font-size: 12px; color: var(--ink-soft); font-weight: 600; letter-spacing: .02em; }
.pomo-sheet .round-dots { display: grid; grid-template-columns: repeat(var(--harvest-columns, 4), 26px); gap: 5px; flex: none; margin: 0; min-width: 0; }
.pomo-sheet .round-dot { display: grid; place-items: center; width: 26px; height: 28px; padding: 0; border-radius: 0; background: none; box-shadow: none; }
.pomo-sheet .round-dot svg { width: 100%; height: 100%; overflow: visible; }
.pomo-sheet .round-dot { --fruit-fill: var(--soft-strong); --fruit-edge: var(--line-strong); --leaf-fill: var(--line-strong); --fruit-shade: var(--line); --fruit-shine: var(--card-raised); }
.pomo-sheet .tomato-fruit { fill: var(--fruit-fill); stroke: var(--fruit-edge); stroke-width: 1.2; stroke-linejoin: round; }
.pomo-sheet .tomato-shade { fill: var(--fruit-shade); }
.pomo-sheet .tomato-highlight { stroke: var(--fruit-shine); stroke-width: 2.6; stroke-linecap: round; opacity: .75; }
.pomo-sheet .tomato-leaf { fill: var(--leaf-fill); }
.pomo-sheet .tomato-stem { stroke: var(--leaf-fill); stroke-width: 2.5; stroke-linecap: round; }
.pomo-sheet .round-dot.is-filled { --fruit-fill: #ed5946; --fruit-edge: #cf4235; --leaf-fill: #458156; --fruit-shade: #d94635; --fruit-shine: #ffcdc0; }
.pomo-sheet .round-dot.is-current { --fruit-fill: var(--cinnabar-soft); --fruit-edge: var(--cinnabar); --leaf-fill: var(--jade); --fruit-shade: var(--cinnabar-soft); background: none; box-shadow: none; }
html[data-theme="dark"] .pomo-sheet .round-dot.is-filled { --fruit-fill: #f1745d; --fruit-edge: #e55b47; --leaf-fill: #83bc7b; --fruit-shade: #dc5845; --fruit-shine: #ffe0cb; }
@media (max-width: 380px) {
  .pomo-sheet .round-dots { grid-template-columns: repeat(var(--harvest-columns, 4), 22px); gap: 3px; }
  .pomo-sheet .round-dot { width: 22px; height: 24px; }
  .pomo-sheet .cycle-label { gap: 6px; font-size: 10px; }
}

/* Shortcut hints stay with the action they trigger. */
.key-hint { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-width: 15px; padding: 1px 4px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--soft); color: inherit; font-family: var(--font-num); font-size: 10px; font-weight: 500; line-height: 1.2; letter-spacing: 0; }
.primary-action { gap: 8px; }
.primary-action kbd { display: inline-flex; padding: 2px 4px; font-size: 10px; line-height: 1.2; letter-spacing: 0; white-space: nowrap; }
.round-btn.has-shortcut { flex-direction: column; gap: 2px; }
.round-btn.has-shortcut .icon { width: 19px; height: 19px; }
.round-btn.has-shortcut .key-hint { font-size: 9px; min-width: 17px; padding: 0 3px; line-height: 12px; }
.record-caption { display: flex; align-items: center; justify-content: center; gap: 3px; }
.record-caption .key-hint { min-width: 13px; padding: 0 2px; font-size: 9px; line-height: 12px; }
@media (max-width: 599px) {
  .focus-trigger { flex-direction: column; gap: 1px; }
  .focus-trigger .icon { width: 18px; height: 18px; }
  .focus-trigger .key-hint { padding: 0 3px; font-size: 9px; line-height: 12px; }
}

/* One timer frame for practice, exam, and pomodoro. */
.timer-sheet, .timer-sheet.pomo-sheet[data-phase] { --ring-color: var(--cinnabar); --ring-soft: var(--cinnabar-soft); }
.timer-sheet { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 73px 44px; align-content: start; gap: 12px; }
.timer-sheet > .sheet-top { min-height: var(--timer-header-height, 82px); align-items: flex-start; }
.timer-sheet .sheet-title h1 { font-size: clamp(22px, 2vw, 28px); line-height: 1.25; }
.timer-direction { align-self: flex-start; margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: .03em; text-align: right; }
.timer-sheet > .timer-config { box-sizing: border-box; width: 100%; min-height: var(--timer-config-height, 68px); margin: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); }
.timer-sheet > .question-target { padding: 8px 12px; align-content: center; }
.timer-sheet > .exam-plan-bar { padding: 8px 12px; display: flex; align-items: center; }
.timer-sheet .plan-bar-top { width: 100%; }
.timer-sheet > .phase-switch { padding: 6px; align-content: center; }
.timer-sheet > .timer-wrap { margin: 0 auto; }
.timer-sheet .timer-center { width: 74%; padding: 10px; }
.timer-sheet .timer-digits { font-size: clamp(26px, calc(var(--timer-size) * .115), 56px); font-weight: 400; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.timer-sheet .timer-kicker { font-size: 12px; line-height: 1.3; letter-spacing: .08em; text-indent: 0; }
.timer-sheet .timer-sub { min-height: 34px; max-width: 100%; margin-top: 8px; font-size: 12px; line-height: 1.4; }
.timer-sheet > .control-deck { display: grid; grid-template-columns: 60px minmax(0, 192px) 60px; width: min(100%, 332px); gap: 10px; justify-content: center; align-items: center; margin: 0 auto; }
.timer-sheet .control-deck > :first-child { justify-self: center; }
.timer-sheet .control-deck > :last-child { justify-self: center; }
.timer-control { display: grid; grid-template-rows: 48px 18px; justify-items: center; align-items: center; gap: 7px; width: 100%; min-width: 0; }
.timer-control .action-shortcut { align-self: start; color: var(--muted); font-size: 10px; line-height: 14px; min-height: 18px; padding: 0 5px; }
.timer-control > .round-btn .icon { width: 22px; height: 22px; }
.timer-control:has(> button:disabled) .action-shortcut { opacity: .45; }
.secondary-timer-control { display: inline-flex; align-items: center; gap: 3px; }
.secondary-timer-control:has(> button:disabled) .key-hint { opacity: .45; }
.timer-sheet .primary-action { width: 100%; height: 48px; padding-inline: 8px; font-size: 14px; border-radius: 14px; }
.timer-sheet .record-btn { width: 60px; height: 48px; }
.timer-sheet .record-btn small { font-size: 10px; }
.timer-sheet > .under-controls { display: flex; justify-content: center; align-items: center; min-height: 44px; margin: 0; padding: 0; }
.timer-sheet .under-controls .control-hint { text-align: center; }
.timer-sheet.pomo-sheet[data-phase] .primary-action.is-running { color: var(--action-text); background: var(--action-paused); }
@media (max-width: 599px) {
  .timer-sheet { gap: 10px; }
  .timer-sheet .sheet-title h1 { font-size: 23px; }
  .timer-sheet .primary-action { font-size: 13px; }
  .timer-sheet > .timer-config { border-radius: 12px; }
  .timer-direction { font-size: 10px; max-width: 100px; }
}
@media (min-width: 600px) and (max-height: 520px) {
  .timer-sheet { grid-template-columns: minmax(220px, 1fr) minmax(200px, 1fr); grid-template-rows: auto auto 73px 44px; gap: 6px 16px; }
  .timer-sheet > .sheet-top { grid-column: 1 / -1; grid-row: 1; }
  .timer-sheet > .timer-config { grid-column: 2; grid-row: 2; }
  .timer-sheet > .timer-wrap { grid-column: 1; grid-row: 2 / span 3; margin: auto; }
  .timer-sheet > .control-deck { grid-column: 2; grid-row: 3; grid-template-columns: 44px minmax(0, 160px) 60px; gap: 6px; }
  .timer-sheet > .under-controls { grid-column: 2; grid-row: 4; }
}

/* Fullscreen studio: one clock, with live context beside it in every mode. */
body.is-focus-mode .app-shell {
  padding: max(76px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
body.is-focus-mode .page-grid { max-width: 1800px; }
body.is-focus-mode .workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
  align-items: stretch;
  gap: clamp(16px, 2vw, 32px);
  max-width: none;
}
body.is-focus-mode .timer-sheet {
  --timer-size: clamp(220px, calc(100dvh - 470px), 640px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) 73px auto;
  min-height: calc(100dvh - 100px);
  max-width: none;
  padding: clamp(20px, 1.7vw, 32px);
  gap: 12px;
  margin: 0;
}
body.is-focus-mode .timer-sheet > * { grid-column: 1; grid-row: auto; }
body.is-focus-mode .timer-sheet > .sheet-top { min-height: 68px; }
body.is-focus-mode .timer-sheet > .timer-config { min-height: 68px; }
body.is-focus-mode .timer-sheet > .timer-wrap {
  width: min(100%, var(--timer-size));
  align-self: center;
  margin: auto;
}
body.is-focus-mode .timer-sheet .timer-digits { font-size: clamp(32px, calc(var(--timer-size) * .125), 80px); }
body.is-focus-mode .timer-sheet .timer-kicker,
body.is-focus-mode .timer-sheet .timer-sub { font-size: clamp(12px, 1vw, 16px); }
body.is-focus-mode .side-stack {
  display: flex !important;
  flex-direction: column;
  gap: clamp(16px, 2vw, 32px);
}
body.is-focus-mode .side-stack > .sheet { padding: clamp(20px, 2vw, 32px); }
body.is-focus-mode .side-stack .history-sheet { display: none; }
body.is-focus-mode .practice-log-sheet,
body.is-focus-mode .progress-sheet,
body.is-focus-mode .today-sheet { flex: 1; }
body.is-focus-mode .practice-log-sheet { display: flex; flex-direction: column; }
body.is-focus-mode .practice-splits { flex: 1; margin-top: 24px; }
body.is-focus-mode .practice-splits .split-item { padding-block: 14px; }
body.is-focus-mode .side-stack .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 24px; }
body.is-focus-mode .side-stack .metric-grid > div { padding: clamp(12px, 1.5vw, 24px); }
body.is-focus-mode .side-stack .metric-grid dd { font-size: clamp(24px, 2.2vw, 36px); }
body.is-focus-mode .side-stack .question-hint { margin-top: 20px; font-size: 14px; line-height: 1.8; }
body.is-focus-mode .side-stack .pace-note { margin-top: 24px; padding: 16px; }
body.is-focus-mode .side-stack .question-actions { flex-wrap: nowrap; margin-top: 20px; }
body.is-focus-mode .side-stack .question-actions > button { flex: 1 1 0; }
body.is-focus-mode .exam-sections { order: 1; }
body.is-focus-mode .today-main { margin-top: 24px; }
body.is-focus-mode .today-main strong { font-size: clamp(56px, 5vw, 88px); }
body.is-focus-mode .week-chart { margin-top: 28px; }
body.is-focus-mode .rhythm-sheet .full-btn { display: none; }
body.is-focus-mode .timer-sheet > .under-controls { display: flex; min-height: 32px; }
body.is-focus-mode .under-controls > .control-hint { display: block; text-align: center; }

@media (min-width: 1600px) and (min-height: 900px) {
  body.is-focus-mode .app-shell { padding-inline: 4vw; }
  body.is-focus-mode .timer-sheet { --timer-size: clamp(220px, calc(100dvh - 530px), 640px); gap: 20px; }
  body.is-focus-mode .side-stack .sheet-heading h2 { font-size: 26px; }
  body.is-focus-mode .side-stack .question-target-hint,
  body.is-focus-mode .side-stack .pace-note p { font-size: 14px; }
}
@media (min-width: 1001px) and (max-height: 899px) {
  body.is-focus-mode .side-stack > .sheet { padding: 20px; }
  body.is-focus-mode .today-main { margin-top: 18px; }
  body.is-focus-mode .week-chart { margin-top: 18px; }
}
@media (max-width: 1000px) {
  body.is-focus-mode .workspace { grid-template-columns: minmax(0, 1fr); }
  body.is-focus-mode .timer-sheet {
    --timer-size: clamp(240px, calc(100dvh - 380px), 500px);
    min-height: 0;
  }
  body.is-focus-mode .side-stack { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  body.is-focus-mode .practice-log-sheet,
  body.is-focus-mode .progress-sheet { grid-column: 1 / -1; }
  body.is-focus-mode .exam-sections { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  body.is-focus-mode .app-shell { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  body.is-focus-mode .timer-sheet { padding: 18px 14px; gap: 12px; }
  body.is-focus-mode .timer-sheet > .sheet-top { min-height: 62px; }
  body.is-focus-mode .side-stack { grid-template-columns: minmax(0, 1fr); }
  body.is-focus-mode .side-stack > .sheet { padding: 20px; }
}
@media (min-width: 600px) and (max-height: 600px) {
  body.is-focus-mode .app-shell { padding-top: 76px; }
  body.is-focus-mode .workspace { grid-template-columns: minmax(0, 1fr); }
  body.is-focus-mode .timer-sheet {
    --timer-size: clamp(200px, calc(100dvh - 180px), 320px);
    grid-template-columns: minmax(200px, 1fr) minmax(240px, 1fr);
    grid-template-rows: auto auto 73px auto;
    min-height: 0;
    gap: 8px 20px;
    padding: 16px 20px;
  }
  body.is-focus-mode .timer-sheet > .sheet-top { grid-column: 1 / -1; grid-row: 1; }
  body.is-focus-mode .timer-sheet > .timer-wrap { grid-column: 1; grid-row: 2 / 5; }
  body.is-focus-mode .timer-sheet > .timer-config { grid-column: 2; grid-row: 2; }
  body.is-focus-mode .timer-sheet > .control-deck { grid-column: 2; grid-row: 3; }
  body.is-focus-mode .timer-sheet > .under-controls { grid-column: 2; grid-row: 4; }
  body.is-focus-mode .side-stack { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.settings-account p { margin: 8px 0; font-size: 13px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.settings-account .group-head { display: block; }
.settings-account .account-hint { color: var(--muted); font-size: 12px; }
.settings-account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.settings-account-actions .ghost-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: 12px; }
.settings-account [hidden] { display: none !important; }
.settings-account .field-error { color: var(--danger); }
