/* ShowMatch — dark streaming-inspired UI, mobile-first (360–430px), OK on desktop. */
:root {
  --bg: #07070b;
  --bg-elevated: #101018;
  --surface: #17171f;
  --surface-2: #22222c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f8;
  --text-muted: #a3a3b0;
  --text-dim: #757584;
  --accent: #e11d48;
  --accent-hover: #fb2d5a;
  --accent-soft: rgba(225, 29, 72, 0.16);
  --violet: #a78bfa;
  --success: #34d399;
  --danger: #fb7185;
  --star: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --page-pad: 18px;
  --app-max: 520px;
  --tap: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #050508;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
}

#app-shell {
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(225, 29, 72, 0.16), transparent 55%),
    radial-gradient(800px 400px at 100% 10%, rgba(167, 139, 250, 0.08), transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 0 1px var(--border);
}

@media (min-width: 721px) {
  :root { --app-max: 640px; }
  body { background: #030306; }
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1rem; }

p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Top bar */
.topbar {
  position: relative;
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding: calc(var(--safe-top) + 8px) var(--page-pad) 8px;
  background: linear-gradient(to bottom, rgba(7, 7, 11, 0.96), rgba(7, 7, 11, 0.86));
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  letter-spacing: -0.04em;
  font-size: 1.15rem;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ff4d6d, #7c3aed);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 16px rgba(225, 29, 72, 0.35);
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
}

.icon-btn.is-on,
.icon-btn:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.icon-btn:hover { background: var(--surface-2); }

/* Main view */
#view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 16px;
  outline: none;
}

.is-onboarding #view {
  padding-bottom: calc(24px + var(--safe-bottom));
}

.is-onboarding .topbar { display: none; }

.page {
  padding: 18px var(--page-pad) 8px;
  animation: fadeIn 0.28s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-intro h1 { margin-bottom: 6px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-hover);
  margin-bottom: 6px;
}

.lede {
  color: var(--text-muted);
  margin: 8px 0 16px;
  max-width: 36rem;
}

.muted { color: var(--text-muted); }
.hint { color: var(--text-dim); font-size: 0.85rem; margin-top: 8px; }
.small { font-size: 0.85rem; }
.small p + p { margin-top: 4px; }

.sample-note {
  display: inline-block;
  margin: 8px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #ff8fa0;
  font-size: 0.75rem;
  font-weight: 600;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-weight: 650;
  gap: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger {
  background: rgba(251, 113, 133, 0.12);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(251, 113, 133, 0.3);
}

.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

.stack-actions { display: flex; flex-direction: column; gap: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.text-link {
  color: var(--violet);
  font-size: 0.9rem;
  font-weight: 600;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--text-muted);
  font-weight: 600;
  margin: -6px 0 8px;
}

/* Section heads & rails */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 12px;
}
.section-head.tight { margin-top: 8px; }

.rail-section { margin-bottom: 8px; }

.rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 2px 2px 14px;
  margin: 0 calc(var(--page-pad) * -1);
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

/* Posters */
.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), var(--shadow);
}

.poster-initials {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.poster-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.poster-sm { width: 56px; flex: 0 0 56px; border-radius: 8px; }
.poster-sm .poster-initials { font-size: 0.85rem; }
.poster-lg { width: 120px; flex: 0 0 120px; border-radius: 14px; }
.poster-lg .poster-initials { font-size: 2rem; }

.poster-wrap { position: relative; }
.poster-wrap .card-progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  top: auto;
  z-index: 3;
}

.show-card {
  flex: 0 0 128px;
  width: 128px;
  scroll-snap-align: start;
  position: relative;
  color: inherit;
  transition: transform 0.15s ease;
}
.show-card:active { transform: scale(0.98); }
.show-card.is-compact { flex-basis: 110px; width: 110px; }

.card-meta { margin-top: 8px; }
.card-title {
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.72);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.card-progress {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 52px;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  overflow: hidden;
  z-index: 3;
}
.card-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 10px;
}
.poster-grid .show-card {
  flex: none;
  width: auto;
}

@media (max-width: 359px) {
  .poster-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.04em;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Up next */
.upnext-list { display: flex; flex-direction: column; gap: 8px; }
.upnext-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: var(--tap);
}
.upnext-text { flex: 1; min-width: 0; }
.chevron { color: var(--text-dim); font-size: 1.4rem; }

/* Search */
.search-form { margin: 12px 0 14px; }
.search-input {
  width: 100%;
  min-height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 18px;
  outline: none;
}
.search-input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(var(--page-pad) * -1);
  padding: 0 var(--page-pad) 4px;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row.wrap {
  flex-wrap: wrap;
  overflow: visible;
  margin: 0;
  padding: 0;
}

.chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.is-on {
  background: var(--accent);
  color: white;
  box-shadow: none;
}

/* Segmented */
.segmented {
  display: flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  margin: 14px 0 18px;
  border: 1px solid var(--border);
}
.seg {
  flex: 1;
  text-align: center;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}
.seg.is-on {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.seg .count { color: var(--text-dim); font-weight: 600; }

/* Library / watchlist cards */
.library-list,
.watch-list { display: flex; flex-direction: column; gap: 12px; }

.library-card,
.watch-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.library-poster { flex: 0 0 72px; width: 72px; }
.library-poster .poster { border-radius: 10px; }
.library-poster .poster-initials { font-size: 1.1rem; }
.library-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.show-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.show-row-body { flex: 1; min-width: 0; }

/* Progress & stars */
.progress-block { margin: 8px 0; }
.progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #fb7185);
  border-radius: inherit;
}
.progress-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.stars { display: inline-flex; gap: 2px; }
.star {
  border: 0;
  background: none;
  color: #3a3a48;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
}
.star.is-on { color: var(--star); }
.stars.lg .star { font-size: 1.7rem; min-width: 40px; min-height: 40px; }
.stars.sm .star { font-size: 1.1rem; min-width: 28px; min-height: 28px; padding: 2px; }

/* Detail */
.detail-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.detail-hero-text { flex: 1; min-width: 0; }
.detail-hero-text h1 { font-size: 1.45rem; margin-bottom: 6px; }
.overview { color: var(--text-muted); margin: 4px 0 14px; }
.detail-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 14px; }
.rate-block, .tracker, .settings-block { margin: 16px 0; }
.next-line { color: var(--violet); font-weight: 600; font-size: 0.9rem; margin-top: 8px; }

.season-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0;
}

.episode-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.episode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.episode-row:last-child { border-bottom: 0; }
.episode-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: 0 0 20px;
}
.ep-code {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  flex: 0 0 58px;
}
.ep-title { flex: 1; }
.ep-done { font-size: 0.75rem; color: var(--success); font-weight: 650; }

/* Recs */
.recs-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 12px;
  margin-top: 16px;
}
.recs-list .show-card,
.rec-item .show-card {
  width: auto;
  flex: none;
}
.reason {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--violet);
  font-weight: 600;
}

/* Empty */
.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--violet);
  border: 1px solid var(--border);
}
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty p { margin-bottom: 16px; }

/* Profile / onboarding */
.profile-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.3rem;
  background: linear-gradient(145deg, #ff4d6d, #7c3aed);
  color: white;
}

.page-onboarding {
  padding-top: calc(var(--safe-top) + 48px);
  min-height: 100%;
}
.onboard-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(145deg, #ff4d6d, #7c3aed);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(225, 29, 72, 0.35);
}
.onboard-actions { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; }

/* Tab bar */
.tabbar {
  position: relative;
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 6px 6px calc(8px + var(--safe-bottom));
  background: rgba(10, 10, 14, 0.94);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  color: var(--text-dim);
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.tab.is-on { color: var(--text); }
.tab.is-on .tab-icon { color: var(--accent-hover); }
.tab-icon { display: grid; place-items: center; height: 22px; }

@media (prefers-reduced-motion: reduce) {
  .page, .btn, .show-card { animation: none; transition: none; }
}
