/* home.css — the front page (home.html): a YouTube-style grid of served clips.
   Own stylesheet: the viewer's style.css pins the body to a fixed, non-scrolling
   stage; the home page scrolls. Same self-hosted Supreme and Nippo (the ChronoSpace design kit) and the same neutral
   dark tones, tuned darker so posters carry the colour; a faint cool glow at
   the top gives the ground depth, and the bars over it are glass. Layout: 56px
   sticky top bar · 72px mini rail · fluid card grid. A card held under the
   pointer pops out (.pop). */
@font-face {
  font-family: "Supreme";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/Supreme-Variable.woff2") format("woff2");
}
@font-face {
  font-family: "Nippo";
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  src: url("fonts/Nippo-Variable.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #0c0c0e;
  --bg-2: #151517;
  --bg-3: #202023;
  --glass: rgba(12, 12, 14, 0.72);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f3f3f5;
  --muted: #a9a9b2;
  --faint: #72727c;
  --chip: rgba(255, 255, 255, 0.08);
  --chip-hover: rgba(255, 255, 255, 0.15);
  --accent: #8ab4ff;
  --danger: #ff6b6b;
  --radius: 14px;
  --top-h: 56px;
  --rail-w: 72px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  font-family: "Supreme", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  background: radial-gradient(1200px 460px at 50% -160px, rgba(138, 180, 255, 0.10), transparent 70%) no-repeat fixed, var(--bg);
  min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--bg-3); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Top bar ---------------------------------------------------------------- */
#top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: grid; grid-template-columns: 1fr minmax(240px, 640px) 1fr; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--glass); -webkit-backdrop-filter: saturate(1.5) blur(18px); backdrop-filter: saturate(1.5) blur(18px);
}
.top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.brand { display: flex; align-items: baseline; gap: 0; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.logo, .logo-er { font-family: "Nippo", "Supreme", sans-serif; }
.logo { font-weight: 600; font-size: 21px; letter-spacing: -0.02em; }
.logo-er { font-weight: 300; font-size: 21px; letter-spacing: -0.02em; color: var(--muted); }
.brand-sub { margin-left: 10px; font-size: 12px; color: var(--faint); letter-spacing: 0.04em; text-transform: uppercase; }
.brand-sub:empty { display: none; }

.ib {                                   /* round icon button */
  appearance: none; border: 0; background: transparent; width: 40px; height: 40px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text);
  transition: background 0.15s var(--ease);
}
.ib:hover { background: var(--chip); }
.ib:active { background: var(--chip-hover); }

#search { display: flex; align-items: center; height: 40px; }
#search input {
  flex: 1; min-width: 0; height: 40px; padding: 0 16px; font: inherit; font-size: 15px; color: var(--text);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-2); border-right: 0; border-radius: 40px 0 0 40px; outline: none;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
#search input::placeholder { color: var(--faint); }
#search input:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px rgba(138, 180, 255, 0.35); }
#search input::-webkit-search-cancel-button { filter: invert(1); }
#search .search-go { width: 64px; height: 40px; border-radius: 0 40px 40px 0; background: var(--chip); border: 1px solid var(--line-2); }
#search .search-go:hover { background: var(--chip-hover); }

.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 10px; border-radius: 18px;
  background: var(--chip); border: 0; cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}
.pill:hover { background: var(--chip-hover); }
.pill:active { transform: scale(0.97); }
.pill.primary { background: var(--text); color: var(--bg); }
.pill.primary:hover { background: #fff; }
.pill svg { width: 20px; height: 20px; }

/* ---- Rail ------------------------------------------------------------------- */
#rail {
  position: fixed; top: var(--top-h); left: 0; bottom: 0; width: var(--rail-w); z-index: 15;
  display: flex; flex-direction: column; align-items: stretch; padding: 4px 4px; gap: 2px;
}
.rail-item {
  appearance: none; border: 0; background: transparent; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0 12px; border-radius: 10px;
  font-size: 10px; letter-spacing: 0.01em; color: var(--muted); transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.rail-item:hover { background: var(--chip); color: var(--text); }
.rail-item.active { font-weight: 600; color: var(--text); }
.rail-item.active svg { stroke-width: 2.2; }
body.rail-hidden #rail { display: none; }
body.rail-hidden #main { margin-left: 0; }

/* ---- Main / chips ----------------------------------------------------------- */
#main { margin-left: var(--rail-w); padding: 0 24px 40px; min-height: calc(100vh - var(--top-h)); }
#chipbar {
  position: sticky; top: var(--top-h); z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 8px 0 12px; margin: 0 -24px; padding-left: 24px; padding-right: 24px;
  background: var(--glass); -webkit-backdrop-filter: saturate(1.5) blur(18px); backdrop-filter: saturate(1.5) blur(18px);
  border-bottom: 1px solid transparent; transition: border-color 0.25s var(--ease);
}
body.scrolled #chipbar { border-bottom-color: var(--line); }
#chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; padding-bottom: 2px; }
#chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; border: 0; flex: none; height: 32px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  background: var(--chip); color: var(--muted); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}
.chip:hover { background: var(--chip-hover); color: var(--text); }
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--text); color: var(--bg); box-shadow: none; }
.chip .n { margin-left: 6px; font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: none; }
.sort select {
  appearance: none; -webkit-appearance: none; font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  background: var(--chip); border: 0; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); height: 32px; padding: 0 30px 0 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.sort select option { background: #1c1c1c; }

/* ---- Shelves + grid --------------------------------------------------------- */
.shelf { margin: 14px 0 36px; }
.shelf-head { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.shelf-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.shelf-head .count {
  padding: 2px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}
.shelf-head .count:empty { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 30px 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---- Card ------------------------------------------------------------------- */
/* the cards of a shelf come in one after the other (--i: the card's place, js/home.js);
   a redraw that must not move (#shelves.still: a search being typed) lands them in place */
#shelves.still .card { animation: none; }
.card { position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius);
  background: var(--bg-2); cursor: pointer; transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
  -webkit-user-select: none; user-select: none;
}
.thumb::after {                          /* a hairline inside the picture's edge: it sits in the page, not on it */
  content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.card:not(.soon):hover .thumb, .thumb:focus-visible { transform: translateY(-3px); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6); }
.card.soon .thumb { cursor: default; }
.thumb .art, .thumb .poster, .thumb .strip { position: absolute; inset: 0; width: 100%; height: 100%; }
.thumb .art { display: block; }
.has-poster .art { visibility: hidden; }     /* the generated art stands in for a missing poster, not under one that is loading */
.thumb .poster { object-fit: cover; opacity: 0; transition: transform 0.8s var(--ease), opacity 0.5s linear; }
.thumb .poster.in { opacity: 1; }        /* fades in once it has loaded */
.thumb .poster[hidden], .thumb .strip[hidden], .thumb .ribbon[hidden], .thumb .hover-hint[hidden] { display: none; }
.card.has-poster:hover .poster { transform: scale(1.05); }
.thumb .strip { background-repeat: no-repeat; background-size: auto 100%; }
.card.soon .art { filter: saturate(0.25) brightness(0.55); }
.badge {
  position: absolute; z-index: 2; padding: 4px 7px; border-radius: 7px; font-size: 12px; font-weight: 600;
  line-height: 1.1; letter-spacing: 0.02em; background: rgba(8, 8, 10, 0.72); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-variant-numeric: lining-nums tabular-nums; pointer-events: none;
}
.badge.dur { right: 8px; bottom: 8px; }
.badge.kind { left: 8px; top: 8px; font-size: 10.5px; letter-spacing: 0.1em; background: rgba(8, 8, 10, 0.55); color: #ddd; }
.badge.kind.k4d { background: rgba(60, 96, 170, 0.55); color: #dbe7ff; }
.badge.proc { left: 8px; bottom: 8px; background: rgba(255, 196, 87, 0.92); color: #201a08; }
.badge:empty { display: none; }
.ribbon {
  position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 6px 12px; border-radius: 999px; border: 1px dashed rgba(255, 255, 255, 0.45);
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: #ddd;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px); pointer-events: none;
}
.hover-hint {
  position: absolute; inset: 0; z-index: 1; display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 10px; background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent 45%);
  opacity: 0; transition: opacity 0.25s var(--ease); pointer-events: none;
}
.hover-hint span { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: #fff; }
.card:not(.soon):hover .hover-hint:not([hidden]) { opacity: 1; }
/* the filmstrip's place in the clip, while a card plays it in place (no pop-out: a touch screen) */
.thumb .strip-bar { position: absolute; left: 0; bottom: 0; z-index: 2; height: 3px; background: var(--accent); transition: width 0.16s linear; }
/* the star: on the picture's corner (it lifts with it) under the pointer, and for good on a favourite */
.card > .star, .pop > .star {
  appearance: none; border: 0; position: absolute; top: 8px; right: 8px; z-index: 4; width: 32px; height: 32px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #fff;
  background: rgba(8, 8, 10, 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity 0.2s var(--ease), transform 0.35s var(--ease), background 0.15s var(--ease);
}
.card > .star:hover, .pop > .star:hover { background: rgba(8, 8, 10, 0.8); }
.card > .star svg, .pop > .star svg { width: 18px; height: 18px; }
.card:hover > .star, .card > .star:focus-visible, .card > .star.on, .pop > .star { opacity: 1; }
.pop > .star { top: 10px; right: 10px; width: 36px; height: 36px; }
.card:hover > .star { transform: translateY(-3px); }
@media (hover: none) { .card > .star { opacity: 1; } }
.star.on { color: #ffd166; }
.star.on svg { fill: currentColor; }
/* the clip's copy on this device (js/offline.js), beside the star: on a favourite's card, and on
   any card that has one. A ring fills as it comes (--p: percent). */
.card > .dl {
  appearance: none; border: 0; position: absolute; top: 8px; right: 46px; z-index: 4; width: 32px; height: 32px; border-radius: 999px;
  display: none; align-items: center; justify-content: center; cursor: pointer; color: #fff;
  background: rgba(8, 8, 10, 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform 0.35s var(--ease), background 0.15s var(--ease);
}
.card > .dl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.shelf.favs .card > .dl, .card > .dl:not([data-state="none"]) { display: inline-flex; }
.card > .dl:hover { background: rgba(8, 8, 10, 0.8); }
.card:hover > .dl { transform: translateY(-3px); }
.card > .dl[data-state="saved"] { color: #7ee2a8; }
.card > .dl[data-state="stale"] { color: #ffc457; }
.card > .dl[data-state="loading"], .card > .dl[data-state="partial"] {
  background: radial-gradient(closest-side, rgba(8, 8, 10, 0.92) 78%, transparent 80%),
    conic-gradient(var(--accent) calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.22) 0);
}
.card > .dl[data-state="loading"] svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.no-offline .card > .dl, .no-offline .dl-all { display: none; }
.shelf-head .dl-all { height: 30px; margin-left: 6px; padding: 0 12px; font-size: 12.5px; }
.shelf-head .dl-all svg { width: 16px; height: 16px; }
.shelf-head .dl-all[data-state="saved"] { color: #7ee2a8; cursor: default; }
/* no connection: the cards whose clip is not on this device are there, dimmed, and do not open */
.offline-tag { padding: 4px 10px; border-radius: 999px; background: rgba(255, 196, 87, 0.16); color: #ffc457; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.offline-tag[hidden] { display: none; }
.card.away .thumb { opacity: 0.35; filter: grayscale(0.7); cursor: default; }
.card.away .body { opacity: 0.55; }
@media (hover: none) { .card > .dl { width: 36px; height: 36px; right: 48px; } }

.body { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: #fff; background: var(--bg-3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.text { flex: 1; min-width: 0; }
.title {
  margin: 0 0 4px; font-size: 15px; font-weight: 600; line-height: 1.32; letter-spacing: -0.008em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.channel, .note { font-size: 13px; color: var(--muted); line-height: 1.4; overflow: hidden; }
.channel { font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
/* why a coming-soon card cannot be opened yet, two lines at most (a clip's figures are not on
   its card: the pop-out and the Details sheet have them) */
.note { max-height: 2.8em; color: var(--faint); }

/* while the catalogue is on its way: the grid's shape, shimmering */
.card.skel { pointer-events: none; }
.card.skel .thumb, .card.skel .avatar, .card.skel .line {
  background: linear-gradient(100deg, var(--bg-2) 35%, #222226 50%, var(--bg-2) 65%) 0 0 / 220% 100%; animation: shimmer 1.4s linear infinite;
}
.card.skel .thumb::after, .card.skel .avatar { box-shadow: none; }
.card.skel .line { height: 12px; border-radius: 6px; margin: 4px 0 10px; }
.card.skel .line.short { width: 55%; }

/* ---- Hover preview (the pop-out) -------------------------------------------- */
/* Laid over its card and grown from it (transform set by js/home.js); under the sticky bars. */
.pop {
  position: absolute; z-index: 9; border-radius: 18px; overflow: hidden; background: #17171a;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.09);
  transform-origin: 0 0; transition: transform 0.34s var(--ease), opacity 0.2s linear; will-change: transform;
}
.pop[hidden] { display: none; }
.pop.closing { opacity: 0; pointer-events: none; }
.pop-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg-2); cursor: pointer; -webkit-user-select: none; user-select: none; }
.pop-media .art, .pop-media .poster, .pop-frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.pop-media .poster { object-fit: cover; }
.pop-media .poster[hidden], .pop-bar[hidden] { display: none; }
.pop-frame { background-repeat: no-repeat; opacity: 0; transition: opacity 0.4s linear; }
.pop-frame.on { opacity: 1; }
.pop-media.scrub .pop-frame { transition: none; }              /* a scrub shows the frame under the pointer at once */
.pop-media::after { content: ""; position: absolute; inset: auto 0 0; height: 40%; pointer-events: none; background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent); }
.pop-media .badge.dur { right: 10px; bottom: 14px; }
.pop-media .badge.kind { left: 10px; top: 10px; }
/* the bar: a 28px band to aim at, a 3px line to look at (it thickens under the pointer) */
.pop-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: 28px; cursor: ew-resize; }
.pop-bar::before, .pop-bar i, .pop-bar b { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; transition: height 0.15s var(--ease); }
.pop-bar::before { right: 0; background: rgba(255, 255, 255, 0.28); }
.pop-bar i { background: var(--accent); transition: height 0.15s var(--ease), width 0.4s linear; }
.pop-bar b { width: 2px; margin-left: -1px; background: #fff; opacity: 0; }
.pop-bar:hover::before, .pop-bar:hover i, .pop-bar:hover b { height: 6px; }
.pop-bar:hover b { opacity: 1; height: 12px; }
.pop-media.scrub .pop-bar i { transition: height 0.15s var(--ease); }
.pop-body { display: flex; flex-direction: column; gap: 13px; padding: 14px 16px 16px; }
.pop-body > * { opacity: 0; transform: translateY(6px); transition: opacity 0.3s linear 0.1s, transform 0.4s var(--ease) 0.1s; }
.pop.open .pop-body > * { opacity: 1; transform: none; }
.pop-body > :empty { display: none; }
.pop-head { display: flex; gap: 12px; align-items: flex-start; }
.pop-head .title { margin-bottom: 2px; font-size: 16px; -webkit-line-clamp: 3; }
.facts { display: flex; gap: 6px 22px; flex-wrap: wrap; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.facts div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.facts dt { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.facts dd { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.pop-desc { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pop-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; letter-spacing: 0.02em; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); font-variant-numeric: lining-nums; }
.pop-actions { display: flex; align-items: center; gap: 8px; }
.pop-actions .pill { height: 34px; }
.pop-actions .ib { width: 34px; height: 34px; background: var(--chip); }
.pop-actions .ib:hover { background: var(--chip-hover); }
.pop-actions .ib svg { width: 18px; height: 18px; }
.pop-actions .gap { flex: 1; }
.more { flex: none; width: 36px; height: 36px; margin: -6px -8px 0 0; opacity: 0; }
.card:hover .more, .more:focus-visible, .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .more { opacity: 1; } }

/* ---- Card menu -------------------------------------------------------------- */
.menu {
  position: fixed; z-index: 30; min-width: 220px; padding: 8px 0; border-radius: 12px;
  background: rgba(34, 34, 38, 0.92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow); animation: rise 0.18s var(--ease) both;
}
.menu[hidden] { display: none; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; border: 0; background: none;
  text-align: left; font-size: 14px; cursor: pointer; color: var(--text);
}
.menu button:hover, .menu a:hover { background: rgba(255, 255, 255, 0.1); }
.menu button:disabled { color: var(--faint); cursor: default; }
.menu button:disabled:hover { background: none; }
.menu svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.menu button.danger, .menu button.danger svg { color: var(--danger); }
.menu .sep { height: 1px; margin: 6px 0; background: var(--line); }
.menu .head { padding: 6px 16px 8px; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; }
.menu .sub { max-height: 260px; overflow-y: auto; }
.menu .sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Details modal ---------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.66); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.modal[hidden] { display: none; }
.modal-card { width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px 22px 18px; border-radius: 16px;
  background: #19191c; box-shadow: var(--shadow); animation: rise 0.25s var(--ease) both; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.rows { margin-top: 10px; border-top: 1px solid var(--line); }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.rows span { color: var(--muted); flex: none; }
.rows b { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.pill[hidden] { display: none; }
.pill:disabled { opacity: 0.5; cursor: default; }

/* ---- Upload sheet ----------------------------------------------------------- */
.fields { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field em { font-style: normal; color: var(--faint); margin-left: 4px; }
.field input[type="text"], .field textarea {
  font: inherit; font-size: 14px; color: var(--text); background: #121212; border: 1px solid #303030;
  border-radius: 10px; padding: 9px 12px; outline: none; resize: vertical;
}
.field input[type="text"]:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="file"] { font: inherit; font-size: 13px; color: var(--text); }
.field input[type="file"]::file-selector-button {
  font: inherit; font-weight: 500; color: var(--text); background: var(--chip); border: 0; border-radius: 8px;
  padding: 7px 12px; margin-right: 10px; cursor: pointer;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thumb-pick {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9;
  border-radius: var(--radius); border: 1px dashed var(--line-2); background: var(--bg-2); overflow: hidden; cursor: pointer;
}
.thumb-pick:hover, .visually-hidden:focus-visible + .thumb-pick { border-color: var(--accent); }
.thumb-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb-pick img[hidden], .thumb-pick span[hidden] { display: none; }
.progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress[hidden] { display: none; }
.progress progress { flex: 1; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--bg-3); }
.progress progress::-webkit-progress-bar { background: var(--bg-3); }
.progress progress::-webkit-progress-value { background: var(--accent); }
.progress progress::-moz-progress-bar { background: var(--accent); }
.error { margin: 12px 0 0; font-size: 13px; color: var(--danger); }
.error[hidden] { display: none; }

/* ---- Empty state, footer, toasts ------------------------------------------- */
.empty { display: flex; justify-content: center; padding: 48px 0; }
.empty[hidden] { display: none; }   /* the attribute must win over display:flex: shown only when nothing is served */
.empty-card { max-width: 560px; text-align: center; padding: 32px 28px; border-radius: 20px; background: var(--bg-2); box-shadow: var(--shadow); }
.empty-logo { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 8px; }
.empty-logo span { font-weight: 300; color: var(--muted); }
.empty pre { text-align: left; padding: 12px 14px; border-radius: 10px; background: #0b0b0b; overflow-x: auto; font-size: 12.5px; }
.empty p { font-size: 15px; line-height: 1.5; }
#foot { padding: 24px 0 0; font-size: 12px; color: var(--faint); }
#foot:empty { display: none; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 999px; background: #f1f1f1; color: #0f0f0f; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); animation: rise 0.25s var(--ease) both; }
.toast button { pointer-events: auto; margin: -4px -6px -4px 12px; padding: 4px 10px; border: 0; border-radius: 999px; background: none; color: #065fd4; font: inherit; font-weight: 600; cursor: pointer; }
.toast button:hover { background: rgba(6, 95, 212, 0.12); }

/* ---- Responsive ------------------------------------------------------------- */
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } }
@media (max-width: 800px) {
  #top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; padding: 0 8px; }
  .brand-sub { display: none; }
  .brand { padding: 4px 2px; }
  #search { min-width: 0; }
  .pill span { display: none; }
  .pill { padding: 0 8px; }
  #rail { display: none; }
  body.rail-open #rail { display: flex; background: var(--bg-2); box-shadow: var(--shadow); }
  #main { margin-left: 0; padding: 0 12px 32px; }
  #chipbar { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .sort span { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px 12px; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .thumb { border-radius: 10px; }
  #search .search-go { width: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .menu, .modal-card, .toast, .card.skel .thumb, .card.skel .avatar, .card.skel .line { animation: none; }
  .thumb, .thumb .poster, .pop, .pop-frame, .pop-body > *, .card > .star, .card > .dl { transition: none; }
  .card:not(.soon):hover .thumb, .card:hover > .star, .card:hover > .dl { transform: none; }
}
