/* Components */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 999px;
  font-weight: 600; font-size: 14.5px; white-space: nowrap; border: 1px solid transparent; transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn--gold { background: var(--gold); color: var(--on-gold); }
.btn--gold:hover { background: var(--gold-hi); }
.btn--burg { background: var(--burg); color: var(--on-burg); }
.btn--burg:hover { background: var(--burg-hi); }
.btn--ghost { border-color: var(--line-strong); color: var(--bone); }
.btn--ghost:hover { background: var(--char); }
.btn--quiet { color: var(--gold-text); height: 36px; padding: 0 10px; }
.btn--quiet:hover { background: var(--char); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn--sm { height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; pointer-events: none; }

/* Chips & segmented tabs */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--mute); font-size: 13.5px; font-weight: 500; transition: all .15s;
}
.chip:hover { color: var(--bone); border-color: var(--bone); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--burg); border-color: var(--burg); color: var(--on-burg); }
.chip svg { width: 15px; height: 15px; }
.tabs { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 0 calc(var(--gutter) * -1) 22px; padding: 0 var(--gutter); }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; padding: 12px 0; color: var(--mute); font-weight: 500; font-size: 14.5px; }
.tab:hover { color: var(--bone); }
.tab[aria-selected="true"] { color: var(--bone); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--gold); }

/* Tags */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 3px; font-size: 11.5px; font-weight: 600;
  background: var(--char-2); color: var(--bone);
}
.tag--new { background: var(--lime); color: var(--on-lime); }
.tag--live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--on-lime); animation: blink 1.4s steps(2) infinite; }
.tag--gold { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold-text); }
.tag--est { background: transparent; color: var(--gold-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 60%, transparent); }
.tag--tba { background: transparent; color: var(--mute); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tag--burg { background: var(--burg); color: var(--on-burg); }
.tag--bad { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
@keyframes blink { 50% { opacity: .25; } }

/* Posters: no card chrome, the artwork is the object. */
.poster { position: relative; display: block; min-width: 0; }
.poster__art {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--r-sm); overflow: hidden; background: var(--char);
  box-shadow: 0 10px 22px -12px rgba(0, 0, 0, .9); transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .25s;
}
.poster:hover .poster__art { transform: translateY(-4px); box-shadow: 0 18px 28px -14px rgba(0, 0, 0, .95); }
.poster__art img { width: 100%; height: 100%; object-fit: cover; }
.poster__fallback {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; text-align: center; background: linear-gradient(160deg, var(--burg-deep), var(--char));
  font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 17px; line-height: 1.15; color: var(--gold-hi);
}
.poster__title { margin-top: 9px; font-size: 14px; font-weight: 600; line-height: 1.25; }
.poster__meta { margin-top: 2px; color: var(--mute); font-size: 12.5px; }
.poster__corner { position: absolute; left: 6px; top: 6px; z-index: 2; display: flex; gap: 4px; }
.poster__add {
  position: absolute; right: 6px; bottom: 6px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 82%, transparent); backdrop-filter: blur(6px); color: var(--bone); border: 1px solid var(--line-strong);
}
.poster__add:hover { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.poster__add[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.poster__add svg { width: 18px; height: 18px; }
.poster__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .55); }
.poster__bar i { display: block; height: 100%; background: var(--gold); }
.poster--rank .poster__art::after { content: attr(data-rank); position: absolute; left: 8px; bottom: -6px; font-family: var(--font-display); font-weight: 700; font-size: 54px; line-height: 1; color: var(--bone); text-shadow: 0 2px 12px rgba(0, 0, 0, .8); }

/* Ticket stub: the episode row. */
.stub {
  --stub-date: 76px; --notch: var(--ink);
  position: relative; display: grid; grid-template-columns: var(--stub-date) minmax(0, 1fr) auto; align-items: stretch; min-height: 78px;
  background: var(--coal); border-radius: var(--r-md); color: inherit; text-align: left; width: 100%;
}
.stub::before, .stub::after {
  content: ""; position: absolute; left: calc(var(--stub-date) - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--notch); z-index: 1;
}
.stub::before { top: -7px; } .stub::after { bottom: -7px; }
.stub__date {
  display: grid; place-content: center; text-align: center; border-right: 2px dashed var(--line-strong); padding: 8px 6px; line-height: 1;
}
.stub__day { font-family: var(--font-display); font-weight: 700; font-size: 30px; color: var(--gold-text); }
.stub__mon { margin-top: 4px; font-size: 12px; color: var(--mute); font-weight: 500; }
.stub__time { margin-top: 5px; font-size: 11.5px; color: var(--bone); font-weight: 600; }
.stub__body { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 0; }
.stub__thumb { width: 38px; aspect-ratio: 2 / 3; border-radius: 3px; background: var(--char); overflow: hidden; flex: none; }
.stub__thumb img { width: 100%; height: 100%; object-fit: cover; }
.stub__text { min-width: 0; display: grid; gap: 2px; }
.stub__show { font-weight: 600; }
.stub__ep { color: var(--mute); font-size: 13.5px; }
.stub__tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.stub__act { display: grid; place-items: center; padding: 0 10px 0 2px; }
.stub--link { cursor: pointer; transition: background .15s; }
.stub--link:hover { background: var(--char); }
.stub--link:hover { --notch: var(--ink); }
.stub--new { box-shadow: inset 3px 0 0 var(--lime); }
.stub--sheet { --notch: var(--coal); background: var(--char); }

.tick {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line-strong); color: var(--mute); transition: all .15s;
}
.tick:hover { border-color: var(--gold); color: var(--gold-text); }
.tick[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.tick svg { width: 19px; height: 19px; }

/* Inputs */
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--mute); }
.field .hint { font-size: 12.5px; color: var(--mute); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--r-md); background: var(--char); border: 1px solid transparent; color: var(--bone);
  transition: border-color .15s, background .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { outline: none; border-color: var(--gold); background: var(--coal); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.searchbar { position: relative; }
.searchbar svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--mute); pointer-events: none; }
.searchbar .input { padding-left: 44px; height: 50px; border-radius: 999px; font-size: 16px; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: var(--char-2); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--bone); transition: transform .2s; }
.switch input:checked + i { background: var(--burg-hi); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--gold-hi); }
.switch input:focus-visible + i { outline: 2px solid var(--gold); outline-offset: 2px; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting__text { min-width: 0; }
.setting__title { font-weight: 600; }
.setting__desc { color: var(--mute); font-size: 13.5px; margin-top: 2px; max-width: 56ch; }
.panel { background: var(--coal); border-radius: var(--r-lg); padding: 6px 20px; }
.panel--pad { padding: 20px; }
.panel h3 { padding: 16px 0 4px; }

/* Sheets (native <dialog>) */
dialog.sheet {
  border: 0; padding: 0; color: var(--bone); background: var(--coal); width: min(560px, 100%); max-height: min(86dvh, 820px); margin: auto auto 0; overflow: hidden;
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow); animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1);
}
dialog.sheet::backdrop { background: rgba(5, 3, 3, .66); backdrop-filter: blur(3px); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: var(--r-lg); } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet__in { display: flex; flex-direction: column; max-height: inherit; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px 22px; }
.sheet__body { overflow-y: auto; padding: 4px 22px calc(24px + var(--safe-b)); display: grid; gap: 16px; align-content: start; }
.sheet__wide { width: min(760px, 100%); }
.menu { display: grid; gap: 2px; }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; height: 48px; padding: 0 12px; border-radius: 10px; text-align: left; font-weight: 500; }
.menu button:hover { background: var(--char); }
.menu button[aria-checked="true"] { color: var(--gold-text); }
.menu button svg { width: 20px; height: 20px; color: var(--mute); }
.menu button[aria-checked="true"] svg { color: var(--gold-text); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 0; }

/* Toast */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 var(--gutter); }
@media (min-width: 900px) { .toasts { bottom: 28px; left: var(--side-w); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 460px; padding: 12px 16px; border-radius: 12px; background: var(--bone); color: var(--ink);
  font-weight: 500; box-shadow: var(--shadow); animation: sheet-in .2s ease-out;
}
:root[data-theme="light"] .toast { background: var(--ink); color: var(--bone); background: #241a19; color: #f3ece0; }
.toast button { color: var(--burg); font-weight: 700; }
:root[data-theme="light"] .toast button { color: var(--gold-hi); }
.toast--err { background: var(--burg); color: var(--on-burg); }
.toast--err button { color: var(--gold-hi); }

/* Loading: a marquee of bulbs. */
.bulbs { display: inline-flex; gap: 8px; align-items: center; }
.bulbs i { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); opacity: .25; animation: chase 1.1s infinite; }
.bulbs i:nth-child(2) { animation-delay: .14s; } .bulbs i:nth-child(3) { animation-delay: .28s; } .bulbs i:nth-child(4) { animation-delay: .42s; } .bulbs i:nth-child(5) { animation-delay: .56s; }
@keyframes chase { 0%, 100% { opacity: .22; } 20% { opacity: 1; background: var(--lime); box-shadow: 0 0 10px var(--lime); } 40% { opacity: .22; } }
.loading { display: grid; place-items: center; gap: 14px; min-height: 40vh; color: var(--mute); }
.skeleton { background: linear-gradient(100deg, var(--coal) 30%, var(--char) 50%, var(--coal) 70%); background-size: 220% 100%; animation: shimmer 1.6s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -220% 0; } }
.sk-poster { aspect-ratio: 2 / 3; }
.sk-line { height: 12px; margin-top: 10px; width: 70%; }
.sk-stub { height: 78px; border-radius: var(--r-md); }

/* Empty / error states */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 44px 20px; color: var(--mute); }
.empty svg { width: 96px; height: 64px; color: var(--gold); opacity: .85; margin-bottom: 6px; }
.empty h3 { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--bone); }
.empty p { max-width: 44ch; }
.empty .btn { margin-top: 8px; }
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: color-mix(in srgb, var(--gold) 13%, transparent); color: var(--bone); font-size: 14px; }
.notice svg { width: 20px; height: 20px; flex: none; color: var(--gold-text); margin-top: 1px; }
.notice--bad { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.notice--bad svg { color: var(--danger); }
.notice .btn { margin-top: 8px; }

/* Facts list */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 22px; }
.facts dt { font-size: 12.5px; color: var(--mute); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 600; }
.facts { margin: 0; }

/* Progress */
.meter { height: 6px; border-radius: 3px; background: var(--char-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--burg-hi), var(--gold)); border-radius: 3px; }

/* Cast */
.cast { display: grid; justify-items: center; gap: 6px; text-align: center; font-size: 13px; }
.cast__img { width: 76px; height: 76px; border-radius: 50%; overflow: hidden; background: var(--char); }
.cast__img img { width: 100%; height: 100%; object-fit: cover; }
.cast b { font-weight: 600; } .cast span { color: var(--mute); font-size: 12px; }

/* Auth, setup */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); background:
  radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--burg) 55%, transparent), transparent 70%), var(--ink); }
.gate__card { width: min(420px, 100%); display: grid; gap: 20px; }
.gate__card .brand__word { font-size: 38px; }
.gate__card .brand__mark { width: 46px; height: 46px; }
.gate form { display: grid; gap: 14px; }
.codeblock { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--char); padding: 12px 14px; border-radius: var(--r-md); overflow-x: auto; white-space: pre; }

/* Fallback artwork is absolutely positioned, so every poster container must be its own positioning context. */
.result__poster, .mini__poster, .stub__thumb, .cast__img { position: relative; }
.stub__thumb .poster__fallback, .result__poster .poster__fallback, .mini__poster .poster__fallback { font-size: 9px; padding: 3px; }
.result__poster .poster__fallback, .mini__poster .poster__fallback { font-size: 11px; }

/* Settings rows wrap instead of overflowing on narrow screens. */
.setting { flex-wrap: wrap; }
.setting__text { flex: 1 1 200px; }
.setting > :last-child:not(.setting__text) { max-width: 100%; }
.setting .select { max-width: 100%; }
.main { min-width: 0; }
.timerow { flex-wrap: wrap; }
