:root {
  --black: #000000;
  --ink: #F2F2F2;
  --soft: #B3B3B3;
  --mute: #8C8C8C;
  --line: #2E2E2E;
  --panel: #141414;
  --bar-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--black); color: var(--ink); }
body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }

/* progress */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; background: #1C1C1C; z-index: 30; }
.progress-bar { height: 100%; width: 0; background: var(--mute); transition: width .35s var(--ease); }

/* stage */
.viewport {
  position: fixed; left: 0; right: 0; top: 0;
  bottom: var(--bar-h);
  overflow: hidden;
}
.is-full .viewport, .is-gated .viewport { bottom: 0; }
.stage {
  position: absolute; left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform-origin: center center;
  background: var(--black);
}
.slide {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transition: opacity .32s var(--ease), visibility 0s linear .32s;
}
.slide.is-active { opacity: 1; visibility: visible; transition: opacity .32s var(--ease); z-index: 1; }
.slide > img.bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.slide video {
  position: absolute; display: block;
  object-fit: cover;
  background: transparent;
  cursor: pointer;
}
.audio-mark {
  position: absolute; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,.62); display: grid; place-items: center;
  pointer-events: none; opacity: 0; transition: opacity .25s var(--ease);
}
.audio-mark svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.audio-mark.is-on { opacity: 1; }

/* sharp layer, selectable text and links */
.slide canvas.sharp { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.textLayer { position: absolute; inset: 0; overflow: clip; line-height: 1; transform-origin: 0 0; z-index: 0;
  -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; text-align: initial; caret-color: transparent; }
.textLayer { --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(242, 242, 242, .28); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.slide video, .audio-mark { z-index: 2; }
.hot { position: absolute; z-index: 3; border-radius: 6px; cursor: pointer; transition: background-color .2s, box-shadow .2s; }
.hot:hover, .hot:focus-visible { background: rgba(242, 242, 242, .08); box-shadow: 0 0 0 1px rgba(242, 242, 242, .35); outline: none; }

/* bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px;
  padding: 0 max(20px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(20px, env(safe-area-inset-left));
  z-index: 20;
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.is-full .bar { background: linear-gradient(to top, rgba(0,0,0,.8), rgba(0,0,0,0)); }
.is-idle.is-full .bar { opacity: 0; transform: translateY(12px); pointer-events: none; }
.is-gated .bar, .is-gated .progress { opacity: 0; pointer-events: none; }
.bar-home img { height: 18px; width: auto; display: block; opacity: .9; }
.bar-title { font-size: 14px; color: var(--mute); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.bar-tools { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.bar-count { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--soft); min-width: 64px; text-align: center; }
.bar-count .sep { color: #555; margin: 0 4px; }
.btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--soft); transition: color .2s, background-color .2s; }
.btn:hover { color: var(--ink); background: #1A1A1A; }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn-sound .off { display: none; }
.btn-sound[aria-pressed="false"] .on { display: none; }
.btn-sound[aria-pressed="false"] .off { display: block; }
.btn-sound[aria-pressed="true"] { color: var(--ink); }

/* gate */
.gate {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(24px, 5vw, 64px);
  background: linear-gradient(to top, rgba(0,0,0,.92) 0%, rgba(0,0,0,.55) 38%, rgba(0,0,0,0) 70%);
}
.gate-body { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.gate-start {
  font-size: 18px; font-weight: 500;
  padding: 18px 34px; border-radius: 999px;
  background: var(--ink); color: var(--black);
  transition: transform .25s var(--ease), background-color .2s;
}
.gate-start:hover { background: #FFFFFF; transform: translateY(-1px); }
.gate-note { color: var(--soft); max-width: 34ch; font-size: 14px; }
.gate-lock { max-width: 420px; }
.gate-lock label { display: block; color: var(--soft); margin-bottom: 14px; }
.gate-row { display: flex; gap: 10px; }
.gate-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 14px 20px;
}
.gate-row button { padding: 14px 26px; border-radius: 999px; background: var(--ink); color: var(--black); font-weight: 500; }
.gate-error { color: var(--ink); min-height: 1.5em; margin-top: 10px; font-size: 14px; }

/* overview */
.overview {
  position: fixed; inset: 0; z-index: 35; background: var(--black);
  display: flex; flex-direction: column;
  animation: ov-in .28s var(--ease);
}
@keyframes ov-in { from { opacity: 0; transform: scale(1.015); } to { opacity: 1; transform: none; } }
.overview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px max(20px, 4vw); border-bottom: 1px solid #1C1C1C; flex: none;
}
.overview-head img { height: 18px; width: auto; }
.overview-body { overflow-y: auto; padding: 8px max(20px, 4vw) 64px; flex: 1; -webkit-overflow-scrolling: touch; }
.ov-section { padding-top: 36px; }
.ov-section h2 { font-size: 22px; font-weight: 500; letter-spacing: -.01em; margin-bottom: 4px; }
.ov-section p.ov-sub { color: var(--mute); font-size: 14px; margin-bottom: 18px; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px 18px; }
.ov-item { text-align: left; display: block; }
.ov-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--panel); overflow: hidden; outline: 1px solid #1F1F1F; }
.ov-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .45s var(--ease); }
.ov-item:hover .ov-thumb img { transform: scale(1.03); }
.ov-item.is-current .ov-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.ov-play { position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.7); display: grid; place-items: center; }
.ov-play svg { width: 12px; height: 12px; fill: var(--ink); }
.ov-label { display: flex; gap: 10px; margin-top: 9px; font-size: 13px; line-height: 1.35; }
.ov-label .n { color: var(--mute); font-variant-numeric: tabular-nums; flex: none; min-width: 20px; }
.ov-label .t { color: var(--soft); }
.ov-item:hover .ov-label .t, .ov-item.is-current .ov-label .t { color: var(--ink); }

/* rotate hint */
.rotate-hint {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px); transform: translateX(-50%);
  background: var(--panel); color: var(--soft); font-size: 13px; padding: 10px 16px; border-radius: 999px;
  white-space: nowrap; z-index: 25;
}

@media (max-width: 720px) {
  :root { --bar-h: 56px; }
  .bar { grid-template-columns: auto 1fr auto; gap: 12px; }
  .bar-title { display: none; }
  .btn-full { display: none; }
  .btn { width: 38px; height: 38px; }
  .bar-count { min-width: 54px; font-size: 13px; }
  .ov-grid { grid-template-columns: repeat(2, 1fr); gap: 16px 12px; }
  .gate-body { flex-direction: column; align-items: flex-start; gap: 16px; }
}
@media (max-width: 380px) {
  .btn-prev, .btn-next { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .slide.is-active, .progress-bar, .bar, .overview, .ov-thumb img, .gate-start { transition: none !important; animation: none !important; }
}
