/* =====================================================================
   Purple cyberpunk theme (dark only).
   All colours live here; contrast was checked: body text 15:1, muted 8:1,
   links/primary ≥ 6.7:1 on cards, white button text ≥ 4.7:1 on the gradient.
   ===================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e0a1a;
  --surface: #1a1230;
  --surface-2: #221840;
  --border: #3b2a66;
  --text: #ede9f7;
  --muted: #b4a9cf;
  --neon-purple: #c084fc;
  --neon-pink: #f472b6;
  --neon-cyan: #22d3ee;
  --btn-from: #7e22ce;
  --btn-to: #c026d3;
  --ok: #4ade80;
  --bad: #fb7185;

  /* Chart series: fixed per media type. CVD-checked (worst adjacent ΔE 8.5). */
  --series-movie: #22d3ee;
  --series-series: #f472b6;
  --series-book: #fde047;
  --series-game: #818cf8;

  --pico-font-family-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pico-font-family: var(--pico-font-family-sans-serif);
  --heading-font: "Chakra Petch", var(--pico-font-family-sans-serif);
  --pico-border-radius: 0.35rem;

  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-text-selection-color: rgba(192, 132, 252, 0.35);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--border);
  --pico-h1-color: var(--text);
  --pico-h2-color: var(--text);
  --pico-h3-color: var(--text);
  --pico-h4-color: var(--text);
  --pico-h5-color: var(--text);
  --pico-h6-color: var(--text);

  --pico-primary: var(--neon-purple);
  --pico-primary-background: var(--btn-from);
  --pico-primary-border: var(--btn-from);
  --pico-primary-underline: rgba(192, 132, 252, 0.5);
  --pico-primary-hover: #e9d5ff;
  --pico-primary-hover-background: #9333ea;
  --pico-primary-hover-border: #9333ea;
  --pico-primary-hover-underline: #e9d5ff;
  --pico-primary-focus: rgba(34, 211, 238, 0.45);
  --pico-primary-inverse: #ffffff;

  --pico-secondary: var(--muted);
  --pico-secondary-background: var(--surface-2);
  --pico-secondary-border: var(--border);
  --pico-secondary-underline: rgba(180, 169, 207, 0.5);
  --pico-secondary-hover: var(--neon-cyan);
  --pico-secondary-hover-background: var(--surface-2);
  --pico-secondary-hover-border: var(--neon-cyan);
  --pico-secondary-focus: rgba(34, 211, 238, 0.35);
  --pico-secondary-inverse: var(--text);

  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--border);
  --pico-card-sectioning-background-color: var(--surface-2);
  --pico-card-box-shadow: 0 0 0 1px var(--border), 0 10px 30px -12px rgba(0, 0, 0, 0.8);

  --pico-form-element-background-color: #140e26;
  --pico-form-element-selected-background-color: var(--surface-2);
  --pico-form-element-border-color: var(--border);
  --pico-form-element-color: var(--text);
  --pico-form-element-placeholder-color: #8a7fa8;
  --pico-form-element-active-background-color: #140e26;
  --pico-form-element-active-border-color: var(--neon-cyan);
  --pico-form-element-focus-color: rgba(34, 211, 238, 0.35);

  --pico-ins-color: var(--ok);
  --pico-del-color: var(--bad);
  --pico-progress-background-color: var(--surface-2);
  --pico-progress-color: var(--neon-purple);
  --pico-table-border-color: var(--border);
  --pico-code-background-color: var(--surface-2);
  --pico-code-color: var(--neon-pink);
}

body {
  background:
    radial-gradient(1100px 550px at 5% -10%, rgba(168, 85, 247, 0.20), transparent 60%),
    radial-gradient(900px 500px at 105% 0%, rgba(236, 72, 153, 0.12), transparent 60%),
    linear-gradient(rgba(168, 85, 247, 0.045) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(168, 85, 247, 0.045) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, h4, hgroup h2, .brand, .stat-tiles strong, .stat strong, button, [role=button], .filters a, summary {
  font-family: var(--heading-font);
}
h1, h2, h3 { letter-spacing: 0.02em; text-shadow: 0 0 22px rgba(192, 132, 252, 0.35); }
h2 small { color: var(--muted); text-shadow: none; }

/* Top bar */
body > header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(14, 10, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, var(--neon-purple), var(--neon-pink), transparent) 1;
  margin-bottom: 1.5rem;
}
body > header nav { padding-block: 0.25rem; }
.brand { font-size: 1.35rem; letter-spacing: 0.06em; font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { color: var(--neon-pink); text-shadow: 0 0 12px rgba(244, 114, 182, 0.6); }
body > header nav a:not([role=button]) { color: var(--muted); }
body > header nav a:not([role=button]):hover { color: var(--neon-cyan); }
body > header nav a.brand { color: var(--text); }
body > header nav a[aria-current] { color: var(--neon-cyan); text-shadow: 0 0 10px rgba(34, 211, 238, 0.5); }

/* Buttons */
button:not(.secondary):not(.outline), [role=button]:not(.secondary):not(.outline), input[type=submit] {
  background: linear-gradient(135deg, var(--btn-from), var(--btn-to));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.03em;
}
button:not(.secondary):not(.outline):hover, [role=button]:not(.secondary):not(.outline):hover {
  box-shadow: 0 0 0 1px rgba(232, 121, 249, 0.6), 0 0 18px rgba(192, 38, 211, 0.55);
}
button.outline:not(.secondary) { color: var(--neon-cyan); border-color: rgba(34, 211, 238, 0.55); }
button.outline:not(.secondary):hover { background: rgba(34, 211, 238, 0.1); border-color: var(--neon-cyan); }

/* Cards & panels */
article { border: 1px solid var(--border); box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.9); position: relative; }
article::before {
  content: ""; position: absolute; left: -1px; top: -1px; width: 2.5rem; height: 2px;
  background: linear-gradient(90deg, var(--neon-cyan), transparent);
}
article > header { border-bottom: 1px solid var(--border); font-family: var(--heading-font); letter-spacing: 0.03em; }
a.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--pico-border-radius); }
a.card strong { color: var(--text); }
a.card { transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--neon-purple); box-shadow: 0 0 0 1px var(--neon-purple), 0 0 22px -4px rgba(192, 132, 252, 0.6); transform: translateY(-2px); }

/* Progress bars: neon gradient */
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink)); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink)); }

/* Focus is always visible */
:focus-visible { outline: 2px solid var(--neon-cyan); outline-offset: 2px; }

.narrow { max-width: 28rem; margin-inline: auto; }
form.inline { margin: 0; }
form.inline button { margin: 0; padding: 0.25rem 0.75rem; }
.stat { text-align: center; }
.stat strong { font-size: 2rem; }
.helptext, .helptext ul { font-size: 0.8rem; color: var(--pico-muted-color); }
.muted { color: var(--pico-muted-color); }
.message.error { border-left: 4px solid var(--bad); }
.message.success { border-left: 4px solid var(--ok); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.card { margin: 0; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; text-decoration: none; color: inherit; }
.card img, .card .no-cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--pico-border-radius); }
.card .no-cover { display: grid; place-items: center; background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface) 10px 20px); color: var(--muted); font-size: 0.8rem; }
.card small { display: block; }
.card form, .card button, .card [role=button] { margin: 0.25rem 0 0; width: 100%; padding: 0.3rem; }

.filters { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 0.5rem 1.5rem; margin-bottom: 1rem; }
.filters a { color: var(--muted); text-decoration: none; padding-bottom: 0.15rem; border-bottom: 2px solid transparent; }
.filters a:hover { color: var(--text); }
.filters a[aria-current] { color: var(--neon-cyan); font-weight: 600; border-bottom-color: var(--neon-cyan); }

.detail { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; }
.detail:has(.poster) { grid-template-columns: 200px 1fr; }
.detail .poster { width: 100%; border-radius: var(--pico-border-radius); }
@media (max-width: 600px) { .detail:has(.poster) { grid-template-columns: 1fr; } .detail .poster { max-width: 200px; } }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags span { font-size: 0.8rem; padding: 0.1rem 0.6rem; border-radius: 1rem; color: #e9d5ff; background: rgba(168, 85, 247, 0.15); border: 1px solid rgba(192, 132, 252, 0.35); }

.watches { list-style: none; padding: 0; }
.watches li { display: flex; align-items: center; justify-content: space-between; list-style: none; }

@media (max-width: 600px) {
  body > header { position: static; }
  header nav { flex-wrap: wrap; }
  header nav ul:first-child { width: 100%; }
  header nav ul:last-child { margin-left: 0; }
}

.type-tabs a { font-size: 1.25rem; }
.card progress { margin: 0.25rem 0 0; height: 0.3rem; }
button.small { padding: 0.2rem 0.6rem; font-size: 0.8rem; margin: 0; width: auto; }

.series-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 768px) { .series-layout { grid-template-columns: 1fr; } }
#series-progress { display: flex; flex-direction: column; gap: 0.4rem; }
#series-progress progress { margin: 0; }
.watch-date { display: flex; align-items: center; gap: 0.75rem; white-space: nowrap; }
.watch-date input { margin: 0; }

.season { border-bottom: 1px solid var(--pico-muted-border-color); padding-bottom: 0.5rem; }
.season summary small { margin-left: 0.5rem; }
.episodes { padding: 0; margin-top: 0.5rem; }
.episodes li { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.35rem 0; border-top: 1px solid var(--pico-muted-border-color); }
.episodes li.unaired { opacity: 0.55; }
.episodes li.watched > span strong { color: var(--neon-cyan); }
.episodes li button { flex-shrink: 0; }

/* ---- Stats ---- */
.swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-right: 0.4rem; vertical-align: baseline; }
.swatch-movie { background: var(--series-movie); }
.swatch-series { background: var(--series-series); }
.swatch-book { background: var(--series-book); }
.swatch-game { background: var(--series-game); }

.stats-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; margin-bottom: 1rem; }
.stats-filters .filters { margin: 0; }
.custom-range { margin: 0; width: 100%; max-width: 28rem; }
.custom-range input { min-width: 0; }
.custom-range button { flex: none; }
.period-nav { display: flex; align-items: center; gap: 0.75rem; }
.period-nav a { text-decoration: none; font-size: 1.4rem; line-height: 1; padding: 0 0.4rem; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-tiles article { margin: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.stat-tiles strong { font-size: 1.75rem; font-variant-numeric: tabular-nums; }
.stat-tiles .hero { background: linear-gradient(135deg, rgba(126, 34, 206, 0.35), rgba(192, 38, 211, 0.18)), var(--surface); border-color: rgba(192, 132, 252, 0.5); }
.stat-tiles .hero strong { font-size: 2.25rem; color: #fff; text-shadow: 0 0 20px rgba(232, 121, 249, 0.55); }

.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; }
.legend { display: flex; gap: 1rem; font-size: 0.9rem; }
.chart { position: relative; height: 240px; margin: 0.5rem 0 1.75rem 2.5rem; }
.y-axis { position: absolute; inset: 0; pointer-events: none; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(59, 42, 102, 0.8); }
.gridline.baseline { border-top-color: var(--pico-muted-color); }
.gridline span { position: absolute; right: calc(100% + 0.4rem); transform: translateY(-50%); font-size: 0.75rem; color: var(--pico-muted-color); }
.bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--count), 1fr); gap: 2px; }
.bar { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.bar:hover, .bar:focus { background: rgba(192, 132, 252, 0.08); }
.stack { width: min(70%, 2.5rem); height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; }
.seg { width: 100%; min-height: 2px; }
.stack .seg:last-child { border-radius: 4px 4px 0 0; }
.seg-movie { background: var(--series-movie); }
.seg-series { background: var(--series-series); }
.seg-book { background: var(--series-book); }
.section-title { margin: 2rem 0 1rem; }
.stat-tiles .hero-book { background: linear-gradient(135deg, rgba(253, 224, 71, 0.16), rgba(192, 38, 211, 0.12)), var(--surface); border-color: rgba(253, 224, 71, 0.45); }
.stat-tiles .hero-book strong { text-shadow: 0 0 20px rgba(253, 224, 71, 0.35); }
.stat-tiles .hero-game { background: linear-gradient(135deg, rgba(129, 140, 248, 0.22), rgba(192, 38, 211, 0.12)), var(--surface); border-color: rgba(129, 140, 248, 0.5); }
.stat-tiles .hero-game strong { text-shadow: 0 0 20px rgba(129, 140, 248, 0.45); }
.playtimes { margin-bottom: 0.5rem; }
.playtimes td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.playtimes tr.current td { color: var(--neon-cyan); font-weight: 600; }
.reading-tiles { grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); margin: 0; }
.reading-tiles div { display: flex; flex-direction: column; }
.reading-tiles strong { font-size: 1.4rem; }
.seg-game { background: var(--series-game); }
.x-label { position: absolute; top: calc(100% + 0.3rem); font-size: 0.7rem; color: var(--pico-muted-color); white-space: nowrap; }
.tip { display: none; position: absolute; bottom: calc(100% + 0.5rem); z-index: 2; min-width: 11rem; padding: 0.5rem 0.75rem; border-radius: var(--pico-border-radius); background: var(--surface-2); box-shadow: var(--pico-card-box-shadow); border: 1px solid var(--pico-muted-border-color); font-size: 0.8rem; flex-direction: column; gap: 0.15rem; pointer-events: none; }
.bar:hover .tip, .bar:focus .tip { display: flex; }
.bar:first-child .tip, .bar:nth-child(2) .tip { left: 0; }
.bar:last-child .tip, .bar:nth-last-child(2) .tip { right: 0; }
.tip b { float: right; margin-left: 1rem; font-variant-numeric: tabular-nums; }
.tip-total { border-top: 1px solid var(--pico-muted-border-color); padding-top: 0.15rem; margin-top: 0.15rem; }
.table-view table { font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.top-titles { padding-left: 1.25rem; }
.top-titles li { display: flex; justify-content: space-between; gap: 1rem; }
.top-titles a { text-decoration: none; }

.rating legend { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
.rating legend strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.story-na-hint { font-size: 0.85em; }

/* Score slider: ten slanted neon segments, lit pink → cyan up to the score. */
.score-field { margin-bottom: 1rem; }
.score-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.35rem; }
.score-head output {
  font-family: var(--heading-font); font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--neon-cyan); text-shadow: 0 0 10px rgba(34, 211, 238, 0.6); min-width: 2ch; text-align: right;
}
.score-slider {
  display: flex; gap: 0.25rem; padding: 0 0.3rem;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.score-slider .seg {
  --c: color-mix(in oklch, var(--neon-cyan) calc((var(--i) - 1) * 11%), var(--neon-pink));
  position: relative; flex: 1 1 0; min-width: 0; height: 2.6rem; margin: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  transform: skewX(-14deg); transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.score-slider .seg input { position: absolute; inset: 0; opacity: 0; margin: 0; pointer-events: none; }
.score-slider .seg span {
  transform: skewX(14deg); font-family: var(--heading-font); font-weight: 600; font-size: 0.9rem;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.score-slider .seg:hover { border-color: var(--c); }
/* Light the picked segment and every number before it. */
.score-slider .seg:not(.seg-clear):has(~ .seg:not(.seg-clear) input:checked),
.score-slider .seg:not(.seg-clear):has(input:checked) {
  background: color-mix(in srgb, var(--c) 30%, var(--surface)); border-color: var(--c);
  box-shadow: 0 0 8px color-mix(in srgb, var(--c) 45%, transparent);
}
.score-slider .seg:not(.seg-clear):has(~ .seg:not(.seg-clear) input:checked) span { color: var(--text); }
.score-slider .seg:not(.seg-clear):has(input:checked) {
  background: var(--c); box-shadow: 0 0 14px var(--c), 0 0 2px #fff inset;
}
.score-slider .seg:not(.seg-clear):has(input:checked) span { color: var(--bg); font-weight: 700; }
.score-slider .seg-clear { flex: 0 0 2.2rem; margin-left: 0.35rem; background: transparent; }
.score-slider .seg-clear:has(input:checked) span { color: var(--text); }
.score-slider .seg:has(input:focus-visible) { outline: 2px solid var(--neon-cyan); outline-offset: 2px; }
@media (max-width: 420px) {
  .score-slider { gap: 0.15rem; }
  .score-slider .seg { height: 2.9rem; }
  .score-slider .seg span { font-size: 0.8rem; }
  .score-slider .seg-clear { flex-basis: 1.9rem; }
}

.code-input { font-family: var(--heading-font); font-size: 1.6rem; letter-spacing: 0.4em; text-align: center; }
