:root {
  color-scheme: dark;
  --bg: #08090c;
  --panel: #101319;
  --line: rgba(255,255,255,.10);
  --text: #f4f5f7;
  --muted: #959cab;
  --accent: #d6b15f;
  --sidebar-width: 280px;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  transition: grid-template-columns .2s ease;
}

.app-shell.menu-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.episode-sidebar {
  position: relative;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #12151c 0%, #0c0e13 100%);
  border-right: 1px solid var(--line);
  opacity: 1;
  transition: opacity .12s ease;
}

.app-shell.menu-collapsed .episode-sidebar {
  opacity: 0;
  pointer-events: none;
  border-right: 0;
}

.sidebar-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 82px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(214,177,95,.42);
  border-radius: 50%;
  color: var(--accent);
  font-size: 18px;
}

.brand-title { font-size: 15px; font-weight: 750; line-height: 1.15; }
.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.icon-button, .episodes-button, .round-button, .episode-menu-item {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.sidebar-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  font-size: 24px;
  line-height: 1;
}

.episode-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  overscroll-behavior: contain;
}

.episode-menu-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 10px;
  margin: 2px 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  transition: background .16s ease, color .16s ease;
}

.episode-menu-item:hover { background: rgba(255,255,255,.055); }
.episode-menu-item.is-active { background: rgba(214,177,95,.12); color: #fff7df; }

.menu-episode-number {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}

.episode-menu-item.is-active .menu-episode-number {
  border-color: rgba(214,177,95,.48);
  color: var(--accent);
}

.menu-episode-title {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-area {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  overscroll-behavior: none;
  scrollbar-width: none;
}

.feed::-webkit-scrollbar { display: none; }

.episode {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
}

/* Same geometry on Mac, iPad, Safari, Chrome and Edge. */
.episode video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 575px;
  max-height: 100%;
  object-fit: cover;
  object-position: center top;
  background: #000;
  cursor: pointer;
}

.episode-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.episode-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px 28px 22px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 62%, rgba(0,0,0,.15) 72%, rgba(0,0,0,.72) 100%);
}

.copyright {
  pointer-events: auto;
  margin-top: 12px;
  color: rgba(255,255,255,.50);
  font-size: 10px;
}

.floating-controls {
  position: absolute;
  z-index: 20;
  top: 16px;
  right: 18px;
}

.round-button, .episodes-button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  background: rgba(13,15,20,.74);
  backdrop-filter: blur(14px);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 8px 30px rgba(0,0,0,.20);
}

.menu-open-button {
  display: none;
  position: absolute;
  z-index: 25;
  top: 16px;
  left: 16px;
}

.app-shell.menu-collapsed .menu-open-button { display: block; }

.tap-hint {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.62);
  color: rgba(255,255,255,.82);
  font-size: 12px;
  opacity: 1;
  transition: opacity .45s ease;
  pointer-events: none;
}

.tap-hint.is-hidden { opacity: 0; }

/* Deploy the Tear: keep the original words visible in the upper safe area. */
.video-safe-caption {
  position: absolute;
  z-index: 8;
  top: max(120px, calc(env(safe-area-inset-top) + 92px));
  left: 50%;
  width: min(88%, 560px);
  transform: translateX(-50%);
  padding: 0 12px;
  color: #fff;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 900;
  font-style: italic;
  line-height: 1.12;
  letter-spacing: .01em;
  text-align: center;
  white-space: pre-line;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 4px 12px rgba(0,0,0,.78);
  opacity: 0;
  pointer-events: none;
}
.video-safe-caption.is-visible { opacity: 1; }

/* Same behavior on narrower screens: only make the sidebar slimmer. */
@media (max-width: 860px) {
  :root { --sidebar-width: 220px; }
  .episode-overlay { padding: 20px 16px max(18px, env(safe-area-inset-bottom)); }
  .floating-controls { top: 14px; right: 14px; }
  .menu-open-button { top: 14px; left: 14px; }
}

@media (max-width: 560px) {
  :root { --sidebar-width: 180px; }
  .brand-subtitle { display: none; }
  .sidebar-head { padding-inline: 10px; }
  .episode-list { padding-inline: 6px; }
  .round-button, .episodes-button { min-height: 40px; padding-inline: 12px; font-size: 12px; }
}


/* ==========================================================
   Safari / iPadOS deterministic layout
   Chrome/Edge keep the existing layout above unchanged.
   On WebKit we do not rely on object-fit + viewport sizing.
   app.js supplies the real visible viewport size in pixels.
   ========================================================== */
.app-shell.webkit-layout {
  position: absolute;
  top: var(--webkit-vv-top, 0px);
  left: var(--webkit-vv-left, 0px);
  right: auto;
  bottom: auto;
  width: var(--webkit-vv-width, 100%);
  height: var(--webkit-vv-height, 100%);
  grid-template-columns:
    var(--sidebar-width)
    minmax(0, 1fr);
  overflow: hidden;
}

.app-shell.webkit-layout.menu-collapsed {
  grid-template-columns:
    0
    minmax(0, 1fr);
}

.app-shell.webkit-layout .episode-sidebar {
  height: var(--webkit-vv-height, 100%);
}

.app-shell.webkit-layout .player-area {
  width: var(--webkit-video-width, 575px);
  height: var(--webkit-video-height, 100%);
  min-width: 0;
  min-height: 0;
  justify-self: center;
  align-self: center;
  overflow: hidden;
}

.app-shell.webkit-layout .feed,
.app-shell.webkit-layout .episode,
.app-shell.webkit-layout .episode-stage {
  width: 100%;
  height: 100%;
}

.app-shell.webkit-layout .episode video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center center;
}
