/* HorseTube - single stylesheet. Dark by default, light via [data-theme=light].
 * Type scale floor is 14px everywhere except --fs-micro labels (badges, durations, counts),
 * which stay at 12px; body copy is 15px. Every interactive control clears 44x44, and hover-only
 * overlay controls are dropped on touch layouts where hover does not exist. */

:root {
  --bg: #0f0f0f;
  --surface: #181818;
  --surface-2: #212121;
  --surface-3: #2f2f2f;
  --line: #303030;
  /* Field borders carry the only boundary the input has, so they clear 3:1 on both fills they
     sit on (--surface and --surface-2); --line stays for decorative hairlines. */
  --line-input: #6e6e6e;
  color-scheme: dark;
  --fg: #f1f1f1;
  --muted: #aaaaaa;
  --accent: #e8843c;
  --accent-ink: #1a1005;
  --danger: #f4483a;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-h: calc(56px + var(--safe-top));
  --rail-w: 232px;
  /* The ramp, one step per line; DESIGN.md typography names the same roles. Nothing in this file
   * sets a font-size that is not one of these, so a step that stops being used shows up here. */
  --fs-card: 15px;       /* .card-title, .who b, .related-col h2, .desc */
  --fs-field: 16px;      /* every field you can type into, and the label or caption with it */
  --fs-section: 17px;    /* .shelf-head */
  --fs-title: 19px;      /* .watch h1.title, .logo-word */
  --fs-stat: 20px;       /* .account-stats b, .auth-head h2 */
  --fs-headline: 22px;   /* .page-head h1, .account-card h1 */
  --fs-display: 24px;    /* .channel-head h1 */
  --font-ui: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --font-mono: Consolas, monospace;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  --fs-micro: 12px;
  --overlay: rgba(0, 0, 0, .62);
}

[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --surface-2: #ebebeb;
  --surface-3: #dedede;
  --line: #d8d8d8;
  --line-input: #858585;
  /* --danger sits on --surface, so the light twin is darker than the dark one. */
  --danger: #b3261e;
  color-scheme: light;
  --fg: #0c0c0c;
  --muted: #4d4d4d;
  --accent: #a34c17;
  --accent-ink: #fff7ef;
  --shadow: 0 4px 18px rgba(0, 0, 0, .14);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--font-ui);
  overscroll-behavior-y: none;
  scrollbar-color: var(--surface-3) var(--bg);
  scrollbar-width: thin;
}

a { color: inherit; text-decoration: none; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
/* Balanced heading wraps: the display face is the system face, so line length is the voice. */
h1, h2, h3 { text-wrap: balance; }

::selection { background: var(--accent); color: var(--accent-ink); }
input, textarea { caret-color: var(--accent); }
:-webkit-scrollbar { width: 12px; height: 12px; }
:-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 3px solid var(--bg); }
:-webkit-scrollbar-track { background: var(--bg); }

.skip {
  position: fixed; left: -999px; top: 8px; z-index: 99;
  display: inline-flex; align-items: center; min-height: 44px;
  background: var(--accent); color: var(--accent-ink); padding: 0 16px; border-radius: 10px; font-weight: 700;
}
.skip:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: var(--safe-top) 14px 0;
  background: var(--bg);
}

.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.icon-btn {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.logo { display: flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 6px; }
.logo-mark { width: 30px; height: 30px; display: grid; place-items: center; background: var(--accent); border-radius: 8px; }
.logo-mark svg { width: 22px; height: 22px; stroke: none; fill: var(--accent-ink); }
.logo-word { font-size: var(--fs-title); letter-spacing: -.4px; font-weight: 400; }
.logo-word b { font-weight: 800; color: var(--accent); }

.search { display: flex; flex: 1 1 640px; max-width: 640px; min-width: 0; margin-left: 24px; }
.search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line-input); color: var(--fg);
  border-radius: 22px 0 0 22px; font-size: var(--fs-field);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.search-btn {
  width: 56px; height: 44px; flex: none; border: 1px solid var(--line-input); border-left: 0;
  background: var(--surface-2);
  border-radius: 0 22px 22px 0; cursor: pointer; display: grid; place-items: center;
}
.search-btn:hover { background: var(--surface-3); }
.search-btn svg { width: 20px; height: 20px; }

/* One control, two spellings: .btn is the flow variant, .pill-btn sits in flex rows. */
.btn, .pill-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 22px; background: var(--surface-2); cursor: pointer; font-weight: 600;
}
.btn:hover, .pill-btn:hover { background: var(--surface-3); }
.btn svg, .pill-btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--fg); color: var(--bg); }
.btn.subbed { background: var(--surface-2); color: var(--muted); }

.me {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; text-transform: uppercase;
}
a.me { text-decoration: none; }
a.me:hover { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The solid recipe keeps the accent on hover; mixing toward the foreground reads as a
   darker (light theme) or brighter (dark theme) accent instead of a grey button. */
.pill-btn.solid { background: var(--accent); color: var(--accent-ink); }
.pill-btn.solid:hover { background: color-mix(in srgb, var(--accent) 82%, var(--fg)); color: var(--accent-ink); }

#authDialog {
  width: min(460px, calc(100vw - 32px)); padding: 18px 20px 22px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
#authDialog::backdrop { background: rgba(0, 0, 0, .62); }
.auth-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auth-head h2 { margin: 0; font-size: var(--fs-stat); }
.auth-note { color: var(--muted); font-size: 14px; line-height: 1.45; }
.auth-captcha { margin: 14px 0 0; }
.auth-captcha .pill-btn { margin-top: 8px; }
#turnstileWidget { min-height: 65px; }
#authForms form, #uploadDialog form { display: flex; flex-direction: column; gap: 6px; }
#authForms label, #uploadDialog label { font-size: 14px; font-weight: 600; margin-top: 8px; }
#authForms input, #uploadDialog input[type="text"] {
  min-height: 44px; padding: 0 12px; font-size: var(--fs-field); border-radius: 10px;
  border: 1px solid var(--line-input); background: var(--bg); color: var(--fg);
}
#authForms input:focus-visible, #uploadDialog input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
#authForms button, #uploadDialog .auth-actions button { align-self: flex-start; margin-top: 12px; }
#authForms hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0 2px; }
/* One error recipe for both forms in the page: the auth dialog and the comment field. */
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; margin: 6px 0 0; }
.auth-code { margin: 10px 0 14px; }
.auth-code code {
  display: block; padding: 12px; border-radius: 10px; background: var(--surface-2);
  font-size: var(--fs-field); font-weight: 700; letter-spacing: .04em; word-break: break-all;
}
.auth-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; padding: 0; list-style: none; }
.account-stats li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--surface); }
.account-stats a { display: block; }
.account-stats b { display: block; font-size: var(--fs-stat); }
.account-stats span { color: var(--muted); font-size: 14px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.account-card { max-width: 62ch; }

/* -------------------------------------------------------------------- uploads */
/* The upload dialog borrows the auth dialog's recipe: same field, same buttons, one more thing
   the account can do. The facts line is the interesting part - it says what was measured, by
   whom, and turns the danger colour when a ceiling is already in the way. */
#uploadDialog {
  width: min(520px, calc(100vw - 32px)); padding: 18px 20px 22px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
#uploadDialog::backdrop { background: rgba(0, 0, 0, .62); }
#uploadFile { min-height: 44px; color: var(--muted); font-size: 14px; }
.upload-facts { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 8px 0 4px; }
.upload-facts.upload-bad, .auth-note.upload-bad { color: var(--danger); }
#uploadProgress { width: 100%; height: 10px; margin: 12px 0 0; accent-color: var(--accent); }
/* The account page's own list uses the card thumbnail recipe, so an upload looks like every
   other clip: 16:9 box, duration chip bottom right. */
.uploads-head { font-size: var(--fs-section); margin: 26px 0 4px; }
.upload-list { display: grid; gap: 12px; margin: 12px 0 4px; }
.upload-row { display: grid; grid-template-columns: 168px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.upload-row .card-meta { margin: 4px 0 0; }
.upload-name { font-weight: 700; color: var(--fg); }
/* h1 and the muted lead-in are page furniture, not watch-page furniture. */
.account-card h1 { font-size: var(--fs-headline); letter-spacing: -.3px; margin: 12px 0 4px; }
.account-card .tags-row { color: var(--muted); font-size: 14px; margin: 0 0 12px; max-width: 70ch; }
/* The sync line is quiet furniture until something fails, then it has to be impossible to miss. */
.account-sync {
  align-items: baseline; color: var(--muted); display: flex; flex-wrap: wrap; font-size: 14px;
  gap: 6px; margin: 0 0 12px;
}
.account-sync[data-sync-state="error"] { color: var(--danger); }
.account-sync button {
  background: none; border: 0; color: inherit; cursor: pointer; font: inherit; min-height: 44px;
  min-width: 44px; text-decoration: underline;
}
.page-cta { margin: 14px 0 0; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--rail-w); z-index: 20;
  padding: 8px 8px 32px; overflow-y: auto; overscroll-behavior: contain; background: var(--bg);
}
.sidebar hr { border: 0; border-top: 1px solid var(--line); margin: 10px 6px; }
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-item {
  display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 12px;
  border-radius: 10px; color: var(--fg);
}
.rail-item svg { width: 22px; height: 22px; flex: none; }
.rail-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item:hover { background: var(--surface-2); }
.rail-item.active { background: var(--surface-3); font-weight: 700; }
.rail-badge {
  margin-left: auto; font-style: normal; font-size: var(--fs-micro); background: var(--accent);
  color: var(--accent-ink); border-radius: 9px; padding: 1px 7px; font-weight: 700;
}
.rail-heading { font-size: 14px; color: var(--muted); margin: 16px 12px 6px; font-weight: 700; }
.rail-about { padding: 0 12px; color: var(--muted); font-size: 14px; }
.rail-about p { margin: 0 0 8px; }
.rail-stats code { color: var(--fg); font-size: 14px; }

.channels .rail-item img { width: 24px; height: 24px; border-radius: 50%; flex: none; }

body.rail-mini .sidebar { width: 84px; }
body.rail-mini .rail-item { flex-direction: column; gap: 4px; height: 74px; padding: 10px 4px 0; font-size: var(--fs-micro); text-align: center; line-height: 1.25; }
/* The mini rail has 68px of usable width, so a long label clips instead of widening the
   sidebar and buying a horizontal scrollbar. */
body.rail-mini .rail-item span { max-width: 68px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.rail-mini .rail-badge { position: absolute; margin: 0; transform: translate(22px, -18px); }
body.rail-mini .rail-heading, body.rail-mini .rail-about, body.rail-mini .sidebar hr { display: none; }
body.rail-mini .channels .rail-item { height: 46px; flex-direction: row; }
body.rail-mini .channels .rail-item span { display: none; }

/* ------------------------------------------------------------------ layout */
#page {
  margin: var(--topbar-h) 0 0 var(--rail-w);
  min-height: calc(100vh - var(--topbar-h));
  min-height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column;
}
body.rail-mini #page { margin-left: 84px; }
body.no-rail #page { margin-left: 0; }
body.no-rail .sidebar { display: none; }

.content { flex: 1; padding: 8px 20px 40px; }

.footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px 26px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line);
}
.build-badge { font-family: var(--font-mono); font-size: var(--fs-micro); }

/* ------------------------------------------------------------------- chips */
.chips {
  position: sticky; top: var(--topbar-h); z-index: 15;
  display: flex; gap: 10px; padding: 10px 20px; overflow-x: auto;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line); scrollbar-width: thin;
}
.chip {
  flex: none; border: 0; background: var(--surface-2); color: var(--fg);
  min-height: 44px; padding: 0 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; font-weight: 600;
}
.chip:hover { background: var(--surface-3); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

/* ------------------------------------------------------------------- cards */
.page-head { padding: 14px 2px 6px; }
.page-head h1 { margin: 12px 0 4px; font-size: var(--fs-headline); letter-spacing: -.3px; }
.page-head p { margin: 0; color: var(--muted); max-width: 70ch; }

.grid {
  display: grid; gap: 22px 16px;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  padding: 12px 0 8px;
}
.grid.list { grid-template-columns: minmax(0, 880px); justify-content: start; gap: 16px; }

.card { display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; }
/* A list row is a two-column grid: the thumbnail column carries its own width, so the text
   column keeps whatever is left instead of being squeezed by a third flex child. */
.card.list-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 4px 16px; align-items: start; }
.card.list-row .thumb { width: auto; grid-row: 1 / span 2; }
.card.list-row .card-body { grid-template-columns: minmax(0, 1fr); }
.card.list-row .card-body > a { display: none; } /* the channel name below is the link */

.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--radius);
  overflow: hidden; background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.thumb:hover img { transform: scale(1.03); }
/* A portrait clip in a 16:9 box otherwise crops to a sliver of sky, so both short thumbnail
   recipes crop from the top third. */
.card[data-kind="short"] .thumb img, .short-tile img { object-position: 50% 30%; }
.dur {
  position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .78); color: #fff;
  font-size: var(--fs-micro); font-weight: 600; padding: 2px 5px; border-radius: 5px; letter-spacing: .2px;
}
.badge {
  position: absolute; left: 8px; top: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-micro); font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 7px; border-radius: 5px;
}
/* Two chips over the thumbnail, in one container: a card has one place for actions. On a pointer
   layout the pair is noise until the card is engaged, and a card already in a list or already saved
   keeps its button visible. */
.card-actions { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; }
.watch-later, .to-list {
  background: rgba(0, 0, 0, .82); color: #fff;
  border: 0; border-radius: 6px; min-height: 44px; padding: 0 12px; font-size: var(--fs-micro);
  cursor: pointer; font-weight: 700;
}
.watch-later[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.card.list-row .card-actions { grid-column: 2; justify-self: start; position: static; align-self: start; }
.card.list-row .watch-later, .card.list-row .to-list {
  background: transparent; color: var(--muted); border: 1px solid var(--line-input);
}
.card.list-row .watch-later[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .card:not(.list-row) .card-actions { opacity: 0; }
  .card:not(.list-row):hover .card-actions,
  .card:not(.list-row):focus-within .card-actions,
  .card:not(.list-row) .card-actions:has([aria-pressed="true"]) { opacity: 1; }
}

/* Playlists: the save dialog's rows, the account's list of lists, the page a share link opens, and
   the queue that follows a clip somebody reached through one of those links. */
.pl-row { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.pl-row label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.pl-row input[type="checkbox"] { width: 20px; height: 20px; min-width: 20px; accent-color: var(--accent); }
.pl-row label span:first-of-type { font-weight: 600; overflow-wrap: anywhere; }
.pl-open { color: var(--accent); font-size: var(--fs-micro); font-weight: 700; white-space: nowrap; }
.pl-new { display: grid; gap: 8px; margin-top: 14px; }
.pl-new input { min-height: 44px; }
.pl-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.pl-item { display: flex; align-items: baseline; gap: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); padding: 12px 14px; }
.pl-item a { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; flex: 1; min-width: 0;
  color: var(--fg); }
.pl-item b { font-size: var(--fs-card); overflow-wrap: anywhere; }
.pl-item span { color: var(--muted); font-size: 14px; }
.pl-item-row { display: grid; gap: 6px; margin: 0 0 14px; }
.pl-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.pl-tools button[disabled] { opacity: .4; cursor: default; }
.pl-share, .pl-rename { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 0; }
.pl-rename { margin-top: 12px; }
.pl-share label, .pl-rename label { color: var(--muted); font-size: 14px; }
.pl-share input, .pl-rename input { flex: 1; min-width: 200px; min-height: 44px; }
.pl-strip { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.pl-strip h2 { margin: 0 0 6px; font-size: var(--fs-card); }
.pl-queue { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.pl-queue li { color: var(--muted); }
.pl-queue li.on { color: var(--fg); font-weight: 700; }

.card-body { display: grid; grid-template-columns: 44px 1fr; gap: 10px; }
.card-body > a { display: grid; place-items: center; height: 44px; }
.card-body img.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); }
.card-title { margin: 0; font-size: var(--fs-card); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.card-title a {
  display: -webkit-box; min-height: 44px;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.card-meta .chan:hover { color: var(--fg); }
.card-meta .dot { margin: 0 5px; }

/* ------------------------------------------------------------------ shorts */
.shelf { padding: 16px 0 4px; }
.shelf-head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-section); font-weight: 700; margin: 14px 0 10px; }
.shelf-head svg { width: 20px; height: 20px; color: var(--accent); }
.shelf-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.short-tile {
  position: relative; flex: none; width: 172px; aspect-ratio: 9 / 16; border-radius: 14px;
  overflow: hidden; background: var(--surface-2); scroll-snap-align: start;
}
.short-tile img { width: 100%; height: 100%; object-fit: cover; }
/* The duration chip is pinned in this tile's lower-right corner like every other thumbnail, so the
   caption leaves that corner clear: 40px of bottom padding is the chip's 22px box plus its 8px inset
   plus 10px. The gradient reaches its plateau at 30% of the band - the same recipe as the Shorts feed
   caption - so both caption lines sit on opaque scrim even over a blown-out frame. */
.short-tile .cap {
  position: absolute; inset: auto 0 0 0; padding: 26px 10px 40px; font-size: 14px; font-weight: 600;
  background-color: var(--overlay); background-image: linear-gradient(transparent, rgba(0, 0, 0, .84) 30%);
  color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.short-tile .dur { background: rgba(0, 0, 0, .78); }

/* ------------------------------------------------------------------- watch */
.watch {
  display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 402px;
  align-items: start; padding-top: 16px;
}
.player-shell {
  background: #000; border-radius: 14px; overflow: hidden; position: relative;
  max-height: 72vh; max-height: 72dvh;
}
.player-shell video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.big-play {
  position: absolute; inset: 0; display: grid; place-items: center; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .25); color: #fff;
}
.play-tri {
  width: 68px; height: 48px; border-radius: 12px; background: var(--accent);
  display: grid; place-items: center;
}
.play-tri::after { content: ""; border-left: 16px solid var(--accent-ink); border-block: 10px solid transparent; margin-left: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
/* The measured facts sit under the picture, never over it. */
.player-facts { margin: 8px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }

.watch h1.title { font-size: var(--fs-title); margin: 16px 0 10px; line-height: 1.35; }
.watch .tags-row { color: var(--muted); font-size: 14px; margin: 0 0 12px; max-width: 70ch; }

.owner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.owner img { width: 42px; height: 42px; border-radius: 50%; }
.owner .who { min-width: 0; margin-right: auto; }
.owner .who b { display: block; font-size: var(--fs-card); }
.owner .who span { color: var(--muted); font-size: 14px; }
/* The Commons credit is a fact about the file, so it is visible without expanding anything. */
.credit { color: var(--muted); font-size: 14px; margin: 10px 2px 0; max-width: 70ch; overflow-wrap: anywhere; }
.credit a { color: var(--accent); text-decoration: underline; }

.seg { display: flex; flex: none; background: var(--surface-2); border-radius: 22px; overflow: hidden; }
.seg button {
  display: flex; align-items: center; gap: 7px; flex: none; min-width: 44px; min-height: 44px;
  padding: 0 16px; border: 0; background: transparent; cursor: pointer; font-weight: 600;
}
.seg button:hover { background: var(--surface-3); }
.seg button[aria-pressed="true"] { color: var(--accent); }
.seg button + button { border-left: 1px solid var(--line); }
.seg .count { font-variant-numeric: tabular-nums; }

.desc {
  background: var(--surface); border-radius: 12px; padding: 12px 14px; margin: 14px 0 0;
  font-size: var(--fs-card); position: relative; max-width: 70ch; overflow-wrap: anywhere;
}
/* 120px leaves the head plus three body lines inside the collapsed box. */
.desc.collapsed { max-height: 120px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); }
.desc .desc-head { font-weight: 600; margin-bottom: 6px; }
.desc .body { white-space: pre-wrap; margin: 0; }
.desc a { color: var(--accent); text-decoration: underline; }
button.more {
  background: none; border: 0; color: var(--fg); font-weight: 700; cursor: pointer;
  padding: 0 12px; min-height: 44px; margin: 2px 0 0 2px; text-decoration: underline;
}

.related-col { display: flex; flex-direction: column; gap: 10px; }
.related-col h2 { font-size: var(--fs-card); margin: 14px 0 2px; }
.rel {
  display: grid; grid-template-columns: 168px 1fr; gap: 10px; padding: 6px; border-radius: 10px;
}
.rel:hover { background: var(--surface); }
.rel .thumb { aspect-ratio: 16 / 9; }
.rel h3 { margin: 6px 0 4px; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --------------------------------------------------------- comments block */
.comments { margin-top: 26px; max-width: 70ch; }
.comments-head { display: flex; align-items: center; gap: 18px; font-size: var(--fs-field); font-weight: 700; margin: 16px 0 10px; }
.comment-form { display: grid; grid-template-columns: 44px 1fr; gap: 12px; margin: 16px 0 22px; }
.comment-form .me-mini {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800;
}
.comment-form input {
  background: transparent; border: 0; border-bottom: 1px solid var(--line-input); color: var(--fg);
  padding: 10px 2px; font: inherit; font-size: var(--fs-field);
}
.comment-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--fg); }
.comment-form .form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.comment {
  display: grid; grid-template-columns: 44px 1fr; gap: 12px; padding: 8px 0;
}
.comment .who-c { font-size: 14px; font-weight: 600; }
.comment .who-c span { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 14px; }
.comment .pin { color: var(--muted); font-size: 14px; margin-bottom: 2px; }
.comment p { margin: 3px 0 6px; white-space: pre-wrap; }
/* A comment that just posted is marked, not animated: reduced motion needs no exemption. */
.comment.just-posted { background: var(--surface); border-radius: 10px; }
.comment .c-actions { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; }
.comment .c-actions button {
  background: none; border: 0; cursor: pointer; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 44px; min-height: 44px;
}
.comment .c-actions button:hover { color: var(--fg); }
.comment .c-owner { background: var(--surface-2); color: var(--muted); border-radius: 6px; padding: 1px 6px; font-size: var(--fs-micro); }
.avatar-dot {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); font-weight: 800; font-size: 14px;
}

/* ------------------------------------------------------------------ shorts feed */
.shorts-feed {
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  overflow-y: scroll; scroll-snap-type: y mandatory; padding: 0; overscroll-behavior-y: contain;
}
.short-frame {
  position: relative; height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  scroll-snap-align: start; display: grid; place-items: center; background: #000; cursor: pointer;
}
.short-frame .blur { position: absolute; inset: 0; }
.short-frame .blur img { width: 100%; height: 100%; object-fit: cover; filter: blur(28px) saturate(1.2); opacity: .5; }
.short-frame video { position: relative; height: 100%; width: auto; max-width: 100%; aspect-ratio: 9 / 16; object-fit: cover; }
.short-pause {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 74px; height: 74px; border-radius: 50%; background: rgba(0, 0, 0, .62); color: #fff;
  display: none; place-items: center; pointer-events: none;
}
.short-pause svg { width: 30px; height: 30px; }
.short-frame[data-paused="true"] .short-pause { display: grid; }
/* The caption and the dock belong to the 9:16 picture, so they take its width and sit centred
   under it instead of stretching across the letterbox. */
.short-info {
  position: absolute; left: 50%; right: auto; bottom: 0; transform: translateX(-50%);
  width: min(100%, calc((100vh - var(--topbar-h)) * 9 / 16));
  width: min(100%, calc((100dvh - var(--topbar-h)) * 9 / 16));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: end;
  padding: 18px 14px calc(20px + var(--safe-bottom)); color: #fff;
  background-color: var(--overlay); background-image: linear-gradient(transparent, rgba(0, 0, 0, .84) 45%);
}
.short-text { grid-column: 1; }
.short-info h2 { margin: 8px 0 4px; font-size: var(--fs-field); }
.short-info .card-meta { color: #e8e8e8; }
.short-info .quiet {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, .34); border-radius: 999px; background: rgba(0, 0, 0, .72);
  color: #fff; font-size: 14px; font-weight: 600; opacity: .78; cursor: default;
}
.short-info .quiet svg { width: 16px; height: 16px; }
.short-dock {
  grid-column: 2; grid-row: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.short-dock button, .short-dock a {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 44px; min-height: 44px; padding: 0;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .34); background: rgba(0, 0, 0, .72);
  color: #fff; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.short-dock svg { width: 18px; height: 18px; }
.short-dock button[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.audio-note { font-weight: 700; color: var(--fg); }

/* ------------------------------------------------------- channel + collections */
.channel-head {
  display: flex; gap: 20px; align-items: center; padding: 22px 2px 16px; border-bottom: 1px solid var(--line);
}
.channel-head img { width: 96px; height: 96px; border-radius: 50%; }
.channel-head h1 { margin: 8px 0 4px; font-size: var(--fs-display); }
.channel-head .card-meta { display: block; margin-bottom: 8px; }
.channel-head .about { max-width: 70ch; color: var(--muted); margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 72px 20px; }
.empty svg { width: 64px; height: 64px; color: var(--surface-3); margin-bottom: 10px; }
.empty h2 { color: var(--fg); margin: 12px 0 6px; }
.error-banner {
  background: #7d1a10; color: #fff; padding: 12px 16px; border-radius: 10px; margin: 12px 0;
  display: flex; gap: 12px; align-items: center;
}
.error-banner button {
  margin-left: auto; background: #fff; border: 0; color: #7d1a10;
  min-height: 44px; padding: 0 16px; border-radius: 10px; cursor: pointer; font-weight: 700;
}

/* --------------------------------------------------------------- skeletons */
.skel { padding: 12px 0; display: grid; gap: 22px 16px; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.skel-card { display: grid; gap: 10px; }
.skel .box { background: var(--surface-2); border-radius: var(--radius); position: relative; overflow: hidden; }
.skel .box.t { aspect-ratio: 16 / 9; }
.skel .box.l { height: 14px; }
.skel .box.l2 { height: 14px; width: 60%; }
.skel .box.t::after, .skel .box.l::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--fg) 10%, transparent), transparent);
  animation: shimmer 1.4s infinite; transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .skel .box.t::after, .skel .box.l::after { animation: none; }
  .thumb img { transition: none; }
  .sidebar { transition: none; }
  .toast { transition: none; }
}

/* ------------------------------------------------------------------ toast */
/* Mounted for the life of the page: a live region that is display:none when the text changes is
   announced by some screen readers and not others. */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--surface-3); color: var(--fg); padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); font-weight: 600; max-width: 82vw;
  opacity: 0; pointer-events: none; transition: opacity .15s ease; margin-bottom: var(--safe-bottom);
}
.toast.show { opacity: 1; }

/* ------------------------------------------- results, collections, shorts feed */
.sortbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 2px 12px; }
.sortbar .chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.grid.list > div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
.watched-note { color: var(--muted); font-size: 14px; margin: 0; }
.chan-id { min-width: 0; }
.sub-group { margin: 4px 0 30px; }
.sub-group .shelf-head img { border-radius: 50%; }
.sub-group > .chan {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px;
  color: var(--muted); text-decoration: underline;
}
body[data-route="shorts"] .content { padding: 0; }
body[data-route="shorts"] .footer { border-top: 0; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .watch { grid-template-columns: minmax(0, 1fr); }
  .related-col { flex-direction: row; flex-wrap: wrap; }
  .rel { width: calc(50% - 5px); }
}

@media (max-width: 900px) {
  /* The closed drawer is out of the tab order and out of the accessibility tree, carries no
     shadow, and does not chain its scroll to the page. */
  .sidebar {
    transform: translateX(-100%); visibility: hidden; width: var(--rail-w);
    transition: transform .18s ease, visibility 0s .18s;
  }
  body.drawer-open .sidebar {
    transform: none; visibility: visible; transition-delay: 0s; box-shadow: var(--shadow);
  }
  body.drawer-open::after {
    content: ""; position: fixed; inset: var(--topbar-h) 0 0 0; background: var(--overlay); z-index: 19;
  }
  body.rail-mini .sidebar { width: var(--rail-w); }
  #page, body.rail-mini #page { margin-left: 0; }
  .topbar { gap: 6px; padding: var(--safe-top) 8px 0; }
  .topbar-right { gap: 4px; }
  .search { margin-left: 2px; flex-basis: 320px; }
  /* The left cluster must keep its content width. Squeezing it to zero let the search field
     slide under the logo, which is what iPhone Safari showed as an overlapping horse. */
  .topbar-left { min-width: 0; flex: 0 0 auto; }
  .rel { width: 100%; }
  .card.list-row { grid-template-columns: 148px minmax(0, 1fr); }
  .content { padding: 8px 12px 32px; }
  /* A sticky chip rail costs 65px of a 667px screen for the one control that is least used on a
     phone; at this width the rail scrolls away with the page. */
  .chips { position: static; }
}

@media (max-width: 620px) {
  .logo-word { display: none; }
  /* An upload is mostly a phone thing, so the button stays - as an arrow, without its word. */
  #createBtn span { display: none; }
  #createBtn { padding: 0 13px; min-width: 44px; }
  .upload-row { grid-template-columns: 116px minmax(0, 1fr); }
  .upload-row button { grid-column: 2; justify-self: start; }
}

@media (max-width: 520px) {
  /* The search field is the useful control at phone width. The button duplicates what the
     keyboard Search key already does, and dropping it buys 46px for typing. */
  .search-btn { display: none; }
}

/* ------------------------------------------------------- iOS hardening */
/* iOS Safari keeps a collapsing toolbar at the top and a home indicator at the bottom, so pinned
   chrome takes the safe-area insets and viewport-height measurements prefer dvh. The duplicate
   declarations above keep engines without dvh on the vh value. */
html { -webkit-text-size-adjust: 100%; }
a, button { -webkit-tap-highlight-color: transparent; }
