:root {
  --bg: #090b0d;
  --surface: rgba(20, 22, 22, .78);
  --surface-raised: rgba(35, 38, 38, .86);
  --surface-soft: rgba(14, 16, 16, .9);
  --line: rgba(232, 242, 246, .11);
  --line-soft: rgba(232, 242, 246, .075);
  --glass-shine: rgba(255, 255, 255, .075);
  --text: #f3f4f2;
  --muted: #9da5a3;
  --accent: #df5558;
  --accent-strong: #f06669;
  --accent-soft: rgba(223, 85, 88, .15);
  --success: #85c89e;
  --shadow: 0 8px 24px rgba(0, 0, 0, .13), inset 0 1px rgba(255, 255, 255, .025);
  color-scheme: dark;
  font-family: Inter, "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

:root[data-theme="paper"] {
  --bg: #f4f2ee;
  --surface: rgba(255, 255, 255, .65);
  --surface-raised: rgba(255, 255, 255, .76);
  --surface-soft: rgba(240, 237, 232, .7);
  --line: rgba(83, 74, 65, .17);
  --line-soft: rgba(83, 74, 65, .09);
  --glass-shine: rgba(255, 255, 255, .66);
  --text: #202321;
  --muted: #727a75;
  --accent: #c9474d;
  --accent-strong: #a93238;
  --accent-soft: rgba(201, 71, 77, .1);
  --shadow: 0 18px 40px rgba(40, 35, 30, .08);
  color-scheme: light;
}

:root[data-theme="forest"] {
  --bg: #09100e;
  --surface: rgba(22, 41, 34, .62);
  --surface-raised: rgba(39, 64, 53, .68);
  --surface-soft: rgba(13, 29, 23, .72);
  --line: rgba(208, 242, 220, .15);
  --line-soft: rgba(208, 242, 220, .08);
  --glass-shine: rgba(224, 255, 235, .1);
  --text: #edf4ef;
  --muted: #a0afa7;
  --accent: #de7058;
  --accent-strong: #ed8269;
  --accent-soft: rgba(222, 112, 88, .16);
  --success: #9cd1a5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(ellipse at 54% 20%, var(--glass-shine), transparent 48%), var(--bg); background-attachment: fixed; color: var(--text); font-size: 14px; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
a, .button { text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); background: rgba(12, 14, 14, .74); backdrop-filter: blur(18px); padding: 22px 12px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { color: var(--text); text-decoration: none; font-size: 14px; letter-spacing: .12em; padding: 0 12px 26px; }
.brand span { color: var(--accent); font-size: 19px; font-weight: 800; margin-right: 4px; }
.navigation { display: grid; gap: 3px; }
.nav-item, .settings-button { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 10px 12px; text-align: left; font-size: 14px; text-decoration: none; }
.nav-item:hover, .nav-item.active, .settings-button:hover { color: var(--text); background: var(--accent-soft); }
.nav-item.active { color: var(--text); box-shadow: inset 2px 0 var(--accent); }
.nav-icon { color: var(--accent); font-size: 16px; width: 15px; text-align: center; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.profile { display: flex; gap: 9px; align-items: center; padding: 13px 8px 0; font-size: 12px; }
.profile small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.avatar { width: 27px; height: 27px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #62353b); display: grid; place-items: center; color: white; font-size: 11px; }

.content { max-width: 1420px; width: 100%; padding: 34px 42px 55px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.eyebrow { color: var(--muted); font-size: 12px; margin: 0 0 3px; }
h1 { font-size: clamp(29px, 3vw, 39px); line-height: 1; letter-spacing: -.035em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.015em; }
.subtitle { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.button { border: 1px solid rgba(255, 255, 255, .07); border-radius: 6px; background: linear-gradient(180deg, var(--accent-strong), var(--accent)); color: #fff; padding: 10px 14px; font-size: 12px; font-weight: 600; box-shadow: inset 0 1px rgba(255, 255, 255, .09); }
.button:hover { background: var(--accent-strong); }
.button.secondary { background: linear-gradient(180deg, var(--glass-shine), transparent), var(--surface-soft); border-color: var(--line); color: var(--text); box-shadow: none; }
.button.secondary:hover { border-color: var(--muted); background: var(--surface-raised); }
.button.small { padding: 7px 10px; font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(310px, 1.35fr) minmax(280px, .9fr); gap: 20px; }
.section-stack { display: grid; gap: 20px; }
.card, .metric-card, .counter-card, .tracker-card { background: linear-gradient(140deg, rgba(255, 255, 255, .07), transparent 30%, rgba(255, 255, 255, .018) 72%), var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(16px) saturate(125%); -webkit-backdrop-filter: blur(16px) saturate(125%); }
.card { border-radius: 7px; padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.muted { color: var(--muted); }
.progress { height: 5px; background: var(--surface-soft); border-radius: 99px; overflow: hidden; border: 1px solid var(--line-soft); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.completion-copy { display: flex; align-items: baseline; justify-content: space-between; margin: 10px 0 8px; font-size: 12px; color: var(--muted); }
.completion-copy strong { color: var(--text); font-size: 13px; }

.task-list { display: grid; gap: 2px; }
.task-row { min-height: 42px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-soft); padding: 6px 3px; }
.task-row:last-child { border-bottom: 0; }
.task-row input { appearance: none; width: 21px; height: 21px; margin: 0; border: 1px solid var(--muted); border-radius: 4px; background: var(--surface-soft); display: grid; place-content: center; cursor: pointer; }
.task-row input::before { content: "✓"; font-size: 15px; transform: scale(0); transition: .12s; color: #fff; }
.task-row input:checked { background: var(--accent); border-color: var(--accent); }
.task-row input:checked::before { transform: scale(1); }
.task-content { flex: 1; min-width: 0; display: grid; gap: 2px; }
.task-streak { color: var(--muted); font-size: 11px; white-space: nowrap; }
.task-name { font-size: 14px; }
.task-row.done .task-name { color: var(--text); }
.task-note { color: var(--muted); font-size: 11px; }
.task-check { display: grid; place-items: center; min-width: 30px; min-height: 30px; cursor: pointer; }
.task-menu { position: relative; }
.task-menu-trigger { width: 34px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 20px; }
.task-menu-trigger:hover, .task-menu-trigger[aria-expanded="true"] { color: var(--text); background: var(--surface-raised); }
.task-menu-panel { position: absolute; z-index: 5; right: 0; top: 34px; min-width: 138px; display: grid; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); box-shadow: var(--shadow); backdrop-filter: blur(24px); }
.task-menu-panel[hidden] { display: none; }
.task-menu-panel button { border: 0; border-radius: 5px; background: transparent; padding: 9px 11px; text-align: left; font-size: 13px; }
.task-menu-panel button:hover { background: var(--accent-soft); }
.task-menu-panel button:last-child { color: var(--accent-strong); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 12px; }
.metric-card { position: relative; min-height: 148px; display: flex; flex-direction: column; border-radius: 9px; padding: 14px; text-align: left; transition: transform .16s, border-color .16s; }
.metric-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.metric-top { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.metric-icon { color: var(--accent); font-size: 18px; }
.metric-value { font-size: 29px; letter-spacing: -.06em; margin: 15px 0 0; }
.metric-unit { color: var(--muted); font-size: 11px; margin: 3px 0 12px; }
.metric-delta { margin-top: auto; color: var(--success); font-size: 11px; }
.metric-delta.negative { color: var(--accent-strong); }
.quick-actions { display: flex; gap: 6px; margin-top: 12px; }
.quick-action { flex: 1; border: 1px solid var(--line); background: var(--surface-raised); border-radius: 5px; padding: 6px; font-size: 10px; }
.quick-action:hover { border-color: var(--accent); }

.tracker-toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: -7px 0 16px; }
.tracker-filters { flex-wrap: wrap; }
.tracker-search { width: min(250px, 100%); padding: 9px 11px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; outline: 0; font-size: 11px; }
.tracker-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tracker-grid { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 12px; }
.tracker-card { min-height: 184px; display: flex; flex-direction: column; text-align: left; border-radius: 9px; padding: 15px; transition: border-color .16s, transform .16s; }
.tracker-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tracker-card-top, .tracker-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.tracker-card-top span { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 12px; }
.tracker-card-top i { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 15px; font-style: normal; }
.tracker-card-top b { color: var(--muted); font-size: 16px; font-weight: 500; }
.tracker-card > strong { margin: 23px 0 0; font-size: 30px; letter-spacing: -.065em; }
.tracker-card > small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tracker-card-bottom { margin-top: auto; }
.tracker-card-bottom em { font-style: normal; font-size: 10px; color: var(--success); }
.tracker-card-bottom em.negative { color: var(--accent-strong); }
.sparkline { width: 70px; height: 26px; overflow: visible; }
.sparkline path, .sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.inline-add { border: 0; color: var(--muted); background: transparent; margin-left: 10px; padding: 2px 0; font-size: 10px; }
.inline-add:hover { color: var(--accent); }

.counter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.counter-card { border-radius: 9px; padding: 16px; min-height: 254px; display: flex; flex-direction: column; }
.counter-card h3 { font-size: 14px; margin: 0; font-weight: 600; }
.counter-timer { margin: 24px 0 14px; font-variant-numeric: tabular-nums; }
.counter-time-values { display: inline-flex; align-items: flex-start; color: var(--text); }
.counter-time-part { display: grid; grid-template-columns: max-content .48ch; justify-items: center; }
.counter-time-part:last-child { grid-template-columns: max-content; }
.counter-time-part b { grid-column: 1; font-size: clamp(24px, 2.1vw, 34px); font-weight: 520; letter-spacing: -.055em; line-height: 1; }
.counter-time-part i { grid-column: 1; margin-top: 6px; color: var(--muted); font-size: 8px; font-style: normal; font-weight: 450; letter-spacing: .01em; line-height: 1; }
.counter-time-part em { grid-column: 2; grid-row: 1; align-self: start; color: var(--text); font-size: clamp(24px, 2.1vw, 34px); font-style: normal; font-weight: 520; line-height: 1; }
.counter-goal { display: grid; gap: 7px; margin-bottom: 13px; }
.counter-goal > div:first-child, .counter-record { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.counter-goal b, .counter-record b { color: var(--text); font-weight: 600; white-space: nowrap; }
.counter-goal .progress { height: 6px; }
.counter-record { margin-bottom: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.counter-meta { color: var(--muted); font-size: 10px; }
.counter-card .button { margin-top: auto; align-self: flex-start; }
.counter-card-compact { min-height: 157px; padding: 14px; }
.counter-card-compact h3 { font-size: 12px; }
.counter-card-compact .counter-timer { margin: 15px 0 5px; }
.counter-card-compact .counter-time-part b { font-size: clamp(17px, 1.7vw, 24px); }
.counter-card-compact .counter-time-part i { margin-top: 4px; font-size: 7px; }
.counter-card-compact .counter-time-part em { font-size: clamp(17px, 1.7vw, 24px); }
.habits-grid { grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); }
.habit-create-tile { min-height: 254px; display: grid; place-content: center; gap: 11px; border-style: dashed; border-width: 2px; background: rgba(255, 255, 255, .012); }
.habit-create-tile span { color: var(--text); font-size: 44px; font-weight: 250; line-height: 1; }
.habit-create-tile b { color: var(--muted); font-size: 14px; font-weight: 550; }
.habit-create-tile:hover { background: var(--surface); }

.today-page { position: relative; }
.today-hero { min-height: 142px; margin-bottom: 17px; padding: 4px 6px; display: flex; align-items: flex-start; justify-content: space-between; gap: 26px; }
.today-hero .eyebrow { text-transform: capitalize; letter-spacing: .04em; font-size: 13px; }
.today-hero h1 { margin-top: 4px; font-size: clamp(34px, 3.1vw, 40px); font-weight: 650; text-transform: capitalize; }
.today-date { margin: 5px 0 0; font-size: 22px; letter-spacing: -.03em; }
.today-hero .subtitle { font-size: 14px; margin-top: 12px; }
.today-date-navigation { width: min(440px, 48%); margin-top: 5px; }
.date-nav-controls { display: grid; grid-template-columns: 44px 1fr 44px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface-soft); }
.date-nav-controls button { min-height: 39px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--text); font-size: 12px; font-weight: 600; }
.date-nav-controls button:last-child { border-right: 0; }
.date-nav-controls button:hover:not(:disabled), .date-strip button:hover { background: var(--surface-raised); }
.date-nav-controls button:disabled { color: var(--muted); cursor: default; opacity: .4; }
.date-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; }
.date-strip button { min-height: 60px; display: grid; gap: 4px; place-content: center; border: 1px solid transparent; border-radius: 7px; background: rgba(255, 255, 255, .015); color: var(--muted); }
.date-strip button small { font-size: 10px; text-transform: capitalize; }.date-strip button b { color: var(--text); font-size: 16px; }
.date-strip button.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 1px rgba(255, 255, 255, .08); }
.date-strip button:disabled { opacity: .32; cursor: default; }
.today-grid { display: grid; gap: 22px; }
.today-top, .today-bottom { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr); align-items: start; gap: 22px; }
.today-primary { display: grid; align-content: start; gap: 16px; }
.today-completion { padding: 15px 17px; }
.today-completion .card-head { margin-bottom: 12px; }
.today-completion .card-head strong { color: var(--accent-strong); }
.today-tasks { min-width: 0; }
.today-tasks .card-head { margin: 0 0 8px; padding: 0 4px; }
.today-tasks .task-panel { max-height: 356px; overflow-y: auto; overscroll-behavior: contain; padding: 3px 10px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.today-trackers { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); padding: 12px; box-shadow: var(--shadow); }
.today-trackers > .card-head { margin: 0 0 9px; padding: 0 3px; }
.today-grid h2 { font-size: 16px; }
.today-grid .card-head { min-height: 31px; }
.today-grid .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.today-trackers.is-paginated .metric-grid { grid-auto-rows: auto; }
.today-trackers .metric-placeholder { visibility: hidden; pointer-events: none; }
.today-grid .metric-card { min-height: 148px; padding: 12px; }
.today-grid .metric-top { color: var(--text); font-size: 15px; font-weight: 550; line-height: 1.25; }
.today-grid .metric-unit, .today-grid .metric-delta { font-size: 12px; }
.today-grid .metric-icon { flex: none; }
.today-grid .metric-value { font-size: 25px; margin-top: 10px; }
.today-grid .metric-unit { margin-bottom: 9px; }
.today-grid .metric-progress { margin-bottom: 10px; }
.today-grid .quick-actions { margin-top: 9px; }
.today-grid .quick-action { background: linear-gradient(180deg, var(--surface-raised), var(--surface)); font-size: 11px; padding: 7px 4px; }
.tracker-pager { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 11px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tracker-pager button { width: 29px; height: 27px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-raised); }
.tracker-pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.tracker-pager button:disabled { opacity: .35; cursor: default; }
.today-grid .counter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.today-grid .counter-card { min-width: 0; min-height: 157px; }
.today-grid .counter-card h3 { font-size: 12px; overflow-wrap: anywhere; }
.today-grid .counter-days { font-size: clamp(16px, 1.6vw, 22px); white-space: nowrap; font-variant-numeric: tabular-nums; }
.today-grid .counter-days small { font-size: .62em; }
.today-grid .counter-meta { font-size: 11px; margin-bottom: 12px; }
.today-grid .journal-box > .card-head { padding: 0 3px; margin-bottom: 9px; }
.today-grid .journal-panel { padding: 13px; }
.today-grid .journal-panel label { display: block; margin: 0 0 8px; font-size: 13px; }
.today-grid .journal-box textarea { min-height: 53px; height: 53px; }
.today-grid .journal-actions { margin-top: 7px; }
.today-grid .task-row { min-height: 48px; }
.today-grid .button.small { font-size: 12px; padding: 8px 10px; }
.today-grid .empty { min-height: 112px; }

.journal-box textarea, .field textarea { min-height: 95px; resize: vertical; }
.journal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 9px; }
.input, .field input, .field textarea, .field select { width: 100%; background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 10px 11px; outline: 0; font-size: 12px; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 6px; margin: 13px 0; }
.field label { color: var(--muted); font-size: 11px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty { min-height: 130px; display: grid; place-content: center; justify-items: center; gap: 7px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; text-align: center; padding: 18px; }
.empty span { color: var(--accent); font-size: 25px; }
.empty p { font-size: 12px; margin: 0; }
.empty-action { width: 100%; background: transparent; font: inherit; cursor: pointer; transition: border-color .18s ease, background-color .18s ease, color .18s ease; }
.empty-action:hover { color: var(--text); border-color: var(--accent); background: rgba(255, 255, 255, .025); }
.empty-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.create-tile { min-height: 148px; background: transparent; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 12px; }
.create-tile:hover { color: var(--text); border-color: var(--accent); }

.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
.stats-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 12px; }
.stat small { display: block; color: var(--muted); font-size: 10px; }
.stat b { display: block; font-size: 20px; letter-spacing: -.04em; margin-top: 6px; }
.chart { height: 250px; padding: 12px 0 0; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.chart-area { fill: url(#chart-gradient); opacity: .36; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 10px; }
.filter-row { display: flex; gap: 6px; }
.filter { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 5px; padding: 6px 9px; font-size: 10px; }
.filter.active, .filter:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.metric-detail-title { display: flex; align-items: center; gap: 11px; }
.metric-detail-title i { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 7px; color: var(--accent); background: var(--accent-soft); font-style: normal; }

.metric-detail-page { display: grid; gap: 16px; }
.detail-back { color: var(--muted); font-size: 12px; width: fit-content; }
.detail-back:hover { color: var(--text); }
.detail-header, .detail-header-actions, .detail-overview, .detail-bottom { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.detail-header { margin-bottom: 2px; }
.detail-header .metric-detail-title i { width: 52px; height: 52px; font-size: 25px; }
.detail-header .metric-detail-title h1 { font-size: clamp(26px, 3vw, 36px); }
.detail-header-actions .task-menu-trigger { width: 38px; height: 37px; font-size: 20px; }
.detail-overview, .detail-bottom { align-items: stretch; }
.detail-overview > *, .detail-bottom > * { min-width: 0; flex: 1; }
.detail-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.detail-summary > div:first-child { display: grid; gap: 4px; }
.detail-summary strong { font-size: 34px; line-height: 1; font-weight: 550; }
.detail-summary span, .detail-goal span { color: var(--muted); font-size: 12px; }
.detail-summary small { color: var(--accent-strong); font-size: 12px; margin-top: 3px; }
.detail-quick-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.detail-quick-actions .quick-action { min-width: 54px; font-size: 12px; padding: 9px; }
.detail-goal { display: grid; align-content: center; gap: 8px; }
.detail-goal strong { font-size: 13px; font-weight: 600; }
.detail-goal-row { display: flex; align-items: center; gap: 10px; }
.detail-goal-row .progress { flex: 1; height: 8px; }
.detail-goal-row b { width: 38px; text-align: right; font-size: 11px; color: var(--muted); }
.detail-chart-panel { padding: 13px; }
.detail-chart-panel h2 { margin: 12px 0 0; font-size: 14px; }
.detail-periods { display: flex; flex-wrap: wrap; gap: 5px; }
.detail-periods .filter { font-size: 11px; padding: 6px 10px; }
.metric-chart { position: relative; height: 240px; padding: 0; }
.metric-chart svg { overflow: visible; }
.chart-axis { fill: var(--muted); font-size: 10px; }
.chart-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; pointer-events: none; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-hit:hover, .chart-hit:focus { fill: rgba(223, 85, 88, .06); outline: none; }
.chart-tooltip { position: absolute; z-index: 3; transform: translate(-50%, -100%); white-space: nowrap; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow); font-size: 11px; pointer-events: none; }
.detail-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; }
.detail-stats .stat { padding: 11px; min-height: 68px; }
.detail-stats .stat small { font-size: 11px; }
.detail-stats .stat b { font-size: 20px; font-weight: 550; }
.detail-bottom > * { min-height: 170px; }
.progress-panel h2, .activity-panel h2 { margin-bottom: 15px; }
.progress-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.progress-tile { min-height: 88px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; display: grid; align-content: center; gap: 7px; }
.progress-tile b { color: var(--accent-strong); font-size: 19px; font-weight: 550; }
.progress-tile b.negative { color: var(--muted); }
.progress-tile small { color: var(--muted); font-size: 10px; }
.activity-panel .card-head { margin-bottom: 7px; }
.activity-panel .card-head h2 { margin: 0; }
.calendar-navigation { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.calendar-navigation button { border: 0; background: transparent; color: var(--muted); padding: 3px 5px; }
.calendar-navigation button:hover:not(:disabled) { color: var(--text); }
.calendar-navigation button:disabled { opacity: .3; cursor: default; }
.activity-body { display: flex; gap: 6px; overflow-x: auto; overflow-y: visible; padding: 12px 0 5px; }
.activity-weekdays { display: grid; grid-template-rows: repeat(7, 11px); gap: 3px; color: var(--muted); font-size: 9px; flex: none; }
.activity-weekdays span:nth-child(1) { grid-row: 1; }.activity-weekdays span:nth-child(2) { grid-row: 3; }.activity-weekdays span:nth-child(3) { grid-row: 5; }
.activity-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); grid-auto-columns: 11px; gap: 3px; }
.activity-cell, .activity-legend i { display: block; width: 11px; height: 11px; border: 1px solid var(--line-soft); border-radius: 3px; background: rgba(232, 242, 246, .07); }
.activity-cell { position: relative; cursor: help; }
.activity-cell:focus { outline: 1px solid var(--text); outline-offset: 1px; }
.activity-cell.level-1, .activity-legend .level-1 { background: rgba(223, 85, 88, .24); }.activity-cell.level-2, .activity-legend .level-2 { background: rgba(223, 85, 88, .43); }.activity-cell.level-3, .activity-legend .level-3 { background: rgba(223, 85, 88, .68); }.activity-cell.level-4, .activity-legend .level-4 { background: var(--accent); }
.activity-cell:hover::after, .activity-cell:focus::after { content: attr(data-tooltip); position: absolute; z-index: 5; bottom: 18px; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow); font-size: 10px; }
.activity-legend { display: flex; justify-content: flex-end; align-items: center; gap: 4px; color: var(--muted); font-size: 10px; margin-top: 8px; }

.journal-list { display: grid; gap: 10px; }
.entry { padding: 15px; }
.entry p { white-space: pre-wrap; font-size: 13px; line-height: 1.55; color: var(--muted); margin: 8px 0 0; }
.tag { color: var(--accent-strong); background: var(--accent-soft); border-radius: 99px; padding: 3px 7px; font-size: 10px; }
.entry-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.theme-tile { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-align: left; }
.theme-tile.active, .theme-tile:hover { border-color: var(--accent); }
.theme-preview { height: 52px; border-radius: 5px; margin-bottom: 10px; border: 1px solid var(--line); background: linear-gradient(135deg, #0a0c0c 0 45%, #df5558 45% 48%, #171b1b 48%); }
.theme-preview.paper { background: linear-gradient(135deg, #f4f2ee 0 45%, #c9474d 45% 48%, #fffefa 48%); }
.theme-preview.forest { background: linear-gradient(135deg, #09100e 0 45%, #de7058 45% 48%, #17241e 48%); }

dialog { width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 30px 90px rgba(0, 0, 0, .6); padding: 23px; }
dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); }
.close { float: right; border: 0; background: none; color: var(--muted); font-size: 25px; line-height: .7; }
.modal-title { margin: 0 0 4px; font-size: 21px; letter-spacing: -.04em; }
.modal-copy { margin: 0 0 15px; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 850px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; padding: 15px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: 13px; }
  .navigation { display: flex; overflow: auto; padding-bottom: 2px; }
  .nav-item { width: auto; white-space: nowrap; }
  .sidebar-bottom { display: none; }
  .content { padding: 26px 17px 38px; }
  .dashboard-grid, .page-grid { grid-template-columns: 1fr; }
  .tracker-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .tracker-toolbar { align-items: stretch; flex-direction: column; }
  .tracker-search { width: 100%; }
  .today-top, .today-bottom { grid-template-columns: 1fr; }
  .today-hero { flex-direction: column; min-height: auto; }.today-date-navigation { width: 100%; }
  .today-grid .counter-days { font-size: 21px; }
  .detail-overview, .detail-bottom { flex-direction: column; }
  .detail-overview > *, .detail-bottom > * { width: 100%; }
  .detail-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header .button { align-self: flex-start; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .metric-grid, .counter-grid { grid-template-columns: 1fr; }
  .tracker-grid { grid-template-columns: 1fr; }
  .today-grid .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-grid .counter-grid { grid-template-columns: 1fr; }
  .detail-header { align-items: flex-start; }
  .detail-summary { align-items: flex-start; flex-direction: column; }
  .detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-tiles { grid-template-columns: 1fr; }
}
/* Account, editing, and recovery screens use the existing theme tokens. */
.auth-card { max-width: 520px; margin: 8vh auto; }
.notification { position: fixed; z-index: 10000; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 16px 24px; max-width: min(90vw, 600px); border-radius: 12px; background: #253a30; color: #fff; box-shadow: 0 4px 24px #0005; }
.notification.error { background: #732e32; }
.notification[hidden] { display: none; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid #8883; overflow-wrap: anywhere; }
.history-row > div, .settings-actions, .pagination { display: flex; flex-wrap: wrap; gap: 10px; }
.pagination { justify-content: center; align-items: center; margin: 20px 0; }
.journal-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-bottom: 20px; }
.journal-filters .field { flex: 1 1 150px; margin-bottom: 0; }
.entry-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.weekday-options { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.weekday-options label { display: flex; align-items: center; gap: 5px; }
.weekday-options input { width: auto; }
.schedule { border: 1px solid #8885; border-radius: 10px; padding: 14px; margin: 16px 0; }
.settings-actions { margin: 16px 0; }
button[aria-busy="true"] { opacity: .6; cursor: wait; }
.task-content small { color: var(--muted); font-size: 11px; }
#metric-history { margin-top: 20px; }
@media (max-width: 600px) { .history-row { align-items: flex-start; flex-direction: column; } .auth-card { margin: 24px 0; } }

.removed-value > span { text-decoration: line-through; opacity: .55; }
.block-loading { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; font-size: 12px; color: var(--muted); }
.block-loading::before { content: ""; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: busy-spin .8s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
.request-error { display: flex; align-items: center; gap: 14px; justify-content: space-between; padding: 12px; border: 1px solid var(--accent); border-radius: 8px; margin-bottom: 12px; }
.field-error { color: var(--accent-strong); margin-top: 5px; display: block; }
.field-error[hidden] { display: none; }
[aria-invalid="true"] { border-color: var(--accent-strong) !important; }
.draft-status { display: block; color: var(--muted); font-size: 12px; min-height: 1.3em; margin: 8px 0; }
.advanced-fields { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 12px; }
.advanced-fields summary { cursor: pointer; font-size: 13px; padding: 8px 0; color: var(--muted); }
.advanced-fields[open] summary { margin-bottom: 10px; }
#connection-status { position: fixed; top: 0; left: 0; right: 0; z-index: 999; padding: 10px 15px; text-align: center; background: var(--surface-raised); color: var(--text); border-bottom: 1px solid var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Shared tracker cards and mobile destinations. */
#mobile-navigation, #quick-create { display: none; }
.metric-title-link { text-decoration: none; color: var(--text); overflow-wrap: anywhere; }
.metric-title-link > span:last-child { margin-left: auto; }
.card-measurement { display: flex; align-items: baseline; gap: 7px; margin: 12px 0; }
.card-measurement > span, .goal-copy { color: var(--muted); font-size: 12px; }
.goal-copy { display: grid; gap: 5px; margin: 10px 0; }
.goal-copy b { font-weight: 500; color: var(--text); }
.metric-progress { margin-bottom: 12px; }
.inline-goal { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.inline-goal summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 5px 0; }
.inline-goal form { display: grid; gap: 8px; padding-top: 12px; }
.inline-goal .field { margin: 0; }
.inline-goal small { color: var(--muted); font-size: 11px; }
.inline-goal button { justify-self: start; }
.more-links, .creation-choices { display: grid; gap: 12px; margin-top: 20px; }
.more-links a { display: flex; gap: 15px; align-items: center; color: var(--text); text-decoration: none; }
.more-links a > span:last-child { margin-left: auto; }
.creation-choices button { min-height: 48px; text-align: left; }
@media (max-width: 850px) {
  .sidebar { display: none; }
  .content { padding-bottom: calc(155px + env(safe-area-inset-bottom)); }
  body[data-authenticated="true"] #mobile-navigation { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 90; bottom: 0; left: 0; right: 0; padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  #mobile-navigation a { display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; min-height: 48px; font-size: 11px; text-decoration: none; color: var(--muted); border-radius: 8px; }
  #mobile-navigation a > span { font-size: 21px; line-height: 22px; }
  #mobile-navigation a[aria-current="page"] { color: var(--text); background: var(--accent-soft); font-weight: 700; }
  body[data-authenticated="true"] #quick-create { display: grid; place-items: center; position: fixed; z-index: 91; right: 20px; bottom: calc(80px + env(safe-area-inset-bottom)); width: 52px; height: 52px; border: 0; border-radius: 18px; background: var(--accent); color: white; font-size: 32px; box-shadow: var(--shadow); }
  .notification { bottom: calc(145px + env(safe-area-inset-bottom)); }
  .quick-action { min-height: 40px; }
}
@media (max-width: 520px) {
  .today-grid .metric-grid { grid-template-columns: 1fr; }
}

.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 15px; font-size: 12px; color: var(--muted); }
.chart-legend span::before { content: ""; display: inline-block; width: 20px; border-top: 2px solid var(--accent); margin: 0 7px 3px 0; }
.chart-legend .legend-previous::before { border-color: var(--muted); border-top-style: dashed; }
.chart-legend .legend-goal::before { border-color: var(--text); border-top-style: dotted; }
.chart-previous { stroke: var(--muted); stroke-dasharray: 6 4; stroke-width: 2; fill: none; }
.chart-previous-dot { fill: var(--muted); }
.chart-goal { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 2 5; }
.chart-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.sparkline polyline { stroke: var(--accent); stroke-width: 2; }
.sparkline circle { fill: var(--accent); }
.metric-chart { overflow-x: auto; }
.metric-chart svg { min-width: 560px; }

.content, .metric-detail-page, .metric-detail-page > * { min-width: 0; }
@media (max-width: 520px) { .detail-header { flex-wrap: wrap; } }
.metric-chart { overflow-y: hidden; } .metric-chart svg { display: block; overflow: hidden; }

/* Card actions remain inside natural-height cards. */
.metric-card, .tracker-card { position: relative; min-width: 0; }
.metric-title-link::after { content: ""; position: absolute; inset: 0; border-radius: 9px; z-index: 1; }
.metric-title-link:focus-visible { outline: none; }
.metric-title-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 3px; }
.metric-card .quick-actions, .tracker-card .quick-actions, .tracker-card .inline-goal { position: relative; z-index: 2; }
.quick-actions { flex-wrap: wrap; }
.quick-actions .quick-action { flex: 1 1 42px; min-height: 36px; }
.quick-actions [data-open-value] { flex-basis: 100%; }
.metric-title-link, .card-measurement, .goal-copy, .metric-delta { overflow-wrap: anywhere; }
.counter-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.counter-heading h3 { min-width: 0; overflow-wrap: anywhere; }
.counter-heading .task-menu { flex: none; }
.counter-card:has(.task-menu-panel:not([hidden])) { position: relative; z-index: 10; }
.history-disclosure > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.history-disclosure:not([open]) { min-height: 0; }

/* Stack daily actions and streaks beside trackers, with a shared bottom edge. */
.today-top { align-items: stretch; }
.today-primary { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.today-primary > .today-habits { margin-top: auto; min-width: 0; }
.today-habits > .counter-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); align-items: stretch; }
.today-bottom > .today-journal { grid-column: 2; min-width: 0; }
@media (max-width: 850px) {
  .today-bottom > .today-journal { grid-column: 1; }
  .today-primary > .today-habits { margin-top: 0; }
}
