/*
  3D Hoops Playbook — UI
  둥근 패널이 간격을 두고 떠 있는 구조. 다크(따뜻한 차콜)와 라이트(웜 그레이) 두 테마.
  토큰: 간격 4px 단위, 패널 20px · 내부 블록 14px · 컨트롤은 알약(999px) 라운드, 강조색 하나(#ee7a3a)
*/
:root {
  --bg: #141311;
  --panel: #1d1b19;
  --raised: #252320;
  --raised-2: #2b2825;
  --line: rgba(237, 232, 225, 0.07);
  --text: #ede8e1;
  --text-body: #dcd6ce;
  --text-sub: #c9c2b9;
  --text-2: #b5aea5;
  --text-3: #8c857c;
  --accent: #ee7a3a;
  --accent-text: #f4a271;
  --accent-soft: #2e2a26;
  --on-accent: #2a1608;
  --def: #3a6fd8;
  --scene: #1c1a18;
  --seg: #252320;
  --seg-on: #3a3632;
  --seg-on-text: #ede8e1;
  --seg-on-shadow: none;
  --tseg-on: #3a3632;
  --tseg-on-text: #ede8e1;
  --track: #34302c;
  --track-done: #7c756d;
  --track-tail: #262421;
  --head: #ede8e1;
  --diff: #3a3632;
  --diff-on: #8c857c;
  --legend: #252320;
  --legend-text: #c9c2b9;
  --pop-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  --float-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  --backdrop: rgba(10, 9, 8, 0.5);
  --r-xl: 20px;
  --r-lg: 14px;
  --r-md: 10px;
  --font: "Rubik", "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f1f0ee;
  --panel: #ffffff;
  --raised: #f6f5f3;
  --raised-2: #efedea;
  --line: rgba(30, 29, 27, 0.08);
  --text: #1e1d1b;
  --text-body: #3a3835;
  --text-sub: #3a3835;
  --text-2: #55524d;
  --text-3: #6f6b65;
  --accent-text: #a3480d;
  --accent-soft: #fcebdf;
  --def: #2f64cf;
  --scene: #e4e1dc;
  --seg: #f1f0ee;
  --seg-on: #ffffff;
  --seg-on-text: #1e1d1b;
  --seg-on-shadow: 0 1px 2px rgba(30, 29, 27, 0.14);
  --tseg-on: #1e1d1b;
  --tseg-on-text: #ffffff;
  --track: #e3e1dd;
  --track-done: #8e8a84;
  --track-tail: #eceae7;
  --head: #1e1d1b;
  --diff: #dddad6;
  --diff-on: #8e8a84;
  --legend: #2a2826;
  --legend-text: #dcd6ce;
  --pop-shadow: 0 6px 28px rgba(255, 255, 255, 0.7);
  --float-shadow: 0 16px 48px rgba(30, 29, 27, 0.18);
  --backdrop: rgba(30, 29, 27, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;          /* 한글은 어절 단위로 줄바꿈 */
  overflow-wrap: break-word;
  transition: background-color 250ms var(--ease);
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd {
  font-family: var(--font); font-size: 11.5px; font-weight: 500;
  display: inline-block; min-width: 20px; padding: 0 6px; text-align: center; line-height: 20px;
  border-radius: 6px; background: var(--raised-2); color: var(--text-2);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.panel { background: var(--panel); border-radius: var(--r-xl); }

#app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 360px;
  gap: 12px;
  padding: 12px;
  height: 100vh;
  height: 100dvh;
}

/* 알약 모양 세그먼트 */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--seg);
}
.seg button {
  min-height: 34px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-2);
  white-space: nowrap; transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-text); box-shadow: var(--seg-on-shadow); }

.round-btn {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--panel); color: var(--text-2);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.round-btn svg { width: 19px; height: 19px; }
.round-btn:hover { color: var(--text); background: var(--raised-2); }

/* ───────── Sidebar ───────── */
#sidebar { display: flex; flex-direction: column; min-height: 0; padding: 20px 12px 12px; }
.brand { padding: 0 8px; }
.brand-link { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wordmark { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; white-space: nowrap; }
.brand-sub { font-size: 12.5px; line-height: 1.3; color: var(--text-3); }

/* 작전 목록: 검색 · 난이도 · 접히는 갈래 */
.library { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 18px; }
.lib-search {
  display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px; margin: 0 2px;
  border-radius: 999px; background: var(--raised); color: var(--text-3);
}
.lib-search:focus-within { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 1px var(--accent) inset; color: var(--text-2); }
.lib-search svg { width: 17px; height: 17px; flex: none; }
.lib-search input {
  flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 14.5px;
}
.lib-search input::placeholder { color: var(--text-3); }
.lib-search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.6; }
.lib-levels { display: flex; margin: 10px 2px 4px; }
.lib-levels button { flex: 1; display: grid; place-items: center; min-height: 30px; padding: 0 6px; font-size: 12.5px; }
.lib-levels button[aria-pressed="true"] .diff i.on { background: var(--accent); }
.lib-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.lib-sec + .lib-sec { margin-top: 6px; }
.sec-head {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 0 12px;
  border-radius: var(--r-md); font-size: 13.5px; font-weight: 600; color: var(--text); text-align: left;
}
.sec-head:hover { background: var(--raised); }
.sec-head .count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sec-head svg { width: 16px; height: 16px; flex: none; color: var(--text-3); transition: transform 150ms var(--ease); }
.sec-head[aria-expanded="false"] svg { transform: rotate(-90deg); }
.sec-body { display: flex; flex-direction: column; gap: 2px; }
.sec-body[hidden] { display: none; }
.lib-empty { margin: 18px 12px; font-size: 13.5px; color: var(--text-3); }
.lib-empty[hidden] { display: none; }
.cat-title { margin: 12px 12px 4px; font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.reads-badge {
  flex: none; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.play-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-lg); text-align: left; font-size: 15px; color: var(--text-sub);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.play-item:hover { background: var(--raised); color: var(--text); }
.play-item.active { background: var(--raised-2); color: var(--text); font-weight: 600; }
.play-item .nm { flex: 1; min-width: 0; line-height: 1.35; }
.diff { display: flex; gap: 4px; flex: none; }
.diff i { width: 6px; height: 6px; border-radius: 50%; background: var(--diff); }
.diff i.on { background: var(--diff-on); }
.play-item.active .diff i.on { background: var(--accent); }

.side-foot { margin-top: 12px; }
.keys-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-lg); background: var(--raised); color: var(--text-2); font-size: 13.5px; text-align: left;
  transition: color 150ms var(--ease);
}
.keys-btn:hover { color: var(--text); }
.keys-btn svg { width: 18px; height: 18px; flex: none; }
.keys-btn span { flex: 1; }

/* ───────── Stage ───────── */
#stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 0 4px 0 8px;
}
.play-head { min-width: 0; }
.play-meta { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text-3); }
.play-head h2 { margin: 1px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-right { display: flex; align-items: center; gap: 8px; }
.toolbar .seg { padding: 4px; background: var(--panel); }
.toolbar .seg button { min-height: 36px; min-width: 44px; padding: 0 12px; }
.toolbar .seg button.on { background: var(--tseg-on); color: var(--tseg-on-text); box-shadow: none; }

/* 3D 뷰 카드: 코트 위에는 아무 컨트롤도 올리지 않는다 (모서리 선수를 가리지 않도록) */
.view {
  position: relative; flex: 1; min-height: 0;
  border-radius: var(--r-xl); overflow: hidden; background: var(--scene);
  transition: background-color 250ms var(--ease);
}
#viewport { position: absolute; inset: 0; overflow: hidden; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#score-pop {
  position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%) scale(0.7);
  font-weight: 700; font-size: 88px; line-height: 1; letter-spacing: -0.02em; color: var(--text);
  text-shadow: var(--pop-shadow); opacity: 0; pointer-events: none;
  transition: opacity 200ms var(--ease), transform 400ms cubic-bezier(0.2, 1.5, 0.4, 1);
}
#score-pop small { font-size: 0.26em; font-weight: 600; letter-spacing: 0.06em; color: var(--accent-text); display: block; text-align: center; margin-top: 4px; }
#score-pop.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#loading {
  position: absolute; inset: 0; display: grid; place-items: center; background: var(--scene);
  color: var(--text-3); font-size: 13px; transition: opacity 400ms var(--ease);
}
#loading.hide { opacity: 0; pointer-events: none; }

/* 설명(캡션) */
#caption { padding: 14px 22px 16px; min-height: 112px; }
.cap-top { display: flex; align-items: center; gap: 12px; min-height: 36px; flex-wrap: wrap; }
.cap-step {
  flex: none; padding: 3px 11px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-text); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums;
}
#cap-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; min-width: 0; }
.cap-status {
  margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none;
  font-size: 13px; color: var(--text-2);
}
.cap-status[hidden] { display: none; }
.cap-ring { width: 18px; height: 18px; flex: none; }
.cap-ring circle { fill: none; stroke-width: 2.5; stroke: var(--track); }
.cap-ring #cap-ring-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 50.27; stroke-dashoffset: 50.27; }
.cap-status.wait .cap-ring { display: none; }
#btn-skip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px 0 14px; border-radius: 999px;
  background: var(--accent-soft); font-size: 13px; font-weight: 500; color: var(--text);
  transition: filter 150ms var(--ease);
}
#btn-skip:hover { filter: brightness(1.12); }
#btn-skip kbd { background: var(--panel); }
#cap-text { margin: 8px 0 0; color: var(--text-body); font-size: 15.5px; line-height: 1.75; max-width: 72ch; }
#cap-text b, .summary b, .block b, .bullets b { color: var(--text); font-weight: 600; }

/* 문장 속 선수 칩 */
.pc {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font-size: 12.5px; font-weight: 600; line-height: 1; vertical-align: 1px; margin: 0 1px; border-radius: 999px;
}
.pc.o { background: var(--accent); color: var(--on-accent); }
.pc.d { background: var(--def); color: #fff; border-radius: 7px; min-width: 26px; }

/* 재생 컨트롤 */
.controls { display: flex; flex-direction: column; gap: 10px; padding: 10px 18px 12px; }
#transport { display: flex; align-items: center; gap: 16px; }
.t-buttons { display: flex; gap: 4px; align-items: center; }
.icon {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-2); transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
}
.icon svg { width: 20px; height: 20px; }
.icon:hover { background: var(--raised); color: var(--text); }
.icon.play { width: 52px; height: 52px; background: var(--accent); color: var(--on-accent); margin: 0 4px; }
.icon.play:hover { background: var(--accent); color: var(--on-accent); transform: scale(1.04); }
.icon.loop svg { width: 18px; height: 18px; }
.icon.loop[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

.timeline { position: relative; flex: 1; min-width: 160px; height: 40px; cursor: pointer; touch-action: none; }
.tl-segs { position: absolute; inset: 0; display: flex; gap: 6px; }
.tl-seg { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding-top: 6px; }
.tl-bar { position: relative; height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; transition: transform 150ms var(--ease); }
.tl-seg.tail .tl-bar { background: var(--track-tail); }
.tl-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: var(--track-done); }
.tl-seg.cur .tl-bar i { background: var(--accent); }
.tl-label {
  font-size: 12px; line-height: 1.4; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-seg.cur .tl-label { color: var(--text); font-weight: 500; }
.timeline:hover .tl-bar { transform: scaleY(1.25); }
.tl-head {
  position: absolute; top: 10px; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  background: var(--head); box-shadow: 0 0 0 4px var(--panel); pointer-events: none;
}
.time {
  font-size: 14px; color: var(--text-sub); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; white-space: nowrap;
}
.time .sep { color: var(--text-3); margin: 0 4px; }

/* 재생 설정 */
#settings {
  display: flex; align-items: center; gap: 10px 20px; flex-wrap: wrap;
  padding-top: 10px; border-top: 1px solid var(--line);
}
#settings .seg button { padding: 0 11px; }
.toggles { margin-left: auto; }
.toggles button[aria-pressed="false"] { color: var(--text-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.set-group { display: flex; align-items: center; gap: 10px; }
.set-label { font-size: 13px; color: var(--text-3); white-space: nowrap; }

/* ───────── Info panel ───────── */
#info { overflow-y: auto; padding: 24px 24px 28px; min-height: 0; }
.summary { font-size: 15.5px; line-height: 1.85; color: var(--text-body); margin: 0; }
.legend {
  display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 18px; padding: 14px 16px;
  border-radius: var(--r-lg); background: var(--legend); font-size: 13px; color: var(--legend-text);
}
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.legend svg { width: 26px; height: 10px; }
.block { margin-top: 28px; }
.block h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.block p { margin: 0; font-size: 14.5px; color: var(--text-sub); line-height: 1.8; }

#info-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#info-steps button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 10px;
  border-radius: var(--r-lg); font-size: 14.5px; color: var(--text-2); text-align: left;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
#info-steps button:hover { background: var(--raised); color: var(--text); }
#info-steps .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 500; background: var(--raised-2); color: var(--text-sub);
}
#info-steps .st { flex: 1; min-width: 0; }
#info-steps .now { display: none; font-size: 12.5px; color: var(--text-2); font-weight: 400; }
#info-steps li.active button { background: var(--raised-2); color: var(--text); font-weight: 600; }
#info-steps li.active .n { background: var(--accent); color: var(--on-accent); font-weight: 600; }
#info-steps li.active .now { display: inline; }

.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 14.5px; color: var(--text-sub); line-height: 1.75; }
.bullets li { position: relative; padding-left: 18px; }
.bullets li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.counters { margin: 0; display: grid; gap: 8px; }
.counters div { padding: 12px 14px; border-radius: var(--r-lg); background: var(--raised); }
.counters dt { font-size: 14px; font-weight: 600; color: var(--text); }
.counters dd { margin: 2px 0 0; font-size: 13.5px; line-height: 1.7; color: var(--text-2); }

.counters dt { display: flex; align-items: center; gap: 10px; }
.counters dt span { flex: 1; min-width: 0; }
.counters .watch {
  display: inline-flex; align-items: center; gap: 5px; flex: none; min-height: 28px; padding: 0 11px 0 9px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; font-weight: 600;
}
.counters .watch svg { width: 12px; height: 12px; }
.counters .watch:hover { background: var(--accent); color: var(--on-accent); }

/* ───────── 수비 대응별 분기 ───────── */
/* 읽기 탭: 타임라인 위 */
.read-bar { display: flex; align-items: center; gap: 12px; min-width: 0; }
.read-bar[hidden] { display: none; }
.read-bar-label { flex: none; font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.read-tabs { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.read-tabs::-webkit-scrollbar { display: none; }
.read-tabs button { flex: none; min-height: 32px; }

/* 분기점 표시(◆): 갈라지는 단계 막대의 왼쪽 끝 */
.tl-seg.branch { position: relative; }
.tl-seg.branch::before {
  content: ""; position: absolute; left: -7px; top: 5px; width: 9px; height: 9px; z-index: 1;
  background: var(--accent); border: 2px solid var(--panel); transform: rotate(45deg); border-radius: 2px;
}

/* 분기점 선택지: 코트 위 카드 */
.branch-prompt {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 2;
  width: min(520px, calc(100% - 24px)); padding: 16px 18px 14px; border-radius: var(--r-xl);
  background: var(--panel); color: var(--text); box-shadow: var(--float-shadow);
  animation: bp-in 220ms var(--ease);
}
.branch-prompt[hidden] { display: none; }
@keyframes bp-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.bp-eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--accent-text); }
.bp-q { margin: 4px 0 12px; font-size: 16.5px; font-weight: 600; line-height: 1.5; }
.bp-options { display: flex; flex-wrap: wrap; gap: 8px; }
.bp-options button {
  flex: 1 1 auto; min-height: 42px; padding: 0 16px; border-radius: 999px; background: var(--raised-2);
  font-size: 14.5px; font-weight: 600; color: var(--text); transition: background-color 150ms var(--ease);
}
.bp-options button:hover { background: var(--seg-on); }
.bp-options button.current { box-shadow: inset 0 0 0 2px var(--accent); }
.bp-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.bp-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bp-bar[hidden] { display: none; }
.bp-bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.bp-hint { margin-left: auto; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* 분기 직후 캡션: 고른 읽기 + 이유 한 줄 */
.cap-read { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 0; padding: 9px 12px; border-radius: var(--r-md); background: var(--raised); }
.cap-read[hidden] { display: none; }
.cap-read .chip { flex: none; font-size: 12.5px; font-weight: 600; color: var(--accent-text); }
.cap-read .why { font-size: 14px; line-height: 1.6; color: var(--text-sub); }

/* 단계 목록의 분기 구분선 */
#info-steps .branch-divider {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; padding: 0 12px;
  font-size: 12.5px; font-weight: 600; color: var(--accent-text);
}
#info-steps .branch-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.disclaimer { margin: 28px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--text-3); }

/* 작전 제목: 데스크톱에서는 그냥 제목, 모바일에서는 목록 시트를 여는 버튼 (▾) */
.title-btn {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; text-align: left;
  font: inherit; letter-spacing: inherit; cursor: text;
}
#hud-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.title-btn .chev { display: none; width: 22px; height: 22px; flex: none; color: var(--text-3); }

/* ───────── 모바일 작전 목록 시트 ───────── */
.sheet {
  width: 100%; max-width: 560px; max-height: 82dvh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--panel); color: var(--text);
  box-shadow: var(--float-shadow); overflow: hidden;
}
.sheet[open] { display: flex; }
.sheet::backdrop { background: var(--backdrop); }
.sheet-inner {
  display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
}
.sheet-inner::before {
  content: ""; align-self: center; width: 40px; height: 4px; border-radius: 2px; margin-bottom: 6px; background: var(--diff);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 4px 4px; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-head .round-btn { width: 40px; height: 40px; background: var(--raised); }
.sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet .library { margin-top: 6px; }
.sheet .lib-search input { font-size: 16px; }   /* iOS가 입력창을 확대하지 않도록 16px 이상 */
.sheet .play-item { min-height: 48px; }

/* ───────── 단축키 팝오버 ───────── */
.keys-pop {
  width: min(380px, calc(100vw - 32px)); margin: auto; padding: 20px 22px 22px; border: 0;
  border-radius: var(--r-xl); background: var(--panel); color: var(--text); box-shadow: var(--float-shadow);
}
.keys-pop::backdrop { background: var(--backdrop); }
.keys-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.keys-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.keys-head .round-btn { width: 40px; height: 40px; background: var(--raised); margin-right: -6px; }
.keys-list { margin: 0; display: grid; }
.keys-list div { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.keys-list div:first-child { border-top: 0; }
.keys-list dt { display: flex; align-items: center; gap: 4px; flex: none; min-width: 92px; color: var(--text-3); }
.keys-list dd { margin: 0; font-size: 14px; color: var(--text-sub); }
.licenses-link { display: inline-block; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.licenses-link[hidden] { display: none; }

/* ───────── Responsive ───────── */
@media (max-width: 1440px) {
  #app { grid-template-columns: 236px minmax(0, 1fr) 328px; }
  .toolbar .cam-bar button { padding: 0 10px; }
}
@media (max-width: 1280px) {
  .play-meta { display: none; }
  .play-head h2 { font-size: 22px; }
}
@media (max-width: 1100px) {
  #app { display: flex; flex-direction: column; height: auto; }
  #sidebar { background: transparent; padding: 4px 0 0; }
  .brand { padding: 0 4px; }
  .side-foot { display: none; }
  .title-btn { cursor: pointer; }
  .title-btn .chev { display: block; }
  .view { flex: none; height: 60vh; min-height: 320px; }
  .toolbar { padding: 0 4px; }
  .play-meta { display: block; }
  #info { overflow: visible; padding: 22px 18px 28px; }
}
@media (max-width: 680px) {
  #app { gap: 10px; }
  .brand-sub { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .toolbar { flex-wrap: wrap; }
  .play-head { flex: 1; }
  .play-head h2 { font-size: 22px; white-space: normal; }
  .tool-right { display: contents; }
  .toolbar .cam-bar { order: 3; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; }
  .toolbar .cam-bar::-webkit-scrollbar { display: none; }
  .toolbar .cam-bar button { flex: 1 0 auto; padding: 0 10px; }
  .view { height: 52vh; min-height: 300px; border-radius: 18px; }
  .toggles { margin-left: 0; }
  #caption { padding: 14px 16px 16px; border-radius: 18px; }
  #cap-title { font-size: 16.5px; }
  #cap-text { font-size: 15px; line-height: 1.75; }
  .cap-status { margin-left: 0; width: 100%; }
  #btn-skip { margin-left: auto; }
  .controls { padding: 12px 14px; border-radius: 18px; }
  #transport { flex-wrap: wrap; gap: 6px 10px; }
  .timeline { order: -1; flex-basis: 100%; height: 24px; }
  .tl-label { display: none; }
  .t-buttons { flex: 1; }
  .time { min-width: 0; }
  #settings { gap: 10px 16px; }
  .set-group { width: 100%; justify-content: space-between; }
  #score-pop { font-size: 64px; }
  .read-bar-label { display: none; }
  .branch-prompt { bottom: 10px; padding: 14px 14px 12px; }
  .bp-q { font-size: 15.5px; }
  .bp-options button { min-height: 40px; padding: 0 12px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
