:root {
  --stage: #0b1418;
  --bar: rgba(9, 20, 25, .86);
  --bar-ink: #e9f2f3;
  --bar-muted: #9ab0b6;
  --mint: #1fc79b;
  --navy: #0f2e3d;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--stage); color: var(--bar-ink); font-family: var(--font); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; border-radius: 8px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- without JS: a plain scrolling list of slides ---- */
.slides { list-style: none; margin: 0 auto; padding: 72px 16px 32px; max-width: 1280px; display: grid; gap: 16px; }
.slides img { display: block; width: 100%; height: auto; border-radius: 6px; }

html:not(.js) [data-action], html:not(.js) .stage-hit { display: none !important; }
.i-exit { display: none; }

/* ---- with JS: one slide at a time ---- */
.js, .js body { height: 100%; overflow: hidden; }
.js .slides {
  position: fixed; inset: 0; max-width: none; padding: 0; margin: 0;
  display: block;
}
.js .slide { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.js .slide.is-current { display: flex; }
.js .slides img {
  width: 100vw; height: 100vh; height: 100dvh;
  object-fit: contain; border-radius: 0;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
}
.js .stage-hit { position: fixed; inset: 0; z-index: 1; touch-action: pan-y pinch-zoom; }

/* ---- top bar ---- */
.bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(to bottom, var(--bar) 0%, var(--bar) 70%, rgba(9, 20, 25, 0) 100%);
  transition: opacity .25s, transform .25s;
}
.bar-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title small { font-weight: 500; color: var(--bar-muted); margin-left: 10px; }
.ibtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; min-width: 40px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  text-decoration: none; color: var(--bar-ink); font-size: 14px; font-weight: 600;
}
.ibtn:hover { background: rgba(255, 255, 255, .1); }
.ibtn svg { width: 20px; height: 20px; flex: none; }
.ibtn[hidden] { display: none; }
.counter { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--bar-muted); padding: 0 8px; white-space: nowrap; }
.back span { white-space: nowrap; }

.progress { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; z-index: 10; background: rgba(255, 255, 255, .08); transition: opacity .25s; }
.progress span { display: block; height: 100%; background: var(--mint); transform-origin: left; transform: scaleX(0); transition: transform .2s; }

.ui-idle .bar { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.ui-idle .progress { opacity: 0; }
.ui-idle, .ui-idle * { cursor: none !important; }

/* ---- edge arrows (pointer devices) ---- */
.nav-arrow {
  position: fixed; top: 50%; z-index: 5; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(9, 20, 25, .55); color: #fff; display: grid; place-items: center;
  opacity: 0; transition: opacity .2s;
}
.nav-arrow svg { width: 24px; height: 24px; }
.nav-arrow.prev { left: 14px; }
.nav-arrow.next { right: 14px; }
@media (hover: hover) {
  body:not(.ui-idle) .nav-arrow { opacity: .7; }
  .nav-arrow:hover { opacity: 1 !important; background: rgba(9, 20, 25, .8); }
}
.nav-arrow:disabled { visibility: hidden; }

/* ---- overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(7, 14, 17, .94);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 72px 20px 32px;
}
.overlay[hidden] { display: none; }
.overlay-head { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: rgba(7, 14, 17, .96); z-index: 1; }
.overlay-head h2 { margin: 0; font-size: 16px; }
.thumbs { list-style: none; margin: 0 auto; padding: 0; max-width: 1200px; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.thumb { display: block; width: 100%; padding: 0; border: 2px solid transparent; border-radius: 10px; background: none; cursor: pointer; text-align: left; overflow: hidden; }
.thumb img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: #1a2a30; }
.thumb span { display: block; padding: 6px 4px 2px; font-size: 13px; color: var(--bar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb:hover { border-color: rgba(31, 199, 155, .5); }
.thumb[aria-current="true"] { border-color: var(--mint); }
.thumb[aria-current="true"] span { color: var(--mint); font-weight: 700; }

.help-card { max-width: 560px; margin: 0 auto; }
.help-card dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; font-size: 15px; }
.help-card dt { text-align: right; white-space: nowrap; }
.help-card dd { margin: 0; color: #cfdde0; }
kbd {
  display: inline-block; min-width: 1.9em; padding: 1px 7px; margin: 0 2px;
  font: 600 12px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; text-align: center;
  color: #fff; background: #1c3540; border: 1px solid #2e4c58; border-bottom-width: 2px; border-radius: 6px;
}

.blank { position: fixed; inset: 0; z-index: 30; background: #000; cursor: none; }
.blank[data-color="white"] { background: #fff; }
.blank[hidden] { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 40; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; background: rgba(9, 20, 25, .92);
  font-size: 15px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.toast[hidden] { display: none; }

@media (max-width: 640px) {
  .bar { gap: 2px; padding-left: 8px; padding-right: 8px; }
  .bar-title small, .back span, .dl span { display: none; }
  .counter { padding: 0 4px; }
  .thumbs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .nav-arrow { display: none; }
}
.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 640px) {
  .js .rotate-hint {
    display: block; position: fixed; left: 0; right: 0; bottom: max(28px, env(safe-area-inset-bottom));
    z-index: 2; margin: 0; text-align: center; font-size: 13px; color: var(--bar-muted);
    pointer-events: none; transition: opacity .25s;
  }
  .ui-idle .rotate-hint { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bar, .progress, .progress span, .nav-arrow { transition: none; }
}
