:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --text: #16161a;
  --muted: #6b6b76;
  --line: #e6e6ea;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --pill-day-one-bg: #dcfce7; --pill-day-one-fg: #166534;
  --pill-wait-bg: #fef3c7;    --pill-wait-fg: #92400e;
  --pill-maybe-bg: #e5e7eb;   --pill-maybe-fg: #374151;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1014; --surface: #1a1b22; --text: #f2f2f5; --muted: #9a9aa6; --line: #2a2b35;
    --accent: #818cf8; --accent-soft: #2b2f57; --danger: #f87171; --danger-soft: #4a1d1d;
    --pill-day-one-bg: #14532d; --pill-day-one-fg: #bbf7d0;
    --pill-wait-bg: #713f12;    --pill-wait-fg: #fde68a;
    --pill-maybe-bg: #374151;   --pill-maybe-fg: #e5e7eb;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
.page { max-width: 520px; margin: 0 auto; padding: 8px 16px 48px; }

.topnav {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 520px; margin: 0 auto; padding: 12px 16px;
}
.brand { color: var(--muted); font-weight: 600; font-size: 14px; letter-spacing: .02em; }
.nav-link { font-weight: 600; font-size: 14px; }

.flash { list-style: none; max-width: 520px; margin: 0 auto; padding: 0 16px; }
.flash li { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; background: var(--accent-soft); font-size: 14px; }
.flash .flash-error { background: var(--danger-soft); }

/* Month header */
.month-header { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.month-header h1 { font-size: 22px; margin: 0; font-weight: 700; }
.month-nav {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  font-size: 28px; line-height: 1; color: var(--text); background: var(--surface); border: 1px solid var(--line);
}

/* Summary card */
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.summary-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total { font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.of-budget { color: var(--muted); font-size: 15px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin: 12px 0 8px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.summary.over .bar-fill { background: var(--danger); }
.over-line { margin: 0; color: var(--danger); font-weight: 600; font-size: 14px; }
.under-line { margin: 0; color: var(--muted); font-size: 14px; }

/* Day groups and rows */
.day-group { margin-bottom: 18px; }
.day-header {
  font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  margin: 0 0 6px 4px;
}
.day-group.vague .day-header { color: var(--accent); }
.row {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px;
}
.cover { width: 44px; height: 60px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--line); }
.cover-placeholder {
  display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13px; margin: 2px 0 4px; }
.row-sub .sep { margin: 0 5px; }
.delayed { color: var(--danger); font-weight: 500; }
.row-price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-price.estimated { color: var(--muted); font-weight: 600; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  letter-spacing: .02em;
}
.pill-day-one { background: var(--pill-day-one-bg); color: var(--pill-day-one-fg); }
.pill-wait-for-sale { background: var(--pill-wait-bg); color: var(--pill-wait-fg); }
.pill-maybe { background: var(--pill-maybe-bg); color: var(--pill-maybe-fg); }
.pill-owned { background: var(--accent-soft); color: var(--accent); }

/* Coming up */
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 28px 0 8px 4px; display: flex; justify-content: space-between; }
.section-meta { font-weight: 500; text-transform: none; letter-spacing: 0; }
.bucket { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 12px; margin-bottom: 8px; }
.bucket-later { border-style: dashed; }
.bucket-quarter .later-title::before, .bucket-year .later-title::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }
.later-summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 10px 0; list-style: none; }
.later-summary::-webkit-details-marker { display: none; }
.later-title { font-weight: 600; }
.later-meta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.bucket[open] .later-summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.bucket .row { border: none; background: transparent; padding-left: 0; padding-right: 0; }
.bucket-link { display: inline-block; font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.past-note { color: var(--muted); font-size: 13px; text-align: center; margin: 20px 0 0; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; }
.notice.error { background: var(--danger-soft); }
code { font-size: 13px; }

/* Search */
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { flex: 1; font: inherit; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); }
button { font: inherit; font-weight: 600; padding: 10px 14px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; cursor: pointer; }
.add-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.add-form select { font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.add-form button { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.result .cover { align-self: flex-start; }

/* Tappable rows */
.row-tappable { cursor: pointer; }
.row-tappable:hover, .row-tappable:focus-visible { border-color: var(--accent); outline: none; }

/* Detail sheet (bottom sheet built on <dialog>) */
.sheet {
  border: none; padding: 0; margin: auto 0 0 0; width: 100%; max-width: 100%;
  background: var(--surface); color: var(--text);
  border-radius: 20px 20px 0 0; box-shadow: 0 -8px 40px rgba(0,0,0,.25);
}
.sheet::backdrop { background: rgba(0,0,0,.45); }
@media (min-width: 640px) {
  .sheet { margin: auto; max-width: 480px; border-radius: 20px; }
}
.sheet-form { padding: 8px 20px 24px; max-width: 520px; margin: 0 auto; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 14px; }
.sheet-title { margin: 0; font-size: 20px; }
.sheet-sub { margin: 2px 0 16px; color: var(--muted); font-size: 14px; }
.sheet-field { display: flex; flex-direction: column; gap: 6px; border: none; padding: 0; margin: 0 0 16px; min-width: 0; }
.sheet-field > span, .sheet-field legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
.sheet-field small { color: var(--muted); font-size: 12px; }
.sheet-field input[type="number"], .sheet-field input[type="text"] {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented { display: flex; gap: 6px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 9px 6px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.segmented input:checked + span { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }
.sheet-actions .primary { flex: 1; }
.sheet-actions .ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.sheet-actions .danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); margin-left: auto; }

/* Nav */
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-link.muted { color: var(--muted); }
.inline-form { display: inline; }
.link-button { background: none; border: none; padding: 0; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }

/* Auth + settings forms */
.hero { margin: 12px 0 20px; }
.hero h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.01em; }
.hero p { margin: 0; color: var(--muted); }
.muted-line { color: var(--muted); font-size: 14px; margin: -6px 0 16px; }
.card-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input:not([type="checkbox"]), .field select {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}
.field small { color: var(--muted); font-size: 12px; }
.field small.error, .form-errors { color: var(--danger); }
.field.has-error input { border-color: var(--danger); }
.field-check label { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; color: var(--text); }
.field-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-errors { list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; }
button.wide { width: 100%; margin-top: 4px; }
.form-foot { margin: 14px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.sheet-field select {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}

.planned { color: var(--accent); font-weight: 600; }
.later-meta.empty-meta { opacity: .6; }

/* Steam import */
.import-controls { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.import-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.import-controls select { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.import-controls button { margin-left: auto; }
.import-row { cursor: pointer; }
.import-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.import-row.already { opacity: .6; }

/* Waiting for a sale */
.bucket-sale { border-color: var(--pill-wait-fg); border-style: dashed; }
.bucket-hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.pill-sale { background: var(--pill-day-one-bg); color: var(--pill-day-one-fg); margin-left: 4px; }

/* Linked Steam profile */
.linked { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.linked-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.linked-body { font-weight: 600; margin: 4px 0 2px; word-break: break-all; }
.linked-id { color: var(--muted); font-weight: 500; font-size: 13px; }
.linked-meta { color: var(--muted); font-size: 13px; }

/* Discover */
.when-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
.when { flex: 1; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; }
.when.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-links { gap: 12px; }
@media (max-width: 420px) { .nav-link.muted { font-size: 13px; } }

/* Share settings */
.share-card { margin-top: 0; }
.share-status { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.share-status.on { color: var(--text); }
.share-url { display: flex; gap: 8px; margin-bottom: 10px; }
.share-url input { flex: 1; font: inherit; font-size: 14px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); min-width: 0; }
.share-url .ghost { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 8px 14px; }
.share-actions { display: flex; gap: 16px; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.share-actions .link-button { color: var(--accent); font-size: 14px; }
.share-actions .danger-text { color: var(--danger); }

/* ---------- Desktop layout ----------
   Phones keep the single column above. From 900px the calendar splits into the month
   (left) and Coming up / sale pool (right); list pages get a wider, two-column grid. */
@media (min-width: 720px) {
  body { font-size: 16px; }
  .topnav { max-width: 1120px; padding: 16px 24px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .brand { font-size: 16px; }
  .nav-links { gap: 20px; }
  .nav-link, .link-button { font-size: 15px; }
  .flash { max-width: 1120px; padding: 0 24px; }
  .page { padding: 8px 24px 64px; }
  .layout-list .page { max-width: 880px; }
  .layout-narrow .page { max-width: 520px; }
}
@media (min-width: 900px) {
  .layout-calendar .page {
    max-width: 1120px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 0 40px;
    align-items: start;
  }
  .layout-calendar .col-side { position: sticky; top: 16px; }
  .layout-calendar .col-side .section-title:first-child { margin-top: 12px; }
  .layout-calendar .month-header h1 { font-size: 28px; }
  .layout-calendar .total { font-size: 48px; }
  .layout-list .page { max-width: 1120px; }
  .layout-list .row.result { margin-bottom: 0; }
  .layout-list main > .row.result, .layout-list main > form > .row { margin-bottom: 10px; }
  .results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero h1 { font-size: 32px; }
}

.brand, .nav-link { white-space: nowrap; }
@media (max-width: 480px) { .nav-note .long { display: none; } }

/* Sheet outbound links */
.sheet-title a { color: var(--text); text-decoration: none; }
.sheet-title a:hover { color: var(--accent); }
.sheet-links { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.sheet-links a { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.sheet-links a:hover { color: var(--accent); border-color: var(--accent); }

/* Subscriptions */
.summary-split { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.day-header .day-meta { float: right; text-transform: none; letter-spacing: 0; font-weight: 500; }
.cover-sub { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.row-sub .row-price small { font-size: 11px; color: var(--muted); font-weight: 500; }
.subs-hint { color: var(--muted); font-size: 13px; margin: 8px 4px 16px; }
.subs-note { color: var(--muted); font-weight: 400; }
.sub-add .sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sub-add small.muted-line { display: block; margin: -4px 0 12px; }
.sub-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin-top: 8px; }
.sub-controls label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sub-controls label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); padding-bottom: 8px; }
.sub-controls input[type="number"], .sub-controls select { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 110px; }
.sub-controls input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
button.small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
button.small.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.sub-row.inactive .row-title { color: var(--muted); text-decoration: line-through; }
.primary-link { font-weight: 600; }
.sub-controls input[type="text"] { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 140px; }

/* Subscription brand tiles */
.cover-sub { display: grid; place-items: center; flex-shrink: 0; }
.cover-sub img { width: 26px; height: 26px; }
.cover-mono { color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .04em; }
.sub-row { align-items: flex-start; }
.sub-row .cover-sub { margin-top: 2px; }

/* One-tap add buttons */
.add-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.add-quick { display: inline; }
.plat { padding: 6px 11px; font-size: 13px; border-radius: 8px; border: 1px solid transparent; color: #fff; }
.plat-pc { background: #1b2838; }
.plat-ps5 { background: #0070d1; }
.plat-xbox { background: #107c10; }
.plat-switch2, .plat-switch { background: #e60012; }
.plat-own { background: transparent; color: var(--accent); border-color: var(--accent); }
.plat:hover { filter: brightness(1.15); }
.setup-hint { font-size: 12px; color: var(--muted); }
.pill-owned-status, .pill-owned { }
.pill-owned { background: var(--accent-soft); color: var(--accent); }
.critic { font-weight: 600; }
.critic.good { color: #16a34a; }
.critic.mixed { color: #d97706; }
.critic.bad { color: #dc2626; }
.pill.critic { background: transparent; border: 1px solid currentColor; margin-left: 4px; }
.check-list ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.check-list li label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--text); }
.check-list input { width: 16px; height: 16px; accent-color: var(--accent); }
.spent { color: var(--accent); }
.bought .day-header { color: var(--accent); }

/* ---------- Mobile fixes ----------
   Nothing may push the page wider than the screen. */
html, body { max-width: 100%; overflow-x: hidden; }
.page, .row, .row-main, .sheet-field, .sheet-grid > *, .results-grid > *, .import-controls, .sub-controls { min-width: 0; }
img, svg { max-width: 100%; }

/* Header: brand + logout on the first row, links on a wrapping second row */
.topnav { display: block; padding: 10px 16px 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.navrow { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 0 10px; border-bottom: 1px solid var(--line); margin: 0 -16px 4px; padding-left: 16px; padding-right: 16px; }
.navrow .nav-link { color: var(--muted); font-size: 14px; padding: 4px 0; }
.navrow .nav-link.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.navrow .nav-link:first-child { color: var(--text); }
.nav-links { display: contents; }
@media (min-width: 720px) {
  .topnav { display: flex; align-items: center; gap: 28px; padding: 14px 24px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .topbar { order: 0; }
  .navrow { order: 1; flex: 1; border: none; margin: 0; padding: 0; gap: 20px; }
  .topbar .inline-form { order: 2; }
  .topnav .topbar { flex: 0 0 auto; gap: 24px; }
  .topnav { justify-content: flex-start; }
  .topnav .topbar .inline-form { position: absolute; right: 24px; }
  .topnav { position: relative; }
}

/* Detail / info sheets on phones */
.sheet { box-sizing: border-box; }
.sheet-form { box-sizing: border-box; width: 100%; padding: 8px 16px 20px; }
.sheet-field input, .sheet-field select { min-width: 0; box-sizing: border-box; }
@media (max-width: 440px) {
  .sheet-grid { grid-template-columns: 1fr; }
  .segmented { flex-wrap: wrap; }
  .segmented label { flex: 1 1 45%; }
  .sheet-actions { flex-wrap: wrap; }
  .sheet-actions .primary { flex: 1 1 100%; }
  .sheet-actions .danger { margin-left: 0; }
  .sub-add .sub-grid { grid-template-columns: 1fr; }
}

/* Info sheet (search / discover) */
.result-tappable { cursor: pointer; }
.result-tappable:hover, .result-tappable:focus-visible { border-color: var(--accent); outline: none; }
.info-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.info-cover { width: 64px; height: 86px; border-radius: 8px; flex-shrink: 0; }
.info-text { min-width: 0; }
.info-text .sheet-sub { margin: 2px 0 0; }
.info-actions { margin: 4px 0 14px; }
.info-actions .add-actions { margin-top: 0; }
.pill-library { background: var(--pill-day-one-bg); color: var(--pill-day-one-fg); }

/* Explicit theme choice (header toggle) beats the device setting */
:root[data-theme="dark"] {
    --bg: #0f1014; --surface: #1a1b22; --text: #f2f2f5; --muted: #9a9aa6; --line: #2a2b35;
    --accent: #818cf8; --accent-soft: #2b2f57; --danger: #f87171; --danger-soft: #4a1d1d;
    --pill-day-one-bg: #14532d; --pill-day-one-fg: #bbf7d0;
    --pill-wait-bg: #713f12;    --pill-wait-fg: #fde68a;
    --pill-maybe-bg: #374151;   --pill-maybe-fg: #e5e7eb;
  }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- Visual pass ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.theme-toggle { background: var(--surface); border: 1px solid var(--line); color: var(--muted); width: 32px; height: 32px; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 15px; line-height: 1; cursor: pointer; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun, .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; } }
:root[data-theme="light"] .theme-toggle .sun { display: inline; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .theme-toggle .sun { display: inline; } }

/* Summary card with cover-art backdrop */
.summary-hero { position: relative; overflow: hidden; isolation: isolate; background: linear-gradient(135deg, #312e81, #4c1d95); border-color: transparent; color: #fff; }
.summary-hero .of-budget, .summary-hero .under-line, .summary-hero .summary-split { color: rgba(255,255,255,.8); }
.summary-hero .bar { background: rgba(255,255,255,.18); }
.summary-hero .bar-fill { background: #fff; }
.summary-hero.over .bar-fill { background: #fca5a5; }
.summary-hero .over-line { color: #fecaca; }
.summary-hero .spent { color: #c7d2fe; }
.hero-covers { position: absolute; inset: -20px; display: flex; z-index: -2; filter: blur(22px) saturate(1.3); opacity: .55; }
.hero-covers img { flex: 1; min-width: 0; height: 100%; object-fit: cover; }
.hero-shade { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(20,18,50,.85), rgba(20,18,50,.55)); }

/* Platform colour dots */
.plat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--muted); }
.plat-dot-pc { background: #60a5fa; }
.plat-dot-ps5 { background: #0070d1; }
.plat-dot-xbox { background: #107c10; }
.plat-dot-switch2, .plat-dot-switch { background: #e60012; }

/* Covers and rows */
.cover { box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.result .cover { width: 56px; height: 76px; }
.row { transition: transform .12s ease, border-color .12s ease; }
.row-tappable:hover, .result-tappable:hover { transform: translateY(-1px); }
.day-header { color: var(--accent); }
.day-group.vague .day-header { color: var(--muted); }

/* Cover strip, second pass: bolder */
.summary-hero { padding: 18px 16px 16px; }
.hero-covers { inset: -12px; filter: blur(7px) saturate(1.4) brightness(.9); opacity: .95; }
.hero-shade { background: linear-gradient(180deg, rgba(18,16,48,.82) 0%, rgba(18,16,48,.55) 55%, rgba(18,16,48,.8) 100%); }
.summary-hero .total, .summary-hero .of-budget, .summary-hero .over-line, .summary-hero .under-line, .summary-hero .summary-split { text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.hero-row { display: flex; gap: 6px; margin: 12px 0 4px; }
.hero-row img { width: 40px; height: 54px; object-fit: cover; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.25); }
@media (min-width: 900px) { .hero-row img { width: 48px; height: 65px; } }

/* Sheet close button */
.sheet-form { position: relative; }
.sheet-close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 22px; line-height: 1; padding: 0; display: grid; place-items: center; cursor: pointer; }
.sheet-close:hover { color: var(--text); border-color: var(--accent); }
.sheet-title, .info-head { padding-right: 40px; }

/* Header, bolder */
.topnav { background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 var(--line), 0 6px 24px rgba(0,0,0,.12); }
.topnav::before { content: ""; display: block; height: 3px; margin: -10px -16px 10px; background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899); }
@media (min-width: 720px) { .topnav::before { position: absolute; top: 0; left: 0; right: 0; margin: 0; } }
.brand { font-size: 17px; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.brand-mark { width: 26px; height: 26px; box-shadow: 0 2px 8px rgba(99,102,241,.45); }
.navrow { border-bottom: none; gap: 6px; }
.navrow .nav-link { padding: 6px 12px; border-radius: 999px; font-weight: 600; color: var(--muted); border: 1px solid transparent; }
.navrow .nav-link:first-child { color: var(--muted); }
.navrow .nav-link:hover { color: var(--text); background: var(--bg); }
.navrow .nav-link.active { color: #fff; background: var(--accent); border-color: var(--accent); border-bottom: 1px solid var(--accent); }
.source-toggle { margin: 10px 0 14px; }
.source-toggle input { display: none; }
.source-toggle .when { cursor: pointer; }
.source-toggle .when.disabled { opacity: .45; cursor: not-allowed; }

/* Room in your budget */
.suggest { margin: 22px 0 6px; }
.suggest .day-header { color: #16a34a; }
.suggest-card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid #16a34a; border-radius: var(--radius); padding: 10px 12px 4px; }
.suggest-intro { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.suggest .row { border: none; background: transparent; padding-left: 0; padding-right: 0; }
.suggest .plan-form { margin-left: 8px; }
.suggest .plan-form button { padding: 6px 10px; font-size: 12px; border-radius: 8px; white-space: nowrap; }
.row-with-action { display: flex; align-items: center; gap: 6px; }
.row-with-action .row { flex: 1; min-width: 0; margin-bottom: 4px; }

/* Landing */
.landing { max-width: 520px; margin: 0 auto; }
@media (min-width: 900px) {
  .landing { max-width: 1000px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: start; }
  .landing .hero { margin-top: 28px; }
  .landing .card-form { margin-top: 36px; }
}
.how { padding-left: 22px; margin: 18px 0 8px; display: grid; gap: 10px; color: var(--text); }
.how li { line-height: 1.45; }
.how li::marker { color: var(--accent); font-weight: 700; }
.how-foot { color: var(--muted); font-size: 14px; }

/* Footer */
.site-foot { max-width: 1120px; margin: 24px auto 0; padding: 16px 16px 28px; border-top: 1px solid var(--line); display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

/* Prose pages */
.prose { max-width: 640px; }
.prose h2 { font-size: 16px; margin: 22px 0 6px; }
.prose ul { padding-left: 20px; margin: 0; }
.prose li, .prose p { color: var(--text); line-height: 1.5; margin: 4px 0; }

/* Delete account */
.danger-card { border-color: var(--danger); }
.danger-solid { background: var(--danger); color: #fff; }
.danger-solid:hover { filter: brightness(1.1); }

/* Subscription catalog pills */
.pill-service { background: transparent; color: #107c10; border: 1px solid #107c10; margin-left: 4px; }
.pill-service.included { background: #107c10; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill-service { color: #4ade80; border-color: #4ade80; } :root:not([data-theme="light"]) .pill-service.included { background: #166534; color: #dcfce7; border-color: #166534; } }
:root[data-theme="dark"] .pill-service { color: #4ade80; border-color: #4ade80; }
:root[data-theme="dark"] .pill-service.included { background: #166534; color: #dcfce7; border-color: #166534; }
