/* Series tracker – "cinema" theme. Dark by default, light when the device prefers light. */

:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --bg-elev: #14171d;
  --surface: #191d24;
  --surface-2: #222731;
  --surface-3: #2b313d;
  --line: #2c323d;
  --ink: #f1f2f5;
  --ink-2: #c6cad3;
  --muted: #8d95a4;
  --accent: #f5b83d;
  --accent-strong: #ffc95e;
  --accent-ink: #1d1503;
  --accent-soft: rgba(245, 184, 61, 0.14);
  --done: #3ecf8e;
  --done-soft: rgba(62, 207, 142, 0.14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", "Rubik", "Heebo", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f1ea;
    --bg-elev: #ebe7de;
    --surface: #ffffff;
    --surface-2: #f2efe8;
    --surface-3: #e6e1d6;
    --line: #e1dbcf;
    --ink: #17191e;
    --ink-2: #3a3f49;
    --muted: #6d7380;
    --accent: #d9930f;
    --accent-strong: #c2820a;
    --accent-ink: #ffffff;
    --accent-soft: rgba(217, 147, 15, 0.12);
    --done: #17945e;
    --done-soft: rgba(23, 148, 94, 0.1);
    --danger: #c93838;
    --danger-soft: rgba(201, 56, 56, 0.08);
    --shadow: 0 10px 30px rgba(60, 50, 30, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.5;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* ---------------------------------------------------------------- inputs & buttons */

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}

textarea {
  resize: vertical;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  direction: rtl;
}

.search-input {
  padding-inline-start: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d95a4' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 18px;
  background-position: right 13px center;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.icon-button:active {
  transform: scale(0.97);
}

.primary-button {
  background: var(--accent);
  color: var(--accent-ink);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.secondary-button {
  background: var(--surface-2);
  border-color: var(--line);
}

.secondary-button:hover:not(:disabled) {
  background: var(--surface-3);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.ghost-button {
  background: transparent;
  color: var(--ink-2);
  padding: 0 12px;
}

.ghost-button:hover:not(:disabled) {
  background: var(--surface-2);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface-2);
  border-color: var(--line);
  font-size: 22px;
  line-height: 1;
}

.wide {
  width: 100%;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* ---------------------------------------------------------------- auth */

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(90, 110, 255, 0.08), transparent 60%),
    var(--bg);
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-line h1 {
  font-size: 24px;
}

.brand-line p {
  color: var(--muted);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  flex: none;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: var(--surface-2);
}

.segment {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment.active {
  background: var(--surface-3);
  color: var(--ink);
}

.stacked-form {
  display: grid;
  gap: 14px;
}

.stacked-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.form-error {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 14px;
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 232px;
  grid-template-areas: "main side";
}

.sidebar {
  grid-area: side;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-inline-start: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 4px;
}

.nav-tab {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  text-align: start;
}

.nav-tab:hover {
  color: var(--ink);
  background: var(--surface);
}

.nav-tab.active {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-tab.active svg {
  color: var(--accent);
}

.main {
  grid-area: main;
  min-width: 0;
  padding: 28px clamp(16px, 4vw, 44px) 48px;
}

.view {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
  animation: fade-in 0.2s ease;
}

.view.active {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.page-head .muted {
  margin-top: 6px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.section-title {
  font-size: 18px;
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------- continue watching */

.continue-section {
  margin-bottom: 30px;
}

.continue-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(300px, 360px);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.continue-card {
  scroll-snap-align: start;
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  isolation: isolate;
}

.continue-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--poster);
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(1.4);
  opacity: 0.22;
  transform: scale(1.3);
}

.continue-card .poster {
  width: 84px;
  border-radius: 8px;
  cursor: pointer;
}

.continue-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.continue-body h3 {
  font-size: 16px;
  line-height: 1.3;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.next-title {
  color: var(--ink-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.continue-body .progress-track {
  margin-top: auto;
}

.continue-body .primary-button {
  min-height: 36px;
  margin-top: 8px;
  align-self: flex-start;
  font-size: 14px;
}

/* ---------------------------------------------------------------- library */

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.library-head .section-title {
  margin: 0;
}

.library-head .search-input {
  max-width: 300px;
  min-height: 40px;
}

.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chip {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.chip .count {
  color: var(--muted);
  font-weight: 500;
  margin-inline-start: 4px;
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.chip.active .count {
  color: inherit;
  opacity: 0.6;
}

.shows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 22px 16px;
}

.show-card {
  position: relative;
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink-2);
  background: linear-gradient(160deg, var(--surface-3), var(--surface));
}

.show-card .poster {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.show-card:hover .poster {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4);
}

.poster-progress {
  position: absolute;
  inset: auto 0 0 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.45);
}

.poster-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.poster-progress.done span {
  background: var(--done);
}

.status-badge {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
}

.status-badge.completed {
  background: var(--done);
  color: #062716;
}

.show-card h3 {
  font-size: 14.5px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.show-card .meta {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: -6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-track.done span {
  background: var(--done);
}

.empty-state {
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.empty-state p {
  color: var(--muted);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------- search */

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.result-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.result-card .poster {
  width: 76px;
  box-shadow: none;
}

.result-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-body h3 {
  font-size: 15.5px;
}

.result-body .muted {
  font-size: 13px;
}

.result-overview {
  color: var(--ink-2);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-body .primary-button,
.result-body .secondary-button {
  min-height: 34px;
  margin-top: auto;
  align-self: flex-start;
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- details */

.details-hero {
  position: relative;
  margin: -28px calc(-1 * clamp(16px, 4vw, 44px)) 0;
  padding: 20px clamp(16px, 4vw, 44px) 26px;
  overflow: hidden;
  isolation: isolate;
}

.details-hero::before {
  content: "";
  position: absolute;
  inset: -40px;
  z-index: -2;
  background-image: var(--poster);
  background-size: cover;
  background-position: center 25%;
  filter: blur(40px) saturate(1.3);
  opacity: 0.45;
}

.details-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, transparent 0%, var(--bg) 100%);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.hero-top .ghost-button {
  padding-inline-start: 6px;
}

.hero-body {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 14px 24px;
  align-items: end;
}

.hero-body .poster {
  grid-row: span 2;
  align-self: start;
  width: 170px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.hero-info {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.hero-info h2 {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.15;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  color: var(--ink-2);
  font-size: 14px;
}

.status-select {
  width: auto;
  min-height: 32px;
  padding: 0 12px 0 30px;
  border-radius: 999px;
  background-color: var(--surface-2);
  font-size: 13.5px;
  font-weight: 700;
}

.hero-extra {
  grid-column: 2;
  display: grid;
  gap: 12px;
}

.overview {
  max-width: 70ch;
  color: var(--ink-2);
  font-size: 14.5px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.overview.expanded {
  -webkit-line-clamp: unset;
}

.hero-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 460px;
  font-size: 13.5px;
  color: var(--ink-2);
}

.hero-progress .progress-track {
  flex: 1;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.menu-wrap {
  position: relative;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 20;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
}

.menu button {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: start;
  font-weight: 600;
}

.menu button:hover {
  background: var(--surface-2);
}

.menu .danger {
  color: var(--danger);
}

.menu hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4px 0;
  width: 100%;
}

.seasons-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.season-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.season-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.season-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: none;
  padding: 0;
  text-align: start;
}

.season-toggle svg {
  color: var(--muted);
  transition: transform 0.2s;
}

.season-panel.open .season-toggle svg {
  transform: rotate(180deg);
}

.season-title {
  min-width: 0;
  flex: 1;
}

.season-title h3 {
  font-size: 16px;
}

.season-title p {
  color: var(--muted);
  font-size: 13px;
}

.season-title .progress-track {
  height: 4px;
  margin-top: 8px;
  max-width: 260px;
}

.season-head .ghost-button {
  min-height: 34px;
  font-size: 13px;
}

.episodes-list {
  display: none;
  border-top: 1px solid var(--line);
}

.season-panel.open .episodes-list {
  display: block;
}

.episode-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.episode-row:last-child {
  border-bottom: 0;
}

.episode-row.is-next {
  background: var(--accent-soft);
}

.check-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  background: transparent;
  color: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.check-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 3;
}

.check-button:hover {
  border-color: var(--done);
  color: var(--done);
}

.check-button:active {
  transform: scale(0.9);
}

.episode-row.watched .check-button {
  background: var(--done);
  border-color: var(--done);
  color: #062716;
}

.episode-main {
  min-width: 0;
}

.episode-main h4 {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-row.watched .episode-main h4 {
  color: var(--muted);
}

.episode-main p {
  color: var(--muted);
  font-size: 12.5px;
}

.episode-main .progress-track {
  height: 3px;
  margin-top: 6px;
  max-width: 220px;
}

.time-button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.time-button svg {
  width: 16px;
  height: 16px;
}

.time-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.time-editor {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.time-editor input {
  width: 100px;
  min-height: 36px;
  padding: 4px 10px;
  text-align: center;
  direction: ltr;
}

/* ---------------------------------------------------------------- stats */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-tile {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat-tile strong {
  display: block;
  font-size: 30px;
  line-height: 1.2;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-tile small {
  color: var(--muted);
  font-size: 12.5px;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel h2 {
  font-size: 17px;
  margin-bottom: 6px;
}

.panel > .muted {
  font-size: 14px;
}

.stats-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 16px;
  align-items: start;
}

.status-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  margin: 14px 0;
  gap: 2px;
}

.status-bar span {
  display: block;
  height: 100%;
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.legend-row b {
  margin-inline-start: auto;
  font-variant-numeric: tabular-nums;
}

.series-bars {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.series-bar {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: start;
}

.series-bar:hover {
  background: var(--surface-2);
}

.series-bar .poster {
  width: 36px;
  border-radius: 5px;
  box-shadow: none;
}

.series-bar .poster-fallback {
  font-size: 11px;
}

.series-bar-main {
  min-width: 0;
}

.series-bar-main div {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-bar-main .progress-track {
  height: 5px;
  margin-top: 6px;
}

.series-bar b {
  font-size: 13.5px;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- settings */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-grid .span-all {
  grid-column: 1 / -1;
}

.settings-grid .stacked-form {
  margin-top: 14px;
}

.settings-grid textarea {
  margin-top: 14px;
}

.status-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13.5px;
}

.status-note.ok {
  background: var(--done-soft);
  color: var(--done);
}

/* ---------------------------------------------------------------- dialog & toast */

.app-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.dialog-head h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: 24px;
  z-index: 50;
  width: fit-content;
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    height: auto;
    padding: 0 0 var(--safe-b);
    border: 0;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    z-index: 30;
  }

  .sidebar .brand {
    display: none;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    height: var(--nav-h);
  }

  .nav-tab {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    font-size: 11.5px;
    text-align: center;
  }

  .nav-tab svg {
    width: 23px;
    height: 23px;
  }

  .nav-tab:hover,
  .nav-tab.active {
    background: none;
  }

  .nav-tab.active {
    color: var(--accent);
  }

  .main {
    padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
  }

  .toast {
    bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  }

  .page-head {
    margin-bottom: 16px;
  }

  .continue-row {
    grid-auto-columns: 86%;
    margin-inline: -16px;
    padding-inline: 16px;
    scroll-padding-inline: 16px;
  }

  .library-head {
    flex-wrap: wrap;
  }

  .library-head .search-input {
    max-width: none;
  }

  .chips {
    margin-inline: -16px;
    padding-inline: 16px;
  }

  .shows-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 16px 12px;
  }

  .show-card h3 {
    font-size: 13.5px;
  }

  .status-badge {
    top: 6px;
    inset-inline-start: 6px;
    font-size: 10.5px;
  }

  .results-list {
    grid-template-columns: 1fr;
  }

  .details-hero {
    margin: calc(-18px - env(safe-area-inset-top, 0px)) -16px 0;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 20px;
  }

  .hero-body {
    grid-template-columns: 112px 1fr;
    gap: 16px;
    align-items: start;
  }

  .hero-body .poster {
    width: 112px;
  }

  .hero-info {
    gap: 8px;
  }

  .hero-body .poster {
    grid-row: auto;
  }

  .hero-extra {
    grid-column: 1 / -1;
  }

  .stats-panels {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .season-head .ghost-button span {
    display: none;
  }
}


@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

a.secondary-button,
a.secondary-button:visited {
  color: var(--ink);
}

.episode-actions {
  display: flex;
  align-items: center;
}

.danger-text,
.danger-text:hover:not(:disabled) {
  color: var(--danger);
}

.time-editor {
  flex-wrap: wrap;
}

.secret-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.secret-box code {
  font-size: 15px;
  letter-spacing: 0.08em;
  word-break: break-all;
  user-select: all;
}

.secret-box a {
  color: var(--accent);
}

.invite-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.invite-row > div:first-child {
  display: grid;
}

.invite-actions {
  display: flex;
  gap: 6px;
}

.invite-actions .secondary-button,
.invite-actions .ghost-button {
  min-height: 34px;
  font-size: 13.5px;
}
