* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0b0f; color: #eee;
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
.hidden { display: none !important; }

/* 로그인 */
.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card { background: #16161d; padding: 32px; border-radius: 14px; width: 300px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 40px #0008; }
.login-card h1 { font-size: 20px; margin: 0 0 8px; }
.login-card input { padding: 11px; border-radius: 8px; border: 1px solid #333;
  background: #0d0d12; color: #eee; font-size: 15px; }
.login-card button { padding: 11px; border: 0; border-radius: 8px; background: #4c7ef3;
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.err { color: #f66; font-size: 13px; min-height: 16px; margin: 0; }

/* 스테이지 */
.stage { display: grid; place-items: center; height: 100%; }
.video-wrap { position: relative; width: 100%; max-width: 1100px; aspect-ratio: 16/9;
  background: #000; overflow: hidden; }
.video-wrap:fullscreen { max-width: none; width: 100%; height: 100%; }
/* 영상 여백 — 강의 영상은 자막이 화면에 박혀 나와(하단 검은 띠) 프레임 바닥에 붙어 보인다.
   영상을 사방 --video-inset 만큼 들여 그려 자막을 바닥에서 띄운다. top/bottom % 는 높이,
   left/right % 는 폭 기준이라 16:9 비율은 그대로 유지된다. 여백은 wrap 배경(검정). */
.video-wrap { --video-inset: 5%; }
video { position: absolute; top: var(--video-inset); left: var(--video-inset);
  width: calc(100% - 2 * var(--video-inset)); height: calc(100% - 2 * var(--video-inset));
  display: block; background: #000; }
/* 썸네일 poster 는 검은 여백 없이 화면을 채우도록(16:9 외 원본 대응) */
video { object-fit: contain; }

/* ── 재생자 정보 워터마크 (불펌 방지) ──
   흐릿하게 얹되 클릭·선택은 통과시키고, 위치는 JS 가 주기적으로 옮긴다.
   컨트롤(z-index 8)보다 아래·영상보다 위에 둔다. */
.viewer-mark { position: absolute; z-index: 6; pointer-events: none; user-select: none;
  white-space: nowrap; color: #fff; font-weight: 600; letter-spacing: .3px;
  text-shadow: 0 1px 3px #000a, 0 0 1px #0008;
  transition: left .6s ease, top .6s ease; }
.viewer-mark:empty { display: none; }

/* 제스처 영역 (Phase 3-2) */
.gesture { position: absolute; top: 0; bottom: 64px; width: 33%; z-index: 5; }
.gesture.left { left: 0; } .gesture.right { right: 0; }
.skip-hint { position: absolute; top: 50%; transform: translateY(-50%);
  background: #000a; padding: 14px 18px; border-radius: 40px; font-size: 15px; z-index: 6;
  transition: opacity .2s; }
.skip-hint.left { left: 8%; } .skip-hint.right { right: 8%; }

.bigplay { position: absolute; inset: 0; margin: auto; width: 84px; height: 84px;
  display: grid; place-items: center; font-size: 34px; background: #000a; border-radius: 50%;
  cursor: pointer; z-index: 7; }
.spinner { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; z-index: 7;
  pointer-events: none; /* ▶ 위에 겹쳐도 탭은 ▶ 로 */
  border: 4px solid #fff3; border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 컨트롤 */
.controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px 10px;
  background: linear-gradient(transparent, #000c); z-index: 8; transition: opacity .25s;
  display: flex; flex-direction: column; gap: 6px; }
.video-wrap.idle .controls { opacity: 0; pointer-events: none; }
/* 컨트롤바가 사라지는 것과 같은 타이밍에 마우스 커서도 감춘다(전체화면 시청) */
.video-wrap.idle { cursor: none; }
.seek-row { padding: 6px 2px; position: relative; }

/* 시크바 장면 미리보기 — 드래그/호버 지점의 프레임을 스프라이트에서 잘라 표시 */
.seek-preview { position: absolute; bottom: 22px; transform: translateX(-50%);
  background: #000c; border: 1px solid #ffffff2e; border-radius: 8px; padding: 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none; z-index: 9; }
.seek-preview-img { background-repeat: no-repeat; border-radius: 4px; background-color: #000; }
.seek-preview-time { font-size: 12px; color: #fff; font-variant-numeric: tabular-nums; }
.seekbar { position: relative; height: 6px; background: #ffffff33; border-radius: 3px; cursor: pointer;
  touch-action: none; /* 터치 드래그 스크럽 허용(스크롤 제스처로 안 뺏김) */ }
.seekbar:hover { height: 8px; }
/* 보이는 바(6px)보다 넓은 터치/클릭 히트영역 */
.seekbar::before { content: ''; position: absolute; left: 0; right: 0; top: -12px; bottom: -12px; }
.buffered, .played, .watermark { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; }
.buffered { background: #ffffff44; }
.watermark { background: #ffffff22; }        /* 최대 시청 지점 (잠금정책 상한) */
.played { background: #4c7ef3; }
.thumb { position: absolute; top: 50%; width: 13px; height: 13px; background: #fff;
  border-radius: 50%; transform: translate(-50%, -50%); }
/* 항상 한 줄 — 좁은 화면에서 두 줄로 접히면 컨트롤바가 커져 가운데 재생 버튼을 덮는다.
   공간이 모자라면 버튼은 유지하고 시간 표기만 말줄임으로 줄인다. */
.btn-row { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; }
.btn-row > * { flex-shrink: 0; }
.ctrl { background: none; border: 0; color: #fff; font-size: 15px; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; min-width: 34px; white-space: nowrap; }
.ctrl:hover { background: #ffffff22; }
.ctrl svg { width: 18px; height: 18px; fill: currentColor; display: block; margin: 0 auto;
  pointer-events: none; }
.time { font-size: 13px; color: #ddd; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 음량 */
.vol { display: flex; align-items: center; }
.vol-slider { -webkit-appearance: none; appearance: none; width: 0; opacity: 0;
  height: 4px; background: #ffffff44; border-radius: 2px; cursor: pointer;
  transition: width .2s, opacity .2s; touch-action: none; }
/* 호버/포커스 시에만 슬라이더 확장 — 컨트롤바 공간 절약 */
.vol:hover .vol-slider, .vol:focus-within .vol-slider, .vol-slider:active {
  width: 72px; opacity: 1; margin-right: 4px; }
.vol-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px;
  background: #fff; border-radius: 50%; border: 0; }
.vol-slider::-moz-range-thumb { width: 12px; height: 12px; background: #fff;
  border-radius: 50%; border: 0; }
/* 터치 기기(호버 없음)는 항상 노출 */
@media (hover: none) {
  .vol-slider { width: 64px; opacity: 1; margin-right: 4px; }
}
.spacer { flex: 1; }

/* 휴대폰 폭(앱 웹뷰 강의 화면 ≈ 360~440px). iframe 안이므로 iframe 폭 기준으로 적용된다.
   간격·글자를 줄이고, 음량 슬라이더(기기 음량 버튼으로 대체)와 화질 부가표기를 숨긴다. */
@media (max-width: 480px) {
  .controls { padding: 4px 8px 6px; gap: 2px; }
  .btn-row { gap: 2px; }
  .ctrl { padding: 4px 6px; min-width: 30px; font-size: 13px; }
  .time { font-size: 12px; }
  .vol .vol-slider { display: none; }
  .q-detail { display: none; }
  /* 배속 7단계를 2열로 — 세로 7줄이면 휴대폰 높이(≈200px)를 넘어 윗줄이 잘린다 */
  .popup { bottom: 34px; padding: 4px; min-width: 0; }
  .popup button { padding: 6px 10px; font-size: 13px; }
  #rateMenu { display: grid; grid-template-columns: 1fr 1fr; }
}
/* 낮은 임베드: 가운데 재생 버튼을 줄여 컨트롤바와 겹치지 않게 */
@media (max-height: 240px) {
  .bigplay { width: 56px; height: 56px; font-size: 24px; }
}

.menu { position: relative; }
/* 높이 상한: 낮은 임베드에서 메뉴 윗부분이 화면 밖으로 잘리지 않게(넘치면 스크롤) */
.popup { position: absolute; bottom: 42px; right: 0; background: #1c1c24; border-radius: 8px;
  padding: 6px; min-width: 96px; box-shadow: 0 6px 24px #000a;
  max-height: calc(100vh - 52px); overflow-y: auto; }
.popup button { display: block; width: 100%; text-align: left; background: none; border: 0;
  color: #ddd; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.popup button:hover { background: #ffffff18; }
.popup button.active { color: #4c7ef3; font-weight: 700; }

.badge { position: absolute; top: 10px; left: 12px; background: #000a; padding: 5px 10px;
  border-radius: 6px; font-size: 12px; z-index: 8; opacity: 0; transition: opacity .3s; }
.badge.show { opacity: 1; }
