/* Chalk & Silver with a breathing backlight.
   Colour is reserved for state: teal↔blue while tracking, amber during an interruption, none when idle. */
:root {
  --ground: #ecebe8;
  --ground-hi: #ffffff;
  --ground-lo: #dcdcd8;
  --ink: #0e1a2b;
  --ink-2: #45505f;
  --line: rgba(14, 26, 43, .12);
  --line-strong: rgba(14, 26, 43, .22);
  --card: rgba(255, 255, 255, .72);
  --card-solid: #fbfbfa;
  --chip: #ffffff;
  --inverse: #0e1a2b;
  --inverse-text: #f5f5f3;
  --alu-grain: repeating-linear-gradient(90deg, rgba(255,255,255,.55) 0 1px, rgba(0,0,0,.025) 1px 2px, rgba(255,255,255,.2) 2px 3px);
  --alu-base: linear-gradient(180deg, #f7f7f5, #dfe0dd 55%, #eeeeec);
  --edge-hi: rgba(255, 255, 255, 1);
  --lift: 0 1px 2px rgba(14,26,43,.06), 0 12px 32px -18px rgba(14,26,43,.25);
  --lift-big: 0 24px 48px -28px rgba(14,26,43,.35);
  /* backlight families */
  --cool-a: #2dd4bf;
  --cool-b: #60a5fa;
  --warm-a: #f59e0b;
  --warm-b: #fb923c;
  --glow-strength: .8;
  --warn: #8a4b08;
  --warn-bg: #fdf3e2;
  --error: #b42318;
  --ok: #0f766e;
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121417; --ground-hi: #1d2024; --ground-lo: #0b0c0e;
    --ink: #e9ecef; --ink-2: #a3abb5; --line: rgba(255,255,255,.1); --line-strong: rgba(255,255,255,.22);
    --card: rgba(255,255,255,.05); --card-solid: #1b1e22; --chip: rgba(255,255,255,.08);
    --inverse: #e9ecef; --inverse-text: #121417;
    --alu-grain: repeating-linear-gradient(90deg, rgba(255,255,255,.035) 0 1px, rgba(0,0,0,.12) 1px 2px, rgba(255,255,255,.015) 2px 3px);
    --alu-base: linear-gradient(180deg, #2a2d32, #1c1f23 55%, #24272b);
    --edge-hi: rgba(255,255,255,.08);
    --lift: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -18px rgba(0,0,0,.7);
    --lift-big: 0 24px 48px -28px rgba(0,0,0,.8);
    --glow-strength: .55;
    --warn: #f3c178; --warn-bg: #33270f; --error: #f59a8f; --ok: #5eead4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); min-height: 100vh;
  background: radial-gradient(900px 500px at 15% -5%, var(--ground-hi), transparent 60%),
              radial-gradient(800px 500px at 100% 100%, var(--ground-lo), transparent 60%), var(--ground);
  background-attachment: fixed;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 1200px; margin: 0 auto; padding: 0 24px 56px; }
.boot { color: var(--ink-2); padding: 40px 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 11px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--ink-2); }
h3 { font-size: .85rem; margin: 14px 0 6px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.error { color: var(--error); }
.warn { color: var(--warn); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.caps { font-size: 11px; font-weight: 700; letter-spacing: .36em; text-transform: uppercase; }

/* ---- surfaces ---- */
.alu { background: var(--alu-grain), var(--alu-base); box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -1px 0 rgba(0,0,0,.06), var(--lift-big); }
.surface { background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); border-radius: var(--radius); }

/* ---- header ---- */
header.top {
  position: sticky; top: 0; z-index: 5; padding: 18px 0 14px; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 12px 20px;
  background: linear-gradient(180deg, var(--ground) 70%, transparent);
}
.brand { font-size: 13px; font-weight: 700; letter-spacing: .42em; text-transform: uppercase; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); display: inline-block; }
.dot.live { background: var(--ok); }
.dot.polling, .dot.connecting { background: var(--warm-a); }
.dot.offline { background: var(--error); }
.tabs {
  display: flex; gap: 2px; padding: 4px; border-radius: 999px; overflow-x: auto; scrollbar-width: none;
  background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), 0 1px 2px rgba(14,26,43,.08);
}
.tabs a { padding: 9px 16px; border-radius: 999px; color: var(--ink-2); text-decoration: none; white-space: nowrap; font-size: 13px; font-weight: 500; transition: background .25s, color .25s; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--inverse); color: var(--inverse-text); }
main { padding-top: 10px; }

/* ---- controls ---- */
button, .button {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s, border-color .25s, background .25s;
}
button:hover:not(:disabled), .button:hover { border-color: var(--line-strong); }
button:active:not(:disabled) { transform: translateY(1px) scale(.99); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
button:disabled { opacity: .4; cursor: default; }
button[aria-busy="true"] { opacity: .7; cursor: progress; }
button.primary { background: var(--inverse); color: var(--inverse-text); border-color: var(--inverse); font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--card); }
button.ghost.on { background: var(--card); border-color: var(--line); }
button.link { background: none; border: none; color: var(--ink); font-weight: 600; padding: 6px 0; min-height: 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
button.small, .button.small { padding: 6px 12px; font-size: .85rem; min-height: 34px; }
button.pill { border-radius: 999px; background: transparent; border-color: var(--line-strong); font-size: 14px; font-weight: 500; padding: 0 22px; min-height: 46px; }
button.pill:hover:not(:disabled) { transform: translateY(-2px); }
button.danger, .danger { color: var(--error); }
input[type=text], input[type=search], input[type=password], input[type=time], input[type=date], select, textarea {
  font: inherit; color: var(--ink); background: var(--card-solid); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; width: 100%;
  min-height: 44px; box-shadow: inset 0 1px 2px rgba(14,26,43,.04);
}
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.field > span:first-child { font-size: 11px; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: .2em; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 14px; font-size: .95rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.spread { justify-content: space-between; }
.row.times .field { flex: 1; }
.row > input[type=search] { flex: 1 1 200px; width: auto; }
.row > .check { margin: 0; }
.segmented { display: inline-flex; background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), 0 1px 2px rgba(14,26,43,.08); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: none; background: transparent; min-height: 34px; padding: 6px 14px; font-size: .88rem; border-radius: 999px; }
.segmented button.on { background: var(--inverse); color: var(--inverse-text); font-weight: 600; }

/* ---- backlight ----
   A blurred light source sits behind an element (z-index -1 inside an isolated stage) and breathes.
   Families: .lit-cool (tracking) and .lit-warm (interruption). */
.stage { position: relative; isolation: isolate; }
.halo, .key-halo { position: absolute; z-index: -1; pointer-events: none; opacity: 0; }
.halo { left: 6%; right: 6%; bottom: -26px; height: 70%; border-radius: 40%; filter: blur(34px); }
.key-halo { left: 14%; right: 14%; bottom: -12px; height: 26px; border-radius: 50%; filter: blur(16px); }
.lit-cool .halo, .lit-cool .key-halo { animation: breathe 9s ease-in-out infinite, hueCool 18s ease-in-out infinite; }
.lit-warm .halo, .lit-warm .key-halo { animation: breathe 7s ease-in-out infinite, hueWarm 14s ease-in-out infinite; }
.lit-cool .key-halo, .lit-warm .key-halo { animation-delay: -2s; }
@keyframes breathe { 0%, 100% { opacity: calc(.4 * var(--glow-strength)); transform: scale(.96); } 50% { opacity: var(--glow-strength); transform: scale(1.02); } }
@keyframes hueCool { 0%, 100% { background: var(--cool-a); } 50% { background: var(--cool-b); } }
@keyframes hueWarm { 0%, 100% { background: var(--warm-a); } 50% { background: var(--warm-b); } }
.led { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-2); flex: 0 0 auto; }
.lit-cool .led { animation: hueCool 18s ease-in-out infinite, ledCool 9s ease-in-out infinite; }
.lit-warm .led { animation: hueWarm 14s ease-in-out infinite, ledWarm 7s ease-in-out infinite; }
@keyframes ledCool { 0%, 100% { box-shadow: 0 0 4px 1px rgba(45,212,191,.5); } 50% { box-shadow: 0 0 14px 3px rgba(96,165,250,.75); } }
@keyframes ledWarm { 0%, 100% { box-shadow: 0 0 4px 1px rgba(245,158,11,.5); } 50% { box-shadow: 0 0 14px 3px rgba(251,146,60,.8); } }
.lit-cool .edge { animation: edgeCool 18s ease-in-out infinite; }
.lit-warm .edge { animation: edgeWarm 14s ease-in-out infinite; }
@keyframes edgeCool { 0%, 100% { box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -2px 0 var(--cool-a), 0 14px 30px -18px rgba(45,212,191,.7); }
  50% { box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -2px 0 var(--cool-b), 0 14px 30px -18px rgba(96,165,250,.7); } }
@keyframes edgeWarm { 0%, 100% { box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -2px 0 var(--warm-a), 0 14px 30px -18px rgba(245,158,11,.75); }
  50% { box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -2px 0 var(--warm-b), 0 14px 30px -18px rgba(251,146,60,.75); } }
@media (prefers-reduced-motion: reduce) {
  .lit-cool .halo, .lit-cool .key-halo, .lit-cool .led { animation: none; background: #4fbfd8; opacity: calc(.6 * var(--glow-strength)); }
  .lit-warm .halo, .lit-warm .key-halo, .lit-warm .led { animation: none; background: var(--warm-a); opacity: calc(.7 * var(--glow-strength)); }
  .lit-cool .led, .lit-warm .led { opacity: 1; }
  .lit-cool .edge, .lit-warm .edge { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ---- current activity ---- */
.current { border-radius: 28px; padding: 36px 40px 26px; display: flex; flex-direction: column; gap: 18px; margin-bottom: 30px; }
.current-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 28px; }
.current-text { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1 1 380px; }
.state-word { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 700; letter-spacing: .4em; color: var(--ink-2); }
.lit-cool .state-word, .lit-warm .state-word { color: var(--ink); }
.activity { font-size: 32px; font-weight: 400; letter-spacing: -.01em; line-height: 1.15; overflow-wrap: anywhere; }
.elapsed { font-weight: 200; font-size: 96px; line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.elapsed .secs { font-size: .32em; letter-spacing: 0; color: var(--ink-2); margin-left: .25em; font-weight: 300; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ctx { font-size: 12px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-strong); font-weight: 600; }
.paused { border-radius: 14px; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  background: repeating-linear-gradient(-45deg, rgba(14,26,43,.035) 0 6px, transparent 6px 12px), var(--card); font-size: 14px; }
.corrections { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-left: -12px; }
.corrections button { background: none; border: none; font-size: 13px; font-weight: 600; padding: 8px 12px; min-height: 40px; }
.corrections button:hover { background: var(--card); }

.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; isolation: isolate; }
.key { position: relative; min-height: 84px; border: none; border-radius: var(--radius); justify-content: flex-start; gap: 14px; padding: 0 22px; text-align: left;
  background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); }
.key:hover:not(:disabled) { transform: translateY(-2px); }
.key.wide { grid-column: span 2; }
.key-icon { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.key-icon.solid { background: var(--inverse); border-color: var(--inverse); color: var(--inverse-text); }
.key-icon svg { width: 16px; height: 16px; }
.key-text { display: flex; flex-direction: column; min-width: 0; }
.key-title { font-size: 18px; font-weight: 600; }
.key-sub { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.below-keys { display: flex; justify-content: flex-end; margin: 6px 0 0; }

.columns { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; margin-top: 26px; }
.col-main { flex: 999 1 560px; min-width: 0; }
.col-side { flex: 1 1 320px; min-width: 0; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.today { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.today-total { font-size: 32px; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.split { display: flex; height: 4px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--line); }
.split span { display: block; height: 100%; background: var(--ink); }
.split span.unplanned { background: var(--ink-2); opacity: .55; }

.block { margin: 26px 0; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.block > h2 { margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
button.tile { flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: left; min-height: 96px; gap: 10px;
  border: none; border-radius: 18px; padding: 18px; background: var(--alu-grain), var(--alu-base); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); }
button.tile:hover:not(:disabled) { transform: translateY(-2px); }
button.tile strong { font-size: 17px; font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list.compact li { padding: 8px 12px; background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), 0 1px 2px rgba(14,26,43,.05); border-radius: 14px; }
.list li.archived { opacity: .55; }
.listbtn { width: 100%; justify-content: space-between; text-align: left; flex-wrap: wrap; border: none; background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), 0 1px 2px rgba(14,26,43,.05); border-radius: 14px; padding: 12px 16px; }
.listbtn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); }
.listbtn > span:first-child { flex: 1 1 200px; }
.listbtn.active { box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -2px 0 var(--cool-a), var(--lift); }

/* ---- chips ---- */
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; font-size: 12.5px; padding: 5px 12px; border-radius: 999px; background: var(--chip); color: var(--ink);
  box-shadow: 0 1px 2px rgba(14,26,43,.1); max-width: 100%; }
/* Label groups: a small backlit dot plus a faint tint of the group colour. */
.g-activity { --g: #3b82f6; } .g-project { --g: #8b5cf6; } .g-location { --g: #10b981; } .g-equipment { --g: #e0569b; }
.g-subject { --g: #d4a106; } .g-semester { --g: #f97316; } .g-cohort { --g: #06b6d4; } .g-other { --g: #94a3b8; }
.chip[class*="g-"] { background: color-mix(in srgb, var(--g) 9%, var(--chip)); box-shadow: 0 1px 2px rgba(14,26,43,.1), inset 0 0 0 1px color-mix(in srgb, var(--g) 22%, transparent); }
.chip[class*="g-"]::before, .gdot { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--g); box-shadow: 0 0 6px color-mix(in srgb, var(--g) 70%, transparent); flex: 0 0 auto; }
.chip[class*="g-"]::before { margin-right: 7px; }
.gdot { display: inline-block; margin-right: 8px; vertical-align: middle; }
.chip.sel { background: var(--inverse); color: var(--inverse-text); }
.chip.more { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip-btn, .chip-x { border: none; background: none; padding: 0; min-height: 0; font-size: inherit; color: inherit; border-radius: 0; }
.chip-x { margin-left: 6px; font-weight: 700; }
.picker .chip { font-size: .88rem; padding: 6px 12px; }
.picker .picked { margin-bottom: 10px; }
.picker-results { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.picker details summary { cursor: pointer; padding: 4px 0; font-size: .9rem; }
.create-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.create-row select { width: auto; }
.badge { display: inline-block; font-size: .7rem; padding: 2px 7px; border-radius: 6px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); margin-left: 6px; color: var(--ink-2); }
.badge.warn { background: var(--warn-bg); color: var(--warn); box-shadow: none; }
.task-pill { padding: 8px 12px; background: var(--card); border-radius: 10px; flex: 1; }

/* ---- timeline ---- */
.daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.daytitle { flex: 1; text-align: center; }
.timeline-list li.sess .listbtn { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: start; }
.when { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .9rem; }
.what { display: flex; flex-direction: column; gap: 6px; }
.what .meta { margin: 0; }
.dur { font-variant-numeric: tabular-nums; font-weight: 600; }
.sess.running .listbtn { box-shadow: inset 0 1px 0 var(--edge-hi), inset 0 -2px 0 var(--cool-a), var(--lift); }
.sess.k-interruption .listbtn { box-shadow: inset 0 1px 0 var(--edge-hi), inset 3px 0 0 var(--warm-a), 0 1px 2px rgba(14,26,43,.05); }
.sess.flagged .listbtn { background: var(--warn-bg); }
.gap { justify-content: center !important; color: var(--ink-2); font-size: .8rem; padding: 2px 0; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 12px; }
.notice .row { margin-top: 8px; }
.notice .row input { flex: 1; min-width: 0; }

/* ---- reports ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 12px 0; }
.card { background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); border-radius: 16px; padding: 14px 16px; }
.card.main { background: var(--alu-grain), var(--alu-base); }
.card-label { font-size: 11px; color: var(--ink-2); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.card-value { font-size: 1.5rem; font-weight: 300; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 90px; gap: 10px; align-items: center; font-size: .88rem; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 6px 0; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td:first-child { white-space: normal; min-width: 140px; }
th { color: var(--ink-2); font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.filters { background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); border-radius: var(--radius); padding: 16px; }

/* ---- settings ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; font-size: .92rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }

/* ---- sheets & toasts ---- */
dialog.sheet {
  border: none; border-radius: 24px; padding: 0; width: min(580px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
  background: var(--card-solid); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(14,26,43,.45), inset 0 1px 0 var(--edge-hi);
}
dialog.sheet[open] { animation: sheetIn .35s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
dialog.sheet::backdrop { background: rgba(14,26,43,.28); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card-solid); z-index: 1; }
.sheet-head h2 { font-size: 15px; letter-spacing: .02em; text-transform: none; color: var(--ink); font-weight: 600; }
.sheet-body { padding: 20px; }
#toasts { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(520px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--inverse); color: var(--inverse-text); box-shadow: var(--lift); font-size: .92rem; animation: sheetIn .3s cubic-bezier(.2,.8,.2,1); }
.toast-error { background: var(--error); color: #fff; }
.toast-ok { background: var(--inverse); color: var(--inverse-text); }

.login { max-width: 380px; margin: 18vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin-bottom: 18px; font-size: 13px; font-weight: 700; letter-spacing: .42em; text-transform: uppercase; }

@media (max-width: 640px) {
  #app { padding: 0 16px 48px; }
  header.top { padding-top: 12px; }
  .current { padding: 24px 22px 18px; border-radius: 24px; }
  .activity { font-size: 24px; }
  .elapsed { font-size: 64px; }
  .key.wide { grid-column: auto; }
  .keys { grid-template-columns: 1fr 1fr; gap: 12px; }
  .keys .key:first-child { grid-column: span 2; }
  .key { min-height: 72px; padding: 0 16px; gap: 10px; }
  .key-sub { display: none; }
  .keys .key:first-child .key-sub { display: block; }
  .timeline-list li.sess .listbtn { grid-template-columns: 1fr auto; }
  .timeline-list .when { grid-column: 1 / -1; }
}

/* ---- timeline overview ---- */
.ov-block > .row { margin-bottom: 14px; }
.ov { position: relative; background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); border-radius: var(--radius); padding: 14px 18px 12px; }
.ov-axis, .ov-lane { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; }
.ov-scale { position: relative; height: 18px; }
.ov-tick { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ov-lane { margin-top: 8px; }
.ov-label { display: flex; flex-direction: column; align-items: flex-start; gap: 0; font-size: 12px; font-weight: 600; text-align: left;
  background: none; border: none; padding: 2px 0; min-height: 0; border-radius: 6px; color: var(--ink); }
button.ov-label:hover { text-decoration: underline; text-underline-offset: 3px; }
.ov-sum { font-weight: 400; color: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.ov-lane.sel .ov-label > span:first-child::before { content: "› "; }
.ov-track { position: relative; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 4%, transparent); }
.ov-lane.sel .ov-track { box-shadow: inset 0 0 0 1px var(--line-strong); }
.ov-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.ov-off { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(-45deg, rgba(14,26,43,.06) 0 4px, transparent 4px 8px); border-radius: 10px; }
.ov-seg { position: absolute; top: 7px; bottom: 7px; padding: 0; min-height: 0; border: none; border-radius: 4px; background: var(--ink-2); cursor: pointer;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), filter .2s; }
/* Start and end marks: thin lines that reach past the bar. */
.ov-seg::before, .ov-seg::after { content: ""; position: absolute; top: -7px; bottom: -7px; width: 2px; border-radius: 2px; background: var(--ink); opacity: .55; }
.ov-seg::before { left: 0; }
.ov-seg::after { right: 0; }
.ov-seg:hover, .ov-seg:focus-visible { transform: scaleY(1.25); filter: brightness(1.08); outline-offset: 4px; }
.ov-seg.t-planned { background: var(--ink); }
.ov-seg.t-plain { background: color-mix(in srgb, var(--ink) 45%, var(--card-solid)); }
.ov-seg.t-warm { background: var(--warm-a); }
.ov-seg.running { box-shadow: 0 0 10px 1px color-mix(in srgb, var(--cool-a) 70%, transparent); }
.ov-seg.running::after { display: none; }
.ov-now { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--cool-b); border-radius: 2px; box-shadow: 0 0 8px var(--cool-b); }
.ov-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }
.ov-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ov-legend i { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }
.ov-legend i.t-planned { background: var(--ink); }
.ov-legend i.t-plain { background: color-mix(in srgb, var(--ink) 45%, var(--card-solid)); }
.ov-legend i.t-warm { background: var(--warm-a); }
.ov-legend i.mark { width: 2px; height: 14px; background: var(--ink); opacity: .55; }
.ov-tip { position: absolute; z-index: 20; width: max-content; max-width: min(300px, 90%); padding: 12px 14px; border-radius: 14px; background: var(--card-solid);
  box-shadow: 0 18px 40px -16px rgba(14,26,43,.45), inset 0 1px 0 var(--edge-hi), 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; font-size: 14px; animation: sheetIn .18s ease-out; }
.ov-tip-time { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .ov { padding: 12px; }
  .ov-axis, .ov-lane { grid-template-columns: 52px 1fr; gap: 8px; }
}
.ov-tip[hidden] { display: none; }

/* ---- trends ---- */
.report-kind { margin-bottom: 18px; }
.trends > .row { margin-bottom: 14px; }
.tracked { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 18px; }
.tracked-item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--card);
  box-shadow: inset 0 1px 0 var(--edge-hi), 0 1px 2px rgba(14,26,43,.08); font-size: 14px; }
.tracked-item .chip-x { min-height: 32px; min-width: 32px; justify-content: center; border-radius: 50%; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--sc); }
.swatch.total { background: color-mix(in srgb, var(--ink) 30%, transparent); }
/* Series colours: validated categorical palette, light and dark steps, fixed slot per series. */
.trends { --c0: #2a78d6; --c1: #eb6834; --c2: #1baf7a; --c3: #eda100; --c4: #e87ba4; --c5: #008300; --c6: #6250d6; --c7: #e34948; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .trends { --c0: #3987e5; --c1: #d95926; --c2: #199e70; --c3: #c98500; --c4: #d55181; --c5: #008300; --c6: #9085e9; --c7: #e66767; }
}
.s0 { --sc: var(--c0); } .s1 { --sc: var(--c1); } .s2 { --sc: var(--c2); } .s3 { --sc: var(--c3); }
.s4 { --sc: var(--c4); } .s5 { --sc: var(--c5); } .s6 { --sc: var(--c6); } .s7 { --sc: var(--c7); }
.chart { position: relative; background: var(--card); box-shadow: inset 0 1px 0 var(--edge-hi), var(--lift); border-radius: var(--radius); padding: 14px 16px 6px; overflow: hidden; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; margin-bottom: 8px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .ylab, .chart .xlab { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .total-area { fill: color-mix(in srgb, var(--ink) 7%, transparent); }
.chart .total-line { fill: none; stroke: color-mix(in srgb, var(--ink) 35%, transparent); stroke-width: 2; stroke-linejoin: round; }
.chart .line { fill: none; stroke: var(--sc); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .partial { stroke-dasharray: 4 4; }
.chart .pt { fill: var(--sc); stroke: var(--card-solid); stroke-width: 2; }
.chart .pt.hollow { fill: var(--card-solid); stroke: var(--sc); }
.chart .limit { stroke: var(--sc); stroke-width: 1.5; stroke-dasharray: 2 4; opacity: .9; }
.chart .end-text, .chart .total-text { fill: var(--ink); font-size: 12px; }
.chart .total-text { fill: var(--ink-2); }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart .hit:focus-visible { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.chart-tip { min-width: 200px; }
.chart-tip[hidden] { display: none; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-box { overflow-x: auto; }
.table-box table { display: table; }
.datatable { margin: 10px 0 20px; }
.datatable summary { cursor: pointer; font-size: 14px; color: var(--ink-2); padding: 6px 0; }

.toggle-row { margin: 0 0 12px; }
.toggle-row .check { margin-bottom: 2px; font-weight: 500; }
.toggle-row p { margin: 0 0 0 26px; }
