:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #171a2b;
  --sub: #4b5068;
  --muted: #747a93;
  --line: #e3e5ef;
  --primary: #5b4cf5;
  --primary-ink: #ffffff;
  --primary-soft: #eeebff;
  --ok: #138a52;
  --warn: #c2410c;
  --warn-soft: #fff4ec;
  --danger: #d92d4a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 26, 43, 0.06), 0 4px 16px rgba(23, 26, 43, 0.05);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 17px;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.55; word-break: keep-all; overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 머리줄 */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 15px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* 틀 */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }
.steps { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 4px; }
.steps .group { margin: 14px 8px 4px; font-size: 15px; font-weight: 700; color: var(--muted); }
.steps .group:first-child { margin-top: 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer; font-weight: 600; color: var(--sub); }
.step:hover { background: #fff; }
.step .n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #e8e9f3; font-size: 15px; font-weight: 800; flex: none; }
.step.done .n { background: #dff5e9; color: var(--ok); }
.step.on { background: var(--primary); color: #fff; }
.step.on .n { background: rgba(255, 255, 255, 0.22); color: #fff; }

main { min-width: 0; }
.step-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.step-no { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--primary); color: #fff; font-size: 24px; font-weight: 800; flex: none; }
.grow { flex: 1; min-width: 0; }
.group-name { margin: 0; font-size: 15px; font-weight: 700; color: var(--primary); }
.step-head h1 { font-size: 30px; font-weight: 800; }
.goal { margin: 4px 0 0; font-size: 18px; color: var(--sub); }
.help { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--primary); background: #fff; color: var(--primary); font-size: 22px; font-weight: 800; cursor: pointer; flex: none; }
.help:hover { background: var(--primary-soft); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
.card h2 { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.card h2 em, .card h3 em { font-style: normal; font-weight: 600; font-size: 16px; color: var(--muted); margin-left: 6px; }
.card h3 { font-size: 17px; font-weight: 800; margin: 14px 0 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.row.center { justify-content: center; }
.note { color: var(--muted); font-size: 16px; margin: 6px 0 0; }
.ok { color: var(--ok); font-weight: 700; }
.warn { color: var(--warn); font-weight: 700; }
.muted { color: var(--muted); }

/* 입력 */
.input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; outline: none; transition: border-color 0.15s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.big { font-size: 19px; padding: 14px 16px; }
textarea.input { resize: vertical; }
.card > .input + .input { margin-top: 8px; }
.card > .input { margin-top: 8px; }
.field { display: block; margin-top: 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; }
.field > span em { font-style: normal; color: var(--primary); font-size: 15px; margin-left: 4px; }
.field.inline { flex: 1; min-width: 240px; margin-top: 0; display: flex; align-items: center; gap: 10px; }
.field.inline > span { margin: 0; white-space: nowrap; }
.why { display: block; margin: 4px 0 16px; padding: 14px 18px; border-radius: var(--radius); background: #fffbea; border: 1px dashed #e7cf6b; }
.why > span { display: block; font-weight: 700; margin-bottom: 6px; }

/* 단추 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #c8cbe0; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 16px; }
.btn.big { min-height: 56px; font-size: 19px; padding: 12px 26px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-size: 17px; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.spin { width: 16px; height: 16px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 15px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { flex: 1 1 auto; min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.seg button small { font-weight: 600; color: var(--muted); font-size: 15px; }
.seg button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.seg button.on small { color: var(--primary); }
.seg.wrap button { flex: 0 1 auto; }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.check:hover { background: #f6f6fd; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--primary); flex: none; }
.qlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 10px; }

/* 시청자 카드 */
.persona-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.persona-head h2 { margin: 0; }
.persona-head p { margin: 2px 0 0; color: var(--sub); }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-size: 30px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols2 ul { margin: 0; padding-left: 20px; }
.interview { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.interview summary { cursor: pointer; font-weight: 800; font-size: 17px; }
.chat { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; max-height: 360px; overflow: auto; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; }
.bubble.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: #f0f1f7; border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: 8px; }

/* 정의 */
.logline { font-size: 19px; font-weight: 700; background: var(--primary-soft); border-color: transparent; }
.stp { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.stp li { display: grid; grid-template-columns: 28px 100px 1fr; gap: 8px; align-items: baseline; }
.suggest { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: #f6f6fd; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.suggest p { margin: 0; flex: 1; min-width: 240px; font-weight: 700; }

/* 아이디어 */
.idea-list, .hook-list { display: grid; gap: 8px; }
.idea, .hook { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; }
.idea.on, .hook.on { border-color: var(--primary); background: #faf9ff; }
.idea p, .hook p { margin: 2px 0 0; color: var(--sub); font-size: 16px; }
.tag { display: inline-block; padding: 4px 10px; border-radius: 8px; background: #f0f1f7; font-weight: 800; font-size: 15px; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #ffe7b0; color: #8a5300; font-size: 14px; font-weight: 800; vertical-align: middle; }
.score-table { display: grid; gap: 6px; overflow-x: auto; }
.score-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) repeat(3, minmax(150px, 1fr)) 50px 90px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; min-width: 760px; }
.score-row.head { font-weight: 800; color: var(--muted); font-size: 15px; }
.score-row.chosen { background: var(--primary-soft); }
.score-row .name { font-weight: 700; }
.score-row .sum { font-size: 22px; font-weight: 800; text-align: center; }
.dots { display: flex; gap: 4px; }
.dot { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 0; }
.dot.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 훅 */
.context { padding: 12px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line); margin-bottom: 16px; font-weight: 700; }
.context.warn { background: var(--warn-soft); border-color: #ffd5bb; }
.feedback { padding: 12px 14px; border-radius: 12px; background: #f6f6fd; margin: 0 0 12px; }
.hook b { font-size: 18px; }

/* 구성 */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.tpl { text-align: left; padding: 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; display: grid; gap: 8px; }
.tpl b { font-size: 18px; }
.tpl .flow { color: var(--sub); }
.tpl.on { border-color: var(--primary); background: #faf9ff; box-shadow: 0 0 0 3px var(--primary-soft); }

/* 대본 */
.sumbar { margin: 12px 0 0; font-size: 18px; }
.av-head { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 22px 6px; font-weight: 800; color: var(--muted); }
.beats { display: grid; gap: 12px; }
.beat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; }
.beat header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.num { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; font-size: 15px; }
.part { font-weight: 800; color: var(--primary); }
.est { color: var(--muted); font-weight: 600; }
.tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.av { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lbl { display: block; font-weight: 700; font-size: 15px; color: var(--sub); margin-bottom: 4px; }
.video { display: grid; gap: 8px; }
.two { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
.input.emoji { text-align: center; font-size: 22px; padding: 8px; }
.lint { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.lint:empty { display: none; }
.lint li { padding: 4px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 700; font-size: 15px; }

/* 점검 */
.rubric { display: grid; gap: 6px; margin-top: 12px; }
.rub { display: grid; grid-template-columns: 170px 70px 1fr; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stars { color: var(--primary); letter-spacing: 2px; font-size: 18px; }
.first-fix { padding: 14px 16px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 800; font-size: 18px; }
.quote { padding: 12px 16px; border-left: 4px solid var(--primary); background: #f6f6fd; border-radius: 0 12px 12px 0; margin: 0 0 8px; }
.quote.big { font-size: 22px; font-weight: 800; }

/* 성우 */
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.voice { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; }
.voice.on { border-color: var(--primary); background: #faf9ff; }
.voice b { display: block; font-size: 18px; }
.voice span { color: var(--sub); font-size: 15px; }
.play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 18px; cursor: pointer; }
.tts-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; }
.tts-list li { display: grid; grid-template-columns: 30px 1fr auto 40px 40px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tts-list .say { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 영상 */
.video-layout { display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.video-layout.wide { grid-template-columns: 1fr; }
.stage { position: sticky; top: 80px; }
.video-layout.wide .stage { position: static; }
.stage canvas { width: 100%; height: auto; display: block; border-radius: 18px; box-shadow: 0 8px 30px rgba(23, 26, 43, 0.18); background: #111; }
.video-layout.shorts .stage canvas { max-height: 72vh; width: auto; max-width: 100%; margin: 0 auto; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sw { height: 56px; border-radius: 12px; border: 3px solid transparent; cursor: pointer; font-weight: 800; }
.sw.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pic-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pic-list li { display: grid; grid-template-columns: 30px 56px 1fr auto auto; gap: 10px; align-items: center; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: #f0f1f7; display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .emo { font-size: 28px; }
.txt { display: grid; min-width: 0; }
.txt small { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 12px; border-radius: 6px; background: #ececf6; overflow: hidden; margin-top: 12px; }
.progress div { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }
.result { margin-top: 14px; }
.result video { display: block; max-width: 100%; border-radius: 14px; background: #000; }
.result video.shorts { max-height: 60vh; }

/* 올리기 */
.copy-field { margin-top: 10px; }
.cf-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-weight: 700; }
.cover-row { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
.cover-row canvas { width: 100%; border-radius: 12px; box-shadow: var(--shadow); }
.cover-row canvas.wide { grid-column: 1 / -1; }
.guide ol { margin: 0; padding-left: 22px; }
.guide li { margin: 4px 0; }
.rules { margin: 14px 0 0; padding: 14px 18px 14px 36px; background: #f6f6fd; border-radius: 12px; }

/* 이론 창 · 모달 */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(15, 17, 30, 0.45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(480px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modal.wide { width: min(640px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-head h2 { font-size: 21px; font-weight: 800; }
.modal-body { padding: 6px 20px 8px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px 20px; }
.theory h3 { margin: 12px 0 6px; font-size: 18px; }
.theory p { margin: 6px 0; }
.theory ul { margin: 0; padding-left: 20px; }
.todo { margin-top: 14px !important; padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); font-weight: 800; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 200;
  padding: 12px 20px; border-radius: 14px; background: #171a2b; color: #fff; font-weight: 700; transition: all 0.2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.pager { display: flex; justify-content: space-between; margin-top: 24px; gap: 12px; }

/* 기획서 */
.plan-bar { display: flex; justify-content: space-between; margin-bottom: 16px; }
.plan { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 36px; }
.plan header h1 { font-size: 26px; }
.plan header p { color: var(--muted); margin: 6px 0 0; }
.plan h2 { font-size: 19px; margin: 24px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.plan table { width: 100%; border-collapse: collapse; }
.plan th, .plan td { text-align: left; vertical-align: top; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.plan th { width: 130px; color: var(--sub); }
.plan .av-table th { width: auto; }
.why-line { margin: 6px 0 0; color: var(--sub); }
.blank { min-height: 70px; border-bottom: 1px dashed var(--line); margin: 8px 0; color: var(--sub); }

/* 화면 폭 */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 0 16px 80px; gap: 0; }
  .steps { position: sticky; top: 61px; z-index: 10; flex-direction: row; overflow-x: auto; gap: 6px; padding: 10px 0; margin: 0 -16px 12px; padding-left: 16px; padding-right: 16px; background: var(--bg); scrollbar-width: none; }
  .steps .group { display: none; }
  .step { flex: none; padding: 7px 12px; background: #fff; border: 1px solid var(--line); }
  .step .n { width: 24px; height: 24px; font-size: 14px; }
  .video-layout { grid-template-columns: 1fr; }
  .stage { position: static; }
}
@media (max-width: 640px) {
  :root { font-size: 16px; }
  .top { padding: 8px 16px; }
  .brand b { font-size: 17px; }
  .card { padding: 16px; }
  .step-head h1 { font-size: 25px; }
  .step-no { width: 44px; height: 44px; font-size: 20px; }
  .cols2, .av, .av-head { grid-template-columns: 1fr; }
  .av-head { display: none; }
  .stp li { grid-template-columns: 24px 1fr; }
  .stp li span:last-child { grid-column: 2; }
  .rub { grid-template-columns: 1fr auto; }
  .rub span:last-child { grid-column: 1 / -1; }
  .idea, .hook { grid-template-columns: 1fr auto; }
  .idea .tag, .hook .tag { grid-column: 1 / -1; justify-self: start; }
  .tts-list li { grid-template-columns: 30px 1fr 40px 40px; }
  .tts-list li > span:nth-child(3) { grid-column: 2; }
  .pic-list li { grid-template-columns: 30px 56px 1fr auto; }
  .pic-list li .icon-btn { grid-column: 4; }
  .cover-row { grid-template-columns: 1fr; }
  .cover-row canvas.shorts { max-width: 220px; }
  .plan { padding: 20px; }
  .field.inline { flex-direction: column; align-items: stretch; }
}

@media print {
  .top, .steps, .no-print, .pager { display: none !important; }
  body { background: #fff; }
  .layout { display: block; padding: 0; }
  .plan { border: 0; padding: 0; }
}
