:root {
  --bg: #0b0b10;
  --panel: #14141c;
  --fg: #f2f2f7;
  --dim: #8a8a99;
  --accent: #ff2d78;
  --accent2: #34e5ff;
  --ok: #3ddc97;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
        "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #22222e;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar h1 span { color: var(--accent); }

.urlform {
  display: flex;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 240px;
}

.urlform input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #2a2a38;
  background: #10101a;
  color: var(--fg);
  font-size: 14px;
}
.urlform input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid #2a2a38;
  background: #1b1b26;
  color: var(--fg);
  padding: 9px 14px;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:disabled {
  background: #33333f;
  border-color: #33333f;
  color: var(--dim);
  cursor: default;
}
button.ghost { background: transparent; }
button.ghost:disabled { color: #44444f; border-color: #22222e; cursor: default; }

.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-color: #ff2d7866;
  background: #ff2d781a;
  color: #ff7eac;
  font-weight: 700;
}
.record-btn:not(:disabled):hover { border-color: var(--accent); background: #ff2d7829; }
.record-btn:disabled { opacity: 0.38; cursor: default; }
.record-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px #ff2d7822;
}

/* <input type=file>은 스타일이 안 먹어서 label을 버튼처럼 쓴다 */
.filebtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid #2a2a38;
  background: #1b1b26;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.filebtn:hover { border-color: var(--accent2); }
.filebtn:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid #2a2a38;
  border-radius: 10px;
  background: #10101a;
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
}
.speed-control[hidden] { display: none; }
.speed-control input { width: 86px; accent-color: var(--accent); }
.speed-control output {
  min-width: 2.5em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.speed-control:focus-within { border-color: var(--accent); }

/* ---------- dance gallery ---------- */

.dance-gallery {
  padding: 10px 14px 12px;
  border-bottom: 1px solid #22222e;
  background: #0d0d14;
}

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto 8px;
}

.gallery-heading {
  display: flex;
  align-items: center;
  gap: 7px;
}

.gallery-heading h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.gallery-heading span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 99px;
  background: #242431;
  color: var(--dim);
  font-size: 10px;
  text-align: center;
}

.gallery-controls {
  display: flex;
  gap: 5px;
}

.gallery-controls button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  color: var(--dim);
  font-size: 21px;
  line-height: 1;
}

.gallery-controls button:not(:disabled):hover { color: var(--fg); border-color: var(--accent2); }
.gallery-controls button:disabled { opacity: 0.28; cursor: default; }

.gallery-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 270px);
  gap: 9px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1px 1px 5px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-snap-type: inline proximity;
  scrollbar-color: #343442 transparent;
  scrollbar-width: thin;
}

.gallery-track:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 3px;
  border-radius: 10px;
}

.gallery-card {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 72px;
  padding: 7px;
  overflow: hidden;
  border-color: #292936;
  background: #15151e;
  text-align: left;
  scroll-snap-align: start;
}

.gallery-card:hover { border-color: #4a4a5d; background: #1a1a25; }
.gallery-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: #ff2d7810;
  box-shadow: inset 0 0 0 1px #ff2d7833;
}

.gallery-thumb {
  display: block;
  width: 52px;
  height: 56px;
  border-radius: 7px;
  background: #050508;
  object-fit: cover;
}

.gallery-card-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.gallery-card-copy b,
.gallery-card-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-copy b { font-size: 13px; }
.gallery-card-copy small { color: var(--dim); font-size: 10px; }
.gallery-play {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff12;
  color: var(--fg);
  font-size: 9px;
}
.gallery-card[aria-pressed="true"] .gallery-play { background: var(--accent); }

/* ---------- stage ---------- */

.stage {
  flex: 1;
  display: flex;
  gap: 20px;
  padding: 18px 14px 8px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

/* 9:16 무대. 세로 숏폼에 맞춘 비율이라 필러박스가 최소화된다. */
.frame {
  position: relative;
  width: min(46vh, 92vw);
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 40px #0008;
  flex: 0 0 auto;
}

.frame #player,
.frame iframe,
.frame .filevideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* 9:16 무대에 어떤 비율이 와도 잘리지 않게 — 레터박스는 포즈 추출에 영향이 없다
   (파일은 videoWidth/Height가 원본 좌표계라 크롭 감지 자체가 불필요하다) */
.frame .filevideo {
  object-fit: contain;
  background: #000;
  z-index: 1;
}
.frame .filevideo[hidden] { display: none; }

/* 좌우 반전: 플레이어만 뒤집는다. .frame 전체를 뒤집으면 HUD 점수 글자까지 거꾸로 나온다.
   오버레이 캔버스는 그대로 두고 좌표를 JS에서 뒤집는다(크롭 박스 등은 화면 좌표계다). */
.frame.flip #player,
.frame.flip iframe,
.frame.flip .filevideo { transform: scaleX(-1); }

.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* 플레이어 클릭을 삼키지 않도록 */
  z-index: 3;
}

/* YouTube 함께 녹화는 현재 탭 픽셀을 쓰므로, 피드백 제외 옵션은 캡처 대상에서 숨긴다. */
.frame.record-feedback-hidden .overlay,
.frame.record-feedback-hidden .hud,
.frame.record-feedback-hidden .grade,
.frame.record-feedback-hidden .round-card { visibility: hidden; }

/* 녹화 결과에도 그대로 들어가는 셀프 카메라 PiP. */
.camera-pip {
  position: absolute;
  left: 64%;
  top: 71.75%;
  z-index: 4;
  width: 31%;
  height: 23.25%;
  overflow: hidden;
  border: 2px solid #fffffff0;
  border-radius: clamp(9px, 2.4vw, 15px);
  background: #111;
  box-shadow: 0 8px 24px #000a;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.camera-pip[hidden] { display: none; }
.camera-pip canvas { width: 100%; height: 100%; display: block; }
.camera-pip:active { cursor: grabbing; }
.camera-pip:focus-visible {
  outline: 3px solid var(--accent2);
  outline-offset: 2px;
}
.camera-pip.pip-fullscreen-active {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.pip-label {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  padding: 2px 5px;
  border-radius: 5px;
  background: #0009;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.pip-control {
  position: absolute;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.camera-pip:hover .pip-control,
.camera-pip:focus-within .pip-control {
  opacity: 1;
  pointer-events: auto;
}
.camera-pip.pip-fullscreen-active .pip-resize { display: none; }
.pip-fullscreen {
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-color: #ffffff66;
  background: #09090dcc;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
}
.pip-resize {
  width: clamp(18px, 26%, 30px);
  height: clamp(18px, 20%, 30px);
  cursor: nwse-resize;
}
.pip-resize::after {
  content: '';
  position: absolute;
  bottom: 5px;
  width: 12px;
  height: 12px;
  border-bottom: 3px solid #fff;
}
.pip-resize-top-left { top: 0; left: 0; }
.pip-resize-top-left::after {
  top: 5px;
  bottom: auto;
  left: 5px;
  border-top: 3px solid #fff;
  border-bottom: 0;
  border-left: 3px solid #fff;
}
.pip-resize-left { bottom: 0; left: 0; cursor: nesw-resize; }
.pip-resize-left::after {
  left: 5px;
  border-left: 3px solid #fff;
}
.pip-resize-right { right: 0; bottom: 0; }
.pip-resize-right::after {
  right: 5px;
  border-right: 3px solid #fff;
}
.pip-resize:focus-visible,
.pip-fullscreen:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent2);
  outline-offset: -2px;
}
.frame.pip-locked .camera-pip { cursor: default; }
.frame.pip-locked .pip-control { display: none; }

@media (hover: none), (pointer: coarse) {
  .camera-pip .pip-control {
    opacity: 1;
    pointer-events: auto;
  }
}

.recording-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 5px 6px 5px 9px;
  border: 1px solid #ffffff26;
  border-radius: 99px;
  background: #09090dd9;
  backdrop-filter: blur(5px);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.recording-badge[hidden] { display: none; }
.recording-badge > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: recPulse 1.1s ease-in-out infinite;
}
.recording-badge button {
  padding: 3px 7px;
  border: 0;
  border-radius: 99px;
  background: #fff;
  color: #111;
  font-size: 9px;
  font-weight: 800;
}
@keyframes recPulse { 50% { opacity: 0.35; } }

.countdown {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #08080bb3;
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.countdown[hidden] { display: none; }
.countdown strong {
  font-size: clamp(84px, 18vw, 150px);
  line-height: 0.9;
  color: #fff;
  text-shadow: 0 0 36px #ff2d78aa;
  animation: countPop 700ms ease-out;
}
.countdown .countdown-label {
  margin-bottom: 18px;
  color: var(--accent2);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.countdown .countdown-hint { margin-top: 18px; color: #ffffffb8; font-weight: 700; }
@keyframes countPop { from { opacity: 0; transform: scale(1.35); } }

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 4;
  pointer-events: none;
  text-shadow: 0 2px 8px #000c;
}

.score { display: flex; align-items: baseline; gap: 8px; }
.score-num {
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-label { font-size: 11px; color: var(--dim); letter-spacing: 0.18em; }

.meter {
  height: 6px;
  margin-top: 6px;
  border-radius: 99px;
  background: #ffffff22;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent2), var(--ok));
  transition: width 90ms linear;
}

.stats {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11px;
  color: #dcdce6;
  letter-spacing: 0.06em;
}

/* 점수 분해 — 자세/움직임/타이밍 중 어디서 깎였는지 */
.axes {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.axis {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}

.axis b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #dcdce6;
}

.grade {
  position: absolute;
  inset: auto 0 22% 0;
  z-index: 4;
  text-align: center;
  font-size: 40px;
  font-weight: 900;
  font-style: italic;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 3px 14px #000a;
}
.grade.show { animation: pop 520ms ease-out; }
@keyframes pop {
  0%   { opacity: 0; transform: scale(0.7); }
  25%  { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1); }
}

/* ---------- 중지 가림막 ---------- */
/* 판 종료 카드(z 5)보다 위. 중지 중에는 이쪽이 화면의 주인이다. */

.pause-veil {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: #0b0b10b8;
  backdrop-filter: blur(3px);
  animation: cardIn 180ms ease-out;
}
.pause-veil[hidden] { display: none; }

.pause-veil .resume {
  width: 62px;
  height: 62px;
  margin-bottom: 10px;
  padding: 0;
  border-radius: 99px;
  border-color: #ffffff2e;
  background: #ffffff14;
  font-size: 22px;
  line-height: 1;
}
.pause-veil .resume:hover { background: #ffffff24; }
.pause-veil .resume:focus-visible { outline: 2px solid var(--accent2); outline-offset: 3px; }

.pv-title { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; }
.pv-sub { font-size: 12px; color: #dcdce6; }
.pause-veil small { margin-top: 4px; font-size: 11px; color: var(--dim); }

/* ---------- 판 종료 카드 ---------- */

.round-card {
  position: absolute;
  inset: auto 12px 12px;
  z-index: 5;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0b0b10e6;
  border: 1px solid #2a2a38;
  backdrop-filter: blur(6px);
  text-align: center;
  pointer-events: none;
  animation: cardIn 320ms ease-out;
}
.round-card[hidden] { display: none; }
.frame.timeline-enabled .round-card { bottom: 62px; }
.rc-title { font-size: 11px; letter-spacing: 0.18em; color: var(--accent); font-weight: 700; }
.rc-num {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.rc-label { font-size: 11px; color: var(--dim); letter-spacing: 0.14em; }
.rc-sub { margin-top: 6px; font-size: 12px; color: #dcdce6; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 취약 구간 집중 반복 ---------- */

.practice-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #34e5ff66;
  border-radius: 11px;
  background: #0b0b10e8;
  box-shadow: 0 8px 24px #0009;
  backdrop-filter: blur(6px);
  font-size: 11px;
}
.practice-bar[hidden] { display: none; }
.practice-bar div { display: flex; flex-direction: column; min-width: 0; }
.practice-bar b { color: var(--accent2); letter-spacing: 0.08em; }
.practice-bar span { color: #dcdce6; font-variant-numeric: tabular-nums; }
.practice-bar button { flex: 0 0 auto; padding: 5px 8px; font-size: 10px; }
.frame.timeline-enabled .practice-bar { bottom: 62px; }

/* ---------- 로컬 비디오 타임바 ---------- */

.file-timeline {
  --timeline-progress: 0%;
  position: absolute;
  inset: auto 10px 10px;
  z-index: 7;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid #ffffff26;
  border-radius: 10px;
  background: #0b0b10d9;
  color: var(--fg);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 18px #0008;
  backdrop-filter: blur(5px);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}
.file-timeline[hidden] { display: none; }
.frame.timeline-enabled:hover .file-timeline,
.file-timeline:focus-within {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.file-timeline input {
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background: transparent;
}
.file-timeline input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg,
    var(--accent2) 0 var(--timeline-progress),
    #ffffff38 var(--timeline-progress) 100%);
}
.file-timeline input::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: #ffffff38;
}
.file-timeline input::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--accent2);
}
.file-timeline input::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border: 2px solid var(--fg);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent2);
  box-shadow: 0 1px 5px #000b;
}
.file-timeline input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 2px solid var(--fg);
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 1px 5px #000b;
}
.file-timeline input:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 3px;
  border-radius: 4px;
}
.file-timeline input:disabled { cursor: progress; opacity: 0.45; }

@media (prefers-reduced-motion: reduce) {
  .file-timeline { transition: none; }
}

@media (hover: none), (pointer: coarse) {
  .frame.timeline-enabled .file-timeline {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

/* ---------- panel ---------- */

.panel {
  flex: 0 1 340px;
  /* 플렉스 아이템의 기본 min-width:auto 는 자식의 max-content 폭을 그대로 물려받는다.
     그래프 트랙이 width:max-content 라 이걸 안 끄면 패널이 판 수만큼 넓어지고
     가로 스크롤이 아예 생기지 않는다. */
  min-width: 0;
  background: var(--panel);
  border: 1px solid #22222e;
  border-radius: var(--radius);
  padding: 16px;
}

.steps { list-style: none; margin: 0; padding: 0; }

.step {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid #22222e;
  color: var(--dim);
}
.step:last-child { border-bottom: 0; }
/* 자식 선택자 — 설명문(small) 안의 <b>까지 배지로 만들지 않도록 */
.step > b {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 99px;
  background: #2a2a38;
  color: var(--dim);
  font-size: 11px;
  margin-right: 6px;
}
.step.active { color: var(--fg); }
.step.active > b { background: var(--accent); color: #fff; }
.step.done { color: var(--ok); }
.step.done > b { background: var(--ok); color: #06110c; }
.step small b { color: var(--fg); }
.step small { color: var(--dim); font-size: 12px; }
.step button { align-self: flex-start; }

.selfwrap {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* display 값이 있으면 [hidden]의 기본 규칙을 이겨버린다 */
.selfwrap[hidden] { display: none; }
.selfview {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 10px;
  border: 1px solid #2a2a38;
}
.calib {
  font-size: 12px;
  color: var(--fg);
}
.calib .eta { color: var(--dim); font-weight: 400; }

/* 프리스캔 중 미리보기는 세로 영상이 많아 4:3 틀에 가둘 이유가 없다 */
.selfwrap.scanning .selfview { aspect-ratio: 3 / 4; }
.selfwrap #btnSkipScan { align-self: flex-start; font-size: 12px; padding: 6px 10px; }
.selfwrap #btnSkipScan[hidden] { display: none; }
.selfwrap small { color: var(--dim); font-size: 11px; line-height: 1.4; }

.status {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--dim);
  min-height: 2.6em;
  white-space: pre-line;
}
.status.err { color: #ff7b7b; }

/* ---------- 판 기록 / 추세 그래프 ---------- */

.results {
  --plot: 84px;   /* 막대가 그려지는 높이 = 0~100점 */
  --padtop: 16px; /* 그래프 위 여백. 눈금선 위치 계산에 쓰인다 */
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #22222e;
}
.results[hidden] { display: none; }

.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.rlast { display: flex; align-items: baseline; gap: 8px; }
.rlast-num {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.rlast-meta { display: flex; flex-direction: column; }
.rlast-label { font-size: 11px; color: var(--dim); letter-spacing: 0.08em; }
.delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--accent); }
.delta.flat { color: var(--dim); }

.rstats {
  display: flex;
  gap: 14px;
  margin: 2px 0 0;
  flex-wrap: wrap;
}
.rstats div { margin: 0; }
.rstats dt { font-size: 10px; color: var(--dim); letter-spacing: 0.06em; }
.rstats dd {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rstats dd .delta { margin-left: 3px; font-size: 10px; }

/* 가로 스크롤 추세 그래프 — 판이 쌓이면 오른쪽으로 늘어난다 */
.chart {
  margin-top: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  background: #10101a;
  border: 1px solid #22222e;
  scrollbar-width: thin;
  scrollbar-color: #33333f transparent;
}
.chart:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.chart::-webkit-scrollbar { height: 8px; }
.chart::-webkit-scrollbar-thumb { background: #33333f; border-radius: 99px; }
.chart::-webkit-scrollbar-track { background: transparent; }

.chart-track {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: var(--padtop) 10px 6px;
  width: max-content;
  min-width: 100%;
}

/* 100점 / 50점 눈금선. 막대와 같이 스크롤돼야 눈금이 어긋나 보이지 않는다. */
.chart-track::before,
.chart-track::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  pointer-events: none;
}
.chart-track::before { top: var(--padtop); background: #ffffff14; }
.chart-track::after { top: calc(var(--padtop) + var(--plot) / 2); background: #ffffff0d; }

.bar {
  flex: 0 0 auto;
  width: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.bar-plot {
  position: relative;
  height: var(--plot);
  width: 100%;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid #ffffff1f;
}
.bar-fill {
  position: relative;
  width: 100%;
  min-height: 3px;
  border-radius: 5px 5px 1px 1px;
  transition: height 240ms ease-out;
}
.bar-val {
  position: absolute;
  bottom: 100%;
  left: -6px;
  right: -6px;
  margin-bottom: 3px;
  text-align: center;
  font-size: 9px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.bar-x {
  margin-top: 5px;
  font-size: 9px;
  color: #55555f;
  font-variant-numeric: tabular-nums;
}
.bar.latest .bar-val { color: var(--fg); font-weight: 700; }
.bar.latest .bar-x { color: var(--fg); }
.bar.latest .bar-fill { box-shadow: 0 0 0 1px #ffffff33; }

.chart-empty {
  padding: 18px 10px;
  font-size: 12px;
  color: var(--dim);
  text-align: center;
}

.results-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.results-foot small { color: var(--dim); font-size: 11px; line-height: 1.4; }
.results-foot button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--dim);
}

.foot {
  padding: 10px 14px 18px;
  text-align: center;
  color: #55555f;
  font-size: 12px;
}
.foot a { color: #55555f; }

/* ---------- 드롭존 ---------- */
/* 파일을 끌고 있을 때만 나타난다. 텍스트 드래그에는 반응하지 않는다. */

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #0b0b10d9;
  backdrop-filter: blur(2px);
  pointer-events: none;   /* 드롭 이벤트는 window가 받는다 */
  animation: cardIn 140ms ease-out;
}
.dropzone[hidden] { display: none; }

.dz-card {
  padding: 30px 36px;
  border: 2px dashed var(--accent2);
  border-radius: var(--radius);
  background: #14141cf2;
  text-align: center;
}
.dropzone.bad .dz-card { border-color: var(--accent); }
.dz-icon { font-size: 34px; line-height: 1; }
.dz-title { margin-top: 10px; font-size: 16px; font-weight: 700; }
.dropzone.bad .dz-title { color: #ff7b7b; }
.dz-sub { margin-top: 4px; font-size: 12px; color: var(--dim); }

/* 은닉 비디오 (파이프라인 입력용) */
#camVideo, #capVideo {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 320px;
}

dialog {
  border: 1px solid #2a2a38;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  padding: 18px;
  max-width: 380px;
}
dialog::backdrop { background: #000b; }
dialog h3 { margin: 0 0 12px; }
dialog label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 14px;
  flex-wrap: wrap;
}
dialog .hint {
  display: block;
  margin: -2px 0 6px 26px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
}
dialog .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
}

/* ---------- 녹화 설정 ---------- */

.record-options {
  width: min(92vw, 440px);
  max-width: 440px;
}
.record-options-lead { margin: -5px 0 14px; color: var(--dim); font-size: 12px; }
.record-mode-options { margin: 0; padding: 0; border: 0; }
.record-mode-options legend { margin-bottom: 7px; font-size: 12px; color: var(--dim); }
dialog label.record-option-card,
dialog label.record-audio-option {
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid #2a2a38;
  border-radius: 12px;
  background: #101018;
  cursor: pointer;
  flex-wrap: nowrap;
}
.record-option-card:has(input:checked),
.record-audio-option:has(input:checked) { border-color: var(--accent); background: #ff2d7812; }
.record-option-card input,
.record-audio-option input { margin-top: 3px; flex: 0 0 auto; }
.record-option-card span,
.record-audio-option span { display: grid; gap: 2px; }
.record-option-card small,
.record-audio-option small { color: var(--dim); font-size: 11px; line-height: 1.4; }
.copyright-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #ffb02012;
  color: #e8c77e;
  font-size: 11px;
}
.record-options .row { justify-content: flex-end; }

/* ---------- 녹화 프리뷰 ---------- */

.record-preview {
  width: min(92vw, 430px);
  max-width: 430px;
  padding: 14px;
}
.preview-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.preview-head h3 { margin: 0; font-size: 18px; }
.preview-head p { margin: 2px 0 12px; color: var(--dim); font-size: 11px; }
.preview-head button { padding: 5px 8px; }
.record-preview video {
  display: block;
  width: min(100%, 320px);
  max-height: 66vh;
  margin: 0 auto;
  aspect-ratio: var(--preview-aspect, 9 / 16);
  object-fit: contain;
  border-radius: 12px;
  background: #000;
}
.preview-notice { min-height: 1.4em; margin: 9px 0 0; color: var(--dim); font-size: 11px; }
.preview-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 720px) {
  .dance-gallery { padding-inline: 10px; }
  .gallery-track { grid-auto-columns: minmax(210px, 78vw); }
  .frame { width: min(92vw, 60vh); }
  .stage { padding: 12px 10px; }
}
