:root, [data-theme="dark"] {
  --bg: #1b1420; --card: #2a1f31; --sub: #1f1726; --input: #140f18; --btn: #3d2d46; --border: #4a3a52; --line: #6b5875; --me: #4a2140;
  --text: #f3e9f5; --muted: #b9a6c0; --accent: #ff4f8b; --ok: #3ccf8e; --ng: #ff7a59; --mid: #ffb347; --bad: #ff6b6b; --link: #7fc8ff; --shadow: none;
}
[data-theme="light"] {
  --bg: #f6f4f8; --card: #ffffff; --sub: #f3eff6; --input: #ffffff; --btn: #ece6f0; --border: #d9cfe0; --line: #b9a8c4; --me: #ffe3ee;
  --text: #2a2030; --muted: #76687e; --accent: #e83e7c; --ok: #1f9d62; --ng: #d9532c; --mid: #b86e00; --bad: #d93a3a; --link: #2f6fd6; --shadow: 0 1px 4px rgba(40, 20, 50, .08);
}
[data-theme="pink"] {
  --bg: #fff0f5; --card: #ffffff; --sub: #ffe6ef; --input: #ffffff; --btn: #ffd9e7; --border: #f5bcd1; --line: #f093b5; --me: #ffd3e4;
  --text: #4a1f33; --muted: #9a6178; --accent: #ff4f8b; --ok: #1f9d62; --ng: #d9532c; --mid: #b86e00; --bad: #d93a3a; --link: #c2185b; --shadow: 0 2px 8px rgba(255, 79, 139, .12);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif; line-height: 1.5; }
main { max-width: 720px; margin: 0 auto; padding: 20px 16px 80px; }
h1 { font-size: 1.5rem; margin: 12px 0 16px; }
h1 small { font-size: .9rem; color: var(--muted); font-weight: normal; margin-left: 6px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card.due { border: 2px solid var(--accent); }
.hint { color: var(--muted); font-size: .9rem; }
.error { color: var(--ng); font-size: .9rem; min-height: 1em; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
input, select, textarea { background: var(--input); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
textarea { width: 100%; font-family: Consolas, monospace; font-size: .85rem; }
button { background: var(--btn); color: var(--text); border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; cursor: pointer; margin: 4px 4px 4px 0; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: #fff; font-weight: bold; }
button.small { padding: 2px 8px; font-size: .8rem; }
.pool { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.char { background: var(--sub); border-radius: 10px; padding: 10px; }
.char p { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.tag { font-size: .75rem; background: var(--border); border-radius: 6px; padding: 1px 6px; }
.cast { margin: 8px 0; }
.pill { display: inline-block; background: var(--sub); border-radius: 999px; padding: 3px 10px; margin: 2px; font-size: .85rem; }
.toggle { display: block; margin-top: 8px; font-size: .9rem; }
.eps { display: grid; gap: 8px; }
.ep { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; background: var(--card); padding: 14px 16px; }
.ep small { color: var(--muted); }
.script { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; border-radius: 14px; padding: 10px 14px; cursor: pointer; }
.bubble.other { background: var(--card); align-self: flex-start; }
.bubble.me { background: var(--me); align-self: flex-end; }
.bubble.active { outline: 2px solid var(--accent); }
.who { font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.ko { color: var(--muted); font-size: .9rem; }
.big { font-size: 1.2rem; margin: 6px 0; }
.ko.big { color: var(--text); }
.en.big { font-family: Georgia, serif; letter-spacing: .02em; }
mark { background: #ffd34f; color: #1b1420; border-radius: 4px; padding: 0 3px; }
.myturn { border: 2px solid var(--accent); }
.result { margin: 10px 0; padding: 8px 12px; border-radius: 10px; }
.result.ok { background: rgba(60, 207, 142, .15); color: var(--ok); }
.result.ng { background: rgba(255, 122, 89, .15); color: var(--ng); }
.listening { color: var(--accent); animation: pulse 1s infinite; margin: 8px 0; }
@keyframes pulse { 50% { opacity: .4; } }
.teaser { font-size: 1.1rem; font-style: italic; }
details { margin: 8px 0; }
.listen-box { background: var(--sub); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.meter { height: 10px; background: var(--input); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.meter i { display: block; height: 100%; width: 3%; background: var(--line); transition: width .08s linear; }
.meter i.on { background: var(--ok); }
.interim { font-family: Georgia, serif; font-size: 1.1rem; min-height: 1.5em; }
.pron { background: var(--sub); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.scores { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; font-size: .9rem; }
.words { font-family: Georgia, serif; font-size: 1.15rem; line-height: 2.2; }
.w { border-radius: 6px; padding: 2px 6px; cursor: help; }
.w sub { font-family: system-ui, sans-serif; font-size: .65rem; margin-left: 2px; opacity: .8; }
.w.good { background: rgba(60, 207, 142, .2); color: var(--ok); }
.w.mid { background: rgba(255, 179, 71, .2); color: var(--mid); }
.w.bad { background: rgba(255, 79, 79, .2); color: var(--bad); }
.w.omit { background: var(--btn); color: var(--muted); text-decoration: line-through; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; background: var(--input); border-top: 1px solid var(--btn); padding: 6px; }
.tabs button { flex: 0 1 160px; margin: 0; background: transparent; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--text); font-weight: bold; }
.graph { position: relative; margin: 0 auto; }
.graph svg { position: absolute; inset: 0; }
.rel { stroke: var(--line); stroke-width: 2; }
.rel.danger { stroke: var(--accent); stroke-dasharray: 6 5; }
.node { position: absolute; transform: translate(-50%, -50%); background: var(--sub); border: 2px solid var(--border); border-radius: 12px; padding: 6px 10px; text-align: center; min-width: 76px; cursor: help; }
.node small { display: block; font-size: .7rem; color: var(--muted); }
.node.me { border-color: var(--accent); background: var(--me); }
.center { text-align: center; }
.char.cast-on { outline: 1px solid var(--accent); }
.tag.role { background: var(--accent); color: #fff; }
.mic-wrap { text-align: center; margin: 14px 0 6px; }
.mic-big { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 150px; height: 150px; border-radius: 50%; background: var(--btn); border: 3px solid var(--line); font-size: 1rem; font-weight: bold; }
.mic-big .mic-icon { font-size: 2.6rem; line-height: 1; }
.mic-big.live { background: var(--accent); border-color: #ffd0e0; color: #fff; animation: ring 1.2s infinite; opacity: 1; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255, 79, 139, .6); } 100% { box-shadow: 0 0 0 26px rgba(255, 79, 139, 0); } }
.listen-status { margin-top: 10px; color: var(--text); font-weight: bold; }
.mic-wrap .meter { max-width: 320px; margin: 8px auto; }
.mic-wrap .interim { text-align: center; }
.guide { background: var(--sub); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.guide summary { cursor: pointer; font-weight: bold; }
.guide ol { padding-left: 20px; margin: 10px 0; }
.guide li { margin: 6px 0; font-size: .92rem; }
.guide ul { padding-left: 18px; margin: 4px 0; }
.guide a { color: var(--link); }
.guide code { background: var(--input); padding: 1px 5px; border-radius: 4px; }
.card, .ep, .bubble { box-shadow: var(--shadow); }
[data-theme="light"] button:hover, [data-theme="pink"] button:hover { filter: brightness(.96); }
.tabs { background: var(--card); border-top-color: var(--border); box-shadow: var(--shadow); }
.themes { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 14px; border: 2px solid transparent; }
.theme-pick.on { border-color: var(--accent); font-weight: bold; }
.swatch { width: 54px; height: 36px; border-radius: 8px; border: 1px solid var(--border); position: relative; overflow: hidden; }
.swatch i { position: absolute; right: 6px; bottom: 6px; width: 14px; height: 14px; border-radius: 50%; }
.ok-msg { color: var(--ok); font-size: .9rem; font-weight: bold; }
.season { border: 1px solid var(--border); }
.season-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.season-bar { background: var(--btn); }
.season-bar i { background: var(--accent); width: 0; }
.gen-now { margin-top: 8px; }
.gen-preview { margin: 6px 0; padding: 8px 12px; background: var(--sub); border-left: 3px solid var(--accent); border-radius: 6px; font-family: Georgia, serif; font-style: italic; color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 10px 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; margin: 6px 0; background: var(--sub); }
.check .mark { font-size: 1.1rem; }
.check .what { flex: 1; }
.check .what small { color: var(--muted); }
.check.todo { outline: 1px dashed var(--accent); }
.check.opt { opacity: .8; }
.big-btn { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 6px; }
.stages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.stages span { padding: 3px 10px; border-radius: 999px; background: var(--sub); }
.stages span.on { background: var(--accent); color: #fff; font-weight: bold; }
.stages i { font-style: normal; opacity: .6; }
.line-card { background: var(--sub); border-radius: 12px; padding: 12px 14px; margin: 10px 0; }
.line-card .en.big { margin: 4px 0 2px; }
.note { font-size: .88rem; margin-top: 6px; }
.note b { color: var(--accent); margin-right: 4px; }
.cue { font-weight: bold; color: var(--accent); font-size: 1.05rem; animation: pulse 1.2s 3; }
.cue small { display: block; font-weight: normal; color: var(--muted); font-size: .8rem; animation: none; }
.cue-badge { background: var(--accent); color: #fff; border-radius: 6px; padding: 0 6px; font-size: .72rem; }
.scene { border-left: 3px solid var(--accent); padding: 4px 0 4px 10px; margin: 8px 0; }
.mini { font-size: .92rem; margin: 3px 0; }
.mini b { color: var(--muted); font-weight: normal; margin-right: 6px; }
.mini.me b { color: var(--accent); }
.cast-row { justify-content: space-between; background: var(--sub); border-radius: 10px; padding: 8px 12px; }
.cast-row span { flex: 1; }
.cast-row small.hint { font-size: .8rem; }
.stop-btn { background: var(--btn); border: 1px solid var(--ng); color: var(--ng); }
.stage-now { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.stage-now b { color: var(--text); }
.stage-list { list-style: none; padding: 0; margin: 8px 0; }
.stage-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 6px 0; border-radius: 10px; background: var(--sub); }
.stage-list .num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: bold; flex: none; }
.stage-list .what { flex: 1; }
.stage-list .what small { color: var(--muted); }
.stage-list li.auto { opacity: .75; }
.stage-list li.auto .num { background: var(--line); }
.regen-line { margin-top: 12px; text-align: right; }
.stage-link { margin: 0; padding: 3px 10px; border-radius: 999px; background: var(--sub); color: var(--muted); font-size: .85rem; border: 1px dashed var(--border); }
.stage-link:hover { border-color: var(--accent); color: var(--text); }
.stage-link.done { color: var(--text); border-style: solid; }
/* 영어 문장(세리프 글꼴) 안에 들어간 버튼은 앱 기본 글꼴로 */
.en button, .en.big button { font-family: "Pretendard", "Malgun Gothic", system-ui, sans-serif; letter-spacing: normal; }
.toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); max-width: 90%; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.char p.speech { color: var(--text); font-size: .82rem; }
.stage-row { cursor: pointer; border: 2px solid transparent; transition: border-color .15s; }
.stage-row:hover { border-color: var(--border); }
.stage-row.current { border-color: var(--accent); }
.stage-row.done .num { background: var(--ok); }
.stage-row .state { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.stage-row.done .state { color: var(--ok); }
.stage-row.partial .state { color: var(--accent); font-weight: bold; }
.now-tag { background: var(--accent); color: #fff; border-radius: 6px; padding: 0 6px; font-size: .72rem; }
.mini-bar { display: block; height: 5px; background: var(--btn); border-radius: 3px; margin-top: 5px; overflow: hidden; max-width: 220px; }
.mini-bar i { display: block; height: 100%; background: var(--accent); }
.tabs button { flex: 0 1 140px; }
.rel.dim { opacity: .15; }
.node.dim { opacity: .3; }
.node.glow { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 79, 139, .25); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 14px 4px rgba(255, 79, 139, .45); } }
.prologue .teaser { margin-top: 0; }
.who-card { background: var(--sub); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }
.who-card p { margin: 4px 0 0; font-size: .88rem; }
.rel-tag { background: var(--btn); color: var(--muted); border-radius: 6px; padding: 0 6px; font-size: .72rem; margin-left: 4px; }
.onstage { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: var(--bg); padding: 8px 0; margin-bottom: 8px; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.onstage span { background: var(--sub); border-radius: 999px; padding: 2px 10px; color: var(--text); }
.onstage button { margin: 0 0 0 auto; }
.mention { text-decoration: underline dotted var(--accent); text-underline-offset: 3px; cursor: help; }
.mention-note { margin-top: 6px; font-size: .8rem; color: var(--muted); background: var(--sub); border-radius: 8px; padding: 4px 8px; }
.mention-note b { color: var(--text); }
details.onstage { display: block; }
details.onstage summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
details.onstage summary::-webkit-details-marker { display: none; }
.rel-toggle { margin-left: auto; font-style: normal; color: var(--accent); font-size: .82rem; }
.rel-panel { padding-top: 6px; }
.rel-panel .graph { transform-origin: top center; }
.rel-panel .node { min-width: 60px; padding: 4px 8px; font-size: .85rem; }
.rel-panel.opening { animation: relOpen .25s ease-out; }
@keyframes relOpen { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.rel-panel .node small { white-space: nowrap; }
.mention { font-weight: bold; }
.name-chip { display: inline-block; margin: 0 2px 0 4px; padding: 0 6px; border-radius: 6px; background: var(--accent); color: #fff; font: .72rem/1.6 "Pretendard", "Malgun Gothic", system-ui, sans-serif; vertical-align: 2px; letter-spacing: normal; }
.people-line { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.people-line span { background: var(--sub); border-radius: 999px; padding: 3px 12px; }
.mention { text-decoration: none; cursor: auto; }
.drama-title { display: flex; align-items: center; gap: 8px; width: 100%; margin: 12px 0 6px; padding: 8px 4px; background: transparent; font-size: 1.35rem; font-weight: bold; text-align: left; }
.drama-title .caret { font-size: .9rem; color: var(--accent); }
.drama-menu { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 6px; margin-bottom: 10px; box-shadow: var(--shadow); animation: relOpen .2s ease-out; }
.drama-item { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; background: transparent; margin: 2px 0; }
.drama-item.on { background: var(--sub); }
.drama-item small { color: var(--muted); }
.drama-item.add { color: var(--accent); font-weight: bold; }
.cast-bar { position: static; border-bottom: 0; background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; }
.drama-row { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.drama-row.on { background: var(--sub); }
.drama-row .drama-item { flex: 1; }
.rename-row { flex-wrap: wrap; gap: 6px; padding: 8px; }
.rename-row input { flex: 1; min-width: 160px; }
.rename-row .error { width: 100%; margin: 0; }
.title-row input { flex: 1; }
.due-left { margin: 0 0 6px; }
.rerun-hero { text-align: center; padding: 32px 20px; margin-top: 12px; }
.rerun-hero h1 { margin: 6px 0 10px; font-size: 1.6rem; }
.rerun-hero .hero-icon { font-size: 3.4rem; line-height: 1; }
.rerun-hero .big-btn { max-width: 360px; margin-top: 14px; font-size: 1.15rem; padding: 16px; }
.play-ctrl { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--bg); padding: 6px 0 2px; }
.play-ctrl button { margin: 0; }
.play-ctrl + .onstage { top: 44px; }
.prologue .story { font-size: .95rem; line-height: 1.6; margin: 2px 0 12px; }
.regen-all { margin-top: 16px; }
.pron-level { background: var(--sub); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.pron-level label { display: block; margin: 4px 0; }

/* ===== 반응형: 관계도 크기 자동, 작은 화면 정리 ===== */
.graph { position: relative; width: 100%; margin: 0 auto; }
.graph-inner { position: relative; width: 100%; padding-top: 100%; }
.graph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tabs { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1 1 0; max-width: 160px; padding: 8px 4px; white-space: nowrap; }
body { overflow-x: hidden; }
img, svg, select, input, textarea { max-width: 100%; }
.ep span { min-width: 0; }

@media (max-width: 480px) {
  main { padding: 12px 10px 84px; }
  h1 { font-size: 1.25rem; }
  .card { padding: 12px; border-radius: 12px; }
  .drama-title { font-size: 1.1rem; }
  .ep { flex-wrap: wrap; gap: 2px 8px; padding: 12px; }
  .ep small { margin-left: auto; }
  .tabs button { font-size: .8rem; }
  .node { min-width: 0; padding: 3px 6px; border-radius: 9px; }
  .node small { font-size: .6rem; white-space: nowrap; }
  .node b { font-size: .8rem; }
  .cast-row { flex-wrap: wrap; }
  .cast-row select { width: 100%; }
  .check { flex-wrap: wrap; }
  .check .what { min-width: 60%; }
  .stage-row { flex-wrap: wrap; }
  .stage-row .state { width: 100%; padding-left: 34px; }
  .stages { gap: 4px; font-size: .75rem; }
  .stages span, .stage-link { padding: 2px 7px; font-size: .75rem; }
  .stages i { display: none; }
  .bubble { max-width: 92%; }
  .big { font-size: 1.05rem; }
  .mic-big { width: 120px; height: 120px; }
  .mic-big .mic-icon { font-size: 2.1rem; }
  .actions button, .rerun-hero .big-btn { width: 100%; }
  .themes .theme-pick { flex: 1 1 30%; padding: 8px; }
  .play-ctrl .hint { font-size: .75rem; }
  .pool { grid-template-columns: 1fr; }
  .rerun-hero { padding: 24px 14px; }
  .drama-item { padding: 8px; }
}
/* 한글은 단어 중간에서 줄바꿈하지 않게 (까먹었/지 → 까먹었지) */
body { word-break: keep-all; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .mic-big > span:last-child { font-size: .82rem; white-space: nowrap; }
}
.usage { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 6px; }
.usage th, .usage td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.usage th { color: var(--muted); font-weight: normal; }
