:root {
  --bg: #101010;
  --surface: #1c1c1c;
  --surface-2: #262626;
  --text: #f2f2f2;
  --muted: #a3a3a3;
  --accent: #00a4dc;
  --accent-ink: #00222e;
  --radius: 6px;
  --gutter: clamp(16px, 3.4vw, 64px);
  --card-w: clamp(150px, 17vw, 300px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { fill: currentColor; }

/* Focus ring: the remote control and the keyboard both rely on it. */
.focusable { outline: none; }
.focusable:focus-visible { box-shadow: 0 0 0 3px var(--accent); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--gutter);
  background: linear-gradient(rgba(16, 16, 16, 0.96), rgba(16, 16, 16, 0.82));
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius);
  font-size: 1.15rem;
  font-weight: 600;
}
.brand svg { width: 26px; height: 26px; color: var(--accent); }
.brand-mark { width: 30px; height: 32px; flex: none; display: block; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  width: min(320px, 46vw);
  background: var(--surface);
  border-radius: 999px;
}
.search:focus-within { box-shadow: 0 0 0 3px var(--accent); }
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
}
.search input:focus-visible { box-shadow: none; }
.search input::placeholder { color: var(--muted); }

/* ---------- page ---------- */
main { padding: 8px 0 64px; outline: none; }
.page-pad { padding: 0 var(--gutter); }
.notice {
  margin: 4px var(--gutter) 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}
.notice strong { color: var(--text); }
.state {
  padding: 18vh var(--gutter);
  text-align: center;
  color: var(--muted);
}
.state h2 { margin: 0 0 8px; color: var(--text); font-weight: 600; }
.state p { margin: 0 auto; max-width: 560px; line-height: 1.5; }

.section-title {
  margin: 22px var(--gutter) 10px;
  font-size: 1.3rem;
  font-weight: 500;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 14px var(--gutter) 4px;
  color: var(--muted);
}
.crumbs a { padding: 4px 8px; border-radius: var(--radius); }
.crumbs a:hover { color: var(--text); }
.crumbs .here { padding: 4px 8px; color: var(--text); font-size: 1.4rem; font-weight: 600; }

/* ---------- rows and grids ---------- */
.row {
  display: flex;
  gap: 14px;
  padding: 6px var(--gutter) 14px;
  overflow-x: auto;
  scroll-padding: 0 var(--gutter);
  scrollbar-width: none;
}
.row::-webkit-scrollbar { display: none; }
.row > .card { flex: 0 0 var(--card-w); min-width: 0; }
.row.wide > .card { flex-basis: calc(var(--card-w) * 1.25); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-w), 44vw), 1fr));
  gap: 18px 14px;
  padding: 10px var(--gutter);
}

/* ---------- cards ---------- */
.card { display: block; border-radius: var(--radius); min-width: 0; }
.card:focus-visible { box-shadow: none; }
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #5a5a5a;
}
.thumb .ph svg { width: 34%; height: 34%; }
.card:hover .thumb { transform: scale(1.03); }
.card:focus-visible .thumb { transform: scale(1.05); box-shadow: 0 0 0 3px var(--accent); }
.card .play-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.card .play-hint svg { width: 46px; height: 46px; padding: 9px; border-radius: 50%; background: var(--accent); color: #fff; }
.card:hover .play-hint, .card:focus-visible .play-hint { opacity: 1; }
.badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.count {
  position: absolute;
  right: 6px;
  top: 6px;
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.25); }
.bar > i { display: block; height: 100%; background: var(--accent); }
.has-bar .badge { bottom: 10px; }
.card-title {
  margin-top: 8px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}
.card-sub {
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
}
.folder .thumb img { filter: brightness(0.55); }
.folder .thumb .label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* ---------- details ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.32);
  transform: scale(1.15);
}
.detail {
  display: grid;
  grid-template-columns: minmax(220px, 34%) 1fr;
  gap: clamp(18px, 3vw, 44px);
  align-items: start;
  padding: 26px var(--gutter);
}
.detail .poster { border-radius: var(--radius); overflow: hidden; background: var(--surface); aspect-ratio: 16 / 9; }
.detail .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail h1 { margin: 0 0 10px; font-size: clamp(1.5rem, 3vw, 2.4rem); font-weight: 600; overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.facts .chip { padding: 1px 7px; border: 1px solid #555; border-radius: 4px; font-size: 0.8rem; color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 6px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn:hover { filter: brightness(1.15); }
.resume-note { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 720px) {
  .detail { grid-template-columns: 1fr; }
}

.spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.spinner[hidden] { display: none; }
.loading { display: grid; place-items: center; padding: 26vh 0; }
.loading .spinner { position: static; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .spinner { animation-duration: 2.4s; }
}

/* ---------- top bar additions ---------- */
.brand svg, .search svg { flex: none; }
.toplinks { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.toplinks a { padding: 8px 12px; border-radius: var(--radius); color: var(--muted); white-space: nowrap; }
.toplinks a:hover, .toplinks a.on { color: var(--text); }
.toplinks a.on { box-shadow: inset 0 -2px 0 var(--accent); }
.topactions { display: flex; align-items: center; gap: 4px; }
.topactions:empty { display: none; }

/* ---------- round icon button (top bar and player) ---------- */
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
  flex: none;
}
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn:focus-visible { outline: none; box-shadow: none; background: var(--accent); }
