/* 사연툰 — 화면 꾸미기 (썰 스튜디오와 같은 결) */

@font-face { font-family: "Pretendard"; font-weight: 400; src: url("fonts/Pretendard-Regular.otf"); }
@font-face { font-family: "Pretendard"; font-weight: 600; src: url("fonts/Pretendard-SemiBold.otf"); }
@font-face { font-family: "Pretendard"; font-weight: 700; src: url("fonts/Pretendard-Bold.otf"); }

[hidden] { display: none !important; }

:root, html[data-theme="밝게"] {
  --bg: #F7F5F1;
  --panel: #FFFFFF;
  --soft: #F1EDE6;
  --line: #E4DFD5;
  --line2: #D3CCBF;
  --text: #221F1B;
  --muted: #6E685F;
  --faint: #9C958A;
  --accent: #B08A3E;
  --accent-hover: #8F6F30;
  --accent-ink: #FFFFFF;
  --accent-bg: rgba(176, 138, 62, .10);
  --hover: #EAE5DB;
  --ok: #2E9A63;
  --warn: #B8843A;
  --err: #C0473A;
  --shadow: 0 1px 2px rgba(60, 45, 20, .05), 0 4px 16px rgba(60, 45, 20, .05);
  --r: 12px;
}
html[data-theme="어둡게"] {
  --bg: #101114;
  --panel: #17191D;
  --soft: #1E2126;
  --line: #2A2E34;
  --line2: #3A3F46;
  --text: #E8E6E3;
  --muted: #9AA0A6;
  --faint: #6B7076;
  --accent: #C9A961;
  --accent-hover: #D8B970;
  --accent-ink: #1A1A1A;
  --accent-bg: rgba(201, 169, 97, .10);
  --hover: #262A30;
  --ok: #5FBF8F;
  --warn: #D8A657;
  --err: #D97066;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.55; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
b { font-weight: 600; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.opt { font-weight: 400; color: var(--faint); font-size: 11.5px; margin-left: 6px; }
::selection { background: var(--accent-bg); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line2); }
::-webkit-scrollbar-track { background: transparent; }

/* ───────── 뼈대 ───────── */
.frame { display: flex; height: 100%; }
.side {
  width: 244px; flex: 0 0 244px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 22px 16px 16px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto;
}
.main { flex: 1; overflow-y: auto; padding: 36px 44px 48px; }
.page { max-width: 940px; margin: 0 auto; }
.page.wide { max-width: 1400px; }
.page > header { margin-bottom: 22px; }
.page h2 { font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.page > header p { color: var(--muted); margin-top: 4px; }

/* ───────── 왼쪽 ───────── */
.brand { display: flex; gap: 11px; align-items: center; margin: 2px 4px 18px; }
.brand h1 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.brand p { font-size: 11.5px; color: var(--faint); }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), #7A5E2C); color: #fff; font-weight: 700; font-size: 15px;
}

.chan { background: var(--soft); border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin-bottom: 12px; }
.chan > label { display: block; font-size: 11px; color: var(--faint); font-weight: 600; margin: 0 2px 5px; }
.chan-row { display: flex; gap: 6px; }
.chan-row select { flex: 1; min-width: 0; font-weight: 600; }
.chan-acts { display: flex; gap: 4px; margin-top: 7px; }
.chan-acts button { flex: 1; font-size: 11.5px; color: var(--muted); padding: 5px 0; border-radius: 7px; }
.chan-acts button:hover { background: var(--hover); color: var(--text); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px;
  color: var(--muted); text-align: left; font-size: 14px; border: 1px solid transparent;
}
.nav-item i {
  width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; font-style: normal;
  border-radius: 7px; background: var(--soft); font-size: 12px; color: var(--muted);
}
.nav-item:hover { background: var(--soft); color: var(--text); }
.nav-item[aria-current="true"] { background: var(--accent-bg); color: var(--text); border-color: var(--accent); font-weight: 600; }
.nav-item[aria-current="true"] i { background: var(--accent); color: var(--accent-ink); }
.nav-item em {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600; min-width: 20px; text-align: center;
  padding: 1px 7px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
}

.run-card {
  margin-top: 14px; padding: 11px 12px; border-radius: 11px; background: var(--accent-bg);
  border: 1px solid var(--accent);
}
.run-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.run-card small {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 11.5px; color: var(--muted); margin: 4px 0 8px;
}
.run-acts { display: flex; gap: 6px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

.key-card {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px;
  background: var(--soft); border: 1px solid var(--line); text-align: left;
}
.key-card:hover { border-color: var(--line2); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--err); }
.dot.on { background: var(--ok); }
.key-text { display: flex; flex-direction: column; min-width: 0; }
.key-text em { font-style: normal; font-size: 12.5px; font-weight: 600; }
.key-text small { font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mode-row { display: flex; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.mode-row button { flex: 1; padding: 6px 0; border-radius: 7px; font-size: 12px; color: var(--muted); }
.mode-row button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ───────── 공통 부품 ───────── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 28px; }
.card-head b { font-size: 14.5px; }
.card-foot { display: flex; justify-content: flex-end; font-size: 12px; color: var(--faint); margin-top: 6px; }
.pad { margin-bottom: 12px; }

.field { margin-bottom: 16px; min-width: 0; }
.field.tight { margin-bottom: 10px; }
.field > label { display: flex; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.help { display: block; font-size: 12px; color: var(--faint); margin-top: 6px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 9px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; outline: none; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
select { cursor: pointer; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.story { min-height: 220px; height: 28vh; border: 0; padding: 4px 2px; background: transparent; }
.story:focus { box-shadow: none; }
textarea.plain { background: var(--soft); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 9px;
  background: var(--soft); border: 1px solid var(--line); color: var(--text); white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); border-color: var(--line2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.big { padding: 11px 26px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; }
.ghost { padding: 5px 10px; border-radius: 8px; color: var(--muted); font-size: 12.5px; }
.ghost:hover { background: var(--soft); color: var(--text); }
.danger { color: var(--err) !important; }
.mini { padding: 4px 10px; border-radius: 7px; font-size: 12px; background: var(--panel); border: 1px solid var(--line); }
.mini:hover { border-color: var(--line2); }
.link { margin-left: auto; font-size: 12px; color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }
.icon-btn {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.icon-btn:hover { color: var(--text); border-color: var(--line2); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 9px; margin: 22px 0; }
.bar.top { margin: 0 0 14px; }
.bar.tight { margin: 12px 0 0; }

/* 고르기 단추 묶음 */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 8px 14px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); text-align: left; line-height: 1.3;
}
.seg button small { display: block; font-size: 11px; color: var(--faint); }
.seg button:hover { border-color: var(--line2); color: var(--text); }
.seg button.on { border-color: var(--accent); background: var(--accent-bg); color: var(--text); font-weight: 600; }
.seg button.on small { color: var(--muted); font-weight: 400; }
.seg.small button { padding: 6px 11px; font-size: 13px; }

.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span2 { grid-column: span 2; }

/* 스위치 */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 6px 0; }
.switch input { display: none; }
.switch > span {
  position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: 22px;
  background: var(--line2); transition: background .15s;
}
.switch > span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch b { display: block; font-size: 13.5px; }
.switch small { display: block; font-size: 12px; color: var(--faint); }
.switch.small b { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.toggles { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 2px; }

/* 진행 */
.prog { margin-top: 4px; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line2); flex: 0 0 9px; }
.state-dot.run { background: var(--accent); animation: pulse 1.4s infinite; }
.state-dot.ok { background: var(--ok); }
.state-dot.err { background: var(--err); }
.state-dot.wait { background: var(--warn); }
.progress { height: 4px; border-radius: 4px; background: var(--soft); overflow: hidden; margin-bottom: 12px; }
.progress i {
  display: block; height: 100%; width: 35%; border-radius: 4px; background: var(--accent);
  animation: slide 1.3s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.log {
  height: 260px; overflow: auto; background: var(--soft); border-radius: 9px; padding: 10px 12px;
  font-family: "Cascadia Mono", Consolas, "Malgun Gothic", monospace; font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all; color: var(--muted);
}

/* ───────── 큐 ───────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.q-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow);
}
.q-row.run { border-color: var(--accent); }
.q-num { width: 24px; text-align: center; color: var(--faint); font-size: 12px; }
.q-main { flex: 1; min-width: 0; }
.q-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-main small { color: var(--faint); font-size: 12px; }
.tag { font-size: 11.5px; padding: 2px 9px; border-radius: 6px; font-weight: 600; white-space: nowrap; }
.tag.wait { background: var(--soft); color: var(--muted); }
.tag.run { background: var(--accent-bg); color: var(--accent); }
.tag.done { background: rgba(46,154,99,.12); color: var(--ok); }
.tag.err { background: rgba(192,71,58,.12); color: var(--err); }
.tag.batch { background: rgba(184,132,58,.14); color: var(--warn); }
.q-acts { display: flex; gap: 4px; }
.q-acts button {
  padding: 4px 9px; border-radius: 7px; font-size: 12px; color: var(--muted); border: 1px solid transparent;
}
.q-acts button:hover { background: var(--soft); color: var(--text); border-color: var(--line); }
.empty { padding: 50px 20px; text-align: center; color: var(--faint); border: 1.5px dashed var(--line); border-radius: var(--r); }
.note { margin-top: 18px; font-size: 12.5px; color: var(--faint); line-height: 1.8; }

/* ───────── 결과 ───────── */
.res-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.res-top select { max-width: 520px; font-weight: 600; }
.res-body { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.slide {
  position: relative; border-radius: 10px; overflow: hidden; background: var(--soft);
  border: 2px solid transparent; cursor: pointer; aspect-ratio: 4 / 5; transition: transform .1s, border-color .1s;
}
.slide:hover { transform: translateY(-2px); }
.slide.on { border-color: var(--accent); }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide .none { display: grid; place-items: center; height: 100%; color: var(--faint); font-size: 12px; }
.slide .no {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600; padding: 1px 7px;
  border-radius: 6px; background: rgba(0,0,0,.6); color: #fff;
}
.slide .mk { position: absolute; right: 6px; bottom: 6px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.slide .mk.ok { background: rgba(46,154,99,.9); color: #fff; }
.slide .mk.warn { background: rgba(184,132,58,.95); color: #fff; }
.slide .pick {
  position: absolute; left: 6px; top: 6px; width: 20px; height: 20px; border-radius: 6px;
  background: rgba(255,255,255,.9); border: 1.5px solid rgba(0,0,0,.25); display: grid; place-items: center;
  font-size: 12px; color: transparent; opacity: 0; transition: opacity .1s;
}
.slide:hover .pick, .slide .pick.on { opacity: 1; }
.slide .pick.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.res-side { position: sticky; top: 0; display: flex; flex-direction: column; margin: 0; max-height: calc(100vh - 84px); }
.res-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.res-view {
  flex: 1; min-height: 240px; display: grid; place-items: center; background: var(--soft); border-radius: 10px;
  overflow: hidden; cursor: zoom-in;
}
.res-view img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.res-info { font-size: 12px; color: var(--muted); margin: 8px 0 10px; white-space: pre-line; min-height: 18px; }
.res-acts { display: flex; gap: 8px; }
.res-acts .btn { flex: 1; justify-content: center; }
.res-video { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.res-video .btn { padding: 7px 11px; font-size: 13px; }

/* ───────── 캐릭터 ───────── */
.chars-body { display: grid; grid-template-columns: minmax(0, 1fr) 500px; gap: 22px; align-items: start; }
.grp-title { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 6px 2px 9px; display: flex; gap: 8px; align-items: center; }
.grp-title em { font-style: normal; font-weight: 400; color: var(--faint); }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 20px; }
.char {
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 11px; overflow: hidden;
  text-align: left; box-shadow: var(--shadow); transition: border-color .1s, transform .1s;
}
.char:hover { border-color: var(--line2); transform: translateY(-1px); }
.char.on { border-color: var(--accent); }
.char .pic { aspect-ratio: 16 / 9; background: var(--soft); display: grid; place-items: center; overflow: hidden; }
.char .pic img { width: 100%; height: 100%; object-fit: cover; }
.char .meta { padding: 8px 11px 10px; }
.char .meta b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char .meta small { color: var(--faint); font-size: 11.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char .warn { color: var(--warn); font-weight: 600; }
.char-form { position: sticky; top: 0; margin: 0; }
.sheet-box {
  aspect-ratio: 16 / 9; background: var(--soft); border-radius: 10px; display: grid; place-items: center;
  overflow: hidden; cursor: zoom-in;
}
.sheet-box img { width: 100%; height: 100%; object-fit: contain; }
.char-form .form-grid { margin-top: 16px; }
.color-row { display: flex; gap: 8px; align-items: center; }
input[type="color"] {
  width: 38px; height: 38px; flex: 0 0 38px; padding: 3px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ───────── 그림체 ───────── */
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-height: 120px; }
.thumb { position: relative; border-radius: 10px; overflow: hidden; background: var(--soft); aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb button {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 13px; display: grid; place-items: center;
}
.thumb button:hover { background: var(--err); }
.thumb.add { display: grid; place-items: center; border: 1.5px dashed var(--line2); background: transparent; color: var(--faint); cursor: pointer; }
.thumb.add:hover { border-color: var(--accent); color: var(--accent); }
.cover-box {
  aspect-ratio: 4 / 5; max-height: 330px; margin: 0 auto; background: var(--soft); border-radius: 10px;
  display: grid; place-items: center; overflow: hidden; color: var(--faint); font-size: 12.5px; text-align: center; padding: 0;
}
.cover-box img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }

/* ───────── 설정 ───────── */
.set .switch { margin-bottom: 8px; }
.voices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.voice {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; border-radius: 10px; text-align: left;
  border: 1px solid var(--line); background: var(--panel); position: relative;
}
.voice:hover { border-color: var(--line2); }
.voice.on { border-color: var(--accent); background: var(--accent-bg); }
.voice b { font-size: 13px; }
.voice small { font-size: 11.5px; color: var(--faint); }
.voice .play {
  position: absolute; right: 7px; top: 7px; width: 24px; height: 24px; border-radius: 50%; font-size: 10px;
  display: grid; place-items: center; background: var(--soft); color: var(--muted); border: 1px solid var(--line);
}
.voice .play:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input[type="range"] { flex: 0 0 280px; accent-color: var(--accent); }
.range-row b { min-width: 52px; font-size: 15px; }
.save-bar {
  position: sticky; bottom: -48px; display: flex; align-items: center; gap: 12px; padding: 14px 0 18px;
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}
#testMsg.ok { color: var(--ok); }
#testMsg.err { color: var(--err); }

/* ───────── 창 ───────── */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 16, 10, .45); display: grid; place-items: center;
  padding: 28px; z-index: 50; backdrop-filter: blur(2px);
}
.box {
  width: 100%; max-width: 460px; max-height: calc(100vh - 56px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.box.wide { max-width: 980px; }
.box h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.01em; }
.box .desc { color: var(--muted); font-size: 13px; margin-bottom: 16px; white-space: pre-line; }
.box-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.zoom { cursor: zoom-out; background: rgba(0,0,0,.75); }
.zoom img { max-width: 96vw; max-height: 94vh; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }

.cast-row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr) 220px; gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--line); align-items: start;
}
.cast-row:last-child { border-bottom: 0; }
.cast-role b { display: block; }
.cast-role small { color: var(--faint); font-size: 12px; display: block; }
.cast-desc { font-size: 12.5px; color: var(--muted); }
.cast-pick select { margin-bottom: 8px; }
.cast-pic { aspect-ratio: 16 / 9; background: var(--soft); border-radius: 9px; overflow: hidden; display: grid; place-items: center; color: var(--faint); font-size: 12px; }
.cast-pic img { width: 100%; height: 100%; object-fit: cover; }
.pool { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--accent-bg); color: var(--accent); font-weight: 600; margin-left: 6px; }

.offer-row { display: grid; grid-template-columns: 28px 220px minmax(0, 1fr) 190px; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.offer-row img { width: 100%; border-radius: 9px; }
.offer-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 4px; }

.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--accent); }

.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  max-width: 420px; padding: 11px 16px; border-radius: 11px; background: var(--text); color: var(--bg);
  font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.2); white-space: pre-line; animation: up .2s ease-out;
}
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1240px) {
  .res-body { grid-template-columns: minmax(0, 1fr) 360px; }
  .chars-body { grid-template-columns: minmax(0, 1fr) 420px; }
  .voices { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.btn.primary.danger-bg { background: var(--err); border-color: var(--err); color: #fff; }

/* ───────── 창 높이에 맞추는 쪽 (결과 보기 · 캐릭터): 쪽 전체가 아니라 안쪽 칸만 스크롤 ───────── */
.main.fit { overflow: hidden; padding-bottom: 20px; }
.page.fit { height: 100%; display: flex; flex-direction: column; }
.page.fit > header { flex: 0 0 auto; margin-bottom: 16px; }
.page.fit .res-body, .page.fit .chars-body { flex: 1; min-height: 0; align-items: stretch; }
.res-grid-wrap, .chars-list { height: 100%; overflow-y: auto; padding: 2px 8px 12px 2px; }
.res-side { position: static; height: 100%; max-height: none; overflow: hidden; }
.res-view { position: relative; flex: 1; min-height: 160px; height: auto !important; }
.res-view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; max-width: none; max-height: none; }
.char-form { position: static; height: 100%; overflow-y: auto; }
.char-form > .bar:last-child { position: sticky; bottom: -16px; margin: 16px -18px -16px; padding: 12px 18px; background: var(--panel); border-top: 1px solid var(--line); }

/* karu.kr */
.res-karu { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.reel-thumb {
  width: 46px; height: 82px; flex: 0 0 46px; border-radius: 7px; overflow: hidden; background: var(--soft);
  border: 1px dashed var(--line2); display: grid; place-items: center; cursor: zoom-in;
  font-size: 10px; color: var(--faint); text-align: center; line-height: 1.2;
}
.reel-thumb img { width: 100%; height: 100%; object-fit: cover; }
.karu-text { display: flex; flex-direction: column; min-width: 0; }
.karu-text b { font-size: 13px; }
.karu-text small { font-size: 11.5px; color: var(--faint); }
.karu-text .link { margin: 2px 0 0; text-align: left; }
.map-row { display: grid; grid-template-columns: 160px 20px minmax(0, 320px); gap: 10px; align-items: center; margin-bottom: 8px; }
#karuMsg.ok { color: var(--ok); }
#karuMsg.err { color: var(--err); }

/* 크게 보기에서 넘기기 */
.zoom-nav {
  position: fixed; top: 50%; transform: translateY(-50%); width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff; font-size: 34px; line-height: 1; display: grid; place-items: center;
  cursor: pointer; transition: background .12s;
}
.zoom-nav:hover { background: rgba(255,255,255,.3); }
.zoom-nav.prev { left: 24px; }
.zoom-nav.next { right: 24px; }
.zoom-pos {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); padding: 5px 14px; border-radius: 20px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; font-weight: 600;
}

/* 인스타 핸들 */
.handle-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.color-line { display: flex; align-items: center; gap: 10px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: 8px; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
.handle-prev label { display: block; margin-bottom: 6px; }
#hdPrev { border-radius: 10px; overflow: hidden; background: var(--soft); min-height: 200px; cursor: zoom-in; }
#hdPrev img { width: 100%; display: block; }
#hdSize { width: 100%; accent-color: var(--accent); }

.slide .wait-tag {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 4px 10px; border-radius: 8px;
  background: rgba(176, 138, 62, .92); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* 시트 넘겨 보기 */
.car { position: relative; }
.car-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: 1px solid var(--line); font-size: 22px; line-height: 1; color: var(--text);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.car-nav:disabled { opacity: .3; cursor: default; }
#carPrev { left: 8px; } #carNext { right: 8px; }
.car-head { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.car-tag { font-size: 11px; padding: 1px 8px; border-radius: 6px; background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.car-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { padding: 3px 10px; border-radius: 14px; font-size: 11.5px; border: 1px dashed var(--line2); color: var(--faint); background: transparent; }
.chip.has { border-style: solid; color: var(--muted); background: var(--soft); }
.chip.on { border-color: var(--accent); color: var(--text); background: var(--accent-bg); font-weight: 600; }

/* 다른 기기에서 접속 */
.rm-urls { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.rm-url { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; background: var(--soft); }
.rm-url b { font-family: Consolas, monospace; font-size: 14px; user-select: all; }
#rmMsg.ok { color: var(--ok); } #rmMsg.err { color: var(--err); }

/* ───────── 폰 화면 ───────── */
@media (max-width: 820px) {
  html, body { overflow: auto; }
  .frame { flex-direction: column; height: auto; min-height: 100%; }
  .side { width: 100%; flex: none; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 12px 10px; gap: 8px; }
  .brand { margin: 0 4px 4px; }
  .chan { margin-bottom: 4px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav-item { flex: 0 0 auto; padding: 7px 10px; font-size: 13px; }
  .nav-item i { display: none; }
  .nav-sep, .key-card, .mode-row { display: none; }
  .run-card { margin-top: 4px; }
  .main { overflow: visible; padding: 18px 14px 40px; }
  .main.fit { overflow: visible; }
  .page.fit { height: auto; }
  .page h2 { font-size: 20px; }
  .opt-grid, .form-grid, .two, .handle-body { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .res-body, .chars-body { grid-template-columns: 1fr; }
  .res-grid-wrap, .chars-list { height: auto; overflow: visible; }
  .res-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .res-side { height: auto; }
  .res-view { min-height: 60vh; flex: none; }
  .res-top { flex-wrap: wrap; }
  .res-top select { max-width: 100%; }
  .char-form { height: auto; overflow: visible; }
  .voices { grid-template-columns: repeat(2, 1fr); }
  .toggles { gap: 14px; }
  .bar { flex-wrap: wrap; }
  .box { padding: 18px; }
  .cast-row, .offer-row { grid-template-columns: 1fr; }
  .range-row input[type="range"] { flex: 1 1 auto; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 820px) {
  .zoom img { max-width: 100vw; max-height: 86vh; border-radius: 0; }
  .zoom-nav { top: auto; bottom: 16px; transform: none; width: 52px; height: 52px; background: rgba(255,255,255,.22); }
  .zoom-nav.prev { left: 16px; } .zoom-nav.next { right: 16px; }
  .zoom-pos { bottom: 30px; }
}

/* 사연 창고 */
.posts-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.posts-bar input[type=text] { width: 220px; }
.posts-bar select { width: 160px; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; text-align: left; box-shadow: var(--shadow); transition: transform .1s, border-color .1s; }
.post:hover { transform: translateY(-2px); border-color: var(--line2); }
.post.used { opacity: .55; }
.post .pic { position: relative; aspect-ratio: 4 / 5; background: var(--soft); }
.post .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pbadge { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: rgba(176,138,62,.92); color: #fff; }
.pbadge.used { background: rgba(60,60,60,.85); }
.post .meta { padding: 8px 10px 10px; }
.post .meta b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.4; }
.post .meta small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--faint); }
.box.viewer-box { max-width: 1200px; padding: 0; overflow: hidden; }
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 460px; height: min(86vh, 900px); }
.v-imgs { overflow-y: auto; background: var(--soft); padding: 14px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.v-imgs figure { margin: 0; width: 100%; max-width: 520px; }
.v-imgs img { width: 100%; border-radius: 8px; display: block; }
.v-imgs figcaption { font-size: 11.5px; color: var(--faint); text-align: center; margin-top: 4px; }
.v-side { padding: 20px 22px; display: flex; flex-direction: column; min-height: 0; }
.v-side h3 { font-size: 17px; }
.v-cap { margin: 8px 0 4px; font-size: 12.5px; }
.v-cap pre { white-space: pre-wrap; font-family: inherit; color: var(--muted); max-height: 120px; overflow: auto; }
.v-side textarea { flex: 1; min-height: 200px; margin-top: 12px; font-size: 13.5px; }
.v-def { margin-top: 8px; }
.v-side .box-foot { margin-top: 12px; }
@media (max-width: 820px) {
  .viewer { grid-template-columns: 1fr; height: auto; }
  .v-imgs { max-height: 50vh; }
  .posts-bar input[type=text], .posts-bar select { width: 100%; }
  .posts-grid { grid-template-columns: repeat(2, 1fr); }
}
