/* ptracker: built to make logging feel good.
   Deep indigo hero for energy, calm light board for focus, warm accents for wins.
   Text inks all >= 4.5:1 on their surfaces. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --bg: #F4F5FA;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --ink: #14152B;           /* 17:1 */
  --ink-2: #555A72;         /* 6.9:1 */
  --ink-3: #8A8FA6;         /* decoration, placeholders */
  --line: #E5E7F0;
  --accent: #4F46E5;        /* white text 6.3:1 */
  --accent-hover: #4338CA;
  --accent-soft: #EEF0FF;
  --flame: #F97316;
  --flame-ink: #C2410C;     /* 5.2:1 */
  --danger: #DC2626;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(20,21,43,.04), 0 8px 24px rgba(20,21,43,.06);
  --hero: linear-gradient(125deg, #1E1B4B 0%, #312E81 38%, #5B21B6 72%, #86198F 100%);

  /* One colour per activity (16, validated on white; only repeats past 16 activities) */
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --series-4: #f2a600;
  --series-5: #ee7fac;
  --series-6: #008a17;
  --series-7: #6a4ce2;
  --series-8: #ec4647;
  --series-9: #0ea5c6;
  --series-10: #a8329a;
  --series-11: #a0522d;
  --series-12: #7cb518;
  --series-13: #3d5afe;
  --series-14: #0d9488;
  --series-15: #d97706;
  --series-16: #db2777;

  /* Consistency ramp: one hue, light -> dark */
  --heat-0: #E9EBF3;
  --heat-1: #C7D2FE;
  --heat-2: #818CF8;
  --heat-3: #5B5BEA;
  --heat-4: #3730A3;

  --display: 'Outfit', 'Inter', system-ui, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
}
body.booting main { opacity: 0; }
main { transition: opacity .25s; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-2); font-size: 14px; }
.small { font-size: 12.5px; }

/* ── Header ── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px clamp(14px, 3vw, 32px);
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(255,255,255,.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.crumbs { display: flex; gap: 8px; font-size: 14px; color: var(--ink-2); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--hero); color: #fff; font-family: var(--display); font-weight: 700; font-size: 14px;
}
#who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; min-height: 44px; font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(79,70,229,.28);
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--accent-hover); box-shadow: 0 8px 20px rgba(79,70,229,.34); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 13px; box-shadow: 0 4px 10px rgba(79,70,229,.22); }
a.btn, a.ghost { text-decoration: none; }
.btn-light { background: #fff; color: var(--ink); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.btn-light:hover { background: #F1F2FF; box-shadow: 0 10px 24px rgba(0,0,0,.22); }
.btn.danger { background: var(--danger); box-shadow: 0 6px 16px rgba(220,38,38,.25); }
.ghost {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 18px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ghost { gap: 6px; color: var(--ink); }
.ghost:hover { background: var(--surface-2); border-color: #cfd3e2; }
.ghost.small { padding: 6px 14px; min-height: 36px; font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; padding: 6px 4px; }
.link-btn:hover { text-decoration: underline; }
.danger-link { color: var(--danger); margin-right: auto; }
.icon-btn {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-3); cursor: pointer;
}
.icon-btn:hover { background: #FEE2E2; color: var(--danger); }

/* ── Panels ── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { font-size: 18px; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }

/* ── Activity page ── */
.activity-page { max-width: 1280px; margin: 0 auto; padding: 18px clamp(12px, 3vw, 32px) 56px; }

/* Hero */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--hero); color: #fff; border-radius: 28px;
  padding: clamp(18px, 3vw, 30px); margin-bottom: 20px;
  box-shadow: 0 20px 40px rgba(49,46,129,.25);
}
.hero-glow {
  position: absolute; inset: auto -10% -60% 40%; height: 120%; z-index: -1;
  background: radial-gradient(closest-side, rgba(251,146,60,.55), rgba(244,114,182,.25) 55%, transparent 75%);
  filter: blur(10px);
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .35;
  background-image: radial-gradient(rgba(255,255,255,.35) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(90deg, transparent, #000 60%);
}
.hero-main { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.hero-date { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.78); }
.hero-title { font-size: clamp(32px, 5vw, 46px); font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 6px; }
.hero-msg { font-size: clamp(15px, 1.8vw, 18px); color: rgba(255,255,255,.92); max-width: 46ch; }

.ring-wrap { position: relative; width: 132px; height: 132px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255,255,255,.16); stroke-width: 10; }
.ring-fill { fill: none; stroke: url(#ringGrad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring-wrap.full .ring { filter: drop-shadow(0 0 10px rgba(251,146,60,.7)); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center strong { font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1.1; }
.ring-center span { font-size: 11.5px; color: rgba(255,255,255,.8); max-width: 90px; }

.day-strip { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin: 20px 0 14px; max-width: 640px; }
.day {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0;
  min-height: 58px; padding: 7px 0 11px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); color: #fff;
  transition: background .15s, transform .1s;
}
.day:hover { background: rgba(255,255,255,.2); }
.day-w { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.8); white-space: nowrap; }
.day-n { font-family: var(--display); font-size: 18px; font-weight: 700; }
.day-dot { position: absolute; bottom: 6px; width: 6px; height: 6px; border-radius: 50%; }
.day.has .day-dot { background: #FDBA74; }
.day[aria-pressed="true"] { background: #fff; color: var(--ink); border-color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.day[aria-pressed="true"] .day-w { color: var(--ink-2); }
.day[aria-pressed="true"].has .day-dot { background: var(--flame); }
.day:focus-visible { outline-color: #fff; }

.chips { list-style: none; display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 10px; border-radius: 16px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.14);
}
.chip strong { display: block; font-family: var(--display); font-size: 17px; font-weight: 700; line-height: 1.2; }
.chip small { display: block; font-size: 12px; color: rgba(255,255,255,.8); }
.chip-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.14); }
.chip-icon.flame { background: linear-gradient(135deg, #FB923C, #F43F5E); }

/* Board: list beside insights */
.board { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(0, 1.12fr); gap: 20px; align-items: start; }
.board > * { min-width: 0; }
.list-panel { position: sticky; top: 72px; max-height: calc(100vh - 88px); display: flex; flex-direction: column; }
.insights { display: flex; flex-direction: column; gap: 20px; }

/* Activity cards: slider always visible */
.acts { list-style: none; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; margin: 0 -6px; padding: 2px 6px 6px; overscroll-behavior: contain; }
.act {
  position: relative; border-radius: 18px; padding: 14px 16px 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.act.logged {
  background: color-mix(in srgb, var(--c) 7%, white);
  border-color: color-mix(in srgb, var(--c) 32%, white);
}
.act-top { display: flex; align-items: flex-start; gap: 12px; }
.act-dot { width: 14px; height: 14px; border-radius: 5px; background: var(--c); flex: none; margin-top: 4px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, white); }
.act-titles { flex: 1; min-width: 0; }
.act-name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.act-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.week-dots { display: inline-flex; gap: 3px; }
.week-dots i { width: 8px; height: 8px; border-radius: 50%; background: #DDE0EA; }
.week-dots i.on { background: var(--c); }
.week-dots i.sel { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--ink-3); }
.act-val {
  font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1.1; min-width: 56px; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.act:not(.logged) .act-val { color: var(--ink-3); font-weight: 600; }
.act .del { margin: -4px -8px 0 -4px; opacity: .7; }
.act .del:hover, .act .del:focus-visible { opacity: 1; }
.act-status { position: absolute; right: 16px; bottom: 8px; font-size: 11.5px; color: var(--ink-2); font-weight: 600; }

/* Stepped slider */
.act input[type="range"] {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 34px; margin-top: 8px;
  background: transparent; cursor: pointer; --fill: var(--c);
}
/* Not logged yet: still in the activity's own colour, just softer */
.act:not(.logged) input[type="range"] { --fill: color-mix(in srgb, var(--c) 55%, #D5D8E3); }
.act input[type="range"]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 5px;
  background: linear-gradient(to right, var(--fill) var(--pct, 0%), #E3E6EF var(--pct, 0%));
}
.act input[type="range"]::-moz-range-track { height: 10px; border-radius: 5px; background: #E3E6EF; }
.act input[type="range"]::-moz-range-progress { height: 10px; border-radius: 5px; background: var(--fill); }
.act input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%;
  background: #fff; border: 4px solid var(--fill); box-shadow: 0 2px 8px rgba(20,21,43,.25);
  transition: transform .1s;
}
.act input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.act input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 4px solid var(--fill); box-shadow: 0 2px 8px rgba(20,21,43,.25); }
.act input[type="range"]:focus-visible { outline-offset: 2px; }
.ticks { position: relative; height: 18px; margin: 0 14px; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

/* Wins */
.act.pop { animation: pop .7s ease-out; }
@keyframes pop {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 45%, transparent); transform: scale(1); }
  30% { transform: scale(1.012); }
  100% { box-shadow: 0 0 0 14px transparent; transform: scale(1); }
}
.spark {
  position: fixed; z-index: 60; width: 7px; height: 7px; border-radius: 2px; pointer-events: none;
  animation: spark .75s cubic-bezier(.2,.8,.3,1) forwards;
}
@keyframes spark {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(160deg) scale(.4); opacity: 0; }
}

.empty { text-align: center; padding: 26px 12px 18px; }
.empty-art {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center;
  font-size: 28px; color: #fff; background: var(--hero); box-shadow: 0 10px 24px rgba(79,70,229,.3);
}
.empty h3 { font-size: 20px; margin-bottom: 6px; }
.empty p { color: var(--ink-2); max-width: 38ch; margin: 0 auto 18px; }

/* Segmented range control */
.seg-group { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.seg { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; min-height: 34px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg:hover { color: var(--ink); }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(20,21,43,.12); }

/* Chart */
.chart-area { position: relative; }
#chart { position: relative; width: 100%; min-height: 200px; }
.chart-svg { display: block; overflow: visible; max-width: 100%; }
.chart-svg .gridline { stroke: #EDEEF3; stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .baseline { stroke: #C9CCD8; stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .tick { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .tick.sel { fill: var(--accent); font-weight: 700; }
.chart-svg .peak { fill: var(--ink); font-size: 11px; font-weight: 700; }
.chart-svg .sel-band { fill: var(--accent-soft); }
.chart-svg .hit { fill: transparent; outline: none; }
.chart-svg .hit.selectable { cursor: pointer; }
.chart-svg .hit.on { fill: rgba(20,21,43,.05); }
.chart-svg .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.chart-empty {
  position: absolute; inset: 26px 8px 30px 40px; display: grid; place-items: center;
  color: var(--ink-2); font-size: 14px; text-align: center; pointer-events: none;
}
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12px;
  min-width: 160px; max-width: 260px; box-shadow: 0 12px 30px rgba(20,21,43,.16);
}
.tip-head { display: flex; flex-direction: column; margin-bottom: 6px; }
.tip-head strong { font-family: var(--display); font-size: 17px; font-weight: 700; }
.tip-head span { color: var(--ink-2); }
.tip-row { display: flex; align-items: baseline; gap: 8px; padding: 1px 0; }
.tip-row i { width: 12px; height: 3px; border-radius: 2px; flex: none; transform: translateY(-3px); }
.tip-row strong { font-weight: 700; min-width: 48px; font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--ink-2); overflow-wrap: anywhere; }
.tip-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--accent); font-weight: 600; }

.table-wrap { margin-top: 12px; overflow: auto; max-height: 340px; border-top: 1px solid var(--line); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-wrap thead th { color: var(--ink-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.table-wrap tbody th { text-align: left; font-weight: 600; }

/* Where your time went */
.split { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.split-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 5px; }
.split-name { font-weight: 600; overflow-wrap: anywhere; }
.split-val { font-size: 13px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.split-bar { height: 10px; border-radius: 5px; background: #EEF0F5; overflow: hidden; }
.split-bar i { display: block; height: 100%; border-radius: 5px; background: var(--c); transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* Consistency grid */
.heat { display: flex; gap: 6px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; font-size: 10px; color: var(--ink-2); width: 24px; }
.heat-days span { line-height: 1; display: flex; align-items: center; }
.heat-grid { flex: 1; display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; gap: 3px; }
.heat-grid i { aspect-ratio: 1; border-radius: 4px; max-width: 18px; }
.heat-grid i.pick { cursor: pointer; }
.heat-grid i.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.heat-grid .future { background: transparent; }
.l0 { background: var(--heat-0); }
.l1 { background: var(--heat-1); }
.l2 { background: var(--heat-2); }
.l3 { background: var(--heat-3); }
.l4 { background: var(--heat-4); }
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; }

/* Dialogs */
.dialog {
  margin: auto; width: min(460px, calc(100vw - 24px)); border: 0; border-radius: 24px; padding: 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 60px rgba(20,21,43,.3);
}
.dialog::backdrop { background: rgba(20,21,43,.45); backdrop-filter: blur(3px); }
.dialog[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.dialog h2 { font-size: 22px; margin-bottom: 4px; }
.field { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 18px 0 6px; }
.dialog input:not([type="radio"]):not([type="checkbox"]), .dialog select {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 16px; font-family: inherit; color: var(--ink);
  border: 1.5px solid #D5D8E5; border-radius: 14px; background: var(--surface);
}
.dialog input:not([type="radio"]):not([type="checkbox"]):focus, .dialog select:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); outline-offset: 0; }
.dialog input::placeholder { color: var(--ink-3); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; min-height: 34px; }
.chip-btn:hover { background: var(--accent-soft); border-color: #C7CCFB; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ── Dashboard (index) ── */
.home { max-width: 1100px; margin: 0 auto; padding: 18px clamp(12px, 3vw, 32px) 56px; }
.home .hero { margin-bottom: 24px; }
.home-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.tracker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.tracker-card { display: flex; flex-direction: column; gap: 14px; text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.tracker-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(20,21,43,.05), 0 18px 36px rgba(20,21,43,.12); }
.tracker-top { display: flex; align-items: center; gap: 12px; }
.tracker-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--hero); color: #fff; flex: none; }
.tracker-card h2 { font-size: 18px; }
.tracker-card p { color: var(--ink-2); font-size: 14px; }
.tracker-stats { display: flex; gap: 24px; }
.tracker-stats div { display: flex; flex-direction: column; }
.tracker-stats span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tracker-stats strong { font-family: var(--display); font-size: 22px; font-weight: 700; }
.mini { display: block; width: 100%; height: 70px; }
.mini rect.bar { fill: #A5B4FC; }
.mini rect.bar.today { fill: var(--accent); }
.mini text { fill: var(--ink-2); font-size: 10px; }
.section-title { font-size: 18px; margin: 0 4px 12px; }
.tracker-body { display: flex; flex-direction: column; gap: 14px; }
.tracker-empty { color: var(--ink-2); font-size: 14px; }
.upcoming { list-style: none; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.upcoming li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13.5px; }
.upcoming i { width: 8px; height: 8px; border-radius: 50%; background: #A5B4FC; }
.upcoming .tone-warn i { background: #F59E0B; }
.up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-when { color: var(--ink-2); white-space: nowrap; }
.tracker-cta { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent); }
.tracker-card.placeholder { border-style: dashed; background: transparent; box-shadow: none; justify-content: center; align-items: center; text-align: center; min-height: 240px; color: var(--ink-2); }
.tracker-card.placeholder .tracker-icon { background: var(--accent-soft); color: var(--accent); }

/* ── Needs your attention (dashboard + trackers) ── */
.attention {
  margin-bottom: 24px; border: 2px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box,
              linear-gradient(120deg, #F97316, #E11D48 55%, #A855F7) border-box;
}
.attention.has-urgent { box-shadow: 0 1px 2px rgba(20,21,43,.04), 0 14px 34px rgba(225,29,72,.16); }
.attention.calm { background: var(--surface); border: 1px solid var(--line); padding: 14px 18px; }
.att-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.att-head h2 { font-size: 19px; }
.att-bell {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(135deg, #FB923C, #E11D48);
}
.has-urgent .att-bell { animation: ring-bell 2.6s ease-in-out 3; }
@keyframes ring-bell { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(12deg); } 82% { transform: rotate(-10deg); } 88% { transform: rotate(6deg); } }
.att-count { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; display: grid; place-items: center; background: #E11D48; color: #fff; font-weight: 700; font-size: 13px; }
.att-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.alert {
  --lvl: #6366F1; --lvl-bg: #EEF0FF; --lvl-ink: #3730A3;
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 12px 14px 12px 12px; border-radius: 16px;
  background: color-mix(in srgb, var(--lvl) 5%, white); border: 1px solid color-mix(in srgb, var(--lvl) 28%, white);
}
.alert.lvl-urgent { --lvl: #E11D48; --lvl-bg: #FFE4E6; --lvl-ink: #9F1239; }
.alert.lvl-soon { --lvl: #F59E0B; --lvl-bg: #FEF3C7; --lvl-ink: #92400E; }
.alert-count {
  align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 70px; border-radius: 12px; background: var(--lvl-bg); color: var(--lvl-ink); padding: 6px 4px;
}
.alert-count strong { font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1.05; }
.alert-count span { font-size: 11px; font-weight: 600; line-height: 1.2; }
.alert-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.alert-due { color: var(--lvl-ink); }
.alert h3 { font-size: 16.5px; margin: 2px 0 3px; overflow-wrap: anywhere; }
.alert h3 a { text-decoration: none; }
.alert h3 a:hover { text-decoration: underline; }
.alert-detail { font-size: 13.5px; color: var(--ink-2); }
.alert-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 360px; }
.calm-row { display: flex; align-items: center; gap: 12px; }
.calm-row p { color: var(--ink-2); }
.calm-row strong { color: var(--ink); }
.calm-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: #DCFCE7; color: #15803D; }

/* Hero chip that points at the alerts */
.chip.warn { background: rgba(255,255,255,.95); color: var(--ink); border-color: #fff; padding: 0; }
.chip.warn small { color: #9F1239; font-weight: 600; }
.chip-link { display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 10px; text-decoration: none; border-radius: 16px; }
.chip-icon.warn { background: linear-gradient(135deg, #FB923C, #E11D48); color: #fff; }

/* ── Subscriptions page ── */
.subs-page { max-width: 1180px; margin: 0 auto; padding: 18px clamp(12px, 3vw, 32px) 56px; }
.subs-page .hero-main { align-items: flex-start; flex-wrap: wrap; }
.subs-page .chips { margin-top: 18px; }
.subs-board { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.subs-side { display: flex; flex-direction: column; gap: 20px; }
.side-note { margin: -6px 0 12px; }
.cal-status { font-size: 14px; font-weight: 600; margin: 10px 0 12px; overflow-wrap: anywhere; }

.subs { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.sub {
  position: relative; border-radius: 18px; padding: 16px; scroll-margin: 90px;
  background: var(--surface-2); border: 1px solid var(--line); transition: box-shadow .3s, border-color .2s;
}
.sub.flag-urgent { background: #FFF6F7; border-color: #FDA4AF; }
.sub.flag-soon { background: #FFFCF0; border-color: #FCD34D; }
.sub.flag-info { border-color: #C7D2FE; }
.sub.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(79,70,229,.5); } 30% { box-shadow: 0 0 0 6px rgba(79,70,229,.25); } 100% { box-shadow: 0 0 0 14px transparent; } }
.sub-top { display: flex; align-items: flex-start; gap: 12px; }
.sub-logo {
  width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: var(--c); color: #fff; font-family: var(--display); font-weight: 800; font-size: 19px;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.st-off .sub-logo, .st-ending .sub-logo { filter: saturate(.35); opacity: .75; }
.sub-titles { flex: 1; min-width: 0; }
.sub-name { font-family: inherit; font-size: 16.5px; font-weight: 600; overflow-wrap: anywhere; letter-spacing: 0; }
.sub-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #ECEEF4; color: var(--ink-2); }
.tag.trial { background: #FEF3C7; color: #92400E; }
.tag.cancel { background: #FFE4E6; color: #9F1239; }
.tag.decide { background: #EDE9FE; color: #5B21B6; }
.tag.ending { background: #E0F2FE; color: #075985; }
.sub-price { text-align: right; white-space: nowrap; }
.sub-price strong { display: block; font-family: var(--display); font-size: 20px; font-weight: 700; line-height: 1.2; }
.sub-price span { font-size: 12px; color: var(--ink-2); }
.sub-when { margin: 14px 0 12px; }
.sub-when-text { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sub-when-text strong { font-size: 14.5px; font-weight: 600; }
.sub-when-text span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.flag-urgent .sub-when-text span { color: #9F1239; font-weight: 700; }
.flag-soon .sub-when-text span { color: #92400E; font-weight: 700; }
.sub-bar { height: 6px; border-radius: 3px; background: #E5E7EF; margin-top: 7px; overflow: hidden; }
.sub-bar i { display: block; height: 100%; border-radius: 3px; background: var(--c); }
.flag-urgent .sub-bar i { background: #E11D48; }
.flag-soon .sub-bar i { background: #F59E0B; }
.sub-plan { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub-plan-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.sub-plan .seg-group { background: var(--surface); }
.seg.plan-cancel[aria-pressed="true"] { color: #9F1239; }
.seg.plan-decide[aria-pressed="true"] { color: #5B21B6; }
.sub-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sub-actions .link-btn { margin-left: auto; }
.sub-history { margin-top: 12px; padding-top: 9px; border-top: 1px dashed #DADDE8; font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.subs.compact .sub { padding: 12px 14px; background: var(--surface); }
.subs.compact .sub-logo { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
.subs.compact .sub-price strong { font-size: 16px; }
.subs.compact .sub-when { margin: 8px 0 0; }
.subs.compact .sub-actions { margin-top: 10px; }

/* Forms */
.dialog.wide { width: min(580px, calc(100vw - 24px)); }
.dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
.dialog fieldset { border: 0; min-width: 0; }
.dialog legend { padding: 0; float: left; width: 100%; }
.dialog legend + * { clear: both; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.opt { font-weight: 400; color: var(--ink-3); }
.hint { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13.5px; font-weight: 600; margin-top: 12px; }
.form-error:empty { display: none; }
.money-input { display: flex; }
.dialog .money-input select { width: auto; flex: none; border-radius: 14px 0 0 14px; padding-right: 6px; background: var(--surface-2); }
.dialog .money-input input { border-radius: 0 14px 14px 0; border-left: 0; min-width: 0; }
.seg-group.radio { display: flex; width: 100%; }
.seg-group.radio label { flex: 1; position: relative; }
.seg-group.radio input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-group.radio span {
  display: grid; place-items: center; min-height: 42px; padding: 6px 10px; border-radius: 999px; text-align: center;
  font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg-group.radio input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(20,21,43,.14); }
.seg-group.radio input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.plan-pick input[value="cancel"]:checked + span { color: #9F1239; }
.plan-pick input[value="decide"]:checked + span { color: #5B21B6; }
.switch {
  display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); position: relative;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 44px; height: 26px; border-radius: 13px; background: #CDD1DE; position: relative; flex: none; transition: background .2s; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch strong { display: block; font-size: 14.5px; }
.switch small { display: block; font-size: 12.5px; color: var(--ink-2); }
.steps { margin: 10px 0 0 20px; font-size: 14px; color: var(--ink-2); }
.steps li { margin: 5px 0; }
.steps strong, .steps em { color: var(--ink); }

/* ── Sign-in ── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--hero); position: relative; overflow: hidden; isolation: isolate; }
.auth-wrap::after { content: ''; position: absolute; inset: 40% -20% -40% 30%; z-index: -1; background: radial-gradient(closest-side, rgba(251,146,60,.5), transparent 70%); filter: blur(20px); }
.auth-card { width: 100%; max-width: 400px; text-align: center; padding: 32px 26px; background: var(--surface); border-radius: 26px; box-shadow: 0 30px 60px rgba(0,0,0,.25); }
.auth-card .brand { justify-content: center; margin-bottom: 20px; font-size: 22px; }
.auth-card h1 { font-size: 26px; }
.auth-card > p { color: var(--ink-2); font-size: 15px; margin: 6px 0 24px; }
.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none;
  min-height: 50px; border-radius: 999px; border: 1.5px solid #D5D8E5; background: var(--surface); font-weight: 600; color: var(--ink);
}
.google-btn:hover { background: var(--surface-2); border-color: #B9BECF; }
.auth-msg { margin-top: 14px; font-size: 13.5px; min-height: 20px; }
.auth-msg[data-kind="error"] { color: var(--danger); }

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 18px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 70; max-width: 92vw;
  box-shadow: 0 12px 30px rgba(20,21,43,.3);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast[data-kind="error"] { background: var(--danger); }

@media (min-width: 901px) {
  .ring-wrap { width: 176px; height: 176px; margin-right: clamp(0px, 4vw, 48px); }
  .ring-center strong { font-size: 34px; }
  .ring-center span { font-size: 12.5px; max-width: 110px; }
}

/* ── Tablet & phone ── */
@media (max-width: 900px) {
  .board { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .list-panel { position: static; max-height: none; }
  .acts { overflow: visible; }
  .crumbs { display: none; }
  .insights { gap: 16px; }
  .subs-board { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .subs-side { gap: 16px; }
  .alert { grid-template-columns: 72px minmax(0, 1fr); }
  .alert-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  #who { display: none; }
  .activity-page, .home, .subs-page { padding-top: 10px; }
  .attention { margin-bottom: 16px; }
  .alert { grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding: 10px; }
  .alert-count { min-height: 60px; }
  .alert-count strong { font-size: 22px; }
  .sub { padding: 14px 12px; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .subs-page .hero-main > .btn { width: 100%; }
  .hero { border-radius: 22px; padding: 18px 16px; margin-bottom: 14px; }
  .hero-main { align-items: flex-start; }
  .hero-title { font-size: 30px; }
  .hero-msg { font-size: 14.5px; }
  .ring-wrap { width: 96px; height: 96px; }
  .ring-center strong { font-size: 19px; }
  .ring-center span { font-size: 10px; max-width: 70px; }
  .day-strip { gap: 4px; margin: 14px 0 12px; }
  .day { min-height: 52px; border-radius: 12px; }
  .day-w { font-size: 10px; }
  .day-n { font-size: 16px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .panel { padding: 16px 14px; border-radius: 18px; }
  .panel-head h2 { font-size: 17px; }
  .act { padding: 12px 12px 8px; }
  .act-val { font-size: 21px; min-width: 48px; }
  .ticks { font-size: 10px; margin: 0 14px; }
  .dialog { padding: 20px; border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
