:root {
  color-scheme: dark;
  --viewer-bg: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(255, 255, 255, 0.18);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent: #38bdf8;
  --accent-strong: #00c9a7;
  --warning: #ff6b35;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: 'Noto Sans KR', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.22), transparent 36rem),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.16), transparent 30rem),
    var(--viewer-bg);
  color: var(--text-main);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

#deck-viewer {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 16px;
}

#slide-stage {
  position: relative;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#slide-frame-shell {
  position: relative;
  width: 1280px;
  height: 720px;
  flex: 0 0 auto;
  transform-origin: center center;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.14);
}

#slide-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 1280px;
  height: 720px;
  border: 0;
  background: #ffffff;
}

#highlight-overlay {
  position: absolute;
  inset: 0;
  width: 1280px;
  height: 720px;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

#highlight-caption {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: 920px;
  padding: 12px 18px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0, 53, 102, 0.92), rgba(0, 201, 167, 0.9));
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  letter-spacing: -0.02em;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.26);
  z-index: 6;
  pointer-events: none;
  animation: captionPop 360ms ease-out both;
}

.focus-box,
.focus-circle {
  fill: transparent;
  stroke: #ffd400;
  stroke-width: 9px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 0 10px rgba(255, 212, 0, 0.85)) drop-shadow(0 0 22px rgba(255, 212, 0, 0.42));
  animation: focusSnap 300ms ease-out both, focusBreath 620ms ease-in-out infinite alternate;
}

.focus-underline {
  stroke: #ffd400;
  stroke-width: 10px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  animation: drawUnderline 420ms ease-out both;
}

@keyframes focusSnap {
  0% {
    opacity: 0;
    transform: scale(0.94);
  }
  62% {
    opacity: 1;
    transform: scale(1.035);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes focusBreath {
  0% {
    opacity: 0.76;
    stroke-width: 7px;
  }
  100% {
    opacity: 1;
    stroke-width: 11px;
  }
}

@keyframes drawUnderline {
  0% {
    stroke-dasharray: 0 1400;
  }
  100% {
    stroke-dasharray: 1400 0;
  }
}

@keyframes captionPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

#missing-slide-message {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 48px));
  padding: 28px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.92);
  color: var(--text-main);
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  z-index: 20;
}

#missing-slide-message strong,
#missing-slide-message span {
  display: block;
}

#missing-slide-message strong {
  margin-bottom: 10px;
  font-size: 20px;
}

#missing-slide-message span {
  color: var(--text-muted);
  line-height: 1.55;
}

#deck-controls {
  width: min(980px, calc(100vw - 32px));
  justify-self: center;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
}

#deck-controls button,
#page-navigator button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 900;
  color: #082f49;
  background: linear-gradient(135deg, #e0f2fe, #38bdf8);
  transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
}

#deck-controls button:hover:not(:disabled),
#page-navigator button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

#deck-controls button:active:not(:disabled),
#page-navigator button:active:not(:disabled) {
  transform: translateY(0);
}

#deck-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

#audio-panel {
  min-width: 0;
  display: grid;
  gap: 8px;
}

#slide-meta-row,
#audio-control-row,
#audio-progress-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#slide-counter {
  flex: 0 0 auto;
  min-width: 78px;
  margin: 0;
  color: var(--text-main);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.04em;
}

#segment-title {
  min-width: 0;
  max-width: 580px;
  margin: 0;
  color: var(--text-muted);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#play-audio.is-playing {
  color: #fff7ed;
  background: linear-gradient(135deg, #ff6b35, #fb923c);
}

#auto-advance-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

#audio-progress-row {
  width: 100%;
}

#audio-current-time,
#audio-duration {
  min-width: 42px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

#audio-progress {
  width: min(520px, 100%);
  accent-color: var(--accent-strong);
  cursor: pointer;
}

#page-navigator {
  width: min(1080px, calc(100vw - 32px));
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(26, minmax(30px, 1fr));
  gap: 5px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(12px);
}

#page-navigator button {
  min-height: 32px;
  padding: 0 4px;
  font-size: 12px;
  background: rgba(226, 232, 240, 0.92);
}

#page-navigator button.is-current {
  color: #ffffff;
  background: linear-gradient(135deg, #00c9a7, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 201, 167, 0.28);
}

@media (max-width: 920px) {
  #deck-viewer {
    padding: 10px;
    gap: 9px;
  }

  #slide-frame-shell {
    border-radius: 10px;
  }

  #deck-controls {
    width: calc(100vw - 20px);
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
  }

  #prev-slide,
  #next-slide {
    width: 100%;
  }

  #slide-meta-row,
  #audio-control-row,
  #audio-progress-row {
    flex-wrap: wrap;
  }

  #segment-title {
    max-width: calc(100vw - 80px);
    text-align: center;
  }

  #page-navigator {
    width: calc(100vw - 20px);
    grid-template-columns: repeat(13, minmax(24px, 1fr));
  }

  #page-navigator button {
    min-height: 28px;
    font-size: 11px;
  }
}
