:root {
  color-scheme: light dark;
  --canvas-bg: #F5F3EC;
  --surface: #FFFEFB;
  --hairline: #E6E1D6;
  --ink: #1F2421;
  --ink-sec: #6B706A;
  --ink-ter: #9A9E97;
  --grid-hour: rgb(31 36 33 / 7%);
  --grid-half: rgb(31 36 33 / 3.5%);
  --now: #C66D49;
  --dim: 0.28;
  --learning-accent: #2B6A58;
  --learning-tint: #E7F0EB;
  --work-accent: #4B6D9B;
  --work-tint: #E8EDF5;
  --social-accent: #C66D49;
  --social-tint: #F7EAE2;
  --entertainment-accent: #A8843A;
  --entertainment-tint: #F4EDDC;
  --life-accent: #94587F;
  --life-tint: #F2E8EE;
  --interest-accent: #5E8A4A;
  --interest-tint: #ECF1E4;
  --other-accent: #7A7F78;
  --other-tint: #EEEDE8;
  --serif: ui-serif, "Songti SC", "Noto Serif CJK SC", "Noto Serif", serif;
  --mono: ui-monospace, "SFMono-Regular", monospace;
  --rule: .5px solid var(--hairline);
  color: var(--ink);
  background: var(--canvas-bg);
  font: 16px/1.55 system-ui, -apple-system, "PingFang SC", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas-bg: #111513;
    --surface: #1A201D;
    --hairline: #2A332E;
    --ink: #E8EAE6;
    --ink-sec: #9AA39C;
    --ink-ter: #6E776F;
    --grid-hour: rgb(232 234 230 / 6%);
    --grid-half: rgb(232 234 230 / 3%);
    --now: #E6A68B;
    --dim: 0.32;
    --learning-accent: #7AC4A8;
    --learning-tint: #1D2E27;
    --work-accent: #9CB9DF;
    --work-tint: #1E2633;
    --social-accent: #E6A68B;
    --social-tint: #33241D;
    --entertainment-accent: #D9B872;
    --entertainment-tint: #2D2719;
    --life-accent: #D29BC0;
    --life-tint: #2D2029;
    --interest-accent: #A6C98F;
    --interest-tint: #222B1C;
    --other-accent: #A9AFA8;
    --other-tint: #232724;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p, ol, ul { margin: 0; }
h1, h2, h3 { text-wrap: pretty; }
button, input, textarea, select {
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
}
button {
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--learning-accent); outline-offset: 2px; }
small, .caption, .empty { color: var(--ink-sec); }
.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1 {
  font: 600 clamp(30px, 4vw, 44px)/1.24 var(--serif);
  letter-spacing: -.04em;
}
h2 { font: 600 21px/1.4 var(--serif); letter-spacing: -.025em; }
h3 { font-size: 14px; line-height: 1.45; font-weight: 600; }
.heading, .section-head, .bar-label, .switch, .brand, .masthead, nav, nav button,
.devices, .device, .device-btn, .segmented, .category-filters, .search-field {
  display: flex;
  align-items: center;
}

.masthead {
  min-height: 56px;
  gap: 12px;
  justify-content: space-between;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  border-bottom: var(--rule);
  background: var(--surface);
}
.brand { gap: 8px; }
.wordmark { font: 600 23px/1 var(--serif); letter-spacing: -.055em; }
.wordmark small { margin-left: 4px; font: 500 12px/1 system-ui, sans-serif; letter-spacing: .06em; }
nav {
  position: fixed;
  z-index: 4;
  inset: auto 0 0;
  justify-content: space-around;
  padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: var(--rule);
  background: var(--surface);
}
nav button {
  flex: 1;
  min-height: 44px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border-radius: 8px;
  color: var(--ink-sec);
  font-size: 11px;
  white-space: nowrap;
}
nav [aria-current="page"] { color: var(--learning-accent); font-weight: 650; }
nav [aria-current="page"] .icon { stroke-width: 2; }
main {
  min-width: 0;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.pages {
  min-width: 0;
  padding: 0 max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}
.pages > section { max-width: 960px; margin-inline: auto; }
#today, .pages > .reading { max-width: 760px; }
.heading {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-block: 24px 16px;
  border-bottom: var(--rule);
  margin-bottom: 16px;
}
.timeline-toolbar { flex-wrap: wrap; }
.heading-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.offline-dialog {
  width: min(440px, calc(100% - 24px));
  max-height: 90dvh;
  padding: clamp(16px, 4vw, 24px);
  border: var(--rule);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}
.offline-dialog::backdrop { background: rgb(22 28 25 / 45%); }
.visual-review .section-head { flex-wrap: wrap; gap: 6px 12px; }
#dayColorPalette {
  display: flex;
  width: 100%;
  height: 32px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--other-tint);
}
#dayColorPalette span { flex: 1 1 0; min-width: 0; }
.wall-link { min-height: 36px; color: var(--learning-accent); font-weight: 600; }
.visual-dialog {
  width: min(860px, calc(100% - 24px));
  max-height: 90dvh;
  padding: clamp(16px, 3vw, 28px);
  border: var(--rule);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  overscroll-behavior: contain;
}
.visual-dialog::backdrop { background: rgb(15 22 18 / 64%); }
.visual-dialog-head, #keyframeLightbox footer, .keyframe-byline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.visual-dialog-head { margin-bottom: 16px; }
.visual-dialog-head > div { min-width: 0; overflow-wrap: anywhere; }
.visual-dialog-head button, .keyframe-delete { flex: none; }
#visualWallGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 172px), 1fr));
  gap: 20px 14px;
}
#visualWallGrid article { min-width: 0; }
.keyframe-thumbnail {
  width: 100%;
  display: grid;
  gap: 3px;
  text-align: start;
}
.keyframe-picture {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: var(--rule);
  border-radius: 8px;
  background: var(--canvas-bg);
}
.keyframe-picture img { display: block; width: 100%; height: 100%; object-fit: cover; }
.keyframe-thumbnail time { margin-top: 4px; color: var(--ink-sec); font: 11px var(--mono); }
.keyframe-thumbnail strong, .keyframe-byline small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.keyframe-thumbnail strong { font-size: 14px; }
.keyframe-delete { min-height: 34px; padding-inline: 6px; color: var(--social-accent); font-size: 13px; }
#keyframePreview .keyframe-picture { aspect-ratio: auto; min-height: 120px; }
#keyframePreview img { width: 100%; height: auto; max-height: 64dvh; object-fit: contain; }
#keyframeLightbox footer { padding-top: 10px; color: var(--ink-sec); font-size: 13px; }
@media (max-width: 599px) {
  #visualWallGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .keyframe-delete { min-height: 44px; }
}
.offline-dialog fieldset { margin: 0; padding: 0; border: 0; }
.offline-dialog legend, #offlineHint { color: var(--ink-sec); font-size: 13px; }
.offline-dialog .category-filters { margin: 4px 0 0; }
.offline-pills, .offline-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.offline-pills button {
  padding: 4px 10px;
  border: var(--rule);
  border-radius: 100px;
  background: var(--canvas-bg);
  font-size: 13px;
}
.offline-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.offline-times input { min-width: 0; }
.offline-actions { justify-content: flex-end; }
.view-mode { border: var(--rule); }
.view-mode button { min-height: 32px; padding: 4px 10px; }
.caption { margin-bottom: 4px; font-size: 12px; letter-spacing: .06em; }
.switch {
  border: var(--rule);
  border-radius: 8px;
  background: var(--surface);
}
.switch button { min-width: 32px; min-height: 36px; color: var(--ink-sec); font-size: 20px; }
.switch input { width: auto; min-height: 36px; border: 0; padding: 0 4px; background: none; font-size: 13px; }
.section-head, .bar-label { gap: 8px; justify-content: space-between; }
.section-head { margin-bottom: 12px; }
.panel, .overview-fold { border: var(--rule); border-radius: 12px; background: var(--surface); }
.panel { padding: 16px; }
.empty { padding: 12px 0; font-size: 14px; }
.quiet, .primary { min-height: 40px; padding: 8px 12px; border-radius: 8px; font-weight: 550; }
.quiet { color: var(--ink-sec); font-size: 13px; }
.primary { background: var(--learning-accent); color: var(--surface); font-size: 14px; }
.devices, .category-filters { gap: 4px 8px; flex-wrap: wrap; }
.devices:not(:empty), .overview-fold { margin-block: 0 16px; }
.device-btn, .category-filters button, .segmented button {
  flex: none;
  gap: 4px;
  min-height: 32px;
  border: var(--rule);
  border-radius: 99px;
  background: var(--surface);
  padding: 4px 12px;
  font-size: 12px;
  color: var(--ink-sec);
}
.device-btn .icon, .device .icon { width: 14px; height: 14px; }
.device-btn[aria-pressed="true"], .category-filters button[aria-pressed="true"] {
  background: var(--other-tint);
  color: var(--ink);
  border-color: var(--ink-ter);
}
.category-filters:not(:empty) { margin: 12px 0 16px; }
.category-filters button { display: inline-flex; align-items: center; gap: 8px; }
.category-filters button[data-category]:not([data-category=""]):not([data-category="all"])::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 100%;
  background-color: var(--dot, var(--other-accent));
}
[data-category="learning"] { --dot: var(--learning-accent); }
[data-category="work"] { --dot: var(--work-accent); }
[data-category="social"] { --dot: var(--social-accent); }
[data-category="entertainment"] { --dot: var(--entertainment-accent); }
[data-category="life"] { --dot: var(--life-accent); }
[data-category="interest"] { --dot: var(--interest-accent); }
[aria-pressed="true"][data-category] { border-color: var(--dot, var(--ink-ter)); }

.overview-fold summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 550;
  list-style: none;
}
.overview-fold summary::-webkit-details-marker { display: none; }
.overview-fold summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid var(--ink-sec);
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}
.overview-fold[open] summary::after { transform: rotate(225deg); }
.fold-metric { margin-inline-start: auto; color: var(--ink-sec); font: 12px var(--mono); }
#mobileOverview { padding: 16px; border-top: var(--rule); }
#inspector, #mobileOverview, #results { overflow-wrap: anywhere; }
#overviewStats section + section, .inspector-section, #inspectorContent > section + section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: var(--rule);
}
#overviewStats > h2 { margin-bottom: 16px; }
#overviewStats h3 { color: var(--ink-sec); font-weight: 550; }
.metric {
  margin-block: 8px 16px;
  font: 500 44px/1.1 var(--serif);
  letter-spacing: -.05em;
}
.metric small { margin-inline: 4px 8px; font: 13px system-ui, sans-serif; letter-spacing: 0; }
.bar-label { margin-bottom: 4px; font-size: 13px; }
.bar-label > span, .clip { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-label small { white-space: nowrap; font-size: 11px; }
.hour-bars { display: block; width: 100%; height: 48px; margin-top: 8px; }
.hour-track { fill: var(--hairline); }
.hour-value { fill: var(--learning-accent); }
.axis { display: flex; justify-content: space-between; margin-top: 4px; color: var(--ink-sec); font: 10px var(--mono); }
.segmented { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--canvas-bg); }
.segmented button { border-radius: 6px; background: none; border: 0; padding: 4px 8px; min-height: 28px; }
.segmented [aria-pressed="true"] { background: var(--surface); color: var(--ink); }
.bar + .bar { margin-top: 12px; }
progress {
  display: block;
  width: 100%;
  height: 4px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: var(--hairline);
  color: var(--learning-accent);
}
progress::-webkit-progress-bar { background: var(--hairline); }
progress::-webkit-progress-value { background: var(--learning-accent); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--learning-accent); border-radius: 4px; }

#inspector, #inspectorBackdrop, #inspectorExpand, #inspectorClose { display: none; }
#inspector {
  position: fixed;
  z-index: 7;
  inset: auto 0 0;
  max-height: 56vh;
  max-height: 56dvh;
  height: 56vh;
  height: 56dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: var(--rule);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  padding: 0 max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
#contentLayout[data-canvas="true"] #inspector[data-open="true"] { display: block; }
#inspector[data-open="true"] #inspectorClose { display: block; margin-left: auto; }
#inspector[data-open="true"] #inspectorExpand {
  display: grid;
  place-items: center;
  width: 100%;
  height: 28px;
}
#inspectorExpand { touch-action: none; }
#inspectorExpand::after { content: ""; width: 36px; height: 4px; border-radius: 4px; background: var(--hairline); }
#inspector[data-expanded="true"] { max-height: 92vh; max-height: 92dvh; height: 92vh; height: 92dvh; }
#contentLayout[data-canvas="true"] #inspector[data-open="true"][data-expanded="true"] + #inspectorBackdrop {
  position: fixed;
  z-index: 6;
  inset: 0;
  display: block;
  background: rgb(0 0 0 / 24%);
}
#inspectorContent { min-width: 0; }
#inspectorContent > h2, #inspectorContent > header { margin-bottom: 16px; }
#inspectorContent :is(h2, h3) + :is(p, .detail, .narrative), .narrative p + p { margin-top: 8px; }
.detail, .inspector-section, #mobileOverview { font-size: 14px; }
.detail { line-height: 1.7; }
.detail > * + * { margin-top: 12px; }
.detail small { display: block; color: var(--ink-sec); }
.detail a { color: var(--learning-accent); text-underline-offset: 3px; }
.detail p, .narrative, .hit p { white-space: pre-line; }
.cues { padding: 0; list-style: none; }
.cues li { padding: 12px 0; border-top: var(--rule); }
.slices { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-sec); }
.privacy-badge, .mode-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--learning-tint);
  color: var(--learning-accent);
  font-size: 12px;
}
.narrative { font-family: var(--serif); line-height: 1.85; }

input, textarea, select {
  min-height: 44px;
  min-width: 0;
  max-width: 100%;
  padding: 8px 12px;
  border: var(--rule);
  border-radius: 8px;
  background: var(--surface);
}
input, textarea { width: 100%; }
textarea { resize: vertical; }
form, label, .fields, .log-columns { display: grid; gap: 12px; }
label { gap: 4px; color: var(--ink-sec); font-size: 13px; }
label input, label textarea { color: var(--ink); font-size: 16px; }
.search-modes { margin-bottom: 12px; border: var(--rule); }
.search-modes button { min-height: 36px; padding-inline: 12px; font-size: 14px; }
#searchForm {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.search-field { flex: 1; min-width: 0; gap: 8px; padding-inline-start: 12px; }
.search-field input { background: none; padding-inline: 0; border: 0; }
#results { display: grid; gap: 8px; margin-top: 16px; }
.evidence-card, .hit {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: var(--rule);
  border-radius: 10px;
  text-align: start;
  color: var(--ink);
  text-decoration: none;
}
.evidence-card strong { font-size: 14px; font-weight: 600; }
.evidence-card > span { color: var(--ink-sec); font-size: 14px; white-space: pre-line; }
#dailyNarrative h3 { margin-top: 16px; margin-bottom: 4px; }
#dailyNarrative .evidence-card + .evidence-card,
#inspectorContent .evidence-card + .evidence-card { margin-top: 4px; }
#dailyNarrative .quiet { padding-inline: 0; color: var(--learning-accent); }
#dailyNarrative .empty { padding-block: 4px; }
.overview > .privacy-badge { margin-top: 16px; }

.evidence-card small, .hit small { color: var(--ink-sec); font-size: 12px; }
.evidence-card p, .hit p { color: var(--ink-sec); font-size: 14px; }
#chart { margin-top: 16px; }
#logForm .primary { justify-self: start; }
.log-columns { align-items: start; }
.guide ol { padding-left: 1.3em; margin-top: 12px; color: var(--ink-sec); font-size: 14px; overflow-wrap: anywhere; }
.guide li + li { margin-top: 8px; }
.guide section + section { margin-top: 18px; padding-top: 18px; border-top: var(--rule); }
.guide-actions { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.guide-actions .quiet, .guide a { color: var(--learning-accent); }
.guide-actions .quiet { padding-inline: 0; }
.guide-note { margin-top: 12px; color: var(--ink-sec); font-size: 13px; overflow-wrap: anywhere; }
.narrow { max-width: 400px; margin: 8vh auto; }
.narrow h1 { font-size: 28px; margin-bottom: 16px; }
#status:not(:empty), noscript {
  display: block;
  margin: 12px 16px;
  border-inline-start: 3px solid var(--learning-accent);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  background: var(--learning-tint);
  font-size: 14px;
}

@media (min-width: 600px) {
  body { --rail-width: 72px; padding-left: var(--rail-width); }
  .masthead {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail-width);
    flex-direction: column;
    justify-content: flex-start;
    padding: max(24px, env(safe-area-inset-top)) 4px max(12px, env(safe-area-inset-bottom));
    gap: 24px;
    border: 0;
    border-right: var(--rule);
    z-index: 4;
  }
  .wordmark { display: none; }
  nav { position: static; flex-direction: column; width: 100%; padding: 0; gap: 4px; border: 0; }
  nav button { flex: none; width: 100%; min-height: 56px; }
  nav [aria-current="page"] { background: var(--learning-tint); }
  #logout { margin-top: auto; font-size: 12px; padding-inline: 0; }
  main { padding-bottom: 0; }
  .pages { padding: 0 24px 24px; }
  .heading { padding-block: 24px; margin-bottom: 24px; }
  .log-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .panel { padding: 24px; }
  #inspector, #inspector[data-expanded="true"] {
    inset: 0 0 0 auto;
    width: 360px;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding: 24px;
    border: 0;
    border-left: var(--rule);
    border-radius: 0;
  }
  #inspector[data-open="true"] #inspectorExpand,
  #contentLayout[data-canvas="true"] #inspector[data-open="true"][data-expanded="true"] + #inspectorBackdrop { display: none; }
}

@media (min-width: 960px) {
  #contentLayout[data-canvas="true"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
  }
  #contentLayout[data-canvas="true"] #inspector {
    position: sticky;
    top: 0;
    display: block;
    width: 100%;
  }
  .overview-fold { display: none; }
}

@media (min-width: 1440px) {
  body { --rail-width: 220px; }
  .masthead { padding-inline: 16px; align-items: stretch; }
  .brand { padding-inline: 8px; }
  .wordmark { display: inline; }
  nav button { flex-direction: row; justify-content: flex-start; min-height: 44px; padding: 8px 16px; gap: 12px; font-size: 14px; }
  #logout { align-self: start; padding-inline: 16px; }
  #contentLayout[data-canvas="true"] { grid-template-columns: minmax(0, 1fr) 420px; }
}

@media (hover: hover) {
  nav button:hover, .quiet:hover, .device-btn:hover, .category-filters button:hover,
  .switch button:hover, .segmented button:hover, #inspectorExpand:hover::after {
    background-color: var(--other-tint);
  }
  .evidence-card:hover, button.hit:hover { border-color: var(--ink-ter); }
}

@media (prefers-reduced-motion: no-preference) {
  #inspector[data-open="true"] #inspectorContent { animation: detail-in 160ms ease-out; }
  @keyframes detail-in { from { opacity: 0; } to { opacity: 1; } }
}

.pages > #stats { max-width: 1120px; }
#stats .heading { margin-bottom: 0; border-bottom: 0; }
.stats-period { border: var(--rule); }
.stats-period button { min-width: 44px; min-height: 34px; }
.stats-board, .stats-lower { display: grid; gap: 24px; min-width: 0; }
#chart.stats-board { margin-top: 0; }
.stats-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-block: var(--rule);
}
.stats-kpi { position: relative; padding: 15px 12px 16px; min-width: 0; }
.stats-kpi:nth-child(odd) { padding-left: 0; }
.stats-kpi:nth-child(even) { border-left: var(--rule); }
.stats-kpi:nth-child(n+3) { border-top: var(--rule); }
.stats-kpi dt, .stats-ring-center > span, .stats-weekday, .stats-legend, .stats-date-axis, .stats-hour-axis {
  color: var(--ink-ter);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .045em;
}
.stats-kpi dd {
  margin: 5px 0 0;
  font: 500 clamp(23px, 3vw, 38px)/1.25 var(--serif);
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}
.stats-delta {
  display: inline-block;
  color: var(--ink-sec);
  background: var(--other-tint);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  margin-top: 6px;
}
.stats-delta[data-trend="up"] { background: var(--learning-tint); color: var(--learning-accent); }
.stats-delta[data-trend="down"] { background: var(--social-tint); color: var(--social-accent); }
.stats-spark { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; max-width: 136px; margin-top: 12px; }
.stats-spark i { height: 5px; border-radius: 1px; background: var(--work-accent); }
.stats-section { min-width: 0; }
.stats-section h2 { font-size: clamp(20px, 2.1vw, 26px); }
.stats-head, .stats-summary, .stats-legend, .stats-legend span, .stats-category-summary,
.stats-category-pills, .stats-pill { display: flex; align-items: center; }
.stats-head { justify-content: space-between; gap: 8px; }
.stats-summary {
  align-content: start;
  min-height: 68px;
  flex-wrap: wrap;
  column-gap: 9px;
  row-gap: 2px;
  padding-top: 8px;
  color: var(--ink-sec);
  font-size: 12px;
}
.stats-summary strong { font-weight: 600; color: var(--ink); }
.stats-summary > span:nth-child(2)::before { content: "·"; margin-right: 8px; }
.stats-category-summary, .stats-legend span, .stats-pill { gap: 6px; }
.stats-category-summary, .stats-pill { max-width: 100%; min-width: 0; }
.stats-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; }
.stats-rhythm { position: relative; height: clamp(114px, 16vw, 172px); margin-top: 10px; }
.stats-gridline, .stats-average { position: absolute; inset-inline: 0; pointer-events: none; }
.stats-gridline { border-top: 1px solid var(--grid-hour); }
.stats-columns { position: absolute; inset: 0; display: flex; }
.stats-day {
  display: flex;
  align-items: end;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  border-radius: 3px;
}
.stats-day[data-dim="true"], .stats-pill[data-dim="true"] { opacity: var(--dim); }
.stats-stack { display: block; width: 70%; max-width: 52px; border-radius: 3px 3px 0 0; overflow: hidden; }
.stats-average { border-top: 1px dashed var(--ink-ter); }
.stats-average span {
  position: absolute;
  right: 0;
  bottom: 3px;
  padding-inline: 3px;
  background: var(--canvas-bg);
  color: var(--ink-sec);
  font: 11px/1.3 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
.stats-date-axis { display: flex; justify-content: space-between; margin-top: 5px; }
.stats-lower > .stats-section { border-top: var(--rule); padding-top: 16px; }
.stats-legend { gap: 10px; }
.stats-heat-grid {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr);
  align-items: center;
  column-gap: 5px;
  margin-top: 18px;
}
.stats-curves, .stats-hour-axis { grid-column: 2; width: 100%; }
.stats-curves { height: 40px; margin-bottom: 9px; }
.stats-heat-row { width: 100%; height: 18px; display: block; }
.stats-hour-axis { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 3px; }
.stats-distribution { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.stats-ring { width: 144px; height: 144px; position: relative; margin: 12px 0; }
.stats-ring svg { display: block; width: 100%; height: 100%; }
.stats-ring svg :is(path, circle) { cursor: pointer; }
.stats-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
.stats-ring-center > span { max-width: 72%; }
.stats-ring-center strong {
  font: 500 23px/1.25 var(--serif);
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}
.stats-category-pills { gap: 5px; flex-wrap: wrap; margin-block: 8px; }
.stats-pill {
  border: var(--rule);
  border-radius: 20px;
  padding: 5px 8px;
  color: var(--ink-sec);
  font-size: 11px;
  white-space: nowrap;
}
.stats-pill[aria-pressed="true"] { border-color: var(--ink-sec); background: var(--surface); color: var(--ink); }
.stats-distribution > :is(.stats-app-head, .stats-apps, .stats-expand, .empty) { grid-column: 1 / -1; }
.stats-app-head { padding-bottom: 6px; border-bottom: var(--rule); }
.stats-app-head h3 { font: 600 18px/1.4 var(--serif); }
.stats-search, .stats-expand { font-size: 12px; color: var(--ink-sec); text-decoration: underline; text-underline-offset: 3px; }
.stats-search { max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-expand { justify-self: end; padding: 5px 0; }
.stats-apps { display: grid; }
.stats-app {
  display: grid;
  align-items: center;
  width: 100%;
  grid-template-columns: 28px minmax(0, 1fr) auto 34px;
  gap: 8px;
  text-align: start;
  min-height: 44px;
  font-size: 13px;
}
.stats-app + .stats-app { border-top: var(--rule); }
.stats-app small { color: var(--ink-ter); text-align: end; }
.stats-app-glyph {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: var(--rule);
  border-radius: 7px;
  background: var(--surface);
  color: var(--dot, var(--other-accent));
  font: 600 15px var(--serif);
}
.stats-app-name, .stats-app-name .clip { display: block; min-width: 0; }
.stats-app-line { display: block; margin-top: 4px; height: 2px; background: var(--dot, var(--other-accent)); }
@media (min-width: 960px) {
  .stats-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats-kpi:nth-child(n) { padding: 20px; border: 0; }
  .stats-kpi:first-child { padding-left: 0; }
  .stats-kpi + .stats-kpi { border-left: var(--rule); }
  .stats-lower { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 28px; }
  .stats-summary { min-height: 48px; }
}

.stats-insight {
  padding: 12px 16px;
  border: var(--rule);
  border-inline-start: 3px solid var(--entertainment-accent);
  border-radius: 9px;
  background: var(--surface);
  font: 500 clamp(16px, 1.6vw, 19px)/1.6 var(--serif);
  overflow-wrap: anywhere;
}
.today-headline {
  margin-bottom: 16px;
  padding-block: 8px 12px;
  border-bottom: var(--rule);
  font: 500 clamp(20px, 2vw, 28px)/1.55 var(--serif);
  overflow-wrap: anywhere;
}
.today-headline p, .stats-insight { margin: 0; }
.recap-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.today-headline ul { margin: 8px 0 0; padding-inline-start: 20px; font: 14px/1.7 system-ui, sans-serif; }
.today-headline small { margin-inline-end: 8px; color: var(--ink-sec); }
.recap-actions, .balance-legend, .balance-chips { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.recap-actions button, .stats-open-day, .stats-short-app {
  color: var(--ink-sec); font: 13px/1.4 system-ui, sans-serif; min-height: 32px;
}
.recap-actions button { padding-inline: 0; }
.stats-open-day { color: var(--learning-accent); }
.stats-rhythm-scroll { overflow-x: auto; }
.stats-category-delta { color: var(--ink-sec); font-size: 11px; }
.balance-panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 8px; }
.balance-panel { padding: 14px; min-width: 0; background: var(--surface); border: var(--rule); border-radius: 10px; }
.balance-panel h3 { margin: 0; }
.stats-proportion { display: flex; height: 7px; overflow: hidden; border-radius: 4px; background: var(--hairline); margin: 12px 0 6px; }
.balance-legend { font-size: 12px; color: var(--ink-sec); }
.balance-legend span { display: inline-flex; align-items: center; gap: 4px; }
.balance-chips:not(:empty) { margin-top: 10px; }
.stats-short-app { padding-inline: 9px; border: var(--rule); border-radius: 16px; overflow-wrap: anywhere; }
.balance-device { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 8px; margin-top: 8px; font-size: 13px; }
.balance-device i { grid-column: 1 / -1; height: 3px; background: var(--work-accent); border-radius: 3px; }
@media (min-width: 740px) {
  .balance-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
