body > header {
  background: var(--ink);
  border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(1px)) {
  body > header, #dock {
    background: color-mix(in srgb, var(--ink) 78%, transparent);
    backdrop-filter: blur(20px) saturate(135%);
  }
}
.logo { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.logo img { flex: none; }
#dock { display: none; }
#nav a.on { background: var(--panel); color: var(--amber); }
.card picture { display: block; width: 100%; height: 100%; }
.card picture img { display: block; width: 100%; height: 100%; object-fit: cover; }
.title-preview {
  position: fixed;
  z-index: 100;
  width: 320px;
  max-width: calc(100vw - 24px);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.96);
  transition: transform .22s ease, opacity .18s ease, visibility .22s;
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
  padding-bottom: 15px;
  background: var(--panel);
  color: var(--silver);
  box-shadow: 0 18px 48px #000b;
}
.title-preview.open { opacity: 1; visibility: visible; transform: none; }
.title-preview img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.title-preview strong, .title-preview small, .title-preview p { display: block; margin: 7px 15px 0; overflow-wrap: anywhere; }
.title-preview strong { font-size: 17px; }
.title-preview small { color: var(--amber); }
.title-preview p { color: var(--silver); font-size: 13px; line-height: 1.4; }
.title-preview p:empty, .title-preview small:empty { display: none; }
@media (min-width: 900px) {
  #app .row .card { flex-basis: clamp(195px, 19vw, 300px); }
  #app .row .card .ph { aspect-ratio: 16 / 9; }
  #app .row .card > span { line-height: 1.3; min-height: 2.6em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
}
@media (max-width: 899px) {
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  body > header { display: grid; grid-template-columns: auto minmax(0,1fr); padding: 8px 14px; gap: 6px 12px; }
  #nav { grid-column: 1 / -1; grid-row: 2; width: 100%; overflow-x: auto; mask-image: none; -webkit-mask-image: none; }
  #sf { width: 100%; min-width: 0; margin: 0; }
  #q { min-width: 0; width: 100%; font-size: 16px; }
  #dock {
    display: grid; position: fixed; inset: auto 0 calc(10px + env(safe-area-inset-bottom)); z-index: 35;
    width: min(410px,calc(100% - 28px)); margin: auto; padding: 5px;
    grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px; border: 1px solid var(--line);
    border-radius: 22px; background-color: var(--panel); box-shadow: 0 8px 28px #0008;
  }
  @supports (backdrop-filter: blur(1px)) { #dock { background-color: color-mix(in srgb,var(--panel) 77%,transparent); } }
  #dock a { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 45px; padding: 3px; border-radius: 16px; color: var(--silver); font-size: 11px; }
  #dock a.on { color: var(--amber); background: var(--line); }
  #dock svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  #app .row .card { flex-basis: clamp(108px, 29vw, 166px); }
}
@media (max-width: 390px) {
  .logo img { width: 29px; height: 29px; }
  body > header { column-gap: 6px; }
  #sf button { padding-inline: .5rem; }
}
@media (any-pointer: fine) {
  html { cursor: url('cursor-silver.png') 3 2, auto; }
  a[href], button:not(:disabled), select, summary { cursor: url('cursor-amber.png') 3 2, pointer; }
  input, textarea { cursor: text; }
  button:disabled, [aria-disabled=true] { cursor: not-allowed; }
}
.reel-shelf-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.reel-shelf-heading h2 { margin-block: 12px; }
.reel-shelf-controls { display:flex; gap:7px; }
.reel-shelf-controls button { display:grid; place-items:center; width:42px; height:42px; border:1px solid var(--line); border-radius:50%; background:var(--panel); color:var(--silver); }
.reel-shelf-controls svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.reel-shelf-controls button:disabled { opacity: .35; }
.reel-shelf-controls button:not(:disabled):hover { border-color: var(--amber); color: var(--amber); }
#dock { -webkit-backdrop-filter: blur(20px) saturate(135%); }
.title-preview { max-height: calc(100dvh - 24px); }
@media (min-width: 900px) and (max-width: 1120px) {
  body > header { gap: 10px; }
  #nav { min-width: 0; overflow-x: auto; }
  #sf { flex: none; }
}
#anime-filters input, #anime-filters select { max-width:100%; min-height:42px; }

.anime-badges:empty { display:none; }
.anime-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 9px;
  row-gap: 5px;
  margin-block: 6px;
}
.anime-badges .media-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  margin: 0;
  overflow: visible;
  color: var(--mute);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.media-badge + .media-badge {
  border-inline-start: 1px solid var(--line);
  padding-inline-start: 9px;
}
.media-badge svg {
  width: 12px;
  height: 12px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.anime-badges .media-badge-rating { color: var(--amber); }
@media (max-width: 520px) {
  .anime-badges { column-gap: 5px; }
  .media-badge + .media-badge { padding-inline-start: 5px; }
}
.title-preview .anime-badges { margin-inline:15px; }
.anime-badges:empty { display: none; }

#pl .player-bridge { padding: 0; border-radius: 16px; background: var(--ink); }
#pl .player-bridge-head, #pl .player-watch-selectors, #pl .player-bridge-controls {
  padding: 12px clamp(10px, 2vw, 22px);
}
#pl .player-stage { border-radius: 0; }
#pl .player-watch-language-hint { margin-inline: clamp(10px, 2vw, 22px); }
#pl .player-capabilities { padding-inline: clamp(10px, 2vw, 22px); }
#pl .player-brand-mark img { display: block; }
@media (max-width: 650px) {
  #pl .player-server-column { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  #pl .player-actions { display: flex; flex-wrap: wrap; gap: 7px; }
  #pl .player-actions > * { flex: 1 1 auto; }
}

#pl .player-server-column { min-width: 0; }
#pl .player-source-field { min-width: 0; }
#pl .player-cine-trigger-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pl .player-cine-option { text-align: left; overflow-wrap: anywhere; }
#pl .player-watch-selectors .player-cine-trigger,
#pl .player-actions > * { min-height: 44px; }

/* Shared controls and page alignment */
#app { scroll-margin-top: 115px; }
#sf { display: flex; align-items: center; }
#sf button { flex: none; min-height: 44px; }
#sf svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#nav, #dock { scrollbar-width: thin; }
#nav a { min-height: 42px; display: inline-flex; align-items: center; }
#app :is(.section-head,.watch-heading,.reel-shelf-heading) { align-items: center; flex-wrap: wrap; }
#app :is(.section-head h1,.watch-heading h1,.det h1,.reel-shelf-heading h2) { overflow-wrap: anywhere; line-height: 1.15; }
#app .bar { align-items: center; flex-wrap: wrap; gap: 8px; }
#app .bar > * { min-width: 0; max-width: 100%; }
#app :is(.bar,.det,.watch-heading,.player-actions,.availability-group) .btn,
#app .bar > :is(input,select,button) { min-height: 44px; }
#app :is(.bar,.watch-heading,.det,.player-actions) .btn { white-space: normal; line-height: 1.25; text-align: center; }
#app .grid .card > span { min-height: 2.6em; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; overflow: hidden; }
#app :is(.bar, .player-bridge) select { max-width: 100%; }
#pl > .player-bridge { padding: 0 !important; }
#pl .player-stage { min-height: 0; aspect-ratio: 16 / 9; }
#pl .player-status { max-width: 100%; white-space: normal; }
@media (max-width: 899px) {
  #sf button { width: 44px; padding: 0; }
  #sf button span { display: none; }
  #nav { flex-wrap: nowrap; justify-content: flex-start; scroll-padding-inline: 8px; }
  #nav a { flex: none; }
  #app .bar :is(input,select) { font-size: 16px; }
}
@media (max-width: 560px) {
  #app .watch-heading { align-items: flex-start; }
  #app .watch-heading > div, #app .det > div { min-width: 0; }
  #app .watch-heading h1, #app .det h1 { font-size: clamp(24px, 7vw, 34px); }
  #app .bar > label { display: flex; align-items: center; gap: 6px; }
  #pl .player-watch-selectors { grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); }
  #pl .player-stage-error-inner { max-width: 95%; }
}

/* Shared watch layout for movies, TV and anime. */
#pl .player-stage { max-height: min(76vh, 790px); background: #000; }
#pl .player-bridge-head { border-block: 1px solid var(--line); margin: 0; }
#pl .player-watch-selectors { justify-content: start; padding-bottom: 4px; }
#pl .player-bridge-controls { border-top: 1px solid var(--line); margin-top: 10px; }
#pl .player-capabilities { padding-bottom: 12px; }
#app .episode-nav { padding: 12px 0; }
@media (max-width: 650px) {
  #pl .player-stage { width: 100%; }
  #pl .player-watch-selectors { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
  #pl .player-brand-copy strong { font-size: 13px; }
}

.watch-screening {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 26%);
  align-items: start;
  gap: clamp(14px, 1.7vw, 26px);
}
.watch-screening > #pl { min-width: 0; margin: 0; }
.watch-episode-queue {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}
.watch-episode-queue h2 { margin: 0 0 12px; }
.watch-episode-queue h2 small { color: var(--mute); font-size: 13px; }
.watch-episode-queue input { width: 100%; padding: 8px 11px; font-size: 16px; }
.watch-episode-queue ol {
  position: relative;
  max-height: min(46vh, 470px);
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
.watch-episode-queue li[hidden], .watch-episode-queue .queue-empty[hidden] { display: none; }
.watch-episode-queue li a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 7px 10px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
.watch-episode-queue li a:hover { background: var(--panel-2); }
.watch-episode-queue li a[aria-current] { background: color-mix(in srgb, var(--amber) 15%, var(--panel)); color: var(--amber-strong); }
.watch-episode-queue li a b { color: var(--amber); font-variant-numeric: tabular-nums; }
@media (max-width: 800px) {
  .watch-screening { grid-template-columns: minmax(0, 1fr); }
  .watch-episode-queue ol { max-height: 320px; }
}

.anime-detail-page { padding-top: 20px; }
.anime-detail-back { display: inline-flex; min-height: 44px; align-items: center; color: var(--mute); }
#app .anime-detail-summary {
  grid-template-columns: clamp(130px, 20vw, 252px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 34px);
  align-items: center;
  max-width: 1050px;
  padding: 14px 0 24px;
}
.anime-detail-copy h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 3.25rem); }
.anime-detail-copy p { margin: 6px 0; }
.anime-detail-summary .ph img { width: 100%; height: 100%; display: block; object-fit: cover; }
.anime-detail-actions, .anime-detail-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.anime-detail-actions { margin: 15px 0 10px; }
.anime-detail-actions .btn { min-height: 44px; }
.anime-detail-actions svg { width: 15px; height: 15px; fill: currentColor; }
.anime-detail-about { max-width: 76ch; border-top: 1px solid var(--line); padding-top: 15px; }
.anime-detail-about h2 { margin: 0 0 6px; }
.anime-detail-about p { line-height: 1.65; }
@media (max-width: 500px) {
  #app .anime-detail-summary { grid-template-columns: minmax(0,1fr); }
  .anime-detail-summary .ph { width: min(44vw, 175px); }
}

/* Keep sticky chrome cheap to composite during scrolling. */
body > header { background: var(--ink); -webkit-backdrop-filter: none; backdrop-filter: none; }
#dock { -webkit-backdrop-filter: none; backdrop-filter: none; }
#app .row { contain: layout paint; }
