:root {
  color-scheme: dark light;
  --page-background: #120d10;
  --page-glow: rgb(255 121 193 / 10%);
  --panel-background: #1e161b;
  --panel-border: #382530;
  --text-primary: #f7ecf1;
  --text-secondary: #ab93a0;
  --accent: #ff79c1;
  --button-text: #260a1a;
  --danger-text: #fb7185;
  --badge-text: #ffffff;
  --badge-airing: #2e7d57;
  --badge-renewed: #8a3fbf;
  --badge-ended: #584a52;
  --badge-cancelled: #a03354;
  --tile-background: rgb(255 121 193 / 16%);
  --tile-border: rgb(255 121 193 / 55%);
  --tile-label-text: #ffa1d3;
}

@media (prefers-color-scheme: light) {
  :root:not([data-mode='dark']) {
    --page-background: #f6f7f9;
    --panel-background: #ffffff;
    --panel-border: #dfe3e8;
    --text-primary: #1a1d21;
    --text-secondary: #5c636d;
    --accent: #2f5fd0;
    --button-text: #ffffff;
    --badge-airing: #2f7d57;
    --badge-renewed: #3f6bb5;
    --badge-ended: #6d737d;
    --badge-cancelled: #a34a4a;
    --tile-background: rgb(47 95 208 / 8%);
  --tile-border: rgb(47 95 208 / 40%);
  --tile-label-text: #2b55b8;
  }
}

[data-mode='dark'] {
  color-scheme: dark;
  --page-background: #120d10;
  --page-glow: rgb(255 121 193 / 10%);
  --panel-background: #1e161b;
  --panel-border: #382530;
  --text-primary: #f7ecf1;
  --text-secondary: #ab93a0;
  --accent: #ff79c1;
  --button-text: #260a1a;
  --danger-text: #fb7185;
  --badge-text: #ffffff;
  --badge-airing: #2e7d57;
  --badge-renewed: #8a3fbf;
  --badge-ended: #584a52;
  --badge-cancelled: #a03354;
  --tile-background: rgb(255 121 193 / 16%);
  --tile-border: rgb(255 121 193 / 55%);
  --tile-label-text: #ffa1d3;
}

[data-mode='light'] {
  color-scheme: light;
  --page-background: #fbf3f6;
  --page-glow: rgb(194 46 114 / 6%);
  --panel-background: #ffffff;
  --panel-border: #eed7e1;
  --text-primary: #2b1a24;
  --text-secondary: #7c6572;
  --accent: #c22e72;
  --button-text: #ffffff;
  --danger-text: #b03d5e;
  --badge-airing: #2e7d57;
  --badge-renewed: #8b4ea3;
  --badge-ended: #7a6a75;
  --badge-cancelled: #b03d5e;
  --tile-background: rgb(194 46 114 / 8%);
  --tile-border: rgb(194 46 114 / 40%);
  --tile-label-text: #a82963;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  background: var(--page-background);
}

.page {
  min-height: 100vh;
  background:
    radial-gradient(60rem 32rem at 80% -8rem, var(--page-glow), transparent 70%) no-repeat,
    var(--page-background);
  color: var(--text-primary);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  line-height: 1.5;
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.site-header {
  border-bottom: 1px solid var(--panel-border);
}

.site-bar {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

.site-name:hover {
  text-decoration: none;
}

.site-home-icon {
  display: none;
}

nav {
  display: flex;
  gap: 1.5rem;
  white-space: nowrap;
}

.sign-in-action {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--button-text);
  font-weight: 600;
  font-size: 0.9rem;
}

.sign-in-action:hover {
  text-decoration: none;
  filter: brightness(1.08);
}

/* Desktop: nav links sit inline in the bar and the burger is hidden. */
@media (min-width: 768px) {
  .site-menu-button {
    display: none;
  }

  .site-nav {
    margin-left: 1rem;
  }

  .site-header .search {
    flex: 1 1 auto;
    max-width: 26rem;
    margin-left: auto;
  }

  .site-header .search + .sign-in-action,
  .site-header .search ~ .sign-in-action {
    margin-left: 0;
  }
}

/* Mobile: the nav moves into the drawer, leaving a home icon in place of the name. */
@media (max-width: 767px) {
  .site-name-text {
    display: none;
  }

  .site-home-icon {
    display: block;
  }

  .site-nav {
    display: none;
  }

  .site-header .search {
    flex: 1 1 auto;
    margin-left: auto;
  }
}

.site-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.site-drawer-nav a {
  padding: 0.7rem 0.5rem;
  border-radius: 0.5rem;
}

.site-drawer-nav a:hover {
  background: var(--panel-border);
  text-decoration: none;
}


a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0.75rem 0 0.5rem;
}

@media (min-width: 640px) {
  h1 {
    margin: 1.5rem 0 0.5rem;
  }
}

h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

main > h2:first-child,
main > section > h2:first-child,
main > section > .visually-hidden + h2 {
  margin-top: 0;
}

h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

p {
  margin: 0.35rem 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.secondary {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.context {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.card-grid {
  display: grid;
  gap: 0.6rem;
}

.card,
.season,
.search-result,
.preferences,
.message {
  background: var(--panel-background);
  border: 1px solid var(--panel-border);
  border-radius: 0.6rem;
  padding: 0.85rem;
}

.message > :first-child {
  margin-top: 0;
}

.tracking {
  margin: 1rem 0;
}

.show-banner {
  width: 100%;
  height: 5.8rem;
  display: flex;
  justify-content: center;
  overflow: hidden;
  --show-banner-feather: 15%;
  background: linear-gradient(
    to right,
    var(--show-banner-left-color, var(--panel-border)) 50%,
    var(--show-banner-right-color, var(--panel-border)) 50%
  );
}

@media (min-width: 640px) {
  .show-banner {
    height: 9rem;
  }
}

.show-banner img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  mask-image: linear-gradient(
    to right,
    transparent,
    #000 var(--show-banner-feather),
    #000 calc(100% - var(--show-banner-feather)),
    transparent
  );
}

.show-banner + main {
  padding-top: 0.5rem;
}

.show-banner + main h1 {
  margin-top: 0.25rem;
}

.seasons-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.seasons-heading .badge {
  font-size: 0.72rem;
}

.tracking-drawer {
  margin: 0.75rem 0 1rem;
}

.tracking-drawer summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tracking-drawer summary::-webkit-details-marker {
  display: none;
}

.tracked-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--tile-border);
  border-radius: 999px;
  background: var(--tile-background);
  color: var(--tile-label-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.tracked-pill::after {
  content: '▾';
}

.tracking-drawer[open] .tracked-pill::after {
  content: '▴';
}

.untrack-button {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.tracking-drawer .preferences {
  margin: 0.5rem 0 0;
}

.preference-fields {
  display: grid;
  gap: 0.35rem;
  justify-items: start;
}

.preference-fields label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.save-preferences {
  margin-top: 0.35rem;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}

@media (max-width: 639px) {
  .save-preferences {
    justify-self: stretch;
    width: 100%;
  }
}

button.button-danger {
  background: transparent;
  color: var(--danger-text);
  border: 1px solid var(--danger-text);
}

@media (min-width: 640px) {
  .tracking-drawer .preferences {
    max-width: 28rem;
  }
}

.card {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr;
  column-gap: 0.7rem;
  align-items: start;
  padding: 0.6rem;
}

.card {
  position: relative;
}

.card-link {
  color: inherit;
  display: contents;
}

.card-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.card-link:hover {
  text-decoration: none;
}

.card:has(.card-link:hover) {
  border-color: var(--tile-border);
}

.card > *,
.card .card-title {
  grid-column: 2;
}

.card .artwork {
  grid-area: 1 / 1 / -1 / 2;
  border-radius: 0.35rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.card > p {
  margin: 0.35rem 0 0;
}

.card > .secondary {
  font-size: 0.78rem;
  margin: 0.1rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artwork {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.4rem;
  background: var(--panel-border);
}

.artwork-placeholder {
  border: 1px dashed var(--panel-border);
  background: linear-gradient(160deg, var(--tile-background), transparent 70%) var(--panel-background);
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--badge-text);
  background: var(--badge-ended);
}

.badge-airing,
.badge-releasing {
  background: var(--badge-airing);
}

.badge-renewed,
.badge-not-yet-released {
  background: var(--badge-renewed);
}

.badge-cancelled {
  background: var(--badge-cancelled);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  background: var(--tile-background);
  border: 1px solid var(--tile-border, var(--panel-border));
  border-radius: 0.4rem;
  padding: 0.25rem 0.4rem 0.3rem;
}

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

.tile-label {
  display: block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.25;
  color: var(--tile-label-text, var(--text-secondary));
}

.tile-value {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.tile-value-missing {
  font-weight: 500;
  color: var(--text-secondary);
}

@media (min-width: 640px) {
  .card-grid {
    gap: 0.75rem;
  }

  .card {
    grid-template-columns: 5.5rem minmax(0, 1fr) auto;
    grid-template-rows: auto auto 1fr;
    column-gap: 1rem;
    padding: 0.75rem;
  }

  .card .artwork {
    grid-area: 1 / 1 / -1 / 2;
    border-radius: 0.4rem;
  }

  .card .card-title {
    grid-area: 1 / 2 / 2 / 3;
    font-size: 1.05rem;
    font-weight: 700;
  }

  .card > .secondary {
    grid-area: 2 / 2 / 3 / 3;
    font-size: 0.85rem;
    margin: 0.15rem 0 0;
    overflow: visible;
    white-space: normal;
  }

  .card > .card-status {
    grid-area: 1 / 3 / 2 / 4;
    justify-self: end;
    margin: 0;
  }

  .card > .tiles {
    grid-area: 3 / 2 / 4 / 4;
    align-self: end;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.6rem;
  }

  .tile {
    flex: 0 1 auto;
    min-width: 5.75rem;
    padding: 0.3rem 0.55rem 0.35rem;
  }

  .tile-label {
    font-size: 0.58rem;
    letter-spacing: 0.09em;
  }

  .tile-value {
    font-size: 0.82rem;
  }
}

.season-list {
  display: grid;
  gap: 1rem;
}

.release-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.release-row {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  background: var(--panel-background);
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  padding: 0.35rem 0.55rem;
}

.release-row .artwork {
  border-radius: 0.25rem;
}

.release-row-body {
  min-width: 0;
}

.release-row h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.release-row h3 a {
  color: inherit;
}

.release-row .secondary {
  margin: 0.05rem 0 0;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.release-row .badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .release-list {
    gap: 0.45rem;
  }

  .release-row {
    grid-template-columns: 2.75rem minmax(0, 1fr) auto;
    padding: 0.45rem 0.65rem;
  }

  .release-row h3 {
    font-size: 0.95rem;
  }
}

.season,
.search-result {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 1rem;
  align-items: start;
}

.search-result {
  grid-template-columns: 4rem 1fr auto;
  align-items: center;
}

.sequence {
  color: var(--text-secondary);
}

.season-facts {
  border-collapse: collapse;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
}

.season-facts th {
  text-align: left;
  vertical-align: baseline;
  padding: 0.15rem 0.75rem 0.15rem 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tile-label-text);
  white-space: nowrap;
}

.season-facts td {
  padding: 0.15rem 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

details summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.episodes {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.15rem 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.episodes li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.preferences {
  display: grid;
  gap: 0.35rem;
  justify-items: start;
  margin: 1rem 0;
}

.preferences h2 {
  margin: 0;
}

.preferences label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
  margin: 0;
}

.search-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.search-field input[type='search'] {
  width: 100%;
}

.search-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  flex: 0 0 auto;
}

.search-submit svg {
  width: 1.25rem;
  height: 1.25rem;
}

.autocomplete-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.autocomplete-thumbnail {
  width: 2.25rem;
  height: 3rem;
  object-fit: cover;
  border-radius: 0.25rem;
  flex: 0 0 auto;
}

.autocomplete-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.autocomplete-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-year {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.autocomplete-tracked {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--tile-label-text);
  flex: 0 0 auto;
}

.autocomplete-option {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 0.6rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  cursor: pointer;
}

.autocomplete-option:hover,
.autocomplete-option[aria-selected='true'] {
  background: var(--panel-border);
}

.autocomplete-thumbnail {
  display: block;
  width: 2.5rem;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.25rem;
  background: var(--panel-border);
}

.autocomplete-title {
  display: inline;
  font-weight: 600;
}

.autocomplete-year,
.autocomplete-tracked {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-left: 0.4rem;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.login-panel {
  max-width: 24rem;
  margin: 2rem auto 0;
  display: grid;
  gap: 0.75rem;
  background: var(--panel-background);
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.login-panel h1 {
  margin: 0;
}

.login-panel p {
  margin: 0;
}

.sign-in-failed {
  color: var(--danger-text);
}

.provider-button {
  display: block;
  text-align: center;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  background: var(--tile-background);
  color: var(--text-primary);
  font-weight: 600;
}

.provider-button:hover {
  text-decoration: none;
  border-color: var(--tile-border);
}

.danger-zone {
  margin: 1rem 0;
}

.danger-zone summary {
  cursor: pointer;
  color: var(--danger-text);
  font-weight: 600;
}

input[type='search'],
button {
  font: inherit;
  padding: 0.4rem 0.7rem;
  border-radius: 0.4rem;
  border: 1px solid var(--panel-border);
  background: var(--panel-background);
  color: var(--text-primary);
}

button {
  background: var(--accent);
  border-color: transparent;
  color: var(--button-text);
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  filter: brightness(0.92);
}

button:focus-visible,
input[type='search']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
