/* Seerr's look: Tailwind's gray scale, an indigo accent, Inter. Dark only. */
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/assets/inter.woff2) format("woff2");
}
:root {
  color-scheme: dark;
  --bg: #111827; --surface: #1f2937; --surface-2: #374151; --border: #374151; --border-strong: #6b7280;
  --text: #e5e7eb; --heading: #fff; --muted: #9ca3af;
  --accent: #6366f1; --accent-hover: #818cf8; --accent-strong: #4f46e5; --accent-soft: rgba(99,102,241,.2);
  --error: #f87171; --error-strong: #dc2626; --star: #fbbf24;
  --ok: #4ade80; --ok-soft: rgba(34,197,94,.18); --warn: #facc15; --warn-soft: rgba(234,179,8,.18);
  --shadow: 0 1px 3px rgba(0,0,0,.3); --shadow-lg: 0 20px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Inter Variable", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: currentColor; vertical-align: -.25em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 64px; }
.muted { color: var(--muted); }

/* Buttons (Seerr's primary/secondary) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 20px; padding: 8px 16px;
  border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); color: #fff;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s;
}
.btn:hover { background: #4b5563; color: #fff; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); }
.btn-block { width: 100%; padding: 10px 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:disabled:hover { background: var(--surface-2); }
.btn-primary:disabled:hover { background: var(--accent-strong); }

/* Sign in (Seerr's Login page) */
body.login-page { min-height: 100vh; padding: 56px 16px; }
.login-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60rem 36rem at 50% -12rem, rgba(99,102,241,.38), transparent 70%),
    radial-gradient(40rem 28rem at 110% 110%, rgba(147,51,234,.22), transparent 70%),
    radial-gradient(36rem 24rem at -10% 90%, rgba(79,70,229,.16), transparent 70%),
    var(--bg);
}
.login { width: 100%; max-width: 448px; margin: 0 auto; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 32px; }
.login-brand img { width: 72px; height: 72px; filter: drop-shadow(0 8px 24px rgba(99,102,241,.45)); }
.login-brand h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; color: var(--heading); }
.login-card {
  background: rgba(31,41,55,.5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  border-radius: 8px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-alert {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--error-strong);
  color: #fecaca; font-size: 14px; font-weight: 500;
}
.login-alert[hidden] { display: none; }
.login-alert .icon { color: #fca5a5; }
.login-body { padding: 32px 40px; }
.login-service { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin-bottom: 24px; }
.login-service img { width: 56px; height: 56px; }
.login-service h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--heading); line-height: 1.35; }
.server-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 999px;
  background: rgba(17,24,39,.6); border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.server-chip[hidden] { display: none; }
.server-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-chip .icon { width: 16px; height: 16px; }
.field { display: block; margin-bottom: 20px; }
.field > span { display: block; font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.input {
  display: block; width: 100%; font: inherit; font-size: 16px; padding: 8px 12px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: #fff; outline: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.login-body .btn { margin-top: 8px; }
.login-body .btn .icon { width: 20px; height: 20px; }
.login-note { display: flex; gap: 8px; align-items: flex-start; margin: 20px 0 0; font-size: 13px; color: var(--muted); }
.login-note .icon { width: 16px; height: 16px; margin-top: 2px; }
@media (max-width: 480px) { .login-body { padding: 24px 20px; } body.login-page { padding-top: 32px; } }

.btn-sm { font-size: 13px; padding: 5px 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 999px;
  color: var(--muted); text-decoration: none;
}
.icon-btn:hover { color: #fff; background: var(--surface-2); }
.icon-btn .icon { width: 20px; height: 20px; }
button.link { font: inherit; font-size: 14px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
button.link:hover { color: var(--accent-hover); }
button.link:disabled { opacity: .5; cursor: default; }
.empty { color: var(--muted); font-size: 14px; padding: 24px 0; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid var(--surface-2); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.spinner.sm { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Top bar (Seerr's search bar) */
.topbar {
  position: sticky; top: 0; z-index: 10; height: 64px;
  background: rgba(17,24,39,.8); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(55,65,81,.6);
}
.topbar-inner { max-width: 1100px; height: 100%; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--heading); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand:hover { color: var(--heading); }
.brand img { width: 32px; height: 32px; }
.search { position: relative; flex: 1; min-width: 0; max-width: 640px; margin: 0 auto; }
.search > .icon { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; font: inherit; font-size: 15px; padding: 8px 40px; border-radius: 999px; outline: none;
  border: 1px solid #4b5563; background: rgba(17,24,39,.8); color: #fff;
  transition: border-color .15s, background-color .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--border-strong); background: var(--bg); }
.search input::-webkit-search-cancel-button { filter: invert(.7); }
.search .spinner { position: absolute; right: 14px; top: 50%; margin-top: -9px; display: none; }
.search.busy .spinner { display: block; }
.user { position: relative; flex: none; }

/* User menu */
.avatar-btn { padding: 0; border: 0; background: none; border-radius: 999px; cursor: pointer; }
.avatar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #9333ea); color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.08);
}
.avatar.lg { width: 40px; height: 40px; font-size: 17px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: 240px; padding: 6px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
}
.menu[hidden] { display: none; }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-who { display: flex; flex-direction: column; min-width: 0; }
.menu-who b { color: var(--heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-via { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.menu-via .icon { width: 13px; height: 13px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: #fff; }
.menu-item .icon { width: 18px; height: 18px; color: var(--muted); }

/* Source filters */
.filters { padding: 20px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 500; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); transition: background-color .15s, border-color .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-strong); border-color: var(--accent); color: #fff; }
.chip .stat { font-size: 12px; color: inherit; opacity: .75; font-variant-numeric: tabular-nums; }
.chip .stat.err { color: #fecaca; opacity: 1; }
.chip .spinner { border-color: rgba(255,255,255,.25); border-top-color: #fff; }
.summary { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 1.5em; }

/* Result grid (Seerr's title cards, square for audiobook covers) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 24px 16px; margin-top: 8px; transition: opacity .15s; }
.grid.stale { opacity: .45; }
.grid > .empty { grid-column: 1 / -1; }
.tcard { display: block; min-width: 0; color: inherit; text-decoration: none; }
.tcard:hover { color: inherit; }
.tcard-cover {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), var(--shadow); transition: transform .3s, box-shadow .3s;
}
.tcard:hover .tcard-cover, .tcard:focus-visible .tcard-cover { transform: scale(1.04); box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-lg); }
.tcard:focus-visible { outline: none; }
.tcard-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tcard-fallback {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center;
  font-weight: 600; color: var(--muted); background: linear-gradient(160deg, #374151, #1f2937);
  overflow: hidden; overflow-wrap: anywhere;
}
.status-dot {
  position: absolute; top: 8px; right: 8px; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 999px; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.status-dot.ok { background: rgba(34,197,94,.9); border: 1px solid #22c55e; }
.status-dot .icon { width: 15px; height: 15px; }
.soon-tag {
  position: absolute; top: 8px; left: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; line-height: 16px; padding: 2px 8px 2px 6px; border-radius: 999px; white-space: nowrap;
  background: rgba(2,132,199,.9); border: 1px solid #0ea5e9; color: #f0f9ff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.soon-tag .icon { width: 13px; height: 13px; }
.tcard-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding: 12px;
  background: linear-gradient(180deg, rgba(17,24,39,.45) 0%, rgba(17,24,39,.97) 70%);
  opacity: 0; transition: opacity .2s; font-size: 12px; color: var(--text);
}
.tcard:hover .tcard-overlay, .tcard:focus-visible .tcard-overlay { opacity: 1; }
.tcard-series { font-weight: 600; color: var(--accent-hover); }
.tcard-sub { font-weight: 500; color: #fff; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard-desc { color: #d1d5db; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.tcard-info { padding: 10px 2px 0; min-width: 0; }
.tcard-title {
  font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--heading);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.tcard-line, .tcard-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tcard-meta { font-size: 12px; color: #6b7280; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  font-size: 11px; padding: 1px 7px; border-radius: 4px; background: rgba(55,65,81,.85);
  color: var(--muted); white-space: nowrap;
}
.badge b { font-weight: 600; color: var(--text); }
@media (max-width: 640px) {
  .brand span { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px 12px; }
}

/* Discover (Seerr's home sliders) */
.grid[hidden], .filters[hidden], .discover[hidden] { display: none; }
.discover { padding-top: 16px; }
.shelf { margin-top: 24px; }
.shelf-head { display: flex; align-items: center; margin-bottom: 4px; }
.shelf-head h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.4; color: #d1d5db; letter-spacing: -.01em; }
.shelf-head h2 a { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.shelf-head h2 a:hover { color: #fff; }
.shelf-head h2 .icon { width: 22px; height: 22px; color: var(--muted); }
.shelf .grid { margin-top: 12px; }
/* Padding leaves room for the cover's hover zoom inside the scroll box. */
.slider {
  display: grid; grid-auto-flow: column; grid-auto-columns: 168px; gap: 16px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
  margin: 0 -16px; padding: 10px 16px 12px; scroll-padding: 0 16px;
}
.slider::-webkit-scrollbar { display: none; }
.slider > * { scroll-snap-align: start; }
.slider > .empty { grid-column: 1 / -1; }
.tcard.skeleton { aspect-ratio: 1; border-radius: 12px; background: var(--surface); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.slider.genres { grid-auto-columns: 220px; }
.genre-card {
  display: flex; align-items: center; justify-content: center; height: 108px; padding: 12px; border-radius: 12px;
  text-align: center; font-size: 17px; font-weight: 700; line-height: 1.25; color: #fff; text-decoration: none;
  text-shadow: 0 1px 6px rgba(0,0,0,.35); box-shadow: 0 0 0 1px rgba(255,255,255,.08), var(--shadow);
  transition: transform .3s, box-shadow .3s;
}
.genre-card:hover { color: #fff; transform: scale(1.04); box-shadow: 0 0 0 1px rgba(255,255,255,.2), var(--shadow-lg); }
.genre-card.g0 { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.genre-card.g1 { background: linear-gradient(135deg, #be123c, #7e22ce); }
.genre-card.g2 { background: linear-gradient(135deg, #0e7490, #1d4ed8); }
.genre-card.g3 { background: linear-gradient(135deg, #c2410c, #be185d); }
.genre-card.g4 { background: linear-gradient(135deg, #047857, #0e7490); }
.genre-card.g5 { background: linear-gradient(135deg, #a16207, #c2410c); }
.genre-card.g6 { background: linear-gradient(135deg, #6d28d9, #be185d); }
.genre-card.g7 { background: linear-gradient(135deg, #1d4ed8, #4f46e5); }
.page-head { display: flex; align-items: center; gap: 8px; margin: 8px 0 -8px -8px; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 700; color: var(--heading); letter-spacing: -.02em; }
@media (max-width: 640px) {
  .slider { grid-auto-columns: 140px; gap: 12px; }
  .slider.genres { grid-auto-columns: 176px; }
  .genre-card { height: 88px; font-size: 15px; }
}

/* Status badges (Seerr's StatusBadge) */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; line-height: 18px;
  padding: 2px 10px; border-radius: 999px; white-space: nowrap;
  background: rgba(55,65,81,.8); border: 1px solid var(--border-strong); color: #e5e7eb;
}
.status-badge .icon { width: 15px; height: 15px; }
.status-badge.ok { background: rgba(34,197,94,.8); border-color: #22c55e; color: #f0fdf4; }
.status-badge.pending { background: rgba(79,70,229,.8); border-color: #6366f1; color: #eef2ff; }
.status-badge.attention { background: rgba(234,179,8,.8); border-color: #eab308; color: #fefce8; }
.status-badge.failed { background: rgba(220,38,38,.8); border-color: #ef4444; color: #fef2f2; }
.status-badge.soon { background: rgba(2,132,199,.8); border-color: #0ea5e9; color: #f0f9ff; }
.status-badge.series { background: rgba(17,24,39,.6); border-color: var(--border); color: var(--text); }
.status-badge.series .icon { width: 13px; height: 13px; margin-right: -4px; color: var(--muted); }
a.status-badge.series { text-decoration: none; transition: border-color .15s, background-color .15s; }
a.status-badge.series:hover { border-color: var(--accent); background: rgba(55,65,81,.8); color: #fff; }

/* Series page */
.cover-tags { position: absolute; top: 8px; left: 8px; right: 40px; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.cover-tags .soon-tag { position: static; }
.cover-tags .status-badge { font-size: 11px; line-height: 16px; padding: 1px 8px; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.tcard-info .tcard-series { font-size: 12px; margin-bottom: 2px; }
.series-confirm {
  margin-top: 14px; padding: 14px 16px; max-width: 560px; font-size: 14px;
  background: rgba(31,41,55,.6); border: 1px solid var(--border); border-radius: 8px;
}
.series-confirm { text-align: left; }
.series-confirm p { margin: 0 0 8px; }
.series-confirm p.sub { margin: 10px 0 0; }
.series-confirm ul { margin: 0; padding: 0; list-style: none; max-height: 240px; overflow: auto; }
.series-confirm .media-actions { margin-top: 12px; }

/* Book page (Seerr's media page) */
.backdrop { position: absolute; top: 0; left: 0; right: 0; height: 560px; z-index: -1; overflow: hidden; }
.backdrop::before {
  content: ""; position: absolute; inset: -60px; background: var(--backdrop, none) center 30% / cover;
  filter: blur(40px) saturate(1.2); opacity: .5;
}
.backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(17,24,39,.35) 0%, var(--bg) 100%); }
.media-header { display: grid; grid-template-columns: 208px 1fr; gap: 32px; align-items: start; padding-top: 40px; }
.media-poster {
  position: relative; width: 208px; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: var(--surface); box-shadow: 0 25px 50px -12px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.06);
}
.media-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-title { min-width: 0; }
.media-status { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.media-title h1 { font-size: 36px; font-weight: 700; line-height: 1.15; margin: 0; color: var(--heading); letter-spacing: -.02em; overflow-wrap: anywhere; }
.media-title .subtitle { font-size: 18px; color: #d1d5db; margin: 4px 0 0; }
.people { font-size: 15px; margin-top: 6px; color: var(--text); }
.people span { color: var(--muted); }
.media-attributes { display: flex; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 14px; color: #d1d5db; }
.media-attributes > * + *::before { content: "|"; margin: 0 8px; color: #6b7280; }
.rating { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: #fff; }
.rating .icon { color: var(--star); width: 16px; height: 16px; }
.media-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.media-actions + .request { margin-top: 10px; }
.media-overview { display: grid; grid-template-columns: 1fr 320px; gap: 32px; margin-top: 40px; align-items: start; }
.media-overview h2, .block > h2 { font-size: 20px; font-weight: 700; color: var(--heading); margin: 0 0 12px; }
.prose { max-width: 72ch; font-size: 15px; line-height: 1.65; color: #d1d5db; }
.prose p { margin: 0 0 12px; }
.prose.clamped { max-height: 15em; overflow: hidden; mask-image: linear-gradient(#000 70%, transparent); -webkit-mask-image: linear-gradient(#000 70%, transparent); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.media-facts { border: 1px solid var(--border); border-radius: 8px; background: rgba(31,41,55,.4); font-size: 14px; overflow: hidden; }
.media-fact { display: flex; justify-content: space-between; gap: 16px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-weight: 600; color: #d1d5db; }
.media-fact:last-child { border-bottom: 0; }
.media-fact .value { font-weight: 400; color: var(--muted); text-align: right; min-width: 0; overflow-wrap: anywhere; }
.media-fact .value.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.block { margin-top: 40px; }

.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.source {
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.source.missing { opacity: .5; }
.source header { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--heading); }
.source header .state { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.source header .state.err { color: var(--error); }
.source .body { display: flex; gap: 10px; min-width: 0; }
.source .open { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; text-decoration: none; }
.source .open .icon, .req-link .icon { width: 15px; height: 15px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-weight: 400; }
.cover { flex: none; width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.info { min-width: 0; flex: 1; }
.title { font-weight: 600; color: var(--heading); overflow-wrap: anywhere; }
.sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .media-header { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 20px; padding-top: 24px; }
  .media-poster { width: min(208px, 60vw); }
  .media-status, .media-attributes, .media-actions { justify-content: center; }
  .media-title h1 { font-size: 26px; }
  .media-title .request { text-align: center; }
  .request .req-status { justify-content: center; }
  .request .req-live { margin-left: auto; margin-right: auto; }
  .request .req-card, .request .req-list, .request .req-search, .request .req-history, .request .req-notice, .request .req-live { text-align: left; }
  .media-actions > .btn, .request > .btn-primary { width: 100%; }
  .request .req-hint { margin-left: auto; margin-right: auto; }
  .media-overview { grid-template-columns: 1fr; }
}

/* Request controls in the book header */
.request { margin-top: 18px; max-width: 760px; }
.request > .btn-primary { padding: 9px 22px; }
.req-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 10px; }
.req-status .sub { display: inline-flex; align-items: center; gap: 6px; }
.req-error { color: var(--error); font-size: 13px; margin: 4px 0; overflow-wrap: anywhere; }
.req-notice {
  font-size: 14px; padding: 10px 12px; border-radius: 6px; margin-bottom: 10px;
  background: var(--warn-soft); border: 1px solid rgba(234,179,8,.6); color: #fef9c3;
}
.req-card { padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); margin-top: 6px; }
.req-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.req-label { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-hover); }
.req-body { display: flex; gap: 12px; min-width: 0; }
.req-score { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.req-score.hi { color: var(--ok); background: var(--ok-soft); }
.req-score.mid { color: var(--warn); background: var(--warn-soft); }
.req-score.lo { color: var(--muted); background: var(--surface-2); }
.req-notes { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin-top: 4px; }
.req-notes span { display: inline-flex; align-items: center; gap: 3px; }
.req-notes .icon { width: 13px; height: 13px; }
.req-notes .good { color: var(--ok); }
.req-notes .bad { color: var(--error); }
.req-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.req-actions .sub { overflow-wrap: anywhere; }
.req-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; text-decoration: none; }
.req-toggle { display: block; margin: 10px 0; font-size: 14px; }
.req-hint { font-size: 14px; margin: 0 0 12px; max-width: 560px; }
.req-search { display: flex; gap: 8px; margin: 4px 0 10px; }
.req-search .input { flex: 1; min-width: 0; font-size: 14px; padding: 5px 10px; }
.req-view { margin: 2px 0 6px; }
.req-history { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.req-history li { padding: 4px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.req-history time { font-variant-numeric: tabular-nums; margin-right: 6px; }
.req-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
/* Linear and about one poll long, so the bar keeps moving between updates. */
.req-bar > div {
  height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-strong), var(--accent-hover));
  transition: width 3s linear, background-color .4s;
}
.req-bar.idle > div { background: var(--muted); }
.req-bar.err > div { background: var(--error); }
.req-bar.indeterminate { position: relative; }
.req-bar.indeterminate::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--accent-hover) 50%, transparent);
  animation: req-slide 1.6s cubic-bezier(.45,0,.55,1) infinite;
}
@keyframes req-slide { from { transform: translateX(-100%); } to { transform: translateX(286%); } }

/* In-progress panel: the book, what's happening, and the steps. */
.req-live {
  display: flex; align-items: center; gap: 18px; max-width: 560px; padding: 14px 18px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  animation: req-in .4s cubic-bezier(.2,.8,.3,1);
}
@keyframes req-in { from { opacity: 0; transform: translateY(6px); } }
.req-book { flex: none; width: 72px; }
.req-book svg { display: block; width: 100%; height: auto; }
.req-live-body { flex: 1; min-width: 0; }
.req-live-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.req-live-title { font-size: 16px; font-weight: 600; color: var(--heading); }
.req-pct { font-size: 15px; font-weight: 600; color: var(--accent-hover); font-variant-numeric: tabular-nums; }
.req-live-detail { margin-top: 2px; font-variant-numeric: tabular-nums; }
.req-steps { display: flex; list-style: none; margin: 14px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.req-steps li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: color .4s; }
.req-steps li.done, .req-steps li.current { color: var(--text); }
/* The line from the previous step's dot to this one, stopping short of both. */
.req-steps li + li::before {
  content: ""; position: absolute; top: 7px; left: calc(-50% + 13px); right: calc(50% + 13px); height: 2px; border-radius: 1px;
  background: var(--surface-2); transition: background-color .4s;
}
.req-steps li.done::before, .req-steps li.current::before { background: var(--accent); }
.req-steps .dot {
  position: relative; z-index: 1; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--surface-2); transition: background-color .4s, border-color .4s;
}
.req-steps .dot .icon { width: 10px; height: 10px; color: #fff; opacity: 0; transform: scale(.4); transition: opacity .3s, transform .3s cubic-bezier(.3,1.6,.6,1); }
.req-steps li.done .dot { background: var(--accent); border-color: var(--accent); }
.req-steps li.done .dot .icon { opacity: 1; transform: none; }
.req-steps li.current .dot { border-color: var(--accent); background: #2d355c; animation: req-ping 1.6s ease-out infinite; }
@keyframes req-ping { from { box-shadow: 0 0 0 0 rgba(99,102,241,.6); } to { box-shadow: 0 0 0 8px rgba(99,102,241,0); } }

/* The book. view-box origins put the turning pages' pivot on the spine. */
.book * { transform-box: view-box; }
.b-cover { fill: var(--accent-strong); }
.b-page { fill: #f5f0e1; stroke: #cfc5a8; stroke-width: .8; stroke-linejoin: round; }
.b-lines, .b-spine { fill: none; stroke-linecap: round; }
.b-lines { stroke: #d6cdb4; stroke-width: 1.5; }
.b-spine { stroke: #c9bf9f; stroke-width: 1; }
.b-turn { transform-origin: 60px 0; animation: b-turn 2.4s cubic-bezier(.45,0,.55,1) infinite; }
.b-turn + .b-turn { animation-delay: -1.2s; }
/* Turn over, then hide while waiting on the left (the left page looks the same). */
@keyframes b-turn {
  0% { transform: scaleX(1); opacity: 1; }
  50% { transform: scaleX(-1); opacity: 1; animation-timing-function: steps(1, end); }
  51%, 100% { transform: scaleX(1); opacity: 0; }
}
.req-live.done .b-turn { animation: none; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .book *, .req-live, .req-steps .dot, .req-bar::after { animation: none !important; }
  .req-bar.indeterminate::after { width: 100%; opacity: .35; }
  .b-turn { opacity: 0; }
  .req-bar > div { transition: none; }
}
@media (max-width: 480px) {
  .req-live { gap: 12px; }
  .req-book { width: 56px; }
}
.req-list { display: flex; flex-direction: column; gap: 6px; }
.req-cand {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.req-cand .title { font-size: 14px; }
@media (max-width: 480px) {
  .req-cand { flex-direction: column; align-items: stretch; }
  .req-body .cover { display: none; }
}

/* Settings page */
.spacer { flex: 1; }
.settings [hidden] { display: none !important; }
.page-title { font-size: 28px; font-weight: 700; color: var(--heading); letter-spacing: -.02em; margin: 32px 0 8px; }
.settings-section { margin-top: 24px; padding: 24px; background: rgba(31,41,55,.4); border: 1px solid var(--border); border-radius: 8px; }
.settings-section h2 { font-size: 20px; font-weight: 700; color: var(--heading); margin: 0 0 6px; }
.settings-section p { margin: 0 0 16px; font-size: 14px; max-width: 75ch; }
.section-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 10px; }
.section-sub h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--heading); }
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 220px; margin-bottom: 0; }
.settings .input { font-size: 14px; }
select.input { appearance: auto; }
.hint { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 0; max-width: 75ch; }
.settings code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row-card {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--heading); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: none; }
.form-card { flex-direction: column; align-items: stretch; border-color: var(--accent); }
.form-card .row-actions { justify-content: flex-start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid .field { margin-bottom: 14px; }
.form-grid .hint { margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.exit-line b { color: var(--text); font-weight: 600; }
@media (max-width: 640px) {
  .row-card { flex-direction: column; }
  .row-actions { justify-content: flex-start; }
  .settings-section { padding: 16px; }
}
