:root {
  color-scheme: light;
  --ink: #1a1b20;
  --muted: #777986;
  --line: #e3e3e8;
  --soft: #f5f5f7;
  --paper: #ffffff;
  --accent: #ffd22e;
  --accent-2: #54c756;
  --accent-3: #8b5cf6;
  --danger: #ff5b66;
  --sidebar: #17181d;
  --sidebar-2: #25262d;
  --shadow: 0 18px 42px rgba(12, 13, 18, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #191a1f 0, #191a1f 230px, var(--soft) 230px);
  color: var(--ink);
}

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

[hidden] {
  display: none !important;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.burger-button,
.nav-backdrop {
  display: none;
}

.sidebar {
  background: var(--sidebar);
  color: #f9fafb;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #151515;
  font-weight: 850;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.settings-panel p {
  margin: 0;
}

.brand h1 {
  font-size: 1.25rem;
}

.brand p {
  color: #aeb5c2;
  font-size: 0.9rem;
}

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

.nav-tab {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: #e8ebf0;
  background: transparent;
  text-align: left;
}

.nav-tab.is-active,
.nav-tab:hover {
  background: var(--sidebar-2);
  color: #fff;
  box-shadow: inset 4px 0 var(--accent);
}

.sidebar-panel {
  margin-top: auto;
  background: var(--sidebar-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.panel-label,
.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.75rem;
  font-weight: 750;
}

.topbar .eyebrow {
  color: rgba(255, 255, 255, 0.62);
}

.sidebar .panel-label,
.sidebar small {
  color: #aeb5c2;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  color: #fff;
}

.topbar h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.topbar-actions,
.button-row,
.dialog-actions > div {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.text-button {
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 42px;
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 1.1rem;
}

.file-button input {
  display: none;
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0 16px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #191919;
  border-color: #eac01d;
}

.auth-button {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-button {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: #fff2f2;
  color: #a22c38;
  border-color: #f2c8ca;
}

.text-button {
  background: transparent;
  color: var(--accent);
  font-weight: 750;
  padding: 0 6px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.series-card,
.release-item,
.timeline-day,
.search-result {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(20, 20, 25, 0.05);
}

.stat-card {
  padding: 18px;
  border-top: 4px solid var(--accent);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.section-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.release-list,
.compact-list,
.timeline,
.search-results {
  display: grid;
  gap: 10px;
}

.release-item,
.timeline-day {
  padding: 14px;
}

.release-item {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
}

.release-poster {
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  background: #22242b;
  color: var(--accent);
  font-weight: 850;
  text-align: center;
  overflow: hidden;
}

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

.release-item h4,
.series-card h3,
.compact-row h4,
.timeline-day h3,
.search-result h4 {
  margin: 0;
}

.release-item p,
.series-card p,
.compact-row p,
.timeline-day p,
.search-result p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.compact-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.watch-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.watch-row h4 {
  margin: 0;
}

.watch-row p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.watch-row .primary-button {
  min-width: 70px;
}

.watch-actions {
  display: grid;
  gap: 8px;
}

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

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ecf2;
  margin-top: 10px;
}

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

.toolbar {
  flex-wrap: wrap;
}

.search-box,
.field {
  display: grid;
  gap: 7px;
}

.search-box {
  flex: 1;
  min-width: 240px;
}

.search-box span,
.field span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.series-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.series-card {
  overflow: hidden;
  display: grid;
  grid-template-columns: 112px 1fr;
  position: relative;
  min-height: 176px;
  border: 1px solid var(--line);
  background: #fff;
}

.poster {
  background: #202129;
  color: #fff;
  display: grid;
  place-items: center;
  min-height: 176px;
  overflow: hidden;
}

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

.series-body {
  min-width: 0;
  padding: 14px 14px 16px;
  display: grid;
  align-content: start;
}

.series-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.series-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.pill {
  border-radius: 999px;
  background: #f0f0f3;
  color: #4d4e57;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 750;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.timeline-day h3 {
  color: #2f3038;
  font-size: 1rem;
  margin-bottom: 10px;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 18px;
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.search-result {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

dialog {
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: min(820px, calc(100vw - 24px));
}

dialog:has(.is-tracking-only) {
  width: min(1040px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(20, 23, 30, 0.48);
}

.dialog-card {
  position: relative;
  padding: 20px;
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(430px, calc(100vw - 24px));
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head {
  margin-bottom: 18px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 1.35rem;
  padding-right: 44px;
}

.dialog-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(10, 12, 18, 0.12);
}

.dialog-close-button:hover {
  background: #f5f5f7;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  gap: 10px;
}

.field.wide {
  grid-column: 1 / -1;
}

.dialog-card.is-tracking-only .form-grid {
  grid-template-columns: 1fr;
}

.detail-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: #f0f0f3;
}

.detail-tab {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.detail-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(20, 20, 25, 0.08);
}

.series-detail-panel {
  display: grid;
  gap: 14px;
}

.series-detail-hero {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  align-items: start;
}

.detail-poster {
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #202129;
  color: #fff;
  font-weight: 850;
}

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

.series-detail-hero h4 {
  margin: 0;
  font-size: 1.2rem;
}

.series-detail-hero p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-facts article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.detail-facts span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.detail-facts strong {
  color: var(--ink);
}

.dialog-actions {
  margin-top: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: #f0f0f3;
}

.auth-tab {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(20, 20, 25, 0.08);
}

.wide-button {
  width: 100%;
}

.auth-separator {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-separator::before,
.auth-separator::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.google-button-slot {
  min-height: 44px;
  display: grid;
  place-items: center;
}

.google-button-slot:empty {
  display: none;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.empty-state {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.auth-required {
  display: grid;
  gap: 10px;
  align-items: start;
}

.auth-required strong {
  color: var(--ink);
}

.auth-required p {
  margin: 0;
}

.auth-required .primary-button {
  justify-self: start;
}

.search-result.with-poster {
  grid-template-columns: 74px 1fr auto;
}

.result-poster {
  width: 74px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  background: #e8ecf2;
  overflow: hidden;
}

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

.episode-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.episode-panel h4 {
  margin: 0;
}

.episode-preview {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}

.episode-preview img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  background: #e8ecf2;
}

.episode-preview p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.episode-checklist {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  max-height: min(52vh, 560px);
  overflow: auto;
  padding-right: 4px;
}

.episode-season {
  display: grid;
  gap: 8px;
}

.episode-season-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 0;
  background: #fbfcfe;
}

.episode-season-head h5 {
  margin: 0;
  font-size: 0.98rem;
}

.episode-season-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.season-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.season-seen-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.episode-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.episode-check {
  display: grid;
  grid-template-columns: auto 64px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.episode-check input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.episode-check strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.3;
}

.episode-check p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.episode-thumb {
  width: 64px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 7px;
  background: #22242b;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 850;
}

.episode-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 900px) {
  body {
    background: var(--soft);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .burger-button {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 20;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(12, 13, 18, 0.14);
  }

  .burger-button span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink);
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
    border: 0;
    padding: 0;
    background: rgba(12, 13, 18, 0.42);
  }

  body.is-nav-open .nav-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 15;
    width: min(310px, 86vw);
    padding: 74px 18px 18px;
    gap: 18px;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 22px 0 44px rgba(12, 13, 18, 0.24);
  }

  body.is-nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .nav-tab {
    text-align: left;
    padding: 12px 14px;
  }

  .sidebar-panel {
    display: none;
  }

  .main {
    padding: 82px 14px 18px;
    max-width: 100vw;
  }

  .topbar {
    color: var(--ink);
  }

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

  .icon-button {
    background: var(--paper);
    border-color: var(--line);
    color: var(--ink);
  }

  .stats-grid,
  .content-grid,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .nav-tabs {
    display: grid;
    overflow: visible;
    max-width: 100%;
  }

  .nav-tab {
    min-width: 0;
  }

  .topbar-actions {
    width: 100%;
  }

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

  .series-card {
    grid-template-columns: 92px 1fr;
    min-height: 150px;
  }

  .watch-row {
    grid-template-columns: 42px 1fr;
  }

  .watch-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .poster {
    min-height: 150px;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    min-width: 0;
  }

  .release-item,
  .search-result,
  .search-result.with-poster,
  .episode-preview,
  .series-detail-hero,
  .detail-facts {
    grid-template-columns: 1fr;
  }

  .detail-poster {
    width: min(160px, 60vw);
  }

  .episode-check {
    grid-template-columns: auto 1fr;
  }

  .episode-thumb {
    display: none;
  }

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

  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions > div {
    width: 100%;
  }

  .dialog-actions button {
    flex: 1;
  }
}
