/* PurePlayer Web — styles */
:root{
  --bg:#0E1014; --panel:#151922; --surface:#1B2030; --line:#1F2634;
  --text:#E8EAF0; --muted:#8C94A6; --accent:#FF3B3B; --accent-ink:#fff;
  --radius:14px; --radius-sm:10px; --shadow:0 10px 30px rgba(0,0,0,.45);
  --sb-w:340px; --bar-h:56px;
  color-scheme:dark;
}
html[data-theme="light"]{
  --bg:#EEF0F4; --panel:#FFFFFF; --surface:#F2F4F8; --line:#DDE2EA;
  --text:#14181F; --muted:#5C6472; --accent:#E03131; --accent-ink:#fff;
  --shadow:0 10px 26px rgba(15,23,42,.12);
  color-scheme:light;
}

*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Pretendard","Apple SD Gothic Neo","Noto Sans KR","Segoe UI",Roboto,sans-serif;
  font-size:15px; line-height:1.45;
  -webkit-text-size-adjust:100%; -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}
button,input{font:inherit;color:inherit}
b{font-weight:700}

/* ── 레이아웃 ───────────────────────────── */
.app{display:flex; height:100vh; height:100dvh; overflow:hidden}

.sidebar{
  width:var(--sb-w); flex:0 0 var(--sb-w);
  background:var(--panel); border-right:1px solid var(--line);
  display:flex; flex-direction:column; gap:2px;
  overflow-y:auto; overscroll-behavior:contain;
  padding-bottom:calc(18px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling:touch;
}
.sb-head{
  position:sticky; top:0; z-index:3;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:14px 16px 12px; background:var(--panel); border-bottom:1px solid var(--line);
}
.brand{display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--text)}
.brand-mark{display:grid; place-items:center; width:32px; height:32px; border-radius:9px; background:rgba(255,59,59,.10)}
.brand-text{font-weight:700; letter-spacing:.2px; font-size:16px}
.brand-text b{color:var(--accent); font-weight:800}

.sb-section{padding:14px 16px; border-bottom:1px solid var(--line)}
.sb-section:last-child{border-bottom:0}
.sb-label{display:block; font-size:12.5px; color:var(--muted); margin-bottom:7px; font-weight:600}
.sb-title{font-size:13px; letter-spacing:.4px; color:var(--muted); margin:0 0 10px; font-weight:700; text-transform:uppercase}
.sb-title-row{display:flex; align-items:center; justify-content:space-between; margin-bottom:10px}
.sb-title-row .sb-title{margin:0}
.count{
  display:inline-block; min-width:20px; padding:1px 6px; margin-left:4px;
  border-radius:999px; background:var(--surface); color:var(--muted);
  font-size:11.5px; text-align:center; vertical-align:1px;
}

/* ── 입력 ───────────────────────────── */
.url-row{display:flex; gap:8px}
#urlInput{
  flex:1; min-width:0; padding:12px 13px;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-sm);
  font-size:15px; outline:none;
}
#urlInput::placeholder{color:var(--muted); opacity:.85}
#urlInput:focus{border-color:var(--accent); box-shadow:0 0 0 3px rgba(255,59,59,.16)}
.row-2{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:8px}
.row-2.tight{margin-top:10px}
.ctl-grid{display:grid; grid-template-columns:1fr 1fr; gap:8px}
.ctl-grid + .ctl-grid{margin-top:8px}
.ctl-grid .btn{justify-content:center; text-align:center}
.field{margin-top:12px}
.field-label{display:block; font-size:12.5px; color:var(--muted); margin-bottom:6px; font-weight:600}

/* ── 버튼 ───────────────────────────── */
.btn:not([hidden]){
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  min-height:44px; padding:10px 12px;
  background:var(--surface); color:var(--text);
  border:1px solid var(--line); border-radius:var(--radius-sm);
  font-size:14px; font-weight:600; cursor:pointer;
  transition:background .12s ease, border-color .12s ease, transform .06s ease;
  touch-action:manipulation; user-select:none;
}
.btn:hover{background:color-mix(in srgb, var(--surface) 78%, var(--text))}
.btn:active{transform:scale(.985)}
.btn.primary{background:var(--accent); border-color:var(--accent); color:var(--accent-ink)}
.btn.primary:hover{filter:brightness(1.06)}
.btn.accent-soft{background:rgba(255,59,59,.12); border-color:rgba(255,59,59,.35); color:var(--text)}
.btn.small{min-height:38px; font-size:13px}
.btn.wide{width:100%}
.icon-btn{
  display:grid; place-items:center; flex:0 0 auto;
  width:44px; height:44px; border-radius:var(--radius-sm);
  background:var(--surface); border:1px solid var(--line); color:var(--text);
  font-size:17px; cursor:pointer;
}
.icon-btn:hover{background:color-mix(in srgb, var(--surface) 78%, var(--text))}
.icon-btn.big{font-size:18px}
.link-btn{background:none; border:0; color:var(--muted); font-size:12.5px; cursor:pointer; padding:4px 2px; text-decoration:underline; text-underline-offset:2px}
.link-btn:hover{color:var(--text)}
.pill{
  display:inline-block; min-width:42px; padding:1px 7px; border-radius:999px;
  background:rgba(255,59,59,.20); color:var(--text); font-variant-numeric:tabular-nums;
  font-size:12.5px; font-weight:700;
}

/* 세그먼트 */
.seg{display:grid; grid-auto-flow:column; grid-auto-columns:1fr; gap:4px; padding:4px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-sm)}
.seg-btn{
  min-height:38px; padding:7px 8px; border:0; border-radius:8px; background:transparent;
  color:var(--muted); font-size:13.5px; font-weight:600; cursor:pointer;
}
.seg-btn.is-on{background:var(--panel); color:var(--text); box-shadow:0 1px 3px rgba(0,0,0,.25)}
html[data-theme="light"] .seg-btn.is-on{box-shadow:0 1px 3px rgba(15,23,42,.14)}

/* ── 목록 ───────────────────────────── */
.list{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px}
.list:empty{display:none}
.item{position:relative; display:flex; gap:9px; align-items:center;
  padding:6px; border-radius:var(--radius-sm); background:var(--surface); border:1px solid transparent}
.item.is-current{border-color:rgba(255,59,59,.5)}
.item-thumb{
  flex:0 0 64px; width:64px; height:38px; border-radius:6px; object-fit:cover;
  background:var(--panel); display:block;
}
.item-thumb.tall{width:34px; flex-basis:34px; height:60px}
.item-body{flex:1; min-width:0}
.item-title{
  display:block; width:100%; text-align:left; background:none; border:0; padding:0;
  font-size:13.5px; font-weight:600; color:var(--text); cursor:pointer;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.item-sub{display:block; font-size:11.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.item-x{
  flex:0 0 auto; width:32px; height:32px; display:grid; place-items:center;
  background:none; border:0; border-radius:8px; color:var(--muted); font-size:14px; cursor:pointer;
}
.item-x:hover{background:var(--panel); color:var(--text)}
.empty-note{margin:0; font-size:12.5px; color:var(--muted); line-height:1.5}
.hint{margin:8px 0 0; font-size:12.5px; color:var(--muted); min-height:16px}
.hint.warn{color:var(--accent)}

/* 안내 */
.info{border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--surface); padding:0}
.info summary{padding:11px 12px; cursor:pointer; font-size:13px; font-weight:600; list-style:none}
.info summary::-webkit-details-marker{display:none}
.info summary::before{content:"▸ "; color:var(--muted)}
.info[open] summary::before{content:"▾ "}
.info-list{margin:0; padding:0 14px 12px 28px; font-size:12.5px; color:var(--muted); line-height:1.6}
.info-list li{margin:5px 0}
.info-list b{color:var(--text); font-weight:600}
.foot-note{margin:12px 0 0; font-size:12px; color:var(--muted); line-height:1.55}

/* ── 무대 ───────────────────────────── */
.stage-wrap{
  position:relative; flex:1; min-width:0; background:#000;
  display:flex; flex-direction:column; overflow:hidden;
}
html[data-theme="light"] .stage-wrap{background:#0B0D11}
.stage-bar{
  position:absolute; top:0; left:0; right:0; z-index:6;
  display:flex; align-items:center; gap:10px;
  min-height:var(--bar-h); padding:8px 14px; padding-top:calc(8px + env(safe-area-inset-top));
  background:linear-gradient(180deg, rgba(6,8,11,.86), rgba(6,8,11,0));
  color:#E8EAF0; pointer-events:none;
}
.stage-bar > *{pointer-events:auto}
.stage-meta{flex:1; min-width:0; display:flex; flex-direction:column; gap:1px}
.stage-title{font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 3px rgba(0,0,0,.6)}
.stage-sub{font-size:11.5px; color:#A7AEBD; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.stage-badge{
  padding:3px 9px; border-radius:999px; background:rgba(255,59,59,.85); color:#fff;
  font-size:12px; font-weight:700; font-variant-numeric:tabular-nums;
}
.stage-bar .icon-btn{background:rgba(255,255,255,.10); border-color:rgba(255,255,255,.18); color:#E8EAF0}

.stage{position:absolute; inset:0; overflow:hidden; touch-action:manipulation}
.frame{
  position:absolute; left:50%; top:50%;
  transform:translate(-50%,-50%) rotate(0deg);
  transform-origin:center center;
  background:#000; overflow:hidden;
  border-radius:10px;
  will-change:width,height,transform;
  box-shadow:0 0 0 1px rgba(255,255,255,.06);
}
.frame.fill{border-radius:0; box-shadow:none}
.frame iframe{position:absolute; inset:0; width:100%; height:100%; border:0; display:block}

/* 빈 화면 */
.empty{position:absolute; inset:0; display:grid; place-items:center; padding:24px}
.empty[hidden]{display:none}
.empty-card{
  max-width:440px; text-align:center; color:#C9CFDC;
  background:rgba(21,25,34,.72); border:1px solid rgba(255,255,255,.08);
  border-radius:20px; padding:30px 24px; backdrop-filter:blur(6px);
}
.empty-mark{
  width:56px; height:56px; margin:0 auto 14px; border-radius:16px;
  display:grid; place-items:center; font-size:24px;
  background:rgba(255,59,59,.16); color:#FF3B3B;
}
.empty-card h1{font-size:20px; margin:0 0 8px; color:#fff; letter-spacing:.2px}
.empty-card p{margin:0 0 18px; font-size:13.5px; line-height:1.65; color:#A7AEBD}
.empty-card p b{color:#E8EAF0}
.empty-actions{display:flex; gap:8px; justify-content:center; flex-wrap:wrap}
.empty-actions .btn{min-height:46px}
.empty-keys{margin:16px 0 0 !important; font-size:11.5px !important; color:#828A99 !important}
kbd{
  display:inline-block; padding:1px 5px; border-radius:5px; font-size:11px;
  background:rgba(255,255,255,.10); border:1px solid rgba(255,255,255,.16); font-family:inherit;
}

/* 토스트 */
.toast{
  position:fixed; left:50%; bottom:calc(22px + env(safe-area-inset-bottom)); transform:translateX(-50%);
  z-index:60; max-width:min(90vw, 460px);
  padding:11px 16px; border-radius:12px;
  background:#0B0D11; color:#F2F4F8; border:1px solid rgba(255,255,255,.14);
  box-shadow:var(--shadow); font-size:13.5px; text-align:center;
}
.toast[hidden]{display:none}
.toast.bad{border-color:rgba(255,59,59,.6)}

/* 좁은 화면: 사이드바 드로어 */
.only-narrow{display:none}
.scrim{position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:20}
.scrim[hidden]{display:none}

@media (max-width:900px){
  .only-narrow{display:grid}
  .sidebar{
    position:fixed; left:0; top:0; bottom:0; z-index:30;
    width:min(88vw, 360px); flex-basis:auto;
    transform:translateX(-102%); transition:transform .2s ease;
    box-shadow:var(--shadow);
  }
  body.nav-open .sidebar{transform:translateX(0)}
  .stage-bar{padding-left:10px}
}

/* 전체화면 */
.stage-wrap:fullscreen .stage-bar,
.stage-wrap:-webkit-full-screen .stage-bar{opacity:0; pointer-events:none; transition:opacity .2s ease}
body.pseudo-fs .stage-wrap{position:fixed; inset:0; z-index:40}
body.pseudo-fs .stage-bar{opacity:0; pointer-events:none}
body.pseudo-fs{overflow:hidden}

@media (prefers-reduced-motion:reduce){
  *{transition:none !important; animation:none !important}
}
