/* ============================================================
   K-Tv PlayOn 모바일 웹 — 앱(ktv_mobile)의 색·레이아웃을 그대로 옮긴 것.
   dp 대신 px 를 쓰되 값은 앱과 동일하게 맞췄다(폰 1:1).
   ============================================================ */
:root {
  --void: #08080e;
  --void2: #11111b;
  --card: #16161f;
  --ink: #f5f6fc;
  --muted: #9799b4;
  --dim: #55566a;
  --brand: #ff2d6f;
  --blue: #2f7bff;
  --live: #ff2b4d;
  --accent: var(--brand);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--void); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
               "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
body { overflow: hidden; }           /* 스크롤은 각 화면(.screen)이 담당 */
img { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }

/* ---- 화면 컨테이너 ---- */
#app { position: fixed; inset: 0; overflow: hidden; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--void);
  overflow: hidden;
  /* 스택 컨텍스트를 만들어 둔다 — 안 그러면 아래 화면의 z-index:1 자식들이
     위 화면의 배경을 뚫고 올라온다(화면이 겹쳐 보임). */
  z-index: 0; isolation: isolate;
}
/* 배경 오로라 — 앱의 AuroraBackground */
.screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  /* color-mix 를 모르는 구형 사파리를 위해 단색 폴백을 먼저 둔다 */
  background: radial-gradient(120% 90% at 8% 2%, rgba(255,255,255,.06) 0%, var(--void) 72%);
  background: radial-gradient(120% 90% at 8% 2%,
              color-mix(in srgb, var(--accent) 22%, transparent) 0%, var(--void) 72%);
  transition: background .35s ease;
}
.screen > * { position: relative; z-index: 1; }

/* 화면 전환(밀어 들어오기) */
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.screen.enter { animation: slideIn .22s cubic-bezier(.2,.7,.3,1); }

/* ---- 앱바 ---- */
.appbar {
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-t) + 8px) 12px 8px 6px;
  flex: none;
}
.appbar .back {
  width: 42px; height: 42px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--ink);
}
.appbar .tt { flex: 1; min-width: 0; }
.appbar .tt b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .tt span { display: block; font-size: 12px; color: var(--muted); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.appbar .act {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: rgba(255,255,255,.06);
}

/* ---- 스크롤 영역 ---- */
.body {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-b) + 24px);
}

/* ---- 상태 메시지 ---- */
.state {
  height: 100%; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 15px; font-weight: 600; padding: 0 32px;
}
.spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2.6px solid rgba(255,255,255,.15); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 홈 ============ */
.home-head {
  display: flex; align-items: flex-end; gap: 10px;
  padding: calc(var(--safe-t) + 14px) 16px 6px;
}
.home-head .logo { flex: 1; }
.home-head .logo b { display: block; font-size: 26px; font-weight: 900; letter-spacing: -.6px; }
.home-head .logo b i { font-style: normal; color: var(--brand); }
.home-head .logo span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  background: rgba(255,255,255,.06); display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* 카드 레일 — 앱의 3D PageView 를 scroll-snap 으로 옮겼다. */
.rail {
  flex: 1; min-height: 0;
  display: flex; align-items: center;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  perspective: 900px;
}
.rail::-webkit-scrollbar { display: none; }
.rail .pad { flex: none; width: 14vw; }
.card {
  flex: none; width: 72vw; max-width: 340px;
  aspect-ratio: 288 / 470;          /* 앱과 같은 카드 비율 */
  max-height: 100%;
  margin: 0 1vw;
  scroll-snap-align: center;
  border-radius: 26px;
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(255,255,255,.10), rgba(255,255,255,.03));
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
  transform-origin: center center;
  will-change: transform, opacity;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 22px 20px 26px;
  text-align: left;
}
.card .glow {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(90% 60% at 50% 0%, var(--c), transparent 70%);
}
/* 카드 가운데가 비어 보이지 않게 큼직하게 띄운다 */
.card .emoji {
  position: absolute; top: 27%; left: 0; right: 0; text-align: center;
  font-size: 88px; line-height: 1; filter: drop-shadow(0 14px 26px rgba(0,0,0,.55));
}
.card .badge {
  position: absolute; top: 34px; right: 20px;
  font-size: 11px; font-weight: 900; letter-spacing: .4px;
  padding: 5px 10px; border-radius: 999px; color: #fff;
  background: var(--c); box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.card h2 { margin: 0 0 8px; font-size: 27px; font-weight: 900; letter-spacing: -.6px; }
.card p { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.card .cnt {
  align-self: flex-start; font-size: 11.5px; font-weight: 800; color: var(--c);
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.14);
  padding: 5px 11px; border-radius: 999px;
}
/* iOS 홈화면 추가 안내 — 사파리에서 처음 열었을 때 한 번만 */
.a2hs {
  margin: 0 14px 8px; flex: none; display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  font-size: 12.5px; color: var(--muted); font-weight: 600; line-height: 1.45;
}
.a2hs b { color: var(--ink); font-weight: 800; }
.a2hs .x { margin-left: auto; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,.08); color: var(--muted); font-size: 15px; }

.dots { display: flex; gap: 6px; justify-content: center; padding: 12px 0 calc(var(--safe-b) + 14px); flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.2); transition: .2s; }
.dots i.on { width: 20px; border-radius: 3px; background: var(--accent); }

/* ============ 목록(채널/다시보기) ============ */
.list { padding: 4px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 14px;
  background: rgba(255,255,255,.04); width: 100%; text-align: left;
}
.row:active { background: rgba(255,255,255,.09); }
.row .no {
  width: 46px; height: 40px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900; color: #fff; background: var(--accent);
}
.row .lg { width: 46px; height: 40px; flex: none; border-radius: 10px; background: var(--card);
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.row .lg img { width: 100%; height: 100%; object-fit: contain; }
.row .mid { flex: 1; min-width: 0; }
.row .mid b { display: block; font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .mid span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .go { color: var(--dim); font-size: 18px; flex: none; }
.tag19 { font-size: 10px; font-weight: 900; color: #fff; background: var(--live);
  padding: 2px 5px; border-radius: 5px; margin-left: 6px; vertical-align: 2px; }
.tag-hd { font-size: 9.5px; font-weight: 900; color: #7fd7ff; background: rgba(47,123,255,.18);
  border: 1px solid rgba(47,123,255,.4); padding: 1px 4px; border-radius: 4px;
  margin-left: 6px; vertical-align: 2px; letter-spacing: .3px; }

/* ============ 칩 ============ */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 12px 12px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; flex: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  background: rgba(255,255,255,.06); color: var(--muted); white-space: nowrap;
  border: 1px solid transparent;
}
.chip.on { background: var(--accent); color: #fff; border-color: transparent; }

/* ============ 포스터 그리드 ============ */
.grid {
  display: grid; gap: 18px 12px; padding: 4px 12px 0;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
.poster { text-align: left; width: 100%; }
.poster .ph {
  position: relative; width: 100%; aspect-ratio: 2 / 3;
  border-radius: 12px; overflow: hidden; background: var(--card);
}
.poster .ph img { width: 100%; height: 100%; object-fit: cover; }
.poster .ph .fb {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center;
}
.poster .ep {
  position: absolute; right: 5px; top: 5px; font-size: 10px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.72); padding: 3px 6px; border-radius: 6px;
}
.poster b { display: block; margin-top: 7px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { padding: 22px 0 8px; display: flex; justify-content: center; }

/* ============ 상세 ============ */
.detail { padding: 0 16px; }
.detail .top { display: flex; gap: 14px; }
.detail .top .ph { width: 118px; flex: none; aspect-ratio: 2/3; border-radius: 14px;
  overflow: hidden; background: var(--card); }
.detail .top .ph img { width: 100%; height: 100%; object-fit: cover; }
.detail .top .meta { flex: 1; min-width: 0; }
.detail .top h1 { margin: 0 0 8px; font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.detail .top .sub { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.btn-play {
  margin: 16px 0 6px; width: 100%; height: 50px; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 10px 26px rgba(0,0,0,.45);
}
.btn-play:active { filter: brightness(.9); }
.desc { margin-top: 14px; font-size: 13.5px; color: var(--muted); line-height: 1.6; white-space: pre-wrap; }
.eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 12px; }
.eps button { height: 44px; border-radius: 11px; background: rgba(255,255,255,.06);
  font-size: 14px; font-weight: 700; }
.eps button:active { background: var(--accent); }
h3.sec { margin: 22px 0 6px; font-size: 14px; font-weight: 800; color: var(--ink); }

/* ============ 검색 ============ */
.searchbar { padding: 0 12px 10px; flex: none; }
.searchbar form { display: flex; gap: 8px; }
.searchbar input {
  flex: 1; height: 46px; border-radius: 14px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05); color: var(--ink); padding: 0 14px; font-size: 15px;
  outline: none; min-width: 0;
}
.searchbar input::placeholder { color: var(--dim); }
.searchbar button {
  width: 62px; flex: none; height: 46px; border-radius: 14px; background: var(--accent);
  color: #fff; font-weight: 800; font-size: 15px;
}

/* ============ 승인대기 / 로그인 ============ */
.gate { padding: 28px 22px calc(var(--safe-b) + 28px); display: flex; flex-direction: column;
  min-height: 100%; justify-content: center; gap: 6px; }
.gate .mark { font-size: 44px; text-align: center; }
.gate h1 { margin: 10px 0 4px; font-size: 23px; font-weight: 900; text-align: center; letter-spacing: -.4px; }
.gate p { margin: 0; font-size: 14px; color: var(--muted); text-align: center; font-weight: 600; line-height: 1.65; }
.keybox {
  margin: 22px 0 8px; padding: 18px 16px; border-radius: 18px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); text-align: center;
}
.keybox small { display: block; font-size: 11.5px; color: var(--dim); font-weight: 700; letter-spacing: .5px; }
.keybox .k {
  margin-top: 8px; font-size: 22px; font-weight: 900; letter-spacing: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); word-break: break-all;
}
.gate .btns { display: flex; gap: 8px; margin-top: 6px; }
.gate .btns button {
  flex: 1; height: 48px; border-radius: 14px; font-size: 14.5px; font-weight: 800;
  background: rgba(255,255,255,.07);
}
.gate .btns button.pri { background: var(--accent); color: #fff; }
.gate .ln { margin-top: 20px; font-size: 12.5px; color: var(--dim); text-align: center; font-weight: 600; }
.gate input.code {
  width: 100%; height: 56px; border-radius: 14px; margin-top: 22px; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: var(--ink);
  font-size: 20px; font-weight: 800; letter-spacing: 2px; outline: none;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.gate input.code:focus { border-color: var(--accent); background: rgba(255,255,255,.09); }
.gate input.code::placeholder { color: var(--dim); letter-spacing: 1px; }
.gate .remember {
  display: flex; align-items: center; gap: 9px; margin: 14px 2px 4px;
  font-size: 14px; color: var(--muted); font-weight: 600; user-select: none;
}
.gate .remember input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.gate-err {
  margin-top: 12px; padding: 11px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 700;
  color: #ffb4c4; background: rgba(255,45,111,.12); border: 1px solid rgba(255,45,111,.3);
  text-align: center; line-height: 1.5;
}
.gate .btns button.wide { flex: 1; }

/* ============ 내 정보 시트 ============ */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--void2); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(var(--safe-b) + 22px);
  animation: up .22s cubic-bezier(.2,.7,.3,1);
  max-height: 82%; overflow-y: auto;
}
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .hd { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.18);
  margin: 4px auto 16px; }
.sheet h2 { margin: 0 0 14px; font-size: 18px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid rgba(255,255,255,.06); font-size: 14px; }
.kv span { color: var(--muted); font-weight: 600; flex: none; }
.kv b { font-weight: 700; text-align: right; word-break: break-all; }
.pill { font-size: 11.5px; font-weight: 900; padding: 3px 9px; border-radius: 999px; color: #fff; }
.pill.ok { background: #2ed17e; } .pill.no { background: var(--live); }
.sheet .wide {
  margin-top: 18px; width: 100%; height: 48px; border-radius: 14px;
  background: rgba(255,255,255,.07); font-weight: 800; font-size: 14.5px;
}

/* ============ 플레이어 ============ */
#player-root:empty { display: none; }
.player { position: fixed; inset: 0; z-index: 60; background: #000; overflow: hidden; }
/* 영상·컨트롤을 한 겹 안에 둔다 — 전체화면 요소 자신에게는 브라우저가
   transform 을 무시시키므로(UA 스타일 transform:none !important) 회전은 여기에 건다. */
.stage { position: absolute; inset: 0; background: #000; transition: transform .25s ease; }
/* 화면이 세로인데 영상이 가로면 90도 돌려 꽉 채운다.
   기기 회전잠금이 켜져 있어도 가로로 보이고, 실제로 기기를 돌려 화면이 가로가 되면
   이 클래스가 자동으로 벗겨진다. 터치 좌표는 브라우저가 알아서 변환해준다. */
.player.rot .stage {
  inset: auto; top: 50%; left: 50%;
  width: 100vh; height: 100vw;
  width: 100dvh; height: 100dvw;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.pv-ctl {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  background: linear-gradient(to bottom, rgba(0,0,0,.7) 0%, rgba(0,0,0,.2) 45%, rgba(0,0,0,.8) 100%);
  padding: calc(var(--safe-t) + 6px) 8px calc(var(--safe-b) + 6px);
  opacity: 1; transition: opacity .2s;
}
.pv-ctl.hide { opacity: 0; pointer-events: none; }
.pv-top { display: flex; align-items: center; gap: 6px; }
.pv-top .x { width: 44px; height: 44px; flex: none; display: flex; align-items: center;
  justify-content: center; font-size: 24px; color: #fff; }
.pv-top .tt { flex: 1; min-width: 0; }
.pv-top .tt b { display: block; font-size: 16px; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-top .tt span { display: block; font-size: 12.5px; color: rgba(255,255,255,.7); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-mid { flex: 1; display: flex; align-items: center; justify-content: center; gap: 26px; }
.rbtn {
  border-radius: 50%; background: rgba(0,0,0,.3); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.rbtn.sm { width: 58px; height: 58px; font-size: 25px; }
.rbtn.lg { width: 82px; height: 82px; font-size: 36px; background: rgba(255,255,255,.18); }
.rbtn:active { background: rgba(255,255,255,.3); }
.pv-bot { padding: 0 8px; }
.pv-bot .seekrow { display: flex; align-items: center; gap: 10px; }
.pv-bot .t { font-size: 12px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums;
  min-width: 46px; text-align: center; }
.pv-bot .t.dim { color: rgba(255,255,255,.7); }
/* LIVE 와 시크바는 class 로만 전환한다(DOM 을 갈아끼우면 시크바가 사라진다) */
.pv-bot .livetag { display: none; text-align: center; font-size: 12px; font-weight: 900;
  color: var(--live); padding: 8px 0; }
.pv-bot.live .livetag { display: block; }
.pv-bot.live .seekrow { display: none; }
/* 손가락으로 잡기 쉽게 세로 여백을 넉넉히 */
.seek { flex: 1; -webkit-appearance: none; appearance: none; height: 34px; background: none;
  min-width: 0; touch-action: none; }
.seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p,0%), rgba(255,255,255,.25) var(--p,0%)); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); margin-top: -7px; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.seek::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255,255,255,.25); }
.seek::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
.seek::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--accent); }
/* 전체화면일 때는 노치 여백이 필요 없다 */
.player:fullscreen .pv-ctl, .player:-webkit-full-screen .pv-ctl { padding: 8px 10px; }
.pv-zap { display: flex; gap: 8px; justify-content: center; padding-bottom: 4px; }
.pv-zap button { padding: 9px 16px; border-radius: 999px; background: rgba(255,255,255,.12);
  color: #fff; font-size: 13px; font-weight: 800; }
.pv-msg {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; color: #fff; font-weight: 700; text-align: center;
  padding: 0 30px; pointer-events: none;
}
.pv-msg button { pointer-events: auto; padding: 11px 22px; border-radius: 12px;
  background: rgba(255,255,255,.14); font-weight: 700; }
/* 가로로 눕히면 컨트롤이 커진다 */
@media (orientation: landscape) { .rbtn.lg { width: 74px; height: 74px; font-size: 32px; } }

/* ============ 토스트 ============ */
#toast { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 26px); z-index: 90;
  display: flex; justify-content: center; pointer-events: none; }
#toast div { background: rgba(20,20,28,.95); border: 1px solid rgba(255,255,255,.12);
  color: var(--ink); padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  animation: up .2s; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
