:root {
  color-scheme: dark;
  --bg: #100B24;
  --surface: #1B1538;
  --surface-2: #241c48;
  --surface-3: #2e2458;
  --purple: #8656E8;
  --lilac: #B49AFF;
  --text: #F4EFFF;
  --muted: #B5AACF;
  --magic: #72DFD0;
  --gold: #F1CA78;
  --danger: #e99ba9;
  --line: #493b78;
  --shadow: 0 18px 50px #08031380;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Trebuchet MS", var(--font);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 90% -10%, #6d49c940, transparent 34rem), radial-gradient(circle at -10% 28%, #287d7c22, transparent 27rem), var(--bg); color: var(--text); font: 400 15px/1.5 var(--font); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--magic); outline-offset: 3px; }
a { color: inherit; }
.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 20px clamp(16px, 4vw, 48px) 36px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 4px 0 22px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 42px; height: 42px; filter: drop-shadow(0 6px 12px #0005); }
.brand strong { display: block; font: 800 18px/1 var(--display); letter-spacing: .14em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.freshness { color: var(--muted); font-size: 12px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: #241a4c99; color: var(--magic); font-size: 20px; }
.hero-card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-height: 300px; align-items: center; overflow: hidden; border: 1px solid #6954a8; border-radius: var(--radius-lg); background: linear-gradient(115deg, #24184d 0%, #1b1538 57%, #172e4a 100%); box-shadow: var(--shadow); }
.hero-card::before, .hero-card::after { content: ""; position: absolute; border: 1px solid #b49aff26; border-radius: 50%; pointer-events: none; }
.hero-card::before { width: 480px; height: 480px; right: -140px; top: -155px; box-shadow: 0 0 0 38px #b49aff0a, 0 0 0 78px #b49aff06; }
.hero-card::after { width: 190px; height: 190px; right: 34px; bottom: -114px; }
.hero-copy { position: relative; z-index: 1; padding: clamp(28px, 6vw, 54px); }
.eyebrow { margin: 0 0 10px; color: var(--magic); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--display); }
h1 { margin-bottom: 16px; font-size: clamp(36px, 7vw, 68px); line-height: .98; letter-spacing: -.06em; }
h1 em { color: var(--lilac); font-style: normal; }
.hero-copy > p:not(.eyebrow) { max-width: 590px; margin-bottom: 22px; color: #d5cceb; }
.hero-actions, .button-row, .heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.hero-orbit { position: relative; z-index: 1; display: grid; place-items: center; align-self: stretch; }
.hero-orbit img { width: 170px; height: 170px; filter: drop-shadow(0 20px 18px #08031366); animation: float 5s ease-in-out infinite; }
.hero-orbit span { position: absolute; color: var(--gold); font-size: 24px; }
.hero-orbit span:first-of-type { top: 24%; right: 18%; }
.hero-orbit span:last-of-type { bottom: 22%; left: 15%; color: var(--magic); }
@keyframes float { 50% { transform: translateY(-7px) rotate(2deg); } }
.button { min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text); font-size: 13px; font-weight: 750; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { border-color: #a887ff; background: var(--purple); box-shadow: 0 8px 22px #8656e844; }
.button-primary:hover { background: #986cf1; }
.button-ghost, .button-soft { border-color: var(--line); background: #241a4c80; }
.button-soft { background: #2d2358; color: #dfd3ff; }
.button-ghost:hover, .button-soft:hover { border-color: var(--lilac); background: #382d68; }
.primary-nav { display: flex; gap: 7px; overflow-x: auto; margin: 22px 0 30px; padding: 5px; border: 1px solid #3c3066; border-radius: 16px; background: #17112fdd; scrollbar-width: thin; }
.nav-tab { flex: 1 0 auto; display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 45px; padding: 9px 16px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 750; white-space: nowrap; }
.nav-tab span { color: var(--lilac); font-size: 17px; }
.nav-tab:hover { color: var(--text); background: #2b2054; }
.nav-tab.is-active { border-color: #8568d4; background: #352660; color: var(--text); box-shadow: inset 0 -2px var(--magic); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 19px; }
.section-heading h2 { margin-bottom: 4px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; }
.section-heading p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.view-note, .muted { color: var(--muted); font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card, .panel-card { border: 1px solid #3d3165; border-radius: var(--radius-md); background: linear-gradient(145deg, #211944e8, #17112fdd); box-shadow: 0 8px 28px #08031326; }
.stat-card { position: relative; overflow: hidden; padding: 18px; }
.stat-card::after { content: "✦"; position: absolute; right: 14px; top: 9px; color: #b49aff33; font-size: 30px; }
.stat-card strong { display: block; font: 800 30px/1 var(--display); color: var(--lilac); }
.stat-card span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.dashboard-grid, .backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel-card { padding: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-heading h3, .panel-card h3 { margin-bottom: 0; font-size: 17px; }
.text-button { padding: 3px; border: 0; background: transparent; color: var(--magic); font-size: 12px; font-weight: 750; }
.stack-list { display: grid; gap: 9px; }
.stack-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px; border: 1px solid #3d3165; border-radius: 12px; background: #2a205022; }
.stack-icon, .poster { display: grid; flex: 0 0 auto; place-items: center; width: 40px; height: 48px; border-radius: 10px; background: linear-gradient(145deg, #7655ce, #235a69); font-size: 22px; }
.stack-copy { min-width: 0; flex: 1; }
.stack-copy strong, .stack-copy span { display: block; overflow-wrap: anywhere; }
.stack-copy strong { font-size: 13px; }
.stack-copy span { color: var(--muted); font-size: 11px; }
.empty-state { padding: 24px 8px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--lilac); }
.calendar-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.select-wrap select, .section-heading select, .search-input { min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none; background: #211944; color: var(--text); }
.search-input { min-width: 230px; }
.day-selector { display: none; gap: 7px; overflow-x: auto; margin-bottom: 11px; padding-bottom: 4px; }
.day-chip { flex: 0 0 auto; min-width: 80px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: #211944; color: var(--muted); text-align: left; }
.day-chip strong, .day-chip small { display: block; }
.day-chip small { color: var(--muted); font-size: 10px; }
.day-chip.is-active { border-color: var(--lilac); background: #382b68; color: var(--text); }
.calendar-layout { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
.calendar-day { min-width: 0; min-height: 230px; padding: 10px; border: 1px solid #3d3165; border-radius: 14px; background: #17112fbb; }
.calendar-day.is-selected { border-color: var(--lilac); box-shadow: 0 0 0 1px #b49aff44; }
.calendar-day > header { display: flex; justify-content: space-between; gap: 5px; padding: 2px 2px 9px; border-bottom: 1px solid #3d3165; }
.calendar-day h3 { margin: 0; font-size: 12px; }
.calendar-day header span { color: var(--muted); font-size: 10px; }
.episode-card { position: relative; margin-top: 8px; padding: 9px; border: 1px solid #493b78; border-radius: 11px; background: #241b48; }
.episode-card strong, .episode-card span { display: block; overflow-wrap: anywhere; }
.episode-card strong { font-size: 12px; }
.episode-card span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.episode-card .confidence { color: var(--magic); }
.episode-card small, .episode-card a { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 10px; }
.episode-card small { color: var(--gold); }
.episode-poster { float: left; width: 32px; height: 45px; margin: 0 6px 5px 0; border-radius: 5px; object-fit: cover; }
.library-grid, .result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.library-card, .result-card { display: flex; gap: 13px; min-width: 0; padding: 14px; border: 1px solid #3d3165; border-radius: var(--radius-md); background: #17112fdd; }
.library-card .poster { width: 62px; height: 82px; font-size: 28px; }
.poster img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.card-content { min-width: 0; flex: 1; }
.card-topline { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.favorite-button { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.favorite-button.is-favorite { color: var(--gold); }
.status-select { max-width: calc(100% - 36px); min-height: 30px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 8px; background: #2b2153; color: var(--text); font-size: 11px; }
.card-content h3 { margin-bottom: 3px; overflow-wrap: anywhere; font-size: 16px; }
.card-meta { color: var(--muted); font-size: 11px; }
.card-meta small { display: block; margin-top: 3px; color: var(--magic); font-size: 10px; }
.progress-line { height: 7px; margin: 11px 0 8px; overflow: hidden; border-radius: 99px; background: #392d5e; }
.progress-line span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), var(--magic)); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.progress-edit-grid, .form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.progress-edit-grid label, .series-form label, .form-grid label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.progress-edit-grid input, .series-form input, .series-form textarea, .series-form select { width: 100%; min-width: 0; padding: 6px 7px; border: 1px solid var(--line); border-radius: 7px; background: #120d29; color: var(--text); font-size: 12px; }
.series-form { display: grid; gap: 10px; margin: 14px 0; }
.series-form textarea { resize: vertical; line-height: 1.4; }
.mini-button { min-height: 30px; padding: 5px 9px; border: 1px solid #55468b; border-radius: 8px; background: #2b2153; color: var(--text); font-size: 11px; font-weight: 700; }
.mini-button:hover { border-color: var(--magic); }
.status-pill, .badge { display: inline-flex; align-items: center; width: fit-content; padding: 3px 8px; border: 1px solid #5b4e8b; border-radius: 99px; color: var(--lilac); font-size: 10px; font-weight: 750; }
.badge-teal { border-color: #3b8880; color: var(--magic); }
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar .search-input { flex: 1; width: 100%; }
.inline-status { min-height: 21px; margin: 8px 0 13px; color: var(--muted); font-size: 12px; }
.result-card { display: block; }
.result-card .poster { float: left; width: 58px; height: 78px; margin-right: 11px; }
.result-card::after { display: block; clear: both; content: ""; }
.result-card h3 { overflow-wrap: anywhere; font-size: 15px; }
.result-card p { min-height: 34px; margin: 7px 0; color: var(--muted); font-size: 11px; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; padding-top: 18px; border-top: 1px solid #3d3165; color: var(--muted); font-size: 11px; }
.footer a { color: var(--magic); text-decoration: none; }
.wizard-dialog { width: min(440px, calc(100% - 30px)); padding: 25px; border: 1px solid #735bbb; border-radius: 20px; background: #1b1538; color: var(--text); box-shadow: var(--shadow); }
.wizard-dialog::backdrop { background: #080313aa; backdrop-filter: blur(4px); }
.dialog-icon { font-size: 31px; }
.wizard-dialog h2 { margin: 7px 0; font-size: 23px; }
.wizard-dialog p { color: var(--muted); }
.is-hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-orbit { position: absolute; right: -15px; bottom: -22px; opacity: .36; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-layout { display: block; }
  .calendar-day { display: none; min-height: 0; }
  .calendar-day.is-selected { display: block; }
  .day-selector { display: flex; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
}

@media (max-width: 580px) {
  .app-shell { padding: 13px 12px 28px; }
  .topbar { padding-bottom: 14px; }
  .freshness { display: none; }
  .hero-copy { padding: 27px 22px 31px; }
  .hero-orbit { display: none; }
  h1 { font-size: 42px; }
  .hero-actions .button { flex: 1; padding-inline: 9px; }
  .dashboard-grid, .backup-grid, .library-grid, .result-grid { grid-template-columns: 1fr; }
  .primary-nav { margin: 15px 0 23px; }
  .nav-tab { padding-inline: 11px; font-size: 12px; }
  .search-bar { align-items: stretch; flex-direction: column; }
  .search-input { min-width: 0; }
  .footer { align-items: flex-start; flex-direction: column; }
  .progress-edit-grid, .form-grid { grid-template-columns: 1fr; }
}
