/* app.css — host site + player chrome. Deck/video content styles itself; this
   only styles the resolver shell and the control bar. Minimal, dark, a11y-aware. */
:root {
  /* shared palette with the landing page (home.css) — one brand, one canvas */
  --bg: #06070b;
  --panel: #11141b;
  --panel-2: #171b23;
  --line: #232834;
  --fg: #e8eaed;
  --muted: #98a1af;
  --accent: #4fd1c5;
  --accent-dim: #2a6f69;
  --violet: #7c6bff;
  --magenta: #ff5cf0;
  --neon: linear-gradient(100deg, #4fd1c5 0%, #7c6bff 52%, #ff5cf0 100%);
  --error: #ff6b6b;
  --radius: 12px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Dynamic-viewport units track the iOS Safari toolbar so the player fills the
     screen without overflowing (avoids the 100vh-too-tall double scrollbar). */
  min-height: 100svh;
  min-height: 100dvh;
}
/* The landing page's aurora, dialed way down — faint corner glows behind the
   player so the app reads as the same place as the home page. Fixed, inert. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(52% 44% at 8% 0%, rgba(79,209,197,.09), transparent 70%),
    radial-gradient(50% 42% at 96% 12%, rgba(255,92,240,.07), transparent 70%),
    radial-gradient(60% 50% at 55% 100%, rgba(124,107,255,.07), transparent 72%);
}

/* --- header / resolver ---
   Two zones: a persistent brand block (logo · name · talk title · sig badge) and
   a foldaway control cluster. Collapsed → only the brand shows and the bar sizes
   to it; hover/focus/pin → the cluster unfolds to the right. Height never changes,
   so revealing the controls never pushes the player down (no page jump). */
.p2-header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 10px;
  width: max-content;
  max-width: calc(100vw - 20px);
  margin: 8px 0 0 8px;
  padding: 6px 8px 6px 10px;
  background:
    linear-gradient(135deg, rgba(79,209,197,.08), rgba(124,107,255,.06) 50%, rgba(255,92,240,.07)),
    rgba(13,15,18,.86);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  backdrop-filter: blur(18px) saturate(1.25);
  position: sticky; top: 0; z-index: 80;
  box-shadow: 0 18px 46px rgba(0,0,0,.28), 0 0 0 1px rgba(255,255,255,.03) inset;
  transition: width .34s var(--ease), max-width .34s var(--ease), transform .28s var(--ease), border-radius .28s ease;
}
.p2-header:not(.p2-shell-collapsed),
.p2-header.p2-shell-pinned,
.p2-header:hover,
.p2-header:focus-within {
  width: min(1180px, calc(100vw - 16px));
}
/* the foldaway cluster */
.p2-cluster {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  transition: opacity .26s ease, transform .3s var(--ease), max-width .34s var(--ease);
}
.p2-brand { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.p2-logo, .p2-home img { width: 27px; height: 27px; border-radius: 8px; object-fit: contain; display: block; }
.p2-home {
  display: inline-flex; align-items: center; gap: 8px; line-height: 1;
  text-decoration: none; padding: 0; border: 0;
  background: transparent; cursor: pointer;
}
.p2-home:hover .p2-name { filter: brightness(1.2); }
.p2-home:focus-visible { outline: 2px solid var(--accent-dim); border-radius: 9px; }
.p2-shell-toggle {
  appearance: none; border: 0; padding: 0; margin: 0;
  background: transparent; color: var(--fg); cursor: pointer;
  font: inherit; font-weight: 750; letter-spacing: 0.2px;
}
.p2-shell-toggle:hover, .p2-shell-toggle:focus-visible { color: var(--accent); outline: none; }
.p2-name {
  letter-spacing: 0.2px; white-space: nowrap; font-weight: 700;
  background: var(--neon);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.p2-deck-title {
  color: var(--muted); font-weight: 500; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(36vw, 520px);
  transition: max-width .28s var(--ease), opacity .22s ease;
}
.p2-deck-title::before { content: "·"; margin-right: 8px; }
.p2-deck-title:empty::before { content: none; }

/* collapsed-header affordance: a pulsing chevron that says "there's more here".
   Visible while collapsed, rotates + dims once the controls are revealed. */
.p2-shell-hint {
  flex: none; display: inline-grid; place-items: center;
  width: 22px; height: 22px; margin-left: 2px; padding: 0; cursor: pointer;
  border: 1px solid rgba(255,255,255,.12); border-radius: 7px;
  background: rgba(255,255,255,.04); color: var(--muted);
  transition: transform .3s var(--ease), opacity .25s ease, color .2s ease, border-color .2s ease, background .2s ease;
}
.p2-shell-hint svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.p2-header:hover .p2-shell-hint, .p2-header:focus-within .p2-shell-hint { color: var(--accent); border-color: var(--accent-dim); }
.p2-shell-hint:hover { color: var(--accent); border-color: var(--accent); background: rgba(79,209,197,.1); }
/* collapsed → point right (expand) + gently pulse to attract the eye */
.p2-header.p2-shell-collapsed:not(.p2-shell-pinned):not(:hover):not(:focus-within) .p2-shell-hint {
  animation: p2HintPulse 2.4s ease-in-out infinite;
}
/* expanded (hover/focus/pinned/uncollapsed) → flip to a collapse hint */
.p2-header:not(.p2-shell-collapsed) .p2-shell-hint,
.p2-header.p2-shell-pinned .p2-shell-hint,
.p2-header:hover .p2-shell-hint,
.p2-header:focus-within .p2-shell-hint { transform: rotate(180deg); }
@keyframes p2HintPulse { 0%,100%{ opacity: .55; transform: translateX(0); } 50%{ opacity: 1; transform: translateX(2px); } }

/* --- author signature badge (Phase 8) --- */
.p2-sig-badge {
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); cursor: default;
}
.p2-sig-badge[hidden] { display: none; }
.p2-sig-badge.is-checking { color: var(--muted); }
.p2-sig-badge.is-unsigned { color: var(--muted); opacity: 0.7; font-weight: 400; }
.p2-sig-badge.is-valid {
  color: var(--accent); border-color: var(--accent-dim);
  background: rgba(79, 209, 197, 0.10);
}
.p2-sig-badge.is-invalid { color: var(--error); border-color: var(--error); }
@media (max-width: 560px) { .p2-sig-badge.is-unsigned { display: none; } }

/* shared line-icon sizing for the header glyphs */
.p2-ico {
  width: 17px; height: 17px; flex: none; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

/* secondary tool group (Builder / Host / Docs) — icon-only chips with tooltips */
.p2-tools {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px;
  background: rgba(255,255,255,.035);
}
.p2-tool {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  color: var(--muted); text-decoration: none;
  border: 1px solid transparent;
}
.p2-tool:hover, .p2-tool:focus-visible {
  border-color: rgba(79,209,197,.5); color: var(--accent); outline: none; text-decoration: none;
  background: rgba(79,209,197,.08);
}
.p2-tool-label { display: none; }

/* primary actions (Load / Save / Share) — labelled pill buttons */
.p2-actions { display: inline-flex; align-items: center; gap: 7px; }
.p2-act {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 7px 13px 7px 11px; border-radius: 12px; cursor: pointer;
  font-size: 13px; font-weight: 600; letter-spacing: 0.1px;
  color: var(--fg); background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.11);
}
.p2-act:hover { border-color: var(--accent); color: var(--accent); }
.p2-act:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 1px; }
.p2-act-label { line-height: 1; }
/* Save & Share are the headline actions — give them the brand accent edge */
.p2-act-save { color: var(--accent); border-color: var(--accent-dim); background: rgba(79,209,197,.10); }
.p2-act-save:hover { background: rgba(79,209,197,.16); }
.p2-act-share { background: rgba(124,107,255,.12); border-color: rgba(124,107,255,.4); }
.p2-act-share:hover { color: #cdc6ff; border-color: var(--violet); background: rgba(124,107,255,.2); }
.p2-act:disabled { opacity: 0.4; cursor: default; }
.p2-act:disabled:hover { border-color: rgba(255,255,255,.11); color: var(--fg); }
.p2-act-save:disabled:hover { color: var(--accent); border-color: var(--accent-dim); background: rgba(79,209,197,.10); }
.p2-act-share:disabled:hover { color: var(--fg); }

.p2-tool, .p2-act { transition: transform .18s var(--ease), background .18s ease, border-color .18s ease, color .18s ease; }
.p2-tool:hover, .p2-act:hover { transform: translateY(-1px); }

/* the source/"Load" form: drops inline to the cluster's own row when opened */
.p2-source {
  display: none; grid-template-columns: minmax(160px, 32vw) auto auto;
  gap: 8px; min-width: 0; order: 5; flex-basis: 100%;
  transform-origin: left center;
  transition: opacity .24s ease, transform .28s var(--ease);
}
.p2-file-open { cursor: pointer; }
.p2-header.p2-source-open .p2-cluster { flex-wrap: wrap; }
.p2-header.p2-source-open .p2-source { display: grid; }
.p2-source input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.055); color: var(--fg);
  border: 1px solid rgba(255,255,255,.11); border-radius: 12px;
  padding: 7px 10px; font-size: 12px;
}
.p2-source input:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
.p2-load, .p2-btn, .p2-speed {
  background: var(--panel-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.p2-load:hover, .p2-btn:hover {
  border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 16px rgba(79,209,197,.18);
}
.p2-load {
  display: grid; place-items: center;
  font-weight: 650; padding: 7px 10px; min-width: 38px; border-radius: 12px;
  background: rgba(255,255,255,.055); border-color: rgba(255,255,255,.11);
  transition: transform .18s var(--ease), background .18s ease, border-color .18s ease, color .18s ease;
}
.p2-load:hover { transform: translateY(-1px); }
.p2-load-icon { color: var(--accent); }

/* --- collapsed: brand stays, the control cluster folds away (height unchanged) --- */
.p2-header.p2-shell-collapsed:not(.p2-shell-pinned):not(:hover):not(:focus-within) .p2-cluster {
  max-width: 0; opacity: 0; transform: translateX(14px) scaleX(.96);
  overflow: hidden; pointer-events: none;
}
.p2-header.p2-shell-collapsed:not(.p2-shell-pinned):not(:hover):not(:focus-within) {
  padding-right: 12px;
}

/* Share popover (YouTube-style "copy link / copy link at current time"). */
.p2-share-wrap { position: relative; display: inline-flex; }
.p2-share-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  display: flex; flex-direction: column; gap: 2px; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.p2-share-menu[hidden] { display: none; }
.p2-share-item {
  text-align: left; white-space: nowrap;
  background: transparent; color: var(--fg);
  border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; cursor: pointer; font-size: 14px;
}
.p2-share-item:hover { border-color: var(--accent); color: var(--accent); }

.p2-status {
  position: fixed; top: 72px; right: 14px; z-index: 120;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  width: min(430px, calc(100vw - 28px));
  pointer-events: none; color: var(--fg); font-size: 13px;
}
.p2-status:empty { display: none; }
.p2-status-item {
  pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px;
  max-width: 100%; padding: 9px 11px; border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(79,209,197,.13), rgba(124,107,255,.12), rgba(255,92,240,.11)),
    rgba(12,14,19,.88);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 16px 44px rgba(0,0,0,.5), 0 0 24px rgba(124,107,255,.12);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  backdrop-filter: blur(16px) saturate(1.25);
  animation: p2ToastIn .28s var(--ease);
}
.p2-status-item.is-leaving { animation: p2ToastOut .28s ease forwards; }
.p2-status-item.is-error { border-color: rgba(255,107,107,.5); background: rgba(38,18,22,.92); }
.p2-status-text { overflow-wrap: anywhere; }
.p2-status-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}
.p2-status-item.is-working .p2-status-dot {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.16);
  border-top-color: var(--accent); background: transparent; box-shadow: none;
  animation: p2Spin .8s linear infinite;
}
.p2-status-item.is-error .p2-status-dot { background: var(--error); box-shadow: 0 0 14px rgba(255,107,107,.8); }
.p2-status-close {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12); background: transparent; color: var(--muted); cursor: pointer;
}
.p2-status-close:hover { color: #fff; border-color: rgba(255,255,255,.28); }
@keyframes p2ToastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes p2ToastOut { to { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes p2Spin { to { transform: rotate(360deg); } }

/* --- app / player --- */
.p2-app { flex: 1; display: flex; min-height: 0; padding: 12px; }
.p2-player { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 10px; position: relative; }

.p2-stage {
  flex: 1; display: flex; align-items: stretch;
  min-height: 0; position: relative;
}
/* iOS Safari only synthesizes `click` on elements it deems clickable (computed
   cursor: pointer) — without this, the tap-to-pause stage handler (and its
   play/pause feedback burst) never fires on touch. Scoped to touch devices so
   the desktop cursor over the slides stays a normal arrow. */
@media (hover: none) {
  .p2-stage { cursor: pointer; -webkit-tap-highlight-color: transparent; }
}
.p2-pane {
  position: relative;
  flex: 1 1 0; min-width: 0; min-height: 0;
  background: #000; border: 1px solid rgba(255,255,255,.09); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  transition: flex-grow .35s ease;
  /* the landing page's showcase glow, at whisper volume */
  box-shadow: 0 16px 42px rgba(0,0,0,.42), 0 0 26px rgba(124,107,255,.07);
}
/* Suspend the grow animation while the user is dragging the divider. */
.p2-stage.is-dragging .p2-pane { transition: none; }
.p2-pane-label {
  position: absolute; top: 8px; left: 10px; z-index: 5;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: rgba(0,0,0,0.45);
  padding: 2px 8px; border-radius: 6px; pointer-events: none;
}
.p2-mount { flex: 1; position: relative; min-height: 0; }
.p2-deck-frame { width: 100%; height: 100%; border: 0; background: #000; }
/* The provider fills the mount; the caption overlay is excluded so it can sit
   bottom-centre (see .p2-cc-overlay) instead of being stretched to inset:0. */
.p2-video-pane .p2-mount > :not(.p2-cc-overlay),
.p2-video-pane iframe, .p2-video-pane video {
  position: absolute; inset: 0; width: 100%; height: 100%;
}

/* --- draggable divider --- */
.p2-divider {
  flex: 0 0 12px; align-self: stretch; cursor: col-resize;
  position: relative; background: transparent; border: 0;
  touch-action: none;   /* let pointer drag work without the page scrolling */
}
.p2-divider::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 4px; height: 40px; border-radius: 4px;
  background: var(--line); transition: background .15s, height .15s, width .15s;
}
.p2-divider:hover::before, .p2-divider:focus-visible::before { background: var(--accent); height: 64px; }
.p2-divider:focus-visible { outline: none; }

/* --- layout modes (data-mode on .p2-stage) --- */
.p2-stage[data-mode="slides-focus"] .p2-divider,
.p2-stage[data-mode="video-focus"] .p2-divider,
.p2-stage[data-mode="overlap"] .p2-divider { display: none; }

/* Overlap: deck fills the stage, video floats as a draggable / resizable PiP. */
.p2-stage[data-mode="overlap"] { display: block; }
.p2-stage[data-mode="overlap"] .p2-deck-pane { position: absolute; inset: 0; }
.p2-stage[data-mode="overlap"] .p2-video-pane {
  position: absolute; z-index: 20;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  border-color: var(--accent-dim);
}
.p2-stage[data-mode="overlap"] .p2-pip-handle {
  pointer-events: auto; cursor: move; user-select: none;
}
.p2-stage[data-mode="overlap"] .p2-pip-resize { display: block; }

/* PiP drag handle + resize grip (inert outside overlap). */
.p2-pip-handle { pointer-events: none; }
.p2-pip-resize { display: none; }
.p2-stage[data-mode="overlap"] .p2-pip-resize {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; z-index: 25;
  background:
    linear-gradient(135deg, transparent 50%, var(--accent-dim) 50%, var(--accent-dim) 62%,
      transparent 62%, transparent 74%, var(--accent-dim) 74%, var(--accent-dim) 86%, transparent 86%);
}

/* --- brand watermark + hover layout dock ---
   Bottom-left of the stage so it never collides with the PiP video (defaults
   bottom-right), the centered captions, or the controls bar below the stage.
   Hovering the mark unfolds a second layout switcher beside it (the morphs are
   the show — flick between modes and watch). It stays open while the pointer is
   anywhere over the dock (picking a mode does NOT collapse it) and folds away on
   leave. Hover-only by design: touch keeps the control-bar fold. */
.p2-wm-dock {
  position: absolute; left: 12px; bottom: 10px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
}
.p2-watermark {
  line-height: 0; opacity: .62; transition: opacity .2s ease, transform .2s ease;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.55));
}
.p2-watermark img { width: 88px; height: auto; display: block; }
.p2-watermark:hover, .p2-watermark:focus-visible,
.p2-wm-dock:hover .p2-watermark { opacity: 1; }
.p2-wm-modes {
  display: inline-flex; align-items: center; gap: 5px;
  visibility: hidden; pointer-events: none;
}
.p2-wm-dock:hover .p2-wm-modes,
.p2-wm-dock:focus-within .p2-wm-modes { visibility: visible; pointer-events: auto; }
/* each mode unfolds from behind the mark with a small stagger */
.p2-wm-mode.p2-btn {
  opacity: 0; transform: translateX(-10px) scale(.9);
  transition: opacity .22s ease, transform .28s var(--ease, ease),
              border-color .15s, color .15s;
  background: rgba(10,12,17,.82);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-color: rgba(255,255,255,.16);
}
.p2-wm-dock:hover .p2-wm-mode,
.p2-wm-dock:focus-within .p2-wm-mode { opacity: 1; transform: none; }
.p2-wm-dock:hover .p2-wm-mode:nth-child(2), .p2-wm-dock:focus-within .p2-wm-mode:nth-child(2) { transition-delay: .05s; }
.p2-wm-dock:hover .p2-wm-mode:nth-child(3), .p2-wm-dock:focus-within .p2-wm-mode:nth-child(3) { transition-delay: .1s; }
.p2-wm-dock:hover .p2-wm-mode:nth-child(4), .p2-wm-dock:focus-within .p2-wm-mode:nth-child(4) { transition-delay: .15s; }
@media (max-width: 560px) { .p2-watermark img { width: 64px; } .p2-wm-dock { left: 8px; bottom: 8px; } }
@media (hover: none) { .p2-wm-modes { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .p2-watermark, .p2-wm-mode.p2-btn { transition: none; }
  .p2-wm-dock:hover .p2-wm-mode { transition-delay: 0s; }
}

/* --- center "start" overlay (brand play mark) ---
   A large, on-brand play affordance centred over the stage before playback.
   Clicking it begins the presentation; it fades out once playing (.p2-started)
   and returns on a full reset. */
.p2-start {
  position: absolute; inset: 0; z-index: 12; margin: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(60% 60% at 50% 46%, rgba(8,10,14,.42), rgba(8,10,14,.66));
  border: 0; cursor: pointer; color: var(--fg);
  opacity: 1; transition: opacity .4s ease, visibility .4s ease;
  -webkit-tap-highlight-color: transparent;
}
.p2-start-mark {
  position: relative; display: grid; place-items: center;
  width: clamp(96px, 18vmin, 168px); aspect-ratio: 1;
}
.p2-start-ico { width: 100%; height: 100%; display: block;
  filter: drop-shadow(0 0 18px rgba(124,107,255,.55)); transition: transform .3s var(--ease, ease); }
/* soft pulsing halo behind the mark */
.p2-start-glow {
  position: absolute; width: clamp(120px, 24vmin, 230px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,107,255,.34), rgba(255,92,240,.12) 55%, transparent 72%);
  filter: blur(2px); pointer-events: none;
  animation: p2StartHalo 3.4s ease-in-out infinite;
}
.p2-start-text {
  font-size: 13px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
  color: var(--fg); opacity: .82; text-shadow: 0 1px 6px rgba(0,0,0,.7);
}
/* gentle float + brighten on hover/focus */
.p2-start:hover .p2-start-mark, .p2-start:focus-visible .p2-start-mark { animation: p2StartFloat 2.6s ease-in-out infinite; }
.p2-start:hover .p2-start-ico, .p2-start:focus-visible .p2-start-ico {
  transform: scale(1.06); filter: drop-shadow(0 0 26px rgba(255,92,240,.7));
}
.p2-start:focus-visible { outline: none; }
.p2-start:focus-visible .p2-start-text { opacity: 1; }
@keyframes p2StartHalo { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes p2StartFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
/* hidden once the talk is playing */
.p2-player.p2-started .p2-start { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .p2-start-glow, .p2-start:hover .p2-start-mark, .p2-start:focus-visible .p2-start-mark { animation: none; }
  .p2-start, .p2-start-ico { transition: none; }
}

/* --- caption (CC) overlay for the YouTube path ---
   Centred along the bottom of the VIDEO pane, readable at any pane size
   (split / focus / overlap PiP). Width hugs the text but is capped so long
   lines wrap instead of overflowing a narrow PiP. */
.p2-cc-overlay {
  position: absolute; left: 50%; bottom: max(6%, 10px);
  transform: translateX(-50%);
  z-index: 15;
  width: max-content; max-width: 92%;
  pointer-events: none; text-align: center; text-wrap: balance;
  background: rgba(0,0,0,0.72); color: #fff;
  padding: 0.2em 0.6em; border-radius: 6px;
  font-size: clamp(13px, 2.6vw, 22px); line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
}
.p2-cc-overlay[hidden] { display: none; }
/* One block per cue line; dir="auto" (set by subtitles.js) resolves each line's
   base direction from its content, so RTL captions with embedded Latin words
   render in the right order. */
.p2-cc-line { display: block; unicode-bidi: plaintext; }
/* Full-window placement: the overlay is mounted on the whole player stage and
   pinned bottom-centre, so captions read over slides + video together in every
   layout mode (and in fullscreen, where the stage fills the viewport). Sits above
   both panes incl. the overlap PiP (z-index 20). */
.p2-cc-window {
  z-index: 30;
  bottom: max(4%, 14px); max-width: min(80%, 60ch);
  font-size: clamp(15px, 2.2vw, 26px);
}
/* Native <track> captions (mp4 path) — keep them off the very bottom edge so
   they don't collide with the video's own control bar. */
.p2-video-pane video::cue { background: rgba(0,0,0,0.72); }

/* PDF deck — pages are absolutely-stacked + centred so that during a fade/slide
   transition the outgoing and incoming canvases overlap (rather than tiling into
   two grid rows). The adapter keeps exactly one visible outside of transitions. */
.p2-pdf-stage { position: absolute; inset: 0; background: #000; }
.p2-pdf-page {
  position: absolute; inset: 0; margin: auto;
  max-width: 100%; max-height: 100%; object-fit: contain;
}

/* --- controls --- */
.p2-controls {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px;
}
.p2-player.p2-floating-controls .p2-stage { padding-bottom: 0; }
.p2-player.p2-floating-controls .p2-controls {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 100;
  width: min(900px, calc(100% - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  transform: translate(-50%, 10px);
  border-radius: 18px;
  border-color: rgba(255,255,255,.16);
  background:
    linear-gradient(135deg, rgba(79,209,197,.16), rgba(124,107,255,.14) 46%, rgba(255,92,240,.15)),
    rgba(10,12,17,.76);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  backdrop-filter: blur(18px) saturate(1.35);
  box-shadow:
    0 20px 48px rgba(0,0,0,.55),
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 0 32px rgba(124,107,255,.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
.p2-player.p2-floating-controls.p2-controls-visible .p2-controls {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.p2-player.p2-floating-controls:not(.p2-controls-visible) { cursor: none; }
.p2-player.p2-floating-controls .p2-btn,
.p2-player.p2-floating-controls .p2-speed {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.14);
}
.p2-player.p2-floating-controls .p2-btn:hover,
.p2-player.p2-floating-controls .p2-speed:hover,
.p2-player.p2-floating-controls .p2-btn:focus-visible,
.p2-player.p2-floating-controls .p2-speed:focus-visible {
  border-color: rgba(79,209,197,.7);
  color: var(--accent);
}
.p2-controls-has-preview { position: relative; }

/* Scrubber hover/seek thumbnail preview — a card that floats above the bar. */
.p2-scrub-preview {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  width: 168px; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; box-shadow: 0 6px 22px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
  z-index: 40;
}
.p2-scrub-preview.is-visible { opacity: 1; transform: translateY(0); }
.p2-preview-img {
  display: none; width: 100%; height: auto; border-radius: 4px;
  background: #000; aspect-ratio: 16 / 9; object-fit: contain;
}
.p2-scrub-preview.has-img .p2-preview-img { display: block; }
.p2-preview-cap {
  margin-top: 4px; font-size: 11px; color: var(--muted);
  text-align: center; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.p2-btn { min-width: 40px; text-align: center; line-height: 1; }
.p2-play-btn { color: var(--accent); border-color: rgba(79,209,197,.45); }
.p2-spacer { flex: 1; }
/* Scrubber — the landing page's neon timeline: gradient-elapsed track (painted
   via --val from player.js, since native ranges can't style their progress) and
   a glowing thumb. Firefox gets ::-moz-range-progress natively. */
.p2-scrub {
  flex: 2; min-width: 120px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  height: 22px; background: transparent; --val: 0%;
}
.p2-scrub::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background:
    linear-gradient(90deg, #4fd1c5, #7c6bff 52%, #ff5cf0) 0 0 / var(--val) 100% no-repeat,
    linear-gradient(rgba(255,255,255,.16), rgba(255,255,255,.16));
}
.p2-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
  background: #fff; border: none;
  box-shadow: 0 0 0 3px rgba(6,7,11,.45), 0 0 14px rgba(124,107,255,.6);
}
.p2-scrub::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(255,255,255,.16); }
.p2-scrub::-moz-range-progress { height: 6px; border-radius: 999px; background: linear-gradient(90deg, #4fd1c5, #7c6bff 52%, #ff5cf0); }
.p2-scrub::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px rgba(6,7,11,.45), 0 0 14px rgba(124,107,255,.6);
}
.p2-scrub:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 3px; border-radius: 999px; }

/* Sync-toggle tip — a transient toast above the control bar, anchored near the
   chain button (right end), telling the viewer what the toggle just did. */
.p2-link-tip {
  position: absolute; bottom: calc(100% + 10px); right: 10px; z-index: 45;
  padding: 7px 12px; border-radius: 10px;
  font-size: 12.5px; white-space: nowrap; color: var(--fg);
  background:
    linear-gradient(135deg, rgba(79,209,197,.18), rgba(124,107,255,.16) 50%, rgba(255,92,240,.17)),
    rgba(10,12,17,.92);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 10px 26px rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transform: translateY(4px);
}
.p2-link-tip.is-live { animation: p2-tip 2.4s ease forwards; }
@keyframes p2-tip {
  0%       { opacity: 0; transform: translateY(4px); }
  8%, 78%  { opacity: 1; transform: none; }
  100%     { opacity: 0; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) { .p2-link-tip.is-live { animation-duration: 1.2s; } }

/* Center play/pause feedback burst (player.js _flashPlayState): a glassy brand
   chip. Play = short pop; pause = linger, then slowly fade so a screenshot a
   beat later is clean, chrome-free video. */
.p2-burst {
  position: absolute; left: 50%; top: 50%; z-index: 45;
  width: 92px; height: 92px; margin: -46px 0 0 -46px;
  display: grid; place-items: center; border-radius: 50%;
  pointer-events: none; opacity: 0;
  background:
    linear-gradient(135deg, rgba(79,209,197,.3), rgba(124,107,255,.26) 50%, rgba(255,92,240,.28)),
    rgba(6,7,11,.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 10px 40px rgba(0,0,0,.45), 0 0 34px rgba(124,107,255,.35);
}
.p2-burst svg { width: 42px; height: 42px; fill: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,.6)); }
.p2-burst.is-play { animation: p2-burst-pop .6s var(--ease) forwards; }
.p2-burst.is-pause { animation: p2-burst-linger 1.7s ease-out forwards; }
@keyframes p2-burst-pop {
  0%   { opacity: 0; transform: scale(.55); }
  25%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}
@keyframes p2-burst-linger {
  0%   { opacity: 0; transform: scale(.75); }
  10%  { opacity: 1; transform: scale(1); }
  60%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.03); }
}
@media (prefers-reduced-motion: reduce) {
  .p2-burst.is-play, .p2-burst.is-pause { animation-duration: .25s; }
}
.p2-time, .p2-slidecount { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.p2-slidecount { color: var(--fg); }
.p2-speed { padding: 6px 8px; }
.p2-link { color: var(--muted); border-color: var(--line); }
.p2-link.is-linked { color: var(--accent); border-color: var(--accent); }
.p2-sync-ico { width: 17px; height: 17px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.p2-sync-slash { stroke: var(--muted); }
.p2-link.is-linked .p2-sync-slash { display: none; }

/* layout-mode switcher + the grouped "Layout" view cluster */
.p2-layout-group {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 8px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2);
}
.p2-group-label {
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; user-select: none;
}
/* --- layout fold: one trigger that unfolds into the four mode options --- */
.p2-fold { position: relative; display: inline-flex; }
.p2-fold-trigger { position: relative; }
/* a small caret hint that the button opens a menu */
.p2-fold-trigger::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 0; height: 0; border-left: 3px solid transparent; border-right: 3px solid transparent;
  border-top: 4px solid currentColor; opacity: .5; transition: transform .25s var(--ease, ease), opacity .2s;
}
.p2-fold.is-open .p2-fold-trigger::after { transform: rotate(180deg); opacity: .9; }
.p2-fold.is-open .p2-fold-trigger { border-color: var(--accent); color: var(--accent); }
.p2-fold-ico { display: block; height: 14px; }
.p2-fold-ico .p2-mode-ico { width: 19px; height: 14px; }
/* the unfolding panel — pops up above the bar; animates open */
.p2-fold-panel {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  display: flex; flex-direction: column; gap: 3px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0,0,0,.55); z-index: 40;
  transform-origin: bottom center;
  opacity: 0; visibility: hidden;
  transform: translateX(-50%) translateY(6px) scale(.92);
  transition: opacity .22s var(--ease, ease), transform .26s var(--ease, ease), visibility .26s;
}
.p2-fold.is-open .p2-fold-panel {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0) scale(1);
}
/* options stagger in as the panel unfolds (.p2-fold prefix beats .p2-icon-btn) */
.p2-fold .p2-fold-item {
  flex-direction: row; gap: 9px; justify-content: flex-start; min-width: 148px;
  text-align: left; padding: 8px 11px;
  opacity: 0; transform: translateY(5px); transition: opacity .2s ease, transform .2s var(--ease, ease), border-color .15s, color .15s;
}
.p2-fold.is-open .p2-fold-item { opacity: 1; transform: none; }
.p2-fold.is-open .p2-fold-item:nth-child(2) { transition-delay: .04s; }
.p2-fold.is-open .p2-fold-item:nth-child(3) { transition-delay: .08s; }
.p2-fold.is-open .p2-fold-item:nth-child(4) { transition-delay: .12s; }
.p2-fold-item .p2-btn-label { font-size: 12px; text-transform: none; letter-spacing: 0; }
.p2-fold-item.is-on { border-color: var(--accent); color: var(--accent); background: var(--panel-2); }
@media (prefers-reduced-motion: reduce) {
  .p2-fold-panel, .p2-fold-item, .p2-fold-trigger::after { transition: none; }
  .p2-fold-item { opacity: 1; transform: none; }
}
/* Icon buttons: SVG glyph that depicts the layout, with a short label beneath. */
.p2-icon-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: auto; padding: 5px 9px; line-height: 1;
}
.p2-mode-ico { width: 19px; height: 14px; display: block; }
.p2-mode-ico rect, .p2-mode-ico path { fill: none; stroke: currentColor; stroke-width: 1.2; }
.p2-mode-ico .f { fill: currentColor; stroke: none; }   /* PiP inset = filled */
.p2-btn-label {
  font-size: 9px; letter-spacing: 0.04em; text-transform: uppercase;
  line-height: 1; color: inherit;
}
.p2-mode-btn.is-on, .p2-fs-btn.is-on { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.p2-btn.is-on { border-color: var(--accent); color: var(--accent); }
/* Narrow widths: drop the text labels (icon + tooltip/aria-label remain) — but
   keep the unfolded layout options labelled, since the panel is a menu. */
@media (max-width: 560px) {
  .p2-btn-label { display: none; }
  .p2-fold-item .p2-btn-label { display: block; }
}

/* CC menu */
.p2-cc { position: relative; }
.p2-cc-btn { font-weight: 600; letter-spacing: 0.05em; }
.p2-cc-btn.is-on { border-color: var(--accent); color: var(--accent); }
.p2-cc-menu {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 30;
  display: none; flex-direction: column; gap: 2px; min-width: 160px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.p2-cc-menu.is-open { display: flex; }
.p2-cc-head {
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 6px 6px 2px; user-select: none;
}
.p2-cc-head:first-child { padding-top: 2px; }
.p2-cc-item, .p2-cc-place { text-align: left; border-color: transparent; }
.p2-cc-item:hover, .p2-cc-place:hover { border-color: var(--accent); }
.p2-cc-item.is-active, .p2-cc-place.is-active { color: var(--accent); border-color: var(--accent-dim); }

/* Fullscreen fallback for platforms without element Fullscreen API (iOS Safari):
   pin the whole player over the viewport. dvh + safe-area keep it clear of the
   notch and the dynamic toolbar. */
.p2-player.is-maximized {
  position: fixed; inset: 0; z-index: 9999;
  width: 100vw; height: 100vh; height: 100dvh;
  margin: 0; background: var(--bg);
  padding: max(8px, env(safe-area-inset-top))
           max(8px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom))
           max(8px, env(safe-area-inset-left));
}
body.p2-maximized { overflow: hidden; }

/* --- immersive (fullscreen / maximized): auto-hiding overlay controls ---
   The control bar is lifted OUT of the flow into a fixed overlay pinned to the
   bottom of the player, so showing/hiding it never resizes or reflows the slides
   or video. It fades out after ~2.5s of inactivity and back in on any activity
   (driven by .p2-controls-visible from player.js). */
.p2-player.p2-immersive .p2-controls {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: auto;
  transform: translateY(8px);
  z-index: 10000;
}
.p2-player.p2-immersive.p2-controls-visible .p2-controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
/* Hide the OS cursor with the bar so immersive playback is truly clean. */
.p2-player.p2-immersive:not(.p2-controls-visible) { cursor: none; }
@media (prefers-reduced-motion: reduce) {
  .p2-player.p2-immersive .p2-controls { transition: opacity .15s linear; transform: none; }
}

.p2-empty {
  margin: auto; color: var(--muted); text-align: center; padding: 40px;
  font-size: 15px; max-width: 640px;
}

.p2-footer {
  padding: 10px 16px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}
.p2-footer a { color: var(--accent); }

/* --- secondary nav: demo picker + tool links --- */
.p2-nav {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 5px 14px; background: rgba(13,15,18,.78);
  border-bottom: 1px solid rgba(255,255,255,.07); font-size: 13px;
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  backdrop-filter: blur(12px) saturate(1.15);
}
.p2-nav-label { color: var(--muted); }
.p2-nav-spacer { flex: 1; }
.p2-nav-link {
  color: var(--fg); text-decoration: none;
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
}
.p2-nav-link:hover { border-color: var(--accent); color: var(--accent); }
.p2-nav-link.is-active { border-color: var(--accent); color: var(--accent); background: var(--panel-2); }
@media (max-width: 820px) { .p2-nav { display: none; } }

/* --- responsive: narrow screens (phones, narrow windows) --- */

/* Portrait / tall: stack vertically (slides on top, video below) with the same
   draggable divider — now a horizontal grab bar the user drags UP/DOWN.
   Landscape phones stay side-by-side (wide but short), so this is portrait-only.
   (Overlap PiP works in either orientation; it's absolutely positioned.) */
@media (max-width: 820px) and (orientation: portrait) {
  .p2-stage:not([data-mode="overlap"]) { flex-direction: column; }
  .p2-stage[data-mode="split"] .p2-divider {
    display: block;
    flex: 0 0 26px; width: 100%; height: auto; align-self: stretch;
    cursor: row-resize;
  }
  .p2-stage[data-mode="split"] .p2-divider::before {
    width: 48px; height: 5px;
  }
  .p2-stage[data-mode="split"] .p2-divider:hover::before,
  .p2-stage[data-mode="split"] .p2-divider:focus-visible::before {
    width: 72px; height: 5px;
  }
}

@media (max-width: 820px) {
  .p2-stage:not([data-mode="overlap"]) .p2-pane { flex-basis: 0; }
  .p2-controls { flex-wrap: wrap; gap: 8px; }

  /* Full-bleed: trim chrome so the player owns the viewport. */
  .p2-header {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    margin: 6px 6px 0;
    padding: 6px 8px; gap: 8px;
    border-radius: 16px;
  }
  .p2-brand { min-width: 0; }
  .p2-name { display: none; }
  .p2-deck-title { max-width: 38vw; font-size: 12px; }
  .p2-tools { gap: 3px; padding: 2px; }
  .p2-tool { width: 31px; height: 31px; border-radius: 10px; }
  .p2-app { padding: 6px; }
  .p2-player { gap: 6px; }
  .p2-footer { display: none; }

  /* No hover on touch: the brand (logo + title + badge) stays put while collapsed
     and tapping the logo/name pins the cluster open. The "Load" form drops to its
     own row when opened. */
  .p2-cluster { gap: 7px; }
  .p2-act { padding: 8px 11px; }
  .p2-source { grid-template-columns: minmax(0, 1fr) auto; }
  .p2-status { top: 60px; right: 8px; width: min(390px, calc(100vw - 16px)); }

  /* Two clean rows: the scrubber owns the top row full-width; every button
     centres on the row below (no stranded controls). Flex wraps gracefully
     instead of a brittle fixed-column grid. */
  .p2-player.p2-floating-controls .p2-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: calc(100% - 14px - env(safe-area-inset-left) - env(safe-area-inset-right));
    bottom: max(7px, env(safe-area-inset-bottom));
    padding: 10px;
    border-radius: 16px;
    gap: 8px;
  }
  .p2-player.p2-floating-controls .p2-btn,
  .p2-player.p2-floating-controls .p2-speed {
    min-width: 38px; min-height: 38px; padding: 7px 8px;
  }
  .p2-scrub { order: -1; flex: 0 0 100%; width: 100%; min-width: 0; margin-bottom: 2px; }
  .p2-time { font-size: 11px; }
  .p2-slidecount { display: none; }
  .p2-link { display: none; }
  .p2-spacer { display: none; }
  .p2-layout-group { padding: 0; border: 0; background: transparent; }
  .p2-group-label { display: none; }
}

/* On smaller phones drop the action labels — the icons carry the meaning. */
@media (max-width: 560px) {
  .p2-act-label { display: none; }
  .p2-act { padding: 8px; }
}

/* Touch devices: every interactive control gets a >=44px tap target. */
@media (pointer: coarse) {
  .p2-btn, .p2-load, .p2-speed, .p2-mode-btn, .p2-act {
    min-height: 44px; min-width: 44px;
  }
  .p2-scrub { height: 28px; }
  /* Widen the vertical (side-by-side) divider so it's a >=24px touch target. */
  .p2-stage[data-mode="split"] .p2-divider { flex-basis: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
