/* MobiPlayer — ink stage · ember signal · Netflix-scale cues */
:root {
  --ink: #07080c;
  --ink2: #0c0d11;
  --surface: rgba(14, 15, 20, 0.94);
  --line: rgba(255, 255, 255, 0.07);
  --line-hot: rgba(196, 30, 38, 0.45);
  --text: #f2efe8;
  --muted: #8a8f99;
  --ember: #c41e26;
  --ember2: #8f141b;
  --ember-soft: #e0353d;
  --ember-glow: rgba(196, 30, 38, 0.18);
  --ice: #7ec8c0;
  --ok: #5dde9a;
  --danger: #ff6b7a;
  --ctrl: linear-gradient(180deg, transparent 0%, rgba(7, 8, 12, 0.4) 18%, rgba(7, 8, 12, 0.96) 100%);
  --tap: 44px;
  --radius: 14px;
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.62);
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
  --display: "Segoe UI", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background: var(--ink);
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(229, 9, 20, 0.2), transparent 55%),
    radial-gradient(700px 480px at 95% 8%, rgba(126, 200, 192, 0.08), transparent 50%),
    radial-gradient(600px 400px at 50% 100%, rgba(178, 7, 16, 0.08), transparent 55%),
    linear-gradient(180deg, #0c0e14 0%, var(--ink) 45%, #050608 100%);
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}

/* ===== Brand ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  animation: rise 0.7s var(--ease) both;
}
.brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  filter: drop-shadow(0 10px 24px rgba(229, 9, 20, 0.4));
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-text h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3.4vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.brand-mobi { color: var(--text); }
.brand-player {
  background: linear-gradient(105deg, var(--ember-soft), var(--ember2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .tag {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.sub {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 0.92rem;
  max-width: 48ch;
  line-height: 1.5;
  animation: rise 0.75s var(--ease) 0.06s both;
}
/* Opacity-only on shells that host menus — transform creates a fixed() containing block and clips sheets */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes riseSoft {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Lookup panel ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 14px;
  margin-bottom: 18px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: rise 0.8s var(--ease) 0.1s both;
}

form.lookup {
  display: grid;
  grid-template-columns: 1.15fr 0.75fr 1.35fr 0.6fr 0.6fr auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 900px) {
  form.lookup { grid-template-columns: 1fr 1fr; }
  form.lookup .go { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  form.lookup {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  form.lookup label,
  form.lookup .go { grid-column: 1 / -1; }
  input, select, button.go {
    min-height: 48px;
    font-size: 16px; /* iOS zoom-lock */
    padding: 12px 14px;
  }
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.66rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
label .hint-temp {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  color: #1a0a08;
  background: linear-gradient(180deg, var(--ember-soft), var(--ember));
  vertical-align: middle;
  text-transform: lowercase;
}
input, select, button {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(7, 8, 12, 0.88);
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  border-color: var(--line-hot);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.16);
}
button.go {
  background: linear-gradient(180deg, var(--ember-soft), var(--ember2));
  color: #140806;
  border: none;
  font-weight: 800;
  cursor: pointer;
  align-self: end;
  min-height: var(--tap);
  letter-spacing: 0.02em;
  transition: transform 0.15s var(--ease), filter 0.15s;
  box-shadow: 0 10px 28px rgba(229, 9, 20, 0.32);
}
button.go:hover { filter: brightness(1.06); }
button.go:active { transform: scale(0.98); }
button.go:disabled { opacity: 0.55; cursor: wait; filter: none; box-shadow: none; }

/* ===== Player shell ===== */
.player-shell {
  position: relative;
  border-radius: calc(var(--radius) + 6px);
  padding: 1px;
  background: linear-gradient(
    140deg,
    rgba(196, 30, 38, 0.42),
    rgba(143, 20, 27, 0.16) 42%,
    rgba(255, 255, 255, 0.05)
  );
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.45);
  animation: riseSoft 0.85s var(--ease) 0.14s both;
  overflow: visible;
}
.player-shell::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(60% 40% at 20% 0%, rgba(196, 30, 38, 0.14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.player {
  position: relative;
  z-index: 1;
  background-color: #000;
  background-image: var(--poster-url, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
  /* Cue scale defaults — JS ResizeObserver overwrites to player-frame % */
  --cue-fs: 18px;
  --cue-ol: 1.5px;
  --cue-blur: 4px;
}
.player.has-poster.is-idle video {
  background: transparent;
  /* Poster paints via attribute; dim so center play pops */
  opacity: 0.92;
}
.player.has-poster:not(.is-idle) {
  background-image: none;
}
/* Soft vignette over poster while waiting for play */
.player.is-idle::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 28%, transparent 72%, rgba(0, 0, 0, 0.4) 100%);
}
.player:fullscreen,
.player:-webkit-full-screen {
  border-radius: 0;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
}

.player video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
  /* Below hitlayer — iOS otherwise swallows taps for custom chrome */
  position: relative;
  z-index: 1;
}

/* Transparent tap catcher above <video>, under overlay/controls/topbar.
 * Needed on iOS/iframe: video absorbs touches and controls never get is-controls. */
.player .hitlayer {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: transparent;
  pointer-events: none;
}
.player:not(.is-idle):not(.is-paused):not(.is-menu-open) .hitlayer {
  pointer-events: auto;
}
.player.has-poster.is-idle video {
  /* poster attribute paints; keep letterbox transparent over shell bg */
  background: rgba(0, 0, 0, 0.35);
}

/*
 * Netflix-faithful cues — sized to PLAYER box (not page viewport).
 * --cue-fs / --cue-ol set by CinemaPlayer.syncCueScale() via ResizeObserver.
 * Embedded 16:9 ≈ smaller type; fullscreen ≈ ~4.5% of frame height.
 */
.player video::cue {
  color: #ffffff;
  background: transparent;
  background-color: transparent;
  font-family: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: var(--cue-fs);
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-shadow:
    calc(var(--cue-ol) * -1) calc(var(--cue-ol) * -1) 0 #000,
    var(--cue-ol) calc(var(--cue-ol) * -1) 0 #000,
    calc(var(--cue-ol) * -1) var(--cue-ol) 0 #000,
    var(--cue-ol) var(--cue-ol) 0 #000,
    calc(var(--cue-ol) * -1) 0 0 #000,
    var(--cue-ol) 0 0 #000,
    0 calc(var(--cue-ol) * -1) 0 #000,
    0 var(--cue-ol) 0 #000,
    0 calc(var(--cue-ol) * 1.2) var(--cue-blur) rgba(0, 0, 0, 0.85);
}

.player .overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  justify-items: center;
  align-items: center;
  pointer-events: none;
  background: transparent;
  transition: background 0.25s;
  z-index: 5;
}
.player.is-idle .overlay,
.player.is-paused .overlay {
  pointer-events: auto;
  cursor: pointer;
}
/* Stack spinner + play in the SAME cell — true optical center */
.player .overlay > * {
  grid-area: 1 / 1;
  place-self: center;
}
.player.is-loading .overlay { background: rgba(0, 0, 0, 0.28); }
.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--ember);
  animation: spin 0.7s linear infinite;
  opacity: 0;
}
.player.is-loading .spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.big-play {
  pointer-events: auto;
  width: clamp(72px, 14vw, 92px);
  height: clamp(72px, 14vw, 92px);
  border-radius: 50%;
  border: none;
  background: linear-gradient(160deg, var(--ember-soft), var(--ember2));
  color: #140806;
  cursor: pointer;
  display: none;
  place-items: center;
  margin: 0;
  padding: 0;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 0 0 0 rgba(229, 9, 20, 0.4);
  transition: transform 0.18s var(--ease);
  z-index: 6;
  animation: playPulse 2.4s var(--ease) infinite;
}
.big-play svg {
  width: 42%;
  height: 42%;
  margin-left: 6%; /* optical center for triangle */
}
.big-play:hover { transform: scale(1.06); }
.big-play:active { transform: scale(0.96); }
/* Idle poster OR mid-pause — center start control */
.player.is-idle .big-play,
.player.is-paused .big-play { display: grid; }
.player.is-loading .big-play { display: none !important; animation: none; }
@keyframes playPulse {
  0%, 100% { box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 0 rgba(229, 9, 20, 0.35); }
  55% { box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 18px rgba(229, 9, 20, 0); }
}

.seek-flash {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 800;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums;
}
.seek-flash.left { left: 10%; }
.seek-flash.right { right: 10%; }
.seek-flash.show { opacity: 1; }

/* Burned-in style lower-third promo — wall-clock 10s, above video/cues, under menus */
.stream-promo {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14%;
  z-index: 25;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
  animation: promoIn 0.45s var(--ease) both;
}
.stream-promo[hidden] {
  display: none !important;
}
.stream-promo.is-out {
  animation: promoOut 0.4s var(--ease) both;
}
.stream-promo a {
  pointer-events: auto;
  max-width: min(920px, 94%);
  text-align: center;
  text-decoration: none;
  color: #fff;
  font-family: "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: clamp(0.95rem, 2.6vw, 1.35rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-shadow:
    -1.5px -1.5px 0 #000,
     1.5px -1.5px 0 #000,
    -1.5px  1.5px 0 #000,
     1.5px  1.5px 0 #000,
     0 2px 8px rgba(0, 0, 0, 0.85);
}
.stream-promo a .promo-host {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
.player.is-controls .stream-promo {
  bottom: 22%;
}
.player:fullscreen .stream-promo,
.player:-webkit-full-screen .stream-promo {
  z-index: 25;
  bottom: 14%;
}
.player:fullscreen.is-controls .stream-promo,
.player:-webkit-full-screen.is-controls .stream-promo {
  bottom: 22%;
}
@keyframes promoIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes promoOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(6px); }
}
@media (max-width: 720px) {
  .stream-promo { bottom: 16%; }
  .player.is-controls .stream-promo { bottom: 26%; }
  .stream-promo a { font-size: clamp(0.88rem, 3.6vw, 1.1rem); }
}

.hotkey-toast {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(10, 11, 16, 0.78);
  border: 1px solid rgba(229, 9, 20, 0.35);
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 6;
  backdrop-filter: blur(12px);
  letter-spacing: 0.01em;
}
.hotkey-toast.show { opacity: 1; }

.controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 40px 14px 12px;
  background: var(--ctrl);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  z-index: 7;
  pointer-events: none;
}
.player.is-controls .controls,
.player:focus-within .controls {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
/* First paint / idle: ONLY poster + center play — no chrome clutter */
.player.is-idle .controls {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(12px);
}

.progress {
  position: relative;
  height: 18px;
  display: grid;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.progress .rail {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  position: relative;
  transition: height 0.12s;
}
.progress:hover .rail,
.progress:active .rail { height: 7px; }
.progress .buf {
  position: absolute; inset: 0 auto 0 0;
  background: rgba(255, 255, 255, 0.22);
}
.progress .fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--ember2), var(--ember), #ffb090);
}
.progress .knob {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.45);
  opacity: 0;
  transition: opacity 0.12s;
}
.progress:hover .knob { opacity: 1; }

.row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.row .spacer { flex: 1; min-width: 8px; }

.btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.02rem;
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.1s, color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn:active { transform: scale(0.96); }
.btn.is-on {
  color: #fff;
  background: var(--ember-glow);
  box-shadow: inset 0 0 0 1px rgba(196, 30, 38, 0.45);
}

.vol-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 140px;
}
.vol-wrap input[type="range"] {
  width: 76px;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--ember);
}
@media (max-width: 640px) {
  .vol-wrap input[type="range"] { display: none; }
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: #ebe6df;
  padding: 0 8px;
  white-space: nowrap;
  font-weight: 600;
}
.time-sep {
  margin: 0 4px;
  opacity: 0.45;
}

.menu-wrap { position: relative; }
/* Desktop: minimal black glass tab */
.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 168px;
  max-width: min(220px, 70vw);
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(8, 8, 10, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px;
  display: none;
  z-index: 40;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px) saturate(1.05);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  pointer-events: auto;
}
.menu.open { display: block; animation: menuIn 0.14s var(--ease); }
@keyframes menuIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.menu-head {
  padding: 6px 10px 7px;
  margin: 0 0 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}
.menu-head::after {
  display: none;
}
.menu .menu-title {
  padding: 0;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  font-weight: 700;
}
/* Keep header one-line; drop verbose subtitle on desktop tabs */
.menu .menu-sub {
  display: none;
}
.menu button,
.menu .menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 34px;
  touch-action: manipulation;
  border-left: none;
  transition: background 0.12s var(--ease), color 0.12s;
}
.menu button:hover,
.menu .menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.menu button:disabled,
.menu .menu-item:disabled { opacity: 0.38; cursor: not-allowed; }
.menu button.active,
.menu .menu-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 700;
  box-shadow: none;
}

/* Menu open (desktop): dropdowns may escape the 16:9 box */
.player.is-menu-open {
  overflow: visible;
  z-index: 40;
}
.player.is-menu-open .overlay {
  pointer-events: none !important;
}
.player.is-menu-open .controls {
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 30;
}
.player.is-menu-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 28;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

/* ========== Native touch UI — sheets LIVE INSIDE .player ==========
 * Never position:fixed to the document/iframe viewport (that parked
 * translucent sheets under the player card). Absolute + opaque only. */
.player .sheet-root {
  display: none;
}
.player.is-touch-ui {
  isolation: isolate;
}
.player.is-touch-ui .sheet-root {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}
.player.is-touch-ui.is-menu-open .sheet-root {
  pointer-events: auto;
}
.player.is-touch-ui .menu-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.72);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
}
.player.is-touch-ui .menu-scrim[hidden] {
  display: none !important;
}

.player.is-touch-ui.is-menu-open {
  overflow: hidden !important;
}
.player.is-touch-ui.is-menu-open::after {
  display: none !important;
  content: none !important;
}
.player.is-touch-ui.is-menu-open .controls {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(12px);
}
.player.is-touch-ui.is-menu-open .hitlayer {
  pointer-events: none !important;
}
.player.is-touch-ui.is-menu-open .topbar {
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 90;
}
.player.is-touch-ui.is-menu-open .stream-promo {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* In-player bottom sheet — compact mobile (fits 16:9 embed stage) */
.player.is-touch-ui .sheet-root > .menu,
.player.is-touch-ui .sheet-root > .menu.menu-from-top {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  /* ~2–5 rows; never swallow most of the frame */
  max-height: min(46%, 220px);
  z-index: 2;
  margin: 0;
  display: none;
  flex-direction: column;
  padding:
    0
    max(8px, env(safe-area-inset-left, 0px))
    max(6px, env(safe-area-inset-bottom, 0px))
    max(8px, env(safe-area-inset-right, 0px));
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px 12px 0 0;
  background: #14161c !important;
  background-image: none !important;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.55);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
  transform: translateZ(0);
}
.player.is-touch-ui .sheet-root > .menu.open,
.player.is-touch-ui .sheet-root > .menu.menu-from-top.open {
  display: flex !important;
  animation: nativeSheetIn 0.22s var(--ease) both;
}
@keyframes nativeSheetIn {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
.player.is-touch-ui .sheet-root > .menu.open::before {
  content: "";
  display: block;
  flex: 0 0 auto;
  width: 28px;
  height: 3px;
  margin: 6px auto 2px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
}
.player.is-touch-ui .sheet-root > .menu .menu-head {
  flex: 0 0 auto;
  padding: 4px 10px 8px;
  margin: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.player.is-touch-ui .sheet-root > .menu .menu-head::after {
  left: 10px;
  width: 22px;
}
.player.is-touch-ui .sheet-root > .menu .menu-title {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: rgba(242, 239, 232, 0.5);
}
.player.is-touch-ui .sheet-root > .menu .menu-sub {
  display: -webkit-box;
  margin-top: 3px;
  font-size: 0.72rem;
  line-height: 1.25;
  color: rgba(242, 239, 232, 0.78);
  word-break: break-word;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.player.is-touch-ui .sheet-root > .menu.open {
  overflow-x: hidden;
  overflow-y: auto;
}
.player.is-touch-ui .sheet-root > .menu.open > .menu-head,
.player.is-touch-ui .sheet-root > .menu.open > .menu-item,
.player.is-touch-ui .sheet-root > .menu.open > button {
  flex: 0 0 auto;
}
.player.is-touch-ui .sheet-root > .menu button,
.player.is-touch-ui .sheet-root > .menu .menu-item {
  min-height: 38px;
  padding: 8px 10px;
  margin: 1px 0;
  font-size: 0.82rem;
  font-weight: 650;
  border-radius: 8px;
  border-left-width: 2px;
  background: transparent;
  color: #f2efe8;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.player.is-touch-ui .sheet-root > .menu button:active,
.player.is-touch-ui .sheet-root > .menu .menu-item:active {
  background: rgba(255, 255, 255, 0.08);
}
.player.is-touch-ui .sheet-root > .menu button.active,
.player.is-touch-ui .sheet-root > .menu .menu-item.active {
  background: rgba(196, 30, 38, 0.22);
  border-left-color: var(--ember);
  color: #fff;
}
.player.is-touch-ui .sheet-root > .menu .mi-row {
  gap: 8px;
}
.player.is-touch-ui .sheet-root > .menu .mi-flag {
  width: 16px;
  height: 12px;
}
.player.is-touch-ui .sheet-root > .menu .mi-text {
  font-size: 0.82rem;
}
.player.is-touch-ui .sheet-root > .menu .mi-check {
  font-size: 0.75rem;
}

/* Closed panels still in chrome must never paint as ghost sheets */
.player.is-touch-ui .controls .menu,
.player.is-touch-ui .topbar .menu {
  display: none !important;
}
.player.is-touch-ui .controls .menu.open,
.player.is-touch-ui .topbar .menu.open {
  display: none !important;
}

.topbar {
  position: absolute;
  left: 0; right: 0; top: 0;
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent);
  opacity: 0;
  transition: opacity 0.22s;
  pointer-events: none;
  /* Above .overlay (z:5) — otherwise idle/paused overlay eats chip clicks */
  z-index: 10;
}
.player.is-controls .topbar,
.player.is-paused .topbar,
.player.is-idle .topbar {
  opacity: 1;
  /* iOS/WebKit: parent pointer-events:none + child:auto often drops touches (esp. iframe) */
  pointer-events: auto;
}
.topbar .title,
.topbar .brand-chip {
  pointer-events: none;
}
.player.is-idle .topbar {
  padding: 12px 14px;
}
.player.is-menu-open .topbar {
  z-index: 35;
  pointer-events: auto;
}
.player.is-idle .topbar .title {
  display: block;
  opacity: 0.95;
  max-width: min(52%, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .brand-chip {
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(242, 239, 232, 0.92);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(196, 30, 38, 0.55);
  border-left: 2px solid var(--ember);
  padding: 5px 9px 5px 8px;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Right-click context menu */
.ctx-menu {
  position: absolute;
  z-index: 20;
  min-width: 220px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(10, 11, 14, 0.97);
  border: 1px solid var(--line);
  border-top: 1px solid rgba(196, 30, 38, 0.35);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
}
.ctx-menu[hidden] { display: none !important; }
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  border-left: 2px solid transparent;
}
.ctx-menu button:hover {
  background: var(--ember-glow);
  border-left-color: var(--ember);
}
.ctx-menu hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 4px 6px;
}
.topbar .title {
  font-size: 1rem;
  font-weight: 650;
  font-family: var(--display);
  letter-spacing: -0.015em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.95);
  line-height: 1.3;
  min-width: 0;
  color: #f7f4ee;
}
.topbar .badges,
.topbar .track-rail {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-start;
  pointer-events: auto;
  max-width: min(56%, 420px);
}
.topbar .top-track {
  pointer-events: auto;
}
.topbar .menu.menu-from-top {
  bottom: auto;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  min-width: 156px;
  max-width: 200px;
  max-height: 220px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.topbar .menu.menu-from-top .menu-head {
  padding: 5px 8px 6px;
}
.topbar .menu.menu-from-top button,
.topbar .menu.menu-from-top .menu-item {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 0.78rem;
  border-radius: 5px;
}
.topbar .menu.menu-from-top .mi-flag {
  width: 14px;
  height: 10px;
}
.topbar .menu.menu-from-top .mi-text {
  font-size: 0.78rem;
}
.topbar .menu.menu-from-top .mi-check {
  font-size: 0.7rem;
  opacity: 0.85;
}
.track-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.48);
  color: #f4f0e8;
  padding: 6px 9px 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  backdrop-filter: blur(10px);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.track-chip:hover,
.track-chip.is-open {
  border-color: rgba(196, 30, 38, 0.55);
  background: rgba(12, 8, 10, 0.72);
}
.track-chip.is-on {
  border-color: rgba(196, 30, 38, 0.5);
}
.track-chip .track-flag {
  width: 18px;
  height: 13px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.track-chip .track-flag .flag-svg,
.menu .mi-flag .flag-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.track-chip .track-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-chip .track-caret {
  opacity: 0.55;
  font-size: 0.62rem;
  flex-shrink: 0;
}
.menu .mi-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.menu .mi-flag {
  width: 22px;
  height: 15px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
  font-size: 0;
}
.menu .mi-text {
  min-width: 0;
  flex: 1;
  text-align: left;
}
.menu .mi-check {
  opacity: 0.75;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}

.status {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--muted);
  word-break: break-word;
  font-weight: 500;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  opacity: 0.9;
}
.hints {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.72rem;
}
.hints kbd {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 5px 8px;
}
.hints span { opacity: 0.7; margin-right: 6px; }

details.debug {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.76rem;
}
details.debug pre {
  white-space: pre-wrap;
  word-break: break-all;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.foot {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}
.foot-mark {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  opacity: 0.85;
}
.foot-sep { opacity: 0.35; }

body.theater .wrap {
  max-width: 100%;
  padding: 8px;
}
body.theater .panel,
body.theater .brand,
body.theater .sub,
body.theater .hints,
body.theater .debug,
body.theater .meta,
body.theater .status,
body.theater .foot,
body.theater .ambient {
  display: none;
}
body.theater .player-shell {
  border-radius: 0;
  padding: 0;
  background: none;
  box-shadow: none;
}
body.theater .player {
  aspect-ratio: auto;
  min-height: calc(100vh - 16px);
  border-radius: 12px;
}

/* ========== Phone / tablet — native-app chrome ========== */
@media (max-width: 720px) {
  :root {
    --tap: 44px;
    --radius: 12px;
  }

  .wrap {
    padding:
      calc(10px + env(safe-area-inset-top, 0px))
      calc(10px + env(safe-area-inset-right, 0px))
      calc(20px + env(safe-area-inset-bottom, 0px))
      calc(10px + env(safe-area-inset-left, 0px));
    max-width: 100%;
  }

  .ambient {
    background:
      radial-gradient(640px 380px at 10% -8%, rgba(229, 9, 20, 0.18), transparent 58%),
      linear-gradient(180deg, #0c0e14 0%, var(--ink) 50%, #050608 100%);
  }

  .brand {
    gap: 10px;
    margin-bottom: 8px;
  }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text h1 {
    font-size: clamp(1.35rem, 6.2vw, 1.7rem);
  }
  .brand .tag {
    font-size: 0.6rem;
    letter-spacing: 0.14em;
  }
  .sub {
    font-size: 0.82rem;
    margin-bottom: 12px;
    max-width: none;
    line-height: 1.45;
  }

  .panel {
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 14px;
  }

  .player-shell {
    border-radius: 14px;
    width: 100%;
  }
  .player {
    border-radius: 12px;
    width: 100%;
    max-height: min(56dvh, 420px);
  }
  .player:fullscreen,
  .player:-webkit-full-screen {
    max-height: none;
  }

  .hints { display: none; }
  .debug { font-size: 0.7rem; }
  .status { font-size: 0.84rem; margin-top: 10px; }
  .meta { font-size: 0.72rem; }
  .foot {
    margin-top: 18px;
    padding-top: 12px;
    font-size: 0.7rem;
    flex-wrap: wrap;
  }

  /* Center play — larger hit target on phone */
  .big-play {
    width: 76px;
    height: 76px;
  }
  .big-play svg { width: 30px; height: 30px; }

  /* Desktop-only chrome stays off the phone bar */
  .ctrl-desk { display: none !important; }

  .topbar {
    padding: 10px 10px 32px;
    gap: 6px;
    align-items: center;
  }
  .topbar .brand-chip { display: none; }
  .topbar .title {
    font-size: 0.8rem;
    max-width: calc(100% - 96px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar .badges,
  .topbar .track-rail {
    flex: 0 0 auto;
    gap: 4px;
    max-width: 58%;
  }
  .track-chip {
    padding: 5px 7px;
    font-size: 0.66rem;
    gap: 4px;
    border-radius: 7px;
  }
  .track-chip .track-flag { width: 16px; height: 11px; }
  .track-chip .track-caret { display: none; }
  .player.is-idle .topbar .title {
    max-width: 42%;
  }

  .controls {
    padding: 24px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .progress {
    height: 22px;
    margin: 0 2px;
  }
  .progress .rail { height: 3px; }
  .progress:active .rail { height: 6px; }
  .progress .knob {
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    opacity: 1;
  }

  .row {
    margin-top: 2px;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    padding: 0 2px 2px;
  }
  .row::-webkit-scrollbar { display: none; }
  .row .spacer {
    flex: 1 1 auto;
    min-width: 6px;
  }

  .btn {
    --tap: 44px;
    min-width: var(--tap);
    min-height: var(--tap);
    font-size: 0.9rem;
    border-radius: 11px;
    flex: 0 0 auto;
  }
  .time {
    font-size: 0.7rem;
    padding: 0 4px;
    flex: 0 0 auto;
  }
  .time-sep { margin: 0 2px; }
  .vol-wrap { display: none !important; }

  /* Menus: see .player.is-touch-ui (in-player native sheets) — no viewport-fixed */

  .ctx-menu {
    position: absolute;
    left: 10px !important;
    right: 10px;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto;
    min-width: 0;
    max-width: none;
    z-index: 95;
    border-radius: 14px;
    background: #14161c;
  }
  .ctx-menu button {
    min-height: 48px;
    font-size: 0.95rem;
    padding: 12px 14px;
  }

  .stream-promo {
    left: 4%;
    right: 4%;
    bottom: 18%;
  }
  .player.is-controls .stream-promo {
    bottom: 30%;
  }
  .stream-promo a {
    font-size: clamp(0.86rem, 3.8vw, 1.05rem);
    padding: 0.55em 0.9em;
  }

  .hotkey-toast {
    font-size: 0.78rem;
    padding: 8px 12px;
  }

  .player.is-paused .controls {
    padding-top: 18px;
  }

  body.theater .wrap { padding: 0; }
  body.theater .player {
    min-height: 100dvh;
    border-radius: 0;
    max-height: none;
  }
  body.theater .player-shell {
    border-radius: 0;
  }
}

@media (max-width: 720px) and (orientation: landscape) {
  .brand, .sub, .panel, .status, .meta, .foot, .debug { display: none; }
  .wrap {
    padding: 0;
    max-width: 100%;
  }
  .player-shell {
    border-radius: 0;
    padding: 0;
  }
  .player {
    border-radius: 0;
    aspect-ratio: auto;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
  }
  .player.is-touch-ui .sheet-root > .menu.open {
    max-height: min(52%, 200px);
    border-radius: 10px 10px 0 0;
  }
  .controls {
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 380px) {
  .big-play { width: 68px; height: 68px; }
  .btn { --tap: 40px; font-size: 0.84rem; }
  .time { font-size: 0.64rem; }
  .topbar .title { font-size: 0.74rem; }
  .menu .menu-sub { font-size: 0.78rem; }
  .menu button,
  .menu .menu-item {
    min-height: 48px;
    font-size: 0.94rem;
  }
}

@media (min-width: 721px) and (max-width: 1024px) {
  .wrap { padding: 18px 16px 32px; }
  form.lookup {
    grid-template-columns: 1fr 1fr 1.2fr 0.7fr 0.7fr;
  }
  form.lookup .go { grid-column: 1 / -1; }
  .ctrl-desk { display: none !important; }
  /* Sheets: .player.is-touch-ui (JS class) — in-player absolute, opaque */
}

/* Embed iframe = full stage; sheet uses player height, not host page */
body.embed-shell .player.is-touch-ui .sheet-root > .menu.open {
  max-height: min(44%, 200px);
}
body.embed-shell .player.is-touch-ui.is-menu-open .topbar {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .player.is-touch-ui .sheet-root > .menu.open {
    animation: none !important;
  }
}
