/* Screen layouts (03-design §3, §6): home, watch + shields, share dialog, lists, library, settings, prose. */

.view { animation: fade-in var(--dur) var(--ease); }
.view-narrow { max-width: var(--prose-max); margin: 0 auto; }
.view-prose { max-width: var(--prose-max); margin: 0 auto; }
.view-prose h2 { margin-top: var(--sp-6); }
.view-prose p, .view-prose li { max-width: 70ch; }

/* --- Home -------------------------------------------------------------------------------------- */
.view-home { max-width: 820px; margin: 0 auto; }
/* Home is flush left: the title, the box and everything after it hang off one edge, like the start of a timeline. */
.home-hero { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: clamp(var(--sp-5), 8vh, 88px) 0 var(--sp-7); }
.home-mark { color: var(--text); margin-bottom: var(--sp-4); }
.home-title { font-size: var(--fs-3xl); font-weight: var(--fw-heavy); letter-spacing: var(--ls-tight); line-height: .95; margin: 0 0 var(--sp-3); }
.home-tagline { font-size: var(--fs-xl); line-height: 1.25; letter-spacing: -0.02em; color: var(--text-muted); margin: 0 0 var(--sp-6); max-width: 22ch; }
.home-form { width: 100%; }
.home-box {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 6px 6px calc(var(--sp-4) + 6px);
  background: var(--surface); border: 2px solid var(--text); border-radius: 0;
}
/* The playhead: a bar at the start of the box. This is where watching begins. */
.home-box::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 4px; background: var(--accent); }
.home-box { position: relative; }
.home-box:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.home-box-icon { color: var(--text-muted); display: flex; }
.input-hero { flex: 1 1 auto; min-height: 56px; border: 0; padding: 0 var(--sp-1); font-size: var(--fs-lg); background: transparent; }
.input-hero:hover { border: 0; }
.input-hero:focus-visible { outline: none; }
.btn-hero { min-height: 52px; padding: 0 var(--sp-5); font-size: var(--fs-md); border-radius: var(--r-sm); }
.home-error { justify-content: center; text-align: left; margin-top: var(--sp-3); font-size: var(--fs-md); }
.home-promise { margin: var(--sp-4) 0 0; color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.home-sections { display: flex; flex-direction: column; gap: var(--sp-7); }
.home-section:empty { display: none; }
/* Section heads are labels with a square marker on the spine: squares are things, circles are moments. */
.home-block-title, .view-home .fx-section-head h2 {
  font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase;
  color: var(--text-muted); margin: 0; padding-left: calc(var(--t-col) + var(--spine-gap));
}
.home-block-title::before, .view-home .fx-section-head h2::before {
  content: ""; position: absolute; left: calc(var(--t-col) + var(--spine-gap) / 2 - 4px); top: 50%; width: 8px; height: 8px; margin-top: -4px; background: var(--text);
}
.home-block-title { position: relative; padding-bottom: var(--sp-3); }
.home-block-title::before { top: calc(50% - var(--sp-3) / 2); }
.view-home .fx-section-head { position: relative; padding: 0 0 var(--sp-2) calc(var(--t-col) + var(--spine-gap)); }
.view-home .fx-section-head h2 { padding-left: 0; }
.view-home .fx-section-head h2::before { top: 0.56em; }
.view-home .link-list { padding-left: calc(var(--t-col) + var(--spine-gap)); }
.how { margin-top: var(--sp-2); }
/* First visit: the three steps sit on a horizontal time line. */
.how-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); border-top: 1px solid var(--border-strong); }
.how-step { position: relative; display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-start; padding: var(--sp-5) 0 0; }
.how-step::before { content: ""; position: absolute; top: calc(var(--tick) / -2 - 0.5px); left: 0; width: var(--tick); height: var(--tick); border: 2px solid var(--tick-ring); border-radius: var(--r-moment); background: var(--bg); box-sizing: border-box; }
.how-step:first-child::before { background: var(--accent); border-color: var(--accent); }
.how-num { font-family: var(--font-time); font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: var(--fs-sm); }
.how-num::before { content: "0"; }
.how-title { font-size: var(--fs-lg); font-weight: var(--fw-heavy); letter-spacing: -0.02em; margin: 0 0 var(--sp-1); }
.how-text { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
@media (max-width: 759.98px) {
  .how-steps { grid-template-columns: 1fr; gap: var(--sp-4); border-top: 0; border-left: 1px solid var(--border-strong); margin-left: calc(var(--tick) / 2); }
  .how-step { padding: 0 0 0 var(--sp-5); }
  .how-step::before { top: 2px; left: calc(var(--tick) / -2 - 0.5px); }
}
@media (max-width: 599.98px) {
  .home-tagline { font-size: var(--fs-lg); margin-bottom: var(--sp-5); }
  .home-box { padding-left: var(--sp-3); }
  .home-box-icon { display: none; }
  .input-hero { font-size: var(--fs-md); min-height: 48px; }
  .btn-hero { min-height: 48px; padding: 0 var(--sp-4); }
}

/* --- Watch ------------------------------------------------------------------------------------- */
.view-watch { position: relative; }
.watch-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4) var(--sp-5); max-width: 960px; margin: 0 auto; }
.watch-layout.has-panel { max-width: none; }
.watch-main { min-width: 0; }

.player-shell { position: relative; border-radius: 0; overflow: hidden; background: #000; }
.player-shell:focus { outline: none; }
.player-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100svh - var(--header-h) - 120px); min-height: 180px; background: #000; }
.player-host, .player-host > iframe, .player-host > div, .player-host .fake-yt-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-state { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--sp-4); background: var(--surface-2); color: var(--text); z-index: 2; overflow-y: auto; }
.player-loading { color: var(--text-muted); margin: 0; }
.player-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); max-width: 520px; }
.player-state:has(.player-card) { background: var(--shield-bg); color: var(--shield-text); }
.player-card .icon { color: var(--shield-muted); }
.player-card-title { font-size: var(--fs-lg); margin: var(--sp-1) 0 0; }
.player-card-text { color: var(--shield-muted); margin: 0 0 var(--sp-2); }
.player-card .btn-row { justify-content: center; }
.player-card :focus-visible { outline-color: var(--shield-focus); }
/* A 16:9 frame on a phone is too short for a card: the frame grows to fit it instead of clipping it. */
@media (max-width: 599.98px) {
  .player-frame:has(> .player-state:not([hidden]) > .player-card) { aspect-ratio: auto; max-height: none; }
  .player-state:has(> .player-card) { position: relative; inset: auto; min-height: 180px; padding: var(--sp-5) var(--sp-4); }
  .player-card-title { font-size: var(--fs-md); }
}

/* Shields */
.shield { position: absolute; z-index: var(--z-shield); color: var(--shield-text); }
.shield :focus-visible { outline-color: var(--shield-focus); }
.shield-end { inset: 0; display: grid; place-items: center; background: var(--shield-bg); padding: var(--sp-4); text-align: center; animation: fade-in var(--dur) var(--ease); overflow-y: auto; }
.shield-inner { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); max-width: 100%; }
.shield-title { font-size: var(--fs-xl); font-weight: var(--fw-heavy); letter-spacing: -0.02em; margin: 0; }
.shield-actions { justify-content: center; }
.shield-next-label { overflow: hidden; text-overflow: ellipsis; max-width: 36ch; }
.shield-countdown { margin: 0; color: var(--shield-muted); font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); }
/* F25: no empty slot between the buttons when there is no countdown. */
.shield-countdown:empty { display: none; }
.shield-pause {
  left: 0; right: 0; bottom: 0; height: 45%; border-top: var(--rule-bold) solid var(--accent);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 clamp(var(--sp-4), 5%, var(--sp-7));
  background: var(--shield-bg); cursor: pointer;
}
.shield-play {
  flex: none; width: 64px; height: 64px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--shield-text); color: var(--shield-bg);
}
.shield-play .icon { margin-left: 3px; }
.shield-play:hover { background: #FFFFFF; }
.shield-text { margin: 0; font-family: var(--font-time); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
@media (max-width: 599.98px) {
  /* F7: at phone width every control fits inside the 16:9 shield; the heading stays for screen readers. */
  .shield-end { padding: var(--sp-2) var(--sp-3); }
  .shield-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .shield-inner { gap: var(--sp-2); }
  .shield-actions { gap: var(--sp-2); }
  .shield-end .btn-lg { min-height: var(--hit); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
  .shield-next-label { max-width: 26ch; }
  /* Next (when there is one) gets its own row; Replay and Back share the row below. */
  .shield-actions [data-testid="shield-next"] { order: -1; flex: 1 0 100%; justify-content: center; }
  .shield-countdown { font-size: var(--fs-sm); }
  .shield-countdown .btn-sm { min-height: 36px; }
  .shield-play { width: 52px; height: 52px; }
  .shield-text { font-size: var(--fs-md); }
}

/* Present: our container is fullscreen */
.player-shell:fullscreen { border-radius: 0; display: flex; align-items: center; justify-content: center; }
.player-shell:fullscreen .player-frame { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; }

/* Title + channel, under a time scale: minor ticks every 12 px, major every 60 px. Decorative. */
.watch-info {
  padding: calc(var(--sp-4) + 10px) 0 var(--sp-3);
  background:
    repeating-linear-gradient(90deg, var(--border-strong) 0 1px, transparent 1px 60px) 0 0 / 100% 10px no-repeat,
    repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 12px) 0 0 / 100% 5px no-repeat;
}
.video-title { font-size: var(--fs-xl); font-weight: var(--fw-heavy); letter-spacing: -0.025em; line-height: 1.15; margin: 0 0 var(--sp-1); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.video-channel { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; min-height: 1.5em; }
.video-channel a { color: var(--text-muted); }
.video-channel a:hover { color: var(--link); }

/* Action bar */
.action-bar-wrap { position: relative; }
.action-bar-scroll { overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--sp-1)); padding: var(--sp-1); }
.action-bar-scroll::-webkit-scrollbar { display: none; }
/* The tool strip: ruled rows of cells. A pressed tool carries the playhead bar. Cells grow to fill each
   wrapped row and draw their own top and left rule; the bar clips the rules that would double its border. */
.action-bar { display: flex; align-items: stretch; gap: 0; padding: 0; border: 1px solid var(--border-strong); border-radius: 0; background: transparent; width: max-content; min-width: 100%; overflow: hidden; }
.action-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--hit); padding: 0 var(--sp-3);
  border: 0; border-radius: 0; background: transparent; color: var(--text);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); white-space: nowrap; flex: 1 0 auto; justify-content: center;
  margin: -1px 0 0 -1px; box-shadow: inset 1px 1px 0 var(--border);
}
.action-btn:hover:not(:disabled) { background: var(--surface-2); }
.action-btn:disabled { opacity: .45; }
.action-btn[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 1px 1px 0 var(--border), inset 0 calc(-1 * var(--rule-bold)) 0 var(--accent); }
.action-btn[aria-expanded="true"] { background: var(--surface-2); }
.action-btn .icon { width: 20px; height: 20px; }
.action-speed { padding-right: var(--sp-1); cursor: pointer; }
.action-speed:focus-within { outline: 3px solid var(--focus); outline-offset: -3px; }
.action-btn:focus-visible { outline-offset: -3px; }
.speed-select {
  min-height: 36px; padding: 0 var(--sp-5) 0 var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent;
  font-family: var(--font-time); font-weight: var(--fw-bold); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
.speed-select:focus-visible { outline: none; }
.speed-select option { background: var(--surface); color: var(--text); }
.watch-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.watch-chips:not(:has(.chip:not([hidden]))) { display: none; }
@media (max-width: 599.98px) {
  .action-btn:not(.keep-label) .action-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .action-btn { padding: 0 var(--sp-3); }
  /* F26: icon buttons wrap onto a second row instead of hiding off-screen. */
  .action-bar-scroll { overflow: visible; }
  .action-bar { flex-wrap: wrap; width: auto; justify-content: flex-start; }
  .action-btn { min-width: var(--hit); justify-content: center; }
}
/* F27: with a panel open beside the player, secondary actions are icon-only so the bar stays on one row. */
@media (min-width: 900px) {
  .watch-layout.has-panel .action-btn:not(.keep-label) .action-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .watch-layout.has-panel .action-btn { min-width: var(--hit); justify-content: center; }
}

.popover-body .clip-field { display: flex; align-items: flex-end; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.popover-body .btn-row { margin-top: var(--sp-2); }

/* Queue */
.queue-bar { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); padding: 0; border: 1px solid var(--border-strong); border-radius: 0; background: transparent; }
.queue-pos { flex: 1 1 auto; margin: 0; text-align: center; font-size: var(--fs-sm); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Side panels (R4): up to two open at once. < 900 px they stack under the action bar; ≥ 900 px they share a
   column beside the player (stacked); ≥ 1400 px two panels sit side by side next to the player. */
.watch-panels { display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0; min-width: 0; }
/* Panels are columns, not cards: a heavy rule on top, a label, and the content on the page's own paper. */
.watch-panel { background: transparent; border: 0; border-top: var(--rule-bold) solid var(--text); border-radius: 0; display: flex; flex-direction: column; min-height: 0; max-height: 60vh; --spine-bg: var(--bg); }
.watch-panel-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) 0 var(--sp-1) 6px; border-bottom: 1px solid var(--border); }
.watch-panel-title { flex: 1 1 auto; margin: 0; font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.watch-panel-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-3) 6px var(--sp-4); min-height: 0; }
@media (min-width: 900px) {
  .watch-layout.has-panel { grid-template-columns: minmax(0, 1fr) var(--panel-w); }
  .watch-layout.has-panel .watch-panels { contain: size; height: 100%; }
  .watch-layout.has-panel .watch-panel { flex: 1 1 0; max-height: none; }
}
@media (min-width: 900px) {
  /* Two panels need more room than one player height: let the column grow, each panel scrolling inside. */
  .watch-layout.has-two-panels .watch-panels { contain: none; height: auto; align-self: start; }
  .watch-layout.has-two-panels .watch-panel { flex: none; height: min(66vh, 520px); }
  .watch-layout.has-two-panels .watch-panel[data-panel="notes"] { height: auto; max-height: min(66vh, 520px); }
}
@media (min-width: 1400px) {
  main:has(.view-watch.has-two-panels) { max-width: calc(1640px + 2 * var(--page-pad)); }
  .watch-layout.has-two-panels { grid-template-columns: minmax(0, 1fr) calc(2 * var(--panel-w) + var(--sp-3)); }
  .watch-layout.has-two-panels .watch-panels { flex-direction: row; }
  .watch-layout.has-two-panels .watch-panel { flex: 1 1 0; min-width: 0; }
}

/* Notes panel */
.notes-form { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.notes-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; --t-col: 3.5rem; }
.note-item { display: grid; grid-template-columns: var(--t-col) var(--spine-gap) minmax(0, 1fr) auto; gap: var(--sp-1) 0; align-items: start; padding: var(--sp-1) 0; }
.note-item::before { margin-top: calc(16px - var(--tick) / 2); }
.note-item > .textarea { grid-column: 3 / -1; }
.note-item > .row-actions { grid-column: 4; }
.note-item > .textarea + .row-actions { grid-column: 3 / -1; }
.note-time { min-height: 32px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--text); font-size: var(--fs-sm); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 4px; }
.note-time:hover { text-decoration-color: currentColor; text-decoration-thickness: 2px; }
.note-text { grid-column: 3; margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.note-item .btn-icon { width: 36px; height: 36px; }
.notes-foot { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
.notes-foot p { margin: 0; }
.notes-empty { margin: 0 0 var(--sp-3); }
.notes-hint { margin: 0; font-size: var(--fs-xs); }

/* Focus mode */
.focus-exit { display: none; }
body.focus-mode .focus-exit { display: inline-flex; position: fixed; top: var(--sp-3); right: var(--sp-3); z-index: 25; background: rgb(255 255 255 / .08); color: var(--shield-text); border-color: rgb(255 255 255 / .3); }
body.focus-mode .focus-exit:hover { background: rgb(255 255 255 / .16); }
body.focus-mode .watch-layout { max-width: none; }
body.focus-mode .player-shell { border-radius: 0; }
body.focus-mode .player-frame { max-height: calc(100svh - var(--header-h) - 24px); margin: 0 auto; }
body.focus-mode .watch-info { display: none; }
body.focus-mode .watch-panel { background: #15181b; border-color: var(--shield-muted); color: var(--shield-text); --spine-bg: #15181b; --spine: #3a4047; --tick-ring: #8a929b; --bg: #15181b; --text: var(--shield-text); --text-muted: var(--shield-muted); --border: #2a2f35; --border-strong: #8a929b; --surface: #1d2125; --surface-2: #262b30; --accent-soft: #232a52; }
body.focus-mode .action-bar { background: rgb(255 255 255 / .06); border-color: rgb(255 255 255 / .2); }
body.focus-mode .action-btn { color: var(--shield-text); box-shadow: inset 1px 1px 0 rgb(255 255 255 / .12); }
body.focus-mode .action-btn:hover:not(:disabled), body.focus-mode .action-btn[aria-expanded="true"] { background: rgb(255 255 255 / .1); }
body.focus-mode .action-btn[aria-pressed="true"] { background: rgb(154 165 255 / .2); box-shadow: inset 1px 1px 0 rgb(255 255 255 / .12), inset 0 -3px 0 #9AA5FF; }
body.focus-mode .speed-select option { background: #1A1D21; color: #E8E6E1; }
body.focus-mode :focus-visible { outline-color: var(--shield-focus); }
body.focus-mode .queue-bar { background: rgb(255 255 255 / .06); border-color: rgb(255 255 255 / .12); }
body.focus-mode .chip { background: rgb(255 255 255 / .1); color: var(--shield-text); }
/* F24: chips would sit below the fold in focus mode. */
body.focus-mode .watch-chips { display: none; }
.view-watch .action-bar-wrap, .view-watch .queue-bar, .focus-exit { transition: opacity var(--dur) var(--ease); }
body.focus-mode .view-watch.is-idle .action-bar-wrap,
body.focus-mode .view-watch.is-idle .queue-bar,
body.focus-mode .view-watch.is-idle .focus-exit { opacity: 0; transition-duration: 600ms; }
@media (prefers-reduced-motion: reduce) {
  body.focus-mode .view-watch.is-idle .action-bar-wrap,
  body.focus-mode .view-watch.is-idle .queue-bar,
  body.focus-mode .view-watch.is-idle .focus-exit { opacity: 1; }
}

/* Embed */
.view-watch.is-embed .watch-layout { max-width: none; }
.view-watch.is-embed .player-shell { border-radius: 0; }
.view-watch.is-embed .player-frame { max-height: calc(100vh - 32px); max-height: calc(100svh - 32px); }
.embed-bar { display: flex; align-items: center; gap: var(--sp-3); height: 32px; padding: 0 var(--sp-3); background: var(--shield-bg); color: var(--shield-text); font-size: var(--fs-sm); border-top: 2px solid #9AA5FF; }
.embed-bar .embed-title { flex: 1 1 auto; font-size: var(--fs-sm); font-weight: var(--fw-bold); letter-spacing: normal; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.embed-open { color: var(--shield-text); display: inline-flex; align-items: center; gap: var(--sp-1); white-space: nowrap; }
.embed-bar :focus-visible { outline-color: var(--shield-focus); }

/* --- Share dialog ------------------------------------------------------------------------------ */
.share-row { margin-bottom: var(--sp-5); }
.share-row legend { font-weight: var(--fw-bold); font-size: var(--fs-xs); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--sp-2); }
.share-row .input-time { font-family: var(--font-time); }
.clip-fields { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); }
.clip-field { display: flex; align-items: flex-end; gap: var(--sp-2); }
.clip-field .field { margin: 0; }
.share-link-row .input-row { margin-top: var(--sp-1); }
.share-qr-row { display: flex; align-items: center; gap: var(--sp-5); }
.qr-side { display: flex; flex-direction: column; gap: var(--sp-2); }
.qr-side p { margin: 0; }
.share-out { margin-bottom: var(--sp-4); }
.share-embed { margin-bottom: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); }
.share-embed summary { cursor: pointer; min-height: var(--hit); display: flex; align-items: center; padding: 0 var(--sp-4); font-weight: var(--fw-bold); font-size: var(--fs-sm); border-radius: var(--r-md); }
.share-embed[open] summary { border-bottom: 1px solid var(--border); border-radius: var(--r-md) var(--r-md) 0 0; }
.share-embed .textarea { margin: var(--sp-3) var(--sp-4) var(--sp-2); width: calc(100% - 2 * var(--sp-4)); font-size: var(--fs-xs); }
.share-embed .btn-row { padding: 0 var(--sp-4) var(--sp-3); }
.share-note { display: flex; align-items: center; gap: var(--sp-2); margin: 0; }
.share-invalid { margin: 0 0 var(--sp-2); }
.share-clip[disabled] .clip-fields { opacity: .6; }
.check-hinted { flex-wrap: wrap; align-items: flex-start; padding-top: 12px; }
.check-hinted > input { margin-top: 1px; }
.check-hint { flex: 1 0 100%; margin: 0 0 var(--sp-2); padding-left: 28px; } /* padding, not margin: 100% + a margin overflowed the dialog */
@media (max-width: 599.98px) {
  .share-qr-row { flex-direction: column; align-items: flex-start; }
}

/* --- Playlists / shared lists ------------------------------------------------------------------ */
.list-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-5); margin-bottom: var(--sp-5); }
.list-head-text { min-width: 0; }
.list-head h1 { margin: 0 0 var(--sp-1); font-size: var(--fs-2xl); letter-spacing: var(--ls-tight); overflow-wrap: anywhere; }
.list-head p { margin: 0; }
.playlist-rows { list-style: none; margin: 0; padding: 0; counter-reset: none; --t-col: 2.5rem; }
.playlist-row { display: grid; grid-template-columns: var(--t-col) var(--spine-gap) minmax(0, 1fr) auto; align-items: start; column-gap: 0; min-height: 64px; padding: var(--sp-2) 0 var(--sp-3); }
.playlist-row::before { margin-top: calc(20px - var(--tick) / 2); }
.playlist-row:focus-within { background-color: var(--accent-soft); }
.playlist-row:focus-within::before { background: var(--accent); border-color: var(--accent); }
.playlist-num { color: var(--text-muted); font-size: var(--fs-sm); padding-top: 9px; }
.playlist-main { grid-column: 3; min-width: 0; }
.playlist-row > .row-actions { grid-column: 4; padding-left: var(--sp-2); }
.playlist-title { margin: 0; overflow-wrap: anywhere; }
/* F19: rows read as links: play mark, underline on hover/focus. */
.playlist-title .video-link { display: inline-flex; align-items: baseline; gap: var(--sp-2); min-height: 32px; padding: 4px 0; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 4px; }
.playlist-title .video-link .icon { flex: none; align-self: center; color: var(--accent); }
.playlist-title .video-link:hover, .playlist-title .video-link:focus-visible { text-decoration-color: currentColor; color: var(--link); }
.playlist-meta { margin: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); color: var(--text-muted); font-family: var(--font-time); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.playlist-meta:not(:has(> :not([hidden]))) { display: none; }
.playlist-clip { display: inline-flex; align-items: center; gap: var(--sp-1); }

/* --- Library ------------------------------------------------------------------------------------ */
.view-library h1 { margin-bottom: var(--sp-4); font-size: var(--fs-2xl); letter-spacing: var(--ls-tight); }
.view-prose h1 { font-size: var(--fs-2xl); letter-spacing: var(--ls-tight); }
.subsection { margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--border); }
.subsection .h3 { margin-bottom: var(--sp-3); }
.import-form { margin-bottom: 0; }

/* --- Settings ----------------------------------------------------------------------------------- */
.view-settings { max-width: calc(var(--prose-max) + var(--t-col) + var(--spine-gap)); margin: 0 auto; counter-reset: settings-section; }
.view-settings > h1, .view-settings > p { margin-left: calc(var(--t-col) + var(--spine-gap)); }
.view-settings > h1 { margin-bottom: var(--sp-1); font-size: var(--fs-2xl); letter-spacing: var(--ls-tight); }
.view-settings > p { margin-bottom: var(--sp-6); }
/* Each section is a numbered stop on the spine: number in the gutter, a square marker on the line. */
.settings-section {
  position: relative; counter-increment: settings-section;
  background: transparent; border: 0; border-top: 1px solid var(--border-strong); border-radius: 0;
  padding: var(--sp-4) 0 var(--sp-6) calc(var(--t-col) + var(--spine-gap)); margin: 0;
}
.settings-section::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--t-col) + var(--spine-gap) / 2 - 0.5px); width: 1px; background: var(--spine);
}
.settings-section::after {
  content: counter(settings-section, decimal-leading-zero) / ""; position: absolute; left: 0; top: var(--sp-4); width: var(--t-col); text-align: right;
  font-family: var(--font-time); font-size: var(--fs-lg); line-height: 1.25; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.settings-title { position: relative; display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-lg); font-weight: var(--fw-heavy); letter-spacing: -0.02em; margin-bottom: var(--sp-4); }
.settings-title::before { content: ""; position: absolute; left: calc(var(--spine-gap) / -2 - 4px); top: 50%; width: 8px; height: 8px; margin-top: -4px; background: var(--text); }
.lock-mark { display: inline-flex; color: var(--text-muted); }
.locked-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); background: var(--surface-2); }
.locked-row > span { flex: 1 1 auto; }
.unlock-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4); border-radius: var(--r-sm); background: var(--accent-soft); font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.unlock-row > span { flex: 1 1 auto; }
.allow-id { font-family: var(--font-mono); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.allow-list .row { min-height: 52px; }
@media (max-width: 599.98px) {
  /* No numbers at phone width: the spine and markers stay, the content gets the room. */
  .view-settings { --t-col: 0px; }
  .settings-section::after { display: none; }
}

/* --- About ------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
.data-table th, .data-table td { text-align: left; vertical-align: top; padding: var(--sp-3) var(--sp-3) var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.data-table thead th { color: var(--text-muted); font-size: var(--fs-xs); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.data-table tbody th { white-space: nowrap; }
.tab-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.new-playlist-form { margin-bottom: var(--sp-5); }

/* --- Polish pass ------------------------------------------------------------------------------- */
:root[data-theme="dark"] .player-shell { box-shadow: 0 0 0 1px var(--border); }
.speed-select { field-sizing: content; }
@media (min-width: 600px) {
  .action-bar-scroll { overflow: visible; }
  .action-bar { flex-wrap: wrap; width: auto; }
}
@media (max-width: 599.98px) {
  .input-hero { font-size: 0.9375rem; }
  .btn-hero { padding: 0 14px; }
  .home-box { padding-left: var(--sp-3); gap: var(--sp-1); }
}
/* Visually hidden labels are absolutely positioned: keep their containing block inside the scroller
   so they can never widen the page at 360 px. */
.action-bar-scroll, .action-btn { position: relative; }

/* --- Classroom notes above the player (G1) ------------------------------------------------------------ */
.lesson-note {
  margin: 0 0 var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--mat-student); border-radius: 0;
}
.lesson-kicker { margin: 0 0 var(--sp-1); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.lesson-name { margin: 0 0 var(--sp-1); font-size: var(--fs-lg); overflow-wrap: anywhere; }
.lesson-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
body.focus-mode .lesson-note, body.focus-mode .video-desc-host { display: none; }

/* --- Description (G3) ---------------------------------------------------------------------------------- */
.video-desc-host .video-desc { margin-top: var(--sp-5); padding: var(--sp-3) 0 0; background: transparent; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.video-desc-host[hidden] { display: none; }
.desc-title { margin: 0 0 var(--sp-2); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--text-muted); }
.desc-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); max-width: 80ch; }
.desc-text.is-collapsed { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.desc-toggle { margin: var(--sp-1) 0 0 calc(-1 * var(--sp-3)); }

/* --- Chapters panel (G3) ---------------------------------------------------------------------------- */
.chapters-list { list-style: none; margin: 0; padding: 0; --t-col: 3.5rem; }
.chapters-note { margin: 0 0 var(--sp-3); }
.chapter-item {
  display: grid; grid-template-columns: var(--t-col) var(--spine-gap) minmax(0, 1fr); align-items: start; width: 100%; min-height: var(--hit); padding: var(--sp-2) var(--sp-3) var(--sp-2) 0;
  border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; line-height: 1.45; text-align: left; cursor: pointer;
}
.chapter-item.is-static { cursor: default; }
button.chapter-item:hover { background: var(--surface-2); }
.chapter-item:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.chapter-item[aria-current="true"] { background: var(--accent-soft); font-weight: var(--fw-bold); }
.chapter-item[aria-current="true"]::before { background: var(--accent); border-color: var(--accent); transform: scale(1.2); }
.chapter-time { font-size: var(--fs-sm); color: var(--text-muted); padding-top: 1px; }
.chapter-item[aria-current="true"] .chapter-time { color: var(--text); }
.chapter-title { grid-column: 3; min-width: 0; overflow-wrap: anywhere; }
.watch-panel[data-panel="chapters"] .watch-panel-body { padding: var(--sp-2) 0; }
body.focus-mode .chapter-time { color: var(--shield-muted); }
body.focus-mode button.chapter-item:hover { background: rgb(255 255 255 / .08); }
body.focus-mode .chapter-item[aria-current="true"] { background: rgb(154 165 255 / .2); }
body.focus-mode .chapter-item[aria-current="true"]::before, body.focus-mode .tx-line[aria-current="true"]::before { background: #9AA5FF; border-color: #9AA5FF; }
@media (forced-colors: active) {
  .chapter-item[aria-current="true"] { forced-color-adjust: none; background: Canvas; color: CanvasText; outline: 2px solid Highlight; outline-offset: -2px; }
  .lesson-note { border-left-color: Highlight; }
}
.watch-panel[data-panel="chapters"] .chapters-note { padding: 0; }

/* A panel toggle that its panel hides (Chapters, when the video has none). */
.action-btn[hidden] { display: none; }

/* --- Picture-in-picture (G7) ------------------------------------------------------------------------------ */
.pip-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2); text-align: center;
  aspect-ratio: 16 / 9; min-height: 180px; max-height: calc(100svh - var(--header-h) - 120px); padding: var(--sp-4);
  background: var(--shield-bg); color: var(--shield-text); border-radius: 0; box-shadow: 0 0 0 1px var(--border);
}
.pip-placeholder .icon { color: var(--shield-muted); }
.pip-placeholder :focus-visible { outline-color: var(--shield-focus); }
.pip-placeholder-title { margin: 0; font-size: var(--fs-lg); }
.pip-placeholder-text { margin: 0 0 var(--sp-2); color: var(--shield-muted); }
/* Inside the floating window itself (same style sheets are loaded there) */
.pip-body { margin: 0; background: #000; overflow: hidden; }
.pip-body .pip-view { height: 100vh; display: flex; }
.pip-body .player-shell { flex: 1 1 auto; border-radius: 0; display: flex; align-items: center; justify-content: center; }
.pip-body .player-frame { width: 100%; max-height: 100vh; min-height: 0; }

/* --- Share dialog: "For viewers" (G1) ------------------------------------------------------------------------ */
.share-viewers .field { margin-bottom: var(--sp-3); }
.share-viewers .textarea { min-height: 80px; }
.share-note-meta { margin: 0; text-align: right; }
.share-note-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
