/* STAGE NOTE — 원래 프로토타입의 무드(남색 사이드바 · 세리프 제목 · 따뜻한 종이색 · 작은 영문 소제목)를 유지한다 */
:root {
  --bg: #f8f7f3; --paper: #fffefa; --card: #ffffff;
  --ink: #24374c; --text: #324456; --muted: #5f6f7e; --line: #e4e6e6; --line2: #ecedef;
  --navy: #243a50; --navy-2: #38546c;
  --side: #1c2b3a; --side-ink: #bdc9d4; --side-on: #33475a;
  --blue: #4e7eaa; --blue-soft: #edf4f9; --blue-line: #9cb8cf;
  --tan: #b8a08b; --tan-soft: #f6f2ec; --tan-ink: #7a5a3a;
  --hero: #e9e6e0; --hero-num: #d0ccc5;
  --warn: #a7774c; --err: #b1605d; --ok: #2f7d4f;
  --on-navy: #ffffff;
  --radius: 12px; --r-btn: 9px;
  --serif: "SN Serif", Georgia, "Noto Serif KR", "Nanum Myeongjo", AppleMyungjo, Batang, serif;
  --sans: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --reading: 17px;
  --bar-h: 56px;
  --side-w: 204px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131b23; --paper: #19222b; --card: #1d2731;
    --ink: #e8e6e0; --text: #d5d9dd; --muted: #93a0ac; --line: #2c3743; --line2: #26303a;
    --navy: #8fb4d8; --navy-2: #a9c7e3; --on-navy: #10161c;
    --blue-soft: #1f2e3c; --blue-line: #44627f; --tan-soft: #262a2c; --tan: #8a7a69; --tan-ink: #d2b99a;
    --hero: #222b34; --hero-num: #34404b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

/* ── 틀: 데스크톱은 남색 사이드바 + 본문, 모바일은 본문만 ── */
.layout { display: block; min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 8; height: var(--bar-h); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar.editing { border-bottom: 2px solid var(--warn); }
.tb-left { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; }
.tb-right { display: flex; align-items: center; gap: 6px; flex: none; }
.icon { border: 0; background: none; color: var(--muted); min-height: 44px; min-width: 44px; padding: 0 8px; font-size: 14px; border-radius: var(--r-btn); }
.icon.back { font-size: 20px; color: var(--ink); padding: 0; }
.crumbs { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.crumbs strong { color: var(--ink); font-size: 14px; display: block; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--serif); letter-spacing: -.03em; font-weight: 600; }
.has-back .c-root, .has-back .c-sep { display: none; }
.step { display: inline-flex; align-items: center; gap: 4px; padding-right: 6px; }
.step i { display: block; width: 22px; height: 4px; border-radius: 2px; background: var(--line); }
.step i.on { background: var(--navy); }
.content { padding: 18px 16px 96px; max-width: 1180px; margin: 0 auto; }
.content > main, main { display: grid; gap: 16px; }
.content.narrow { max-width: 760px; }
.content.work { padding: 0 0 96px; max-width: none; }

.sb-brand { font-family: var(--serif); letter-spacing: .06em; font-size: 21px; color: #f9f7f3; padding: 8px 12px 28px; }
.nav { display: flex; gap: 12px; align-items: center; text-align: left; background: transparent; border: 0; color: var(--side-ink); border-radius: 9px; padding: 0 14px; min-height: 46px; font-size: 14px; width: 100%; }
.nav .glyph { width: 22px; height: 20px; display: grid; place-items: center; }
.nav .glyph svg { display: block; }
.nav.active { color: #fff; background: var(--side-on); font-weight: 700; }
.nav:hover:not(.active):not([disabled]) { background: #314154; }
.nav[disabled] { opacity: .4; cursor: not-allowed; }
.sb-label { font-size: 11px; letter-spacing: .14em; color: #9fb2c4; padding: 18px 14px 4px; text-transform: uppercase; }
.sb-work { font-family: var(--serif); color: #e9eef3; padding: 0 14px 6px; font-size: 14px; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-bottom { margin-top: auto; padding: 18px 13px 4px; border-top: 1px solid #52617455; font-size: 11px; color: #9eaebe; line-height: 1.7; }

/* ── 공통 요소 ── */
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.page-title { font-family: var(--serif); font-size: 27px; letter-spacing: -.05em; font-weight: 500; color: var(--ink); margin: 8px 0 4px; line-height: 1.3; }
.lead { margin: 0; color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.center { text-align: center; }
.foot { margin-top: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
h3 { font-size: 15px; letter-spacing: -.02em; margin-bottom: 6px; }

.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid color-mix(in srgb, var(--line) 65%, var(--muted)); background: var(--card); color: var(--text); border-radius: var(--r-btn); padding: 0 16px; min-height: 44px; font-size: 14px; font-weight: 650; }
@media (prefers-color-scheme: dark) { .btn { border-color: var(--line); color: var(--ink); } }
.btn:hover:not([disabled]) { background: var(--blue-soft); }
.btn.primary { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
.btn.primary:hover:not([disabled]) { background: var(--navy-2); }
.btn.big { width: 100%; min-height: 52px; font-size: 15px; }
.btn.secondary { background: transparent; }
.btn.link { border: 0; background: none; color: var(--blue); padding: 0 4px; text-decoration: underline; min-height: 44px; font-weight: 600; }
.btn.danger { border-color: var(--err); color: var(--err); background: transparent; }
.btn.grow { flex: 1; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary[disabled] { opacity: 1; background: var(--line); border-color: var(--line); color: var(--muted); }
.chip-btn { padding: 0 14px; font-size: 13px; }
.field { display: grid; gap: 6px; }
.lab { font-weight: 700; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
input[type=text], textarea, select { width: 100%; border: 1px solid color-mix(in srgb, var(--line) 65%, var(--muted)); background: var(--card); border-radius: 8px; padding: 10px 12px; min-height: 44px; font-size: 15px; color: var(--ink); }
textarea { resize: vertical; line-height: 1.7; }
.drop { display: grid; gap: 4px; place-items: center; text-align: center; border: 1px solid var(--line); border-radius: 14px; padding: 24px 14px 22px; cursor: pointer; background: var(--paper); }
.drop strong { font-size: 15px; color: var(--ink); }
.drop-ic { color: var(--tan-ink); margin-bottom: 2px; }
.drop-ic .glyph { width: 32px; height: 32px; }
.drop-ic svg { width: 32px; height: 32px; stroke-width: 1.4; }
.drop:hover, .drop:focus-within { border-color: var(--navy); background: var(--blue-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.busy { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; padding: 12px; background: var(--card); }
.busy .bar-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--blue) 18%, transparent); transition: width .2s; }
.busy span { position: relative; }
.error { border: 1px solid var(--err); color: var(--err); border-radius: 10px; padding: 12px; background: color-mix(in srgb, var(--err) 8%, var(--card)); }
.warn { color: var(--warn); }
.note { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.result { display: flex; gap: 12px; align-items: flex-start; }
.result-body { min-width: 0; }
.result h3 { margin: 0 0 2px; }
.result p { margin: 4px 0; font-size: 14px; }
.ok-ic { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.ok-ic .glyph { width: 16px; height: 16px; }
.ok-ic svg { width: 16px; height: 16px; stroke-width: 2.2; }
.actions { display: grid; gap: 8px; }
.actions.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.sticky { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.stats, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid color-mix(in srgb, var(--line) 65%, var(--muted)); background: var(--card); border-radius: 8px; padding: 4px 12px; font-size: 13px; min-height: 32px; display: inline-flex; align-items: center; color: var(--text); }
@media (prefers-color-scheme: dark) { .chip { border-color: var(--line); color: var(--text); } }
.chip.stat { background: transparent; }
.chip.add { cursor: pointer; border-style: dashed; min-height: 44px; }
.chip.choice { cursor: pointer; min-height: 44px; }
.chip.choice.on { background: var(--blue-soft); border-color: var(--blue-line); color: var(--ink); font-weight: 700; }

/* ── 홈 ── */
.home { gap: 22px; }
.crumbs.is-home .c-sep, .crumbs.is-home strong { display: none; }
.crumbs.is-home .c-root { font-family: var(--serif); font-size: 16px; font-weight: 600; letter-spacing: .14em; color: var(--ink); }
.hero { position: relative; display: grid; gap: 6px; justify-items: start; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 20px; }
.hero:after { content: ''; position: absolute; top: -1px; right: 22px; width: 16px; height: 34px; background: var(--tan); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%); }
.hero.empty { padding: 26px 22px 22px; }
.hero.empty:after { display: none; }
.hero-kicker { margin: 0; font-size: 13px; font-weight: 650; color: var(--tan-ink); }
.hero-title { font-family: var(--serif); font-weight: 600; font-size: clamp(25px, 7vw, 32px); line-height: 1.25; letter-spacing: -.045em; color: var(--ink); margin: 2px 0 0; word-break: keep-all; padding-right: 36px; }
.hero.empty .hero-title { padding-right: 0; }
.hero-meta { margin: 0; font-size: 14px; line-height: 1.6; color: var(--muted); max-width: 34em; }
.hero-go { margin-top: 12px; min-width: 168px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; }
.section-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.03em; color: var(--ink); display: flex; align-items: baseline; gap: 8px; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); }
.shelf { display: grid; gap: 4px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--line2); }
.item { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line2); }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 12px 0; border: 0; background: none; text-align: left; color: inherit; }
.poster { flex: none; position: relative; width: 44px; height: 58px; border-radius: 3px 6px 6px 3px; background: linear-gradient(145deg, var(--tone, #31455b), #131f2e); box-shadow: 0 2px 6px #25384b30; }
.poster:before { content: ''; position: absolute; inset: 0 auto 0 5px; width: 1px; background: #ffffff40; }
.item-text { min-width: 0; display: grid; gap: 1px; }
.cover-label { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: -.03em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-main:hover .cover-label { text-decoration: underline; text-underline-offset: 3px; }
.meta { color: var(--muted); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon.del { flex: none; font-size: 12.5px; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.notice p { flex: 1; margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.notice .btn { flex: none; }
.notice.alert { background: color-mix(in srgb, var(--warn) 9%, var(--paper)); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.notice.alert p { color: var(--text); }
.foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 4px; margin: 0; }
.foot .btn.link { color: var(--muted); text-decoration: none; font-size: 13px; padding: 0 10px; }
.foot .btn.link:hover { color: var(--ink); text-decoration: underline; }
.filebtn { position: relative; cursor: pointer; }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filebtn:focus-within { outline: 2px solid var(--blue); }

/* ── 배역 목록 ── */
.chars { list-style: none; margin: 0 0 8px; padding: 0; display: grid; }
.char { border-bottom: 1px solid var(--line2); }
.char:last-child { border-bottom: 0; }
.char-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 4px 2px; border: 0; background: none; text-align: left; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--dot, #7486a0); }
.cname { font-weight: 700; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calias { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cnt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.char-head .cnt { margin-left: auto; }
.cnt.zero { color: var(--warn); }
.chev { color: var(--muted); width: 16px; height: 16px; display: inline-grid; place-items: center; font-size: 0; }
.chev:before { content: ''; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translate(-1px, -1px); }
.chev.up:before { transform: rotate(-135deg) translate(-1px, -1px); }
.char-edit { display: grid; gap: 10px; padding: 4px 2px 14px 20px; }
.sug { margin: 8px 0; }
.paste summary { cursor: pointer; padding: 10px 0; min-height: 44px; display: flex; align-items: center; color: var(--blue); font-weight: 600; font-size: 14px; }
.addrow { display: flex; gap: 8px; margin-top: 8px; }

/* ── 대본 미리보기(만들기 화면): 간단한 목록 ── */
.script { display: grid; gap: 2px; }
.script.small { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; background: var(--paper); }
.blk { padding: 9px 13px; margin: 3px 0; border-radius: 4px; cursor: default; content-visibility: auto; contain-intrinsic-size: auto 54px; word-break: keep-all; overflow-wrap: anywhere; font-size: var(--reading); line-height: 1.9; color: var(--text); }
.script.small .blk { cursor: pointer; }
.script.small .blk:hover { background: var(--blue-soft); }
.blk:focus-visible { outline: 2px solid var(--blue); }
.r-speech { border-left: 3px solid var(--c, var(--line)); }
.who { display: block; font-size: 12px; font-weight: 750; letter-spacing: .01em; color: var(--c); line-height: 1.5; margin-bottom: 2px; }
.say { display: block; }
.r-speech.label { padding-bottom: 0; }
.mine .say { background: var(--blue-soft); padding: 1px 5px; margin-left: -5px; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.mine { border-left-width: 4px; }
.r-direction { color: var(--muted); font-size: calc(var(--reading) - 2px); }
.r-scene { font-family: var(--serif); font-weight: 500; font-size: 23px; letter-spacing: -.05em; line-height: 1.4; margin-top: 30px; padding: 4px 0 12px; color: var(--ink); border-bottom: 1px solid var(--line); border-radius: 0; }
.r-scene:before { content: 'SCENE'; display: block; font-family: var(--sans); font-size: 11px; letter-spacing: .16em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.r-number { margin: 22px 0 6px; padding: 12px 16px; background: var(--tan-soft); border-left: 3px solid var(--tan); border-radius: 0 8px 8px 0; font-family: var(--serif); font-size: 19px; letter-spacing: -.04em; font-weight: 600; color: var(--tan-ink); line-height: 1.5; }
.r-lyric { font-family: var(--serif); text-align: center; color: var(--muted); line-height: 2; }
.r-noise { color: var(--muted); text-decoration: line-through; font-size: 13px; }
.r-unknown { border-left: 3px dotted var(--line); }
figure.page { margin: 8px 0; }
figure.page img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
figure.page figcaption { text-align: center; color: var(--muted); font-size: 12px; }
.flash { animation: flash 1.5s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--blue) 30%, transparent); } to { background: transparent; } }

/* ── 읽기 글꼴: 앱에 넣어 둔 명조·고딕 (기기마다 모양이 달라지지 않게) ── */
@font-face { font-family: "SN Serif"; src: url(./fonts/serif-400.woff) format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SN Serif"; src: url(./fonts/serif-600.woff) format("woff"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "SN Sans"; src: url(./fonts/sans-400.woff) format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SN Sans"; src: url(./fonts/sans-600.woff) format("woff"); font-weight: 600 800; font-display: swap; }
:root {
  --r-serif: "SN Serif", "Noto Serif KR", "Nanum Myeongjo", AppleMyungjo, "Noto Serif CJK KR", Batang, serif;
  --r-sans: "SN Sans", "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --r-family: var(--r-serif);
}
html[data-rfont="sans"] { --r-family: var(--r-sans); }

/* ── 읽기 화면 테마: 이 화면 안의 색 토큰을 통째로 바꾼다 (창·메뉴·막대가 함께 바뀜) ── */
.app-root.is-work {
  --r-bg: #f3eddf; --r-bar: #f8f3e7; --r-card: #fbf8ef; --r-ink: #2e2a22; --r-text: #3b352b; --r-sub: #6c624f; --r-line: #e0d7c3;
  --r-mine: #ecdcb8; --r-soft: #ebe3cf; --r-edge: #c5b48f; --r-accent: #7a5a3a; --r-navy: #4a3f2f; --r-navy2: #5e5240; --r-on: #fbf8ef;
  --r-tan-soft: #ebe2cf; --r-tan: #a88f68; --r-tan-ink: #6f5632;
  --bg: var(--r-bg); --paper: var(--r-bar); --card: var(--r-card); --ink: var(--r-ink); --text: var(--r-text); --muted: var(--r-sub);
  --line: var(--r-line); --line2: color-mix(in srgb, var(--r-line) 60%, var(--r-bg));
  --blue: var(--r-accent); --blue-soft: var(--r-soft); --blue-line: var(--r-edge);
  --navy: var(--r-navy); --navy-2: var(--r-navy2); --on-navy: var(--r-on);
  --tan-soft: var(--r-tan-soft); --tan: var(--r-tan); --tan-ink: var(--r-tan-ink);
  background: var(--r-bg); color: var(--r-text); min-height: 100dvh;
}
html[data-rt="white"] .app-root.is-work {
  --r-bg: #fbfbf9; --r-bar: #ffffff; --r-card: #ffffff; --r-ink: #1f2328; --r-text: #2a2f35; --r-sub: #646c74; --r-line: #e6e8ea;
  --r-mine: #e3eef7; --r-soft: #eef4f9; --r-edge: #9cb8cf; --r-accent: #4e7eaa; --r-navy: #243a50; --r-navy2: #38546c; --r-on: #ffffff;
  --r-tan-soft: #f6f2ec; --r-tan: #b8a08b; --r-tan-ink: #7a5a3a;
}
html[data-rt="gray"] .app-root.is-work {
  --r-bg: #e2e2de; --r-bar: #eaeae6; --r-card: #efefeb; --r-ink: #222222; --r-text: #2c2c2a; --r-sub: #5a5a54; --r-line: #cdcdc6;
  --r-mine: #c9d6de; --r-soft: #d8dee2; --r-edge: #9fb2c0; --r-accent: #3f6585; --r-navy: #34424f; --r-navy2: #475766; --r-on: #f2f2ee;
  --r-tan-soft: #d9d6cd; --r-tan: #9a8a76; --r-tan-ink: #5f4d38;
}
html[data-rt="night"] .app-root.is-work {
  --r-bg: #14161a; --r-bar: #1a1d21; --r-card: #1f2328; --r-ink: #e3e5e8; --r-text: #c7cbd1; --r-sub: #858c95; --r-line: #2b3036;
  --r-mine: #26394d; --r-soft: #1f2e3c; --r-edge: #44627f; --r-accent: #7fa8d0; --r-navy: #34506a; --r-navy2: #41607e; --r-on: #e6edf3;
  --r-tan-soft: #24272b; --r-tan: #8a7a69; --r-tan-ink: #d2b99a;
}

/* ── 대본 읽기: 웹소설처럼 — 넉넉한 줄 간격, 알맞은 줄 길이, 장식 없는 문단 ── */
.script.rd { display: block; font-family: var(--r-family); font-size: var(--r-size, 18px); line-height: var(--r-lh, 1.85); width: 100%; max-width: var(--r-measure, 560px); margin: 0 auto; color: var(--text); text-wrap: pretty; -webkit-font-smoothing: antialiased; }
.script.rd .blk { padding: 0; margin: 0; border: 0; border-radius: 0; font-size: 1em; line-height: inherit; color: var(--text); content-visibility: visible; contain-intrinsic-size: none; word-break: keep-all; overflow-wrap: break-word; }
/* 아주 긴 대본(1,000줄 이상)만 화면 밖 줄의 그리기를 미룬다 */
.script.rd.big .blk { content-visibility: auto; contain-intrinsic-size: auto 3.7em; }
.script.rd .r-speech { margin-top: 1.1em; }
.script.rd .r-speech.cont { margin-top: .35em; }
/* 대본 형식(기본): 이름은 왼쪽 칸, 대사는 같은 줄 오른쪽 칸 — 줄이 바뀌어도 대사 칸에 맞춰 정렬 */
html:not([data-rnames="top"]) .script.rd .r-speech { position: relative; padding-left: calc(var(--name-w, 3em) + .9em); }
html:not([data-rnames="top"]) .script.rd .who { position: absolute; left: 0; top: 0; width: calc(var(--name-w, 3em) / .78); margin: 0; line-height: calc(var(--r-lh, 1.85) / .78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html:not([data-rnames="top"]) .script.rd .r-speech.label { min-height: calc(var(--r-lh, 1.85) * 1em); }
html:not([data-rnames="top"]) .script.rd .r-speech.label + .cont { margin-top: calc(var(--r-lh, 1.85) * -1em); }
html:not([data-rnames="top"]) .script.rd.editing .r-speech { padding-left: calc(var(--name-w, 3em) + 1.5em); }
html:not([data-rnames="top"]) .script.rd.editing .who { left: .6em; top: .3em; }
.script.rd .who { display: block; font-family: var(--r-sans); font-size: .78em; font-weight: 650; letter-spacing: .03em; line-height: 1.6; margin: 0 0 .1em; color: color-mix(in srgb, var(--c, var(--muted)) 78%, var(--ink)); }
/* 내 배역을 골랐을 때: 내 이름만 내 색으로, 나머지 이름은 차분하게 */
.script.rd.has-mine .r-speech:not(.mine) .who { color: var(--muted); font-weight: 500; }
.script.rd .say { display: block; }
.script.rd .mine .say { display: inline; background: color-mix(in srgb, var(--c, var(--blue)) 20%, transparent); padding: .1em .4em; margin-left: -.4em; border-radius: .35em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.script.rd .mine .who { font-weight: 800; color: color-mix(in srgb, var(--c) 88%, var(--ink)); }
.script.rd .r-direction { margin: 1.15em 0; font-size: .92em; line-height: 1.8; color: var(--muted); }
.script.rd .r-scene { margin: 3.4em 0 1.5em; text-align: center; font-family: var(--r-serif); font-weight: 600; font-size: 1.3em; line-height: 1.4; letter-spacing: -.01em; color: var(--ink); }
.script.rd > .r-scene:first-child { margin-top: 1.4em; }
.script.rd .r-scene:before { content: 'SCENE'; display: block; font-family: var(--r-sans); font-size: max(11px, .46em); font-weight: 600; letter-spacing: .32em; color: var(--muted); margin-bottom: .9em; }
.script.rd .r-scene:after { content: ''; display: block; width: 2.4em; height: 1px; background: var(--line); margin: 1.1em auto 0; }
.script.rd .r-number { margin: 2.6em 0 1em; padding: 1.1em .5em; text-align: center; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: none; font-family: var(--r-serif); font-size: 1.12em; font-weight: 600; letter-spacing: -.01em; color: var(--tan-ink); line-height: 1.5; }
.script.rd .r-lyric { font-family: var(--r-serif); text-align: center; color: var(--text); opacity: .85; line-height: calc(var(--r-lh, 1.85) + .1); margin: .1em 0; }
.script.rd .r-unknown { border: 0; color: var(--muted); }
.script.rd .r-noise { font-size: .8em; }
.script.rd figure.page { margin: 1.2em 0; }
.script.rd.editing .blk { padding: .3em .6em; margin: 0 -.6em; border-radius: 8px; cursor: pointer; }
.script.rd.editing .blk:hover { background: var(--blue-soft); }
.script.rd.editing .r-unknown { box-shadow: inset 3px 0 0 var(--warn); }
.script.rd.editing .r-speech { margin-top: .6em; }
.script.rd.editing .r-speech.cont { margin-top: 0; }

/* ── 읽기 화면 틀: 카드 없이 한 장의 종이처럼 ── */
.work-layout { display: block; }
.reader { padding: 14px 22px 120px; min-width: 0; }
.reader-head { display: none; }
.sidepanel { display: none; }
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; }
.check.small { font-size: 13px; color: var(--muted); }

/* 위쪽 가는 읽은 정도 막대 */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 40; pointer-events: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--blue); opacity: .75; transition: width .15s linear; }

/* ── 하단 막대: 내 대사 이동 / 교정 상태 ── */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 8px; align-items: center; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--paper) 94%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.dock-step { min-width: 56px; padding: 0 16px; font-size: 16px; }
.dock-mid { flex: 1; min-width: 0; min-height: 44px; border: 1px solid var(--blue-line); border-radius: var(--r-btn); background: var(--blue-soft); font-weight: 700; font-size: 14px; color: var(--ink); padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-info { flex: 1; font-size: 13px; color: var(--warn); font-weight: 600; }

/* 내 대사 이동: 모서리의 작은 알약 (넓은 화면에서는 목차 패널 왼쪽) */
.mine-nav { position: fixed; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10; display: flex; align-items: center; background: color-mix(in srgb, var(--paper) 92%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: 0 6px 22px #0002; backdrop-filter: blur(8px); }
.mine-nav .nav-b { min-width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 999px; background: none; font-size: 13px; color: var(--ink); }
.mine-nav .nav-b:hover { background: var(--blue-soft); }
.mine-nav .nav-mid { min-height: 44px; padding: 0 8px; border: 0; background: none; font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.role-hint { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 auto 1.4em; max-width: var(--r-measure, 560px); padding: 8px 8px 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font: 13px/1.5 var(--sans); color: var(--muted); }
.role-hint .btn { flex: none; min-height: 40px; }
.num-hint .btn { min-height: 44px; }

/* 메뉴 묶음 제목 */
.menu-group { margin: 14px 0 2px; font: 700 12px var(--sans); letter-spacing: .06em; color: var(--muted); }

/* 단원 · 공유 */
.tp-title { margin: 0; font-size: 15px; color: var(--text); }
.tp-box { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.tp-code { font: 700 26px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .14em; color: var(--ink); word-break: break-all; user-select: all; }
.tp-sync { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tp-h { margin: 14px 0 0; font: 700 14px var(--sans); color: var(--ink); }
.tp-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.tp-main { display: grid; gap: 2px; min-width: 0; }
.tp-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.tp-state { font-size: 13px; color: var(--muted); }
.tp-state.warn { color: var(--warn); font-weight: 600; }
.chip .picked { color: var(--muted); font-weight: 500; }

/* 만들기 화면의 미리보기: 읽기 화면과 같은 모양 */
.preview-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 14px 14px; background: var(--paper); overflow: hidden; }
.preview-box .script.rd { font-size: 17px; }
.stat-line { margin: 0; font-size: 14px; color: var(--muted); }
.stat-line .st { margin-right: 14px; white-space: nowrap; }
.stat-line b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-line .stat-warn, .stat-line .stat-warn b { color: var(--warn); font-weight: 600; }

/* 위 막대의 아이콘 버튼: 테두리 없이 선 그림만 */
.tb-btn { display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--ink); cursor: pointer; }
.tb-btn:hover { background: var(--blue-soft); }
.tb-btn.on { color: var(--blue); background: var(--blue-soft); }
.tb-btn .glyph { display: grid; place-items: center; }
.tb-btn .glyph svg { display: block; }

/* 암기 모드: 내 대사를 가리거나 첫 글자만 보인다 */
.script.rd .hint-t { display: none; }
.script.rd.mem-hide .mine:not(.revealed) .full { color: transparent; user-select: none; -webkit-user-select: none; background: color-mix(in srgb, var(--c, var(--blue)) 30%, transparent); border-radius: .3em; -webkit-box-decoration-break: clone; box-decoration-break: clone; text-shadow: none; }
.script.rd.mem-hint .mine:not(.revealed) .full { display: none; }
.script.rd.mem-hint .mine:not(.revealed) .hint-t { display: inline; letter-spacing: .06em; color: color-mix(in srgb, var(--c, var(--blue)) 55%, var(--text)); }
.script.rd.mem-hide .mine, .script.rd.mem-hint .mine { cursor: pointer; }

/* 읽어주는 중인 문단 */
.script.rd .blk.speaking { box-shadow: 0 0 0 .35em color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); background: color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); border-radius: .5em; }
.script.rd .r-scene.speaking, .script.rd .r-number.speaking { box-shadow: none; }

/* 연습 진행 막대: 화면 아래에 떠 있는 작은 조종판 */
.practice-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 11; max-width: 460px; margin: 0 auto; padding: 8px 8px 8px 14px; background: color-mix(in srgb, var(--paper) 96%, transparent); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 28px #0003; backdrop-filter: blur(10px); }
.pb-status { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font: 600 13px/1.4 var(--sans); color: var(--ink); padding: 2px 6px 4px 0; }
.pb-pos { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.pb-row { display: flex; gap: 4px; align-items: center; }
.pb-b { flex: 1; min-height: 44px; padding: 0 6px; border: 0; border-radius: 12px; background: none; font: 600 13px var(--sans); color: var(--ink); cursor: pointer; white-space: nowrap; }
.pb-b:hover { background: var(--blue-soft); }
.pb-b.main { flex: 1.3; background: var(--navy, var(--blue)); color: #fff; }
.pb-b.main:hover { filter: brightness(1.08); background: var(--navy, var(--blue)); }
.practicing .script.rd { padding-bottom: 150px; }
.practicing .mine-nav { display: none; }
.pr-sec { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.pr-sec h4 { margin: 0; font: 700 15px var(--sans); color: var(--ink); }
.hint.warn { color: var(--warn); }
.role-hint.inline { margin: 0; max-width: none; }

/* 몰입 모드: 읽는 동안 위·아래 막대가 물러난다 */
.is-work .topbar, .is-work .dock { transition: transform .28s ease, visibility 0s linear 0s; }
.is-work.chrome-off .topbar { transform: translateY(-101%); visibility: hidden; transition: transform .28s ease, visibility 0s linear .28s; }
.is-work.chrome-off .dock { transform: translateY(101%); visibility: hidden; transition: transform .28s ease, visibility 0s linear .28s; }
@media (prefers-reduced-motion: reduce) { .is-work .topbar, .is-work .dock, .progress i { transition: none !important; } }

/* ── 읽기 설정 창: 뒤의 글이 보이도록 어둡게 덮지 않는다 ── */
.sheet-bg.clear { background: transparent; pointer-events: none; }
.sheet-bg.clear .sheet { pointer-events: auto; box-shadow: 0 -10px 36px #0003; border-top: 1px solid var(--line); gap: 12px; }
.rp-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: center; gap: 10px; }
.rp-lab { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch { display: grid; justify-items: center; gap: 4px; background: none; border: 0; padding: 0; min-height: 44px; font-size: 12px; color: var(--muted); }
.swatch i { width: 40px; height: 40px; border-radius: 50%; background: var(--sw-bg); color: var(--sw-fg); display: grid; place-items: center; font-style: normal; font-size: 16px; font-family: var(--r-serif); border: 1px solid color-mix(in srgb, var(--sw-fg) 25%, transparent); }
.swatch.on i { outline: 2px solid var(--blue); outline-offset: 2px; }
.swatch.on { color: var(--ink); font-weight: 700; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--line2); border-radius: 10px; padding: 4px; }
.seg-b { min-height: 44px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 15px; }
.seg-b.on { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px #0002; }
.stepper { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.stepper .val { min-width: 48px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.rp-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rp-foot .hint { margin: 0; }
.chip-btn.aa { font-family: var(--r-serif); font-weight: 600; letter-spacing: -.02em; }

/* ── 시트(창) ── */
.sheet-bg { position: fixed; inset: 0; background: rgba(33, 52, 73, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--bg); width: min(100%, 640px); max-height: 88dvh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 10px; align-content: start; }
.sheet:focus { outline: none; }
.sheet.tall { min-height: 50dvh; }
.sheet blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--tan); background: var(--tan-soft); border-radius: 0 8px 8px 0; white-space: pre-wrap; font-size: 15px; }
.samples { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.cands { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cands li { display: flex; justify-content: space-between; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.cands em { color: var(--muted); font-size: 12px; font-style: normal; }
.menu { display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.menu-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--line2); background: none; text-align: left; font-size: 15px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover:not([disabled]) { background: var(--blue-soft); }
.menu-item[disabled] { opacity: .45; cursor: not-allowed; }
.mv { color: var(--muted); font-size: 13px; text-align: right; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--line2); border-radius: 9px; padding: 4px; }
.tab { min-height: 44px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; }
.tab.on { background: var(--card); color: var(--ink); font-weight: 750; box-shadow: 0 1px 3px #25384b1a; }
.toc { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 7px; }
.toc-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; width: 100%; min-height: 48px; padding: 8px 12px; border: 0; border-left: 2px solid var(--blue-line); background: var(--card); text-align: left; font-size: 14px; color: var(--text); border-radius: 0 6px 6px 0; }
.toc-item:hover { background: var(--blue-soft); }
.tt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn { color: var(--muted); font-size: 12px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }

/* ── 표·알림 ── */
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; white-space: nowrap; }
.json { font: 12px/1.4 ui-monospace, monospace; }
.toast { position: fixed; left: 0; right: 0; bottom: calc(20px + env(safe-area-inset-bottom)); margin: 0 auto; width: max-content; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 12px; background: #263e53; color: #fff; padding: 11px 18px; border-radius: 9px; z-index: 30; box-shadow: 0 8px 30px #26364c55; font-size: 14px; }
.toast.up { bottom: calc(76px + env(safe-area-inset-bottom)); }
.toast.top { bottom: auto; top: calc(12px + env(safe-area-inset-top)); }
.toast-act { border: 0; background: none; color: #bcd8f0; font-weight: 800; text-decoration: underline; min-height: 44px; padding: 0 4px; white-space: nowrap; }

@media (max-width: 899px) { .section-head .chip-btn { display: none; } }
.tocbody { display: grid; gap: 8px; }

/* ── 넓은 화면 ── */
@media (min-width: 900px) {
  :root { --bar-h: 63px; }
  .layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .btn, .chip-btn, .icon { min-height: 40px; }
  .chip-btn { min-height: 36px; }
  .sidebar { display: flex; flex-direction: column; gap: 6px; background: var(--side); padding: 26px 13px 20px; position: sticky; top: 0; height: 100dvh; overflow: auto; }
  .topbar { padding: 0 clamp(18px, 3vw, 46px); }
  .has-back .c-root, .has-back .c-sep { display: inline; }
  .content { padding: clamp(18px, 3vw, 40px) clamp(18px, 3vw, 46px) 60px; }
  .content.work { padding: 0 0 90px; }
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
  .hero { padding: 26px 30px 24px; }
  .crumbs.is-home .c-root { display: none; }
  .crumbs.is-home strong { display: block; }
  .mine-nav { right: 288px; bottom: 24px; }
  .practice-bar { left: auto; right: 304px; bottom: 24px; width: 440px; margin: 0; }
  .dock { left: var(--side-w); padding-inline: max(14px, calc((100% - 700px) / 2)); }
  .progress { left: var(--side-w); }
  .sheet-bg { align-items: center; }
  .sheet-bg.clear { align-items: flex-end; justify-content: flex-end; padding: 0 28px 84px; }
  .sheet-bg.clear .sheet { width: 380px; border-radius: 16px; border: 1px solid var(--line); }
  .sheet { border-radius: 16px; max-height: 82dvh; }
  .sheet.tall { min-height: 0; }
  .work-layout { display: grid; grid-template-columns: minmax(0, 1fr) 264px; }
  .reader { padding: 40px clamp(24px, 4vw, 64px) 140px; }
  .reader-head { display: block; max-width: var(--r-measure, 560px); margin: 0 auto 34px; }
  .reader-head h1 { font-family: var(--r-serif); font-size: 28px; letter-spacing: -.02em; font-weight: 600; margin: 8px 0 6px; line-height: 1.3; }
  .meta-line { color: var(--muted); font-size: 12px; }
  .role-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
  .role-line .rl { font-size: 11px; color: var(--muted); margin-right: 2px; }
  .role-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 0 12px; font-size: 13px; color: var(--text); }
  .role-chip.active { background: var(--blue-soft); border-color: var(--blue-line); color: var(--ink); font-weight: 750; }
  .sidepanel { display: block; border-left: 1px solid var(--line); padding: 28px 18px 28px 20px; position: sticky; top: var(--bar-h); align-self: start; min-height: calc(100dvh - var(--bar-h)); max-height: calc(100dvh - var(--bar-h)); overflow: auto; }
  .sidepanel h3 { font-size: 11px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin-bottom: 10px; }
  .only-narrow { display: none; }
}
@media print {
  .sidebar, .topbar, .dock, .sidepanel, .toast { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
}

/* ── 넘버 연습: 위에 영상, 아래에 가사 ── */
.script.rd .r-number .num-open { display: flex; align-items: center; justify-content: center; min-height: 44px; width: 100%; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; letter-spacing: inherit; text-align: center; cursor: pointer; border-radius: .4em; }
.script.rd .r-number .num-open:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

.nm-root { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; min-height: 0; height: 100dvh; padding-top: env(safe-area-inset-top); overflow: hidden; overflow: clip; font-family: var(--sans); }
.nm-top { flex: none; height: var(--bar-h); display: grid; grid-template-columns: 84px 1fr 84px; align-items: center; gap: 8px; padding: 0 10px; background: var(--paper); border-bottom: 1px solid var(--line); }
.nm-close, .nm-gear { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 650; }
.nm-gear.ghost { visibility: hidden; border: 0; }
.nm-title { margin: 0; text-align: center; font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.25; color: var(--ink); letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nm-title small { display: block; font-family: var(--sans); font-size: 12px; letter-spacing: 0; color: var(--tan-ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; overflow: clip; }
.nm-media { flex: none; width: 100%; max-width: 760px; margin: 0 auto; padding: 10px 14px 0; }
.nm-video { position: relative; width: min(100%, calc(40dvh * 16 / 9)); margin: 0 auto; aspect-ratio: 16 / 9; background: #000; border-radius: 14px; overflow: hidden; display: grid; }
.nm-video iframe { width: 100%; height: 100%; border: 0; display: block; }
.nm-video:has(.nm-novideo) { aspect-ratio: auto; width: 100%; background: transparent; overflow: visible; }
.nm-loading { display: grid; place-items: center; color: #fff; font-size: 14px; }
.nm-novideo { display: grid; gap: 10px; padding: 14px; background: var(--card); border: 1px dashed var(--blue-line); border-radius: 14px; color: var(--text); font-size: 14px; }
.nm-novideo p { margin: 0; }
.nm-novideo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
a.btn { text-decoration: none; }
.nm-info { display: flex; align-items: center; gap: 8px; padding: 6px 0 0; flex-wrap: wrap; }
.nm-me { flex: 1 1 140px; min-width: 0; min-height: 44px; display: grid; align-content: center; gap: 1px; text-align: left; padding: 2px 4px; border: 0; background: none; color: var(--ink); border-radius: 10px; }
.nm-me-main { font-size: 15px; font-weight: 700; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-me-main b { color: var(--mine, var(--ink)); font-weight: 800; }
.nm-me-sub { font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-me.none .nm-me-main { color: var(--ink); text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 3px; }
.nm-me:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.nm-chips { display: flex; flex-wrap: nowrap; gap: 6px; flex: none; margin-left: auto; }
.nm-chip { flex: none; }
.nm-chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 13px; font-weight: 650; }
.nm-chip.on { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
/* 타이밍 막대: 누가 언제 부르는지. 색이 있는 것은 내 파트뿐 */
.nm-tl { position: relative; margin: 8px 0 0; padding: 7px 0; min-height: 44px; cursor: pointer; display: grid; align-content: center; border-radius: 10px; background: color-mix(in srgb, var(--ink) 4%, transparent); -webkit-tap-highlight-color: transparent; }
.nm-tl[hidden] { display: none; }
.nm-tl-lanes { display: grid; gap: 4px; padding: 0 8px; }
.nm-tl.dense .nm-tl-lanes { gap: 3px; }
.nm-lane { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 6px; min-width: 0; }
.nm-lane-name { font-size: 11px; font-weight: 650; line-height: 1; color: color-mix(in srgb, var(--text) 72%, var(--bg)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-lane.is-mine .nm-lane-name { color: var(--mine, var(--ink)); font-weight: 800; }
.nm-lane-track { position: relative; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nm-tl.dense .nm-lane-track { height: 10px; }
.nm-sp { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 28%, transparent); }
.nm-sp.on { background: color-mix(in srgb, var(--ink) 62%, transparent); }
.nm-sp.is-mine { background: color-mix(in srgb, var(--mine, var(--ink)) 62%, transparent); }
.nm-sp.is-mine.on { background: var(--mine, var(--ink)); }
.nm-tl-head { position: absolute; top: 3px; bottom: 3px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; pointer-events: none; left: 0; }
.nm-cap { margin: 4px 2px 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.nm-cap:empty { display: none; }
.nm-stamping .nm-video { width: min(100%, calc(22dvh * 16 / 9)); }
.nm-stampbox { display: grid; gap: 8px; margin: 4px 0 6px; padding: 8px 12px; background: var(--blue-soft); border: 1px solid var(--blue-line); border-radius: 12px; font-size: 14px; color: var(--ink); }
.nm-stampbox[hidden] { display: none; }
.nm-stamp-actions { display: flex; gap: 6px; }
.nm-stamp-actions .btn { flex: 1; padding: 0 6px; font-size: 13px; }
.nm-stamp-count { color: var(--muted); }
.nm-lyrics { position: relative; flex: 1; min-height: 0; width: 100%; max-width: 760px; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 6px 18px 40vh; font-family: var(--r-family); font-size: max(23px, calc(var(--r-size, 18px) * 1.32)); line-height: 1.62; scroll-padding: 30vh 0; }
.nm-lyrics:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.nm-list { list-style: none; margin: 0; padding: 0; }
.nm-line { position: relative; margin: .1em 0; padding: .22em 3.4em .22em .7em; border-left: 3px solid transparent; cursor: pointer; color: color-mix(in srgb, var(--text) 62%, var(--bg)); word-break: keep-all; overflow-wrap: anywhere; font-weight: 600; transition: color .18s, border-color .18s, background .18s; }
.nm-line.on { color: var(--ink); border-left-color: color-mix(in srgb, var(--ink) 55%, transparent); }
.nm-line.is-mine { color: var(--mine, var(--ink)); font-weight: 750; border-left-color: color-mix(in srgb, var(--mine, var(--ink)) 45%, transparent); }
.nm-line.is-mine.on { border-left-color: var(--mine, var(--ink)); }
.nm-line.nm-chorus { margin-left: 1.1em; font-size: .86em; line-height: 1.55; padding-top: .12em; padding-bottom: .12em; }
.nm-line.nm-chorus .nm-who { margin-top: .3em; font-size: 12px; }
.nm-soon { display: none; position: absolute; right: .5em; top: .3em; padding: 0 .55em; border: 1.5px solid var(--mine, var(--ink)); border-radius: 999px; font-family: var(--r-sans); font-size: 13px; font-weight: 800; line-height: 1.5; color: var(--mine, var(--ink)); background: var(--bg); }
.nm-line.soon .nm-soon { display: inline-block; }
.nm-line.on .nm-soon { display: none; }
.nm-who { display: block; margin-top: .55em; font-family: var(--r-sans); font-size: 13px; font-weight: 700; letter-spacing: .04em; color: color-mix(in srgb, var(--text) 72%, var(--bg)); line-height: 1.6; }
.nm-line.is-mine .nm-who { color: var(--mine, var(--ink)); }
.nm-t { display: none; position: absolute; right: .6em; top: 50%; transform: translateY(-50%); font-family: var(--r-sans); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--muted); }
.nm-stamping .nm-t { display: block; }
.nm-text.hinted .full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nm-text.hinted .hint-t { display: inline; letter-spacing: .06em; }
.nm-empty { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 28px 8px; color: var(--muted); font-family: var(--sans); font-size: 14px; }
.nm-empty p { margin: 0; }
.nm-bar { flex: none; display: flex; gap: 8px; justify-content: center; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.nm-ctl, .nm-main { min-height: 56px; border-radius: 16px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 17px; font-weight: 700; }
.nm-ctl { width: 76px; background: var(--card); color: var(--ink); }
.nm-main { flex: 1; max-width: 460px; background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
.nm-main[disabled] { opacity: .45; }
.nm-stampbtn { background: var(--err); border-color: var(--err); color: #fff; }
.nm-note { position: absolute; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); width: max-content; background: #263e53; color: #fff; padding: 9px 16px; border-radius: 9px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; text-align: center; }
.nm-note.show { opacity: 1; }
.nm-link { display: grid; gap: 8px; }
.nm-link-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.nm-err { margin: 0; color: var(--err); font-size: 13px; }
.nm-err:empty { display: none; }
.nm-set-group { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.nm-set-group h4 { margin: 0; font-size: 14px; color: var(--ink); }
.nm-aud-row { display: grid; gap: 6px; padding: 8px 0; border-top: 1px dashed var(--line); }
.nm-aud-main { display: grid; gap: 1px; font-size: 14px; color: var(--ink); }
.nm-aud-name { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.nm-aud-act { display: flex; flex-wrap: wrap; gap: 6px; }
.nm-aud-act .btn { padding: 0 12px; font-size: 13px; }
.nm-range { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 52dvh; overflow-y: auto; }
.nm-range-item { width: 100%; min-height: 44px; display: grid; gap: 2px; text-align: left; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font-size: 14px; }
.nm-range-item em { font-style: normal; font-size: 12px; color: var(--muted); }
.nm-range-item.on { border-color: var(--blue); background: var(--blue-soft); }
@media (min-width: 900px) {
  .nm-lyrics { font-size: max(26px, calc(var(--r-size, 18px) * 1.5)); padding-bottom: 30vh; }
  .nm-body { flex-direction: row; max-width: 1240px; margin: 0 auto; width: 100%; }
  .nm-media { flex: 0 0 54%; max-width: none; margin: 0; padding: 18px 18px 0; overflow-y: auto; }
  .nm-video { width: 100%; }
  .nm-lyrics { flex: 1; max-width: none; margin: 0; padding: 18px 22px 40px; }
}
@media (prefers-reduced-motion: reduce) { .nm-line, .nm-note { transition: none; } }

/* ── 대본 위 미니 재생기 (반주·원곡 파일) ── */
.app-root.mp-root { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; min-height: 0; height: auto; padding: 8px 14px 8px; background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px #0001; font-family: var(--sans); display: grid; gap: 2px; }
@media (min-width: 900px) { .app-root.mp-root { left: var(--side-w, 0px); padding-inline: max(14px, calc((100% - 700px) / 2)); } }
.mp-row1 { display: flex; align-items: center; gap: 8px; }
.mp-ttl { flex: 1; min-width: 0; display: grid; }
.mp-ttl b { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-ttl small { font-size: 12px; font-weight: 600; color: var(--muted); }
.mp-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.mp-segb { min-height: 44px; padding: 0 14px; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 650; }
.mp-segb.on { background: var(--navy); color: var(--on-navy); }
.mp-x { width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 18px; border-radius: 12px; }
.mp-row2 { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.mp-play { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--navy); display: grid; place-items: center; color: var(--on-navy); }
.mp-play[disabled] { opacity: .45; }
.mp-ic { display: block; width: 0; height: 0; border-left: 16px solid currentColor; border-top: 10px solid transparent; border-bottom: 10px solid transparent; margin-left: 4px; }
.mp-play.playing .mp-ic { width: 16px; height: 18px; margin: 0; border: 0; border-left: 5px solid currentColor; border-right: 5px solid currentColor; box-sizing: border-box; }
.mp-seek { flex: 1; min-width: 0; height: 44px; margin: 0; accent-color: var(--navy); background: none; }
.mp-time { flex: none; min-width: 74px; text-align: right; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.mp-row3 { display: flex; gap: 6px; }
.mp-chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 13px; font-weight: 650; }
.mp-err { display: flex; align-items: center; gap: 10px; flex: 1; font-size: 13px; line-height: 1.45; color: var(--err); }
.mp-err span { flex: 1; }
html.has-mini body { padding-bottom: var(--mp-h, 0px); }
/* 넘버 제목 아래 음원 버튼 */
.script.rd .r-number .num-tracks { display: flex; flex-wrap: wrap; gap: .5em; justify-content: center; margin-top: .6em; }
.script.rd .r-number .num-track { display: inline-flex; align-items: center; gap: .45em; min-height: 44px; padding: 0 1.1em; border-radius: 999px; border: 1px solid var(--tan); background: transparent; color: var(--tan-ink); font-family: var(--r-sans); font-size: max(13px, .62em); font-weight: 650; letter-spacing: 0; }
.script.rd .r-number .num-track:before { content: ''; border-left: .75em solid currentColor; border-top: .45em solid transparent; border-bottom: .45em solid transparent; }
.script.rd .r-number .num-track.on { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }

/* ───── 녹음 (v0.11) ───── */
.mp-row3 { flex-wrap: wrap; }
.mp-chip[disabled] { opacity: .45; }
.mp-chip.mp-recbtn { color: var(--err); border-color: currentColor; font-weight: 700; }
.mp-chip.mp-go { background: var(--navy); color: var(--on-navy); border-color: var(--navy); }
.mp-note { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); padding: 2px 2px 4px; }
.mp-ask { flex: 1; display: grid; gap: 6px; padding: 4px 0; }
.mp-ask p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text); }
.mp-ask-b { display: flex; gap: 6px; }
.mp-rec { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 52px; font-size: 14px; color: var(--ink); }
.mp-rec .mp-time { flex: 1; text-align: left; font-size: 15px; font-weight: 700; color: var(--ink); }
.mp-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--err); animation: mp-blink 1.1s ease-in-out infinite; }
@keyframes mp-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .mp-dot { animation: none; } }
.mp-chip.mp-recstop { background: #953b38; color: #fff; border-color: #953b38; font-weight: 700; }
.script.rd .r-number .num-track.rec:before { border: 0; width: .55em; height: .55em; border-radius: 50%; background: currentColor; }
/* 내 녹음 목록 */
.rl-bg { z-index: 25; }
.rl-sheet { gap: 8px; font-family: var(--sans); }
.rl-head { display: flex; align-items: center; gap: 8px; }
.rl-head > div { flex: 1; min-width: 0; display: grid; }
.rl-head h3 { margin: 0; font-size: 17px; }
.rl-head small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-note { margin: 0; }
.rl-empty { margin: 10px 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.rl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rl-item { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; }
.rl-top { display: flex; align-items: center; gap: 10px; }
.rl-title { flex: 1; min-width: 0; display: grid; }
.rl-title b { font-size: 15px; color: var(--ink); overflow-wrap: anywhere; }
.rl-title small { color: var(--muted); font-size: 12.5px; }
.rl-play { width: 48px; height: 48px; }
.rl-player { display: flex; align-items: center; gap: 8px; }
.rl-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.rl-edit { display: flex; gap: 6px; align-items: center; }
.rl-name-in { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px; }
.rl-del { color: var(--err); }

/* ── 백업·복원 시트 ── */
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h3 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: -.03em; color: var(--ink); }
.sheet-x { font-size: 16px; margin-right: -8px; }
.bk-copy { margin: 0; font-size: 14px; line-height: 1.6; }
.bk-status { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.bk-status b { display: block; font-size: 14px; color: var(--ink); }
.bk-status small { display: block; font-size: 12.5px; color: var(--muted); }
.bk-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.bk-status.done .bk-dot { background: var(--ok); }
.bk-status.none { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 8%, var(--paper)); }
.bk-actions { display: grid; gap: 8px; }
.bk-warn { margin: 0; font-size: 12.5px; }
@media (prefers-color-scheme: dark) { :root { --ok: #6cc28c; } }
