/* Stable page geometry when filters switch between short and long lists. */
html {
  scrollbar-gutter: stable;
  background-color: var(--surface) !important;
  scrollbar-color: var(--outline-variant) var(--surface);
}
body { background-color: var(--surface) !important; }
html::-webkit-scrollbar { width: 11px; }
html::-webkit-scrollbar-track { background: var(--surface); }
html::-webkit-scrollbar-thumb { background: var(--outline-variant); border: 3px solid var(--surface); border-radius: 999px; }

:root { --theme-accent: var(--primary); }

/* A smaller, distinct palette: four calm solids and four expressive gradients. */
html[data-theme="sage"] {
  --md-sys-color-primary: #758a12;
  --md-sys-color-primary-container: #edf7a8;
  --md-sys-color-on-primary-container: #202900;
  --md-sys-color-secondary-container: #e8edc9;
  --md-sys-color-on-secondary-container: #22270d;
  --theme-accent: #a9c42b;
}
html[data-theme="aurora"] {
  --md-sys-color-primary: #087d79;
  --md-sys-color-primary-container: #c6f4ed;
  --md-sys-color-on-primary-container: #002f2c;
  --md-sys-color-secondary-container: #dceeea;
  --md-sys-color-on-secondary-container: #17312d;
  --theme-accent: linear-gradient(120deg,#00f5b8 0%,#00a7ff 48%,#7b2cff 100%);
}
html[data-theme="sunset"] {
  --md-sys-color-primary: #c44f3c;
  --md-sys-color-primary-container: #ffe1d6;
  --md-sys-color-on-primary-container: #42120a;
  --md-sys-color-secondary-container: #f6e3dc;
  --md-sys-color-on-secondary-container: #351b15;
  --theme-accent: linear-gradient(120deg,#ffd60a 0%,#ff5a36 48%,#ef007f 100%);
}
html[data-theme="nebula"] {
  --md-sys-color-primary: #7658a8;
  --md-sys-color-primary-container: #eadfff;
  --md-sys-color-on-primary-container: #28104d;
  --md-sys-color-secondary-container: #eee0ec;
  --md-sys-color-on-secondary-container: #321c30;
  --theme-accent: linear-gradient(120deg,#ff3cac 0%,#b13cff 48%,#4361ee 100%);
}
html[data-theme="ocean"] {
  --md-sys-color-primary: #1767c8;
  --md-sys-color-primary-container: #d6efff;
  --md-sys-color-on-primary-container: #062d42;
  --md-sys-color-secondary-container: #daebe9;
  --md-sys-color-on-secondary-container: #19302e;
  --theme-accent: linear-gradient(120deg,#00f5ff 0%,#1464f4 46%,#6d20d9 100%);
}
html[data-theme="red"] { --theme-accent: #d84b3f; }
html[data-theme="purple"] {
  --md-sys-color-primary: #7734c8;
  --md-sys-color-primary-container: #eadcff;
  --md-sys-color-on-primary-container: #270052;
  --md-sys-color-secondary-container: #eadff2;
  --md-sys-color-on-secondary-container: #2c1837;
  --theme-accent: #8e3de6;
}
html[data-theme="blue"] {
  --md-sys-color-primary: #1769e0;
  --md-sys-color-primary-container: #dbe7ff;
  --md-sys-color-on-primary-container: #001a43;
  --md-sys-color-secondary-container: #dce5f8;
  --md-sys-color-on-secondary-container: #142039;
  --theme-accent: #1771e6;
}

.theme-options i { width: 46px; height: 46px; }
.theme-options [data-theme="purple"] i { background: #8e3de6; }
.theme-options [data-theme="blue"] i { background: #1771e6; }
.theme-options [data-theme="sage"] i { background: #a9c42b; }
.theme-options [data-theme="aurora"] i { background: linear-gradient(120deg,#00f5b8,#00a7ff 48%,#7b2cff); }
.theme-options [data-theme="sunset"] i { background: linear-gradient(120deg,#ffd60a,#ff5a36 48%,#ef007f); }
.theme-options [data-theme="nebula"] i { background: linear-gradient(120deg,#ff3cac,#b13cff 48%,#4361ee); }
.theme-options [data-theme="ocean"] i { background: linear-gradient(120deg,#00f5ff,#1464f4 46%,#6d20d9); }

.progress-fill,
.season-progress-fill,
.check.watched::before,
.empty-mark { background: var(--theme-accent) !important; }

/* The title is intentionally more expressive than the UI, but remains readable. */
.hero h1 {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif !important;
  font-weight: 700 !important;
  letter-spacing: -.05em !important;
  line-height: 1.08 !important;
  font-synthesis: none;
  -webkit-text-stroke: .12px currentColor;
  transform: scaleX(1.015);
  transform-origin: left center;
}

.headline-editor {
  display: flex;
  align-items: center;
  gap: 8px;
}
.headline-editor input {
  min-width: 0;
  height: 46px;
  flex: 1;
  padding: 0 14px;
  border: 1px solid var(--outline-variant);
  border-radius: 14px;
  background: var(--surface-container-low);
  color: var(--on-surface);
  font-size: 14px;
}
.headline-editor button {
  height: 40px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-weight: 600;
  white-space: nowrap;
}
.personalize-hint { margin: 8px 0 0; color: var(--on-surface-variant); font-size: 11px; }

/* Keep only the two marks that read clearly at small sizes. */
.mark-options { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
.v-mark,
html[data-mark="v"] .check-glyph::before {
  font-family: "Roboto Mono", ui-monospace, monospace !important;
  font-weight: 700 !important;
  font-style: normal;
  letter-spacing: -.08em;
}
html[data-mark="v"] .check-glyph::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 1px 1px 0;
  font-size: 15px !important;
  line-height: 1 !important;
  transform: none !important;
}

/* Cards remain the detail entry point; the small control marks only the next episode. */
.show-card {
  position: relative;
  cursor: pointer;
  color: var(--on-surface);
  font: inherit;
  text-align: left;
}
.show-card:focus-visible { outline: 3px solid color-mix(in srgb,var(--primary) 65%,transparent); outline-offset: 3px; }
.card-episode-row { display: flex; align-items: flex-start; gap: 10px; }
.card-episode-row .next-episode { min-width: 0; flex: 1; }
.card-quick-watch {
  width: 38px;
  height: 38px;
  min-width: 38px;
  margin-top: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--outline-variant);
  border-radius: 50%;
  color: transparent;
  background: transparent !important;
  box-shadow: none;
  transition: transform 140ms ease,filter 160ms ease,background 180ms ease,border-color 180ms ease;
}
.card-quick-watch:hover { border-color: var(--primary); background: color-mix(in srgb,var(--primary) 7%,transparent) !important; transform: scale(1.06); }
.card-quick-watch:active { transform: scale(.92); }
.card-quick-watch .check-glyph::before { opacity: 0 !important; transform: scale(.55) !important; }
.card-quick-watch.is-confirming {
  color: #fff;
  border-color: transparent;
  background: var(--theme-accent) !important;
  transform: scale(1.04);
}
.card-quick-watch.is-confirming .check-glyph::before { opacity: 1 !important; transform: none !important; }
html[data-mark="check"] .card-quick-watch.is-confirming .check-glyph::before { transform: none !important; }

@media (max-width:719px) {
  html { scrollbar-gutter: auto; }
  .hero h1 { transform: none; }
  .card-episode-row { gap: 6px; }
  .card-quick-watch { width: 32px; height: 32px; min-width: 32px; margin-top: 6px; }
  .headline-editor { align-items: stretch; flex-direction: column; }
  .headline-editor button { align-self: flex-end; }
}
