:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1d2433;
  --muted: #6b7280;
  --brand: #2f5bea;
  --brand-soft: #eaf0ff;
  --ok: #138a4a;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --changed: #fff3b0;
  --paid: #7c3aed;
  --side: #1d2433;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.error { color: #c0262d; min-height: 1.4em; }
.warn-t { color: var(--warn); }
.ok-t { color: var(--ok); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: #f8f9fb; color: var(--text); }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 14px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap;
}
button:hover, .btn:hover { border-color: #c5cad3; }
button:disabled { opacity: .5; cursor: wait; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { background: #2549c4; border-color: #2549c4; }
.ghost { background: transparent; }
.paid { border-color: var(--paid); color: var(--paid); }
.link { border: 0; background: none; color: #aab1c0; padding: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.notice { background: var(--warn-soft); border: 1px solid #f6d79a; color: #7a4a06; padding: 10px 14px; border-radius: 8px; }

/* 로그인 */
.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 340px; display: grid; gap: 14px; }
.login label { display: grid; gap: 6px; }

/* 배치 */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--side) 260px, transparent 260px); }
.side { background: var(--side); color: #e7eaf0; padding: 18px 14px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 0 4px 6px; }
.new { display: grid; gap: 8px; }
.new input { background: #2a3245; border-color: #3a4359; color: #fff; }
.seg { display: flex; gap: 10px; font-size: 13px; }
.seg label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.seg input { width: auto; }
.guide-btn { background: #2a3245; border-color: #3a4359; color: #e7eaf0; justify-content: center; }
.guide-btn:hover { border-color: #5a6684; }
.side-title { font-size: 12px; color: #8d95a7; margin-top: 8px; padding: 0 4px; }
.projects { display: grid; gap: 4px; overflow-y: auto; flex: 1; align-content: start; }
.projects a { display: grid; padding: 8px 10px; border-radius: 8px; color: #e7eaf0; text-decoration: none; }
.projects a:hover { background: #2a3245; }
.projects a.on { background: var(--brand); }
.pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmeta { font-size: 11px; color: #aab1c0; }
.projects a.on .pmeta { color: #dce4ff; }

.main { padding: 24px 32px 80px; max-width: 1400px; width: 100%; }
.empty { max-width: 640px; }
.empty ol { padding-left: 20px; }

.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.phead > div:first-child { display: flex; align-items: center; gap: 10px; }
.actions { display: flex; gap: 8px; }
.tag { background: var(--brand-soft); color: var(--brand); border-radius: 99px; padding: 2px 10px; font-size: 12px; }

.steps { display: flex; gap: 6px; margin: 18px 0; flex-wrap: wrap; }
.step { border-radius: 99px; padding: 8px 16px; }
.step .ic { width: 1.2em; text-align: center; }
.step.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.step.done .ic { color: var(--ok); }
.step.stale .ic { color: var(--warn); }

.stage { display: grid; gap: 16px; }
.shead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.shead select { width: auto; max-width: 360px; }
.badge { font-size: 12px; border-radius: 99px; padding: 2px 10px; background: #eef0f3; color: var(--muted); }
.badge.ok { background: #e3f6ea; color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.sec { margin-top: 6px; }

/* 폼 */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; max-width: 980px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.form label:has(textarea) { grid-column: 1 / -1; }
.form .row { grid-column: 1 / -1; }
.groups { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 12px; }
.group { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0; display: grid; gap: 8px; align-content: start; }
.group legend { font-weight: 700; padding: 0 4px; }
.group label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }

/* 분석 */
.field { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-of-type { border-bottom: 0; }
.flabel { font-weight: 600; color: var(--muted); font-size: 13px; }
.fval p, .fval ul { margin: 0; }
.fval ul { padding-left: 18px; }
.changed { background: var(--changed); border-radius: 6px; }
.field.changed { padding-left: 8px; padding-right: 8px; }

.tbl { border-collapse: collapse; width: 100%; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.tbl th { background: #f8f9fb; font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tbl td.changed { background: var(--changed); }
.tbl td input, .tbl td textarea { padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.tblwrap { overflow-x: auto; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.tblwrap .tbl th, .tblwrap .tbl td { border-left: 0; border-right: 0; }
.cuts td { min-width: 120px; }
.cuts td.num, .cuts th:first-child { min-width: 44px; width: 44px; text-align: center; }
.cuts td.num input { width: 64px; }
.rowbtns { white-space: nowrap; min-width: 0 !important; }
.rowbtns button { padding: 2px 7px; font-size: 12px; }

/* 컨셉·인물 */
.concepts, .personas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.concept, .persona { display: grid; gap: 6px; align-content: start; }
.concept.on, .persona.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.chead { display: grid; gap: 4px; margin-bottom: 4px; }
.pick { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.pick input { width: auto; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: 13px; padding: 2px 4px; }
.kv b { color: var(--muted); font-weight: 600; }

/* AI 상자 */
.ai { border: 1px dashed #b7c4ef; background: #fbfcff; display: grid; gap: 10px; }
.ai label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.ai label select { width: auto; min-width: 200px; }
.aisteps { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.aisteps li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.checks label { font-weight: 400; gap: 4px; }
.checks input { width: auto; }

/* 프롬프트 */
.pcut { display: grid; gap: 10px; }
.pcut.changed { background: #fffbe0; }
.pchead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cap { font-size: 12px; background: #eef0f3; border-radius: 6px; padding: 2px 8px; }
.pcols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.en { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
pre { white-space: pre-wrap; margin: 4px 0 0; background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; }
pre.en { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.guide p { margin: 6px 0; }

.check ul { margin: 8px 0; padding-left: 18px; }
.check .checklist { list-style: none; padding-left: 0; }
mark { background: #ffe1e1; color: #a1161d; padding: 0 3px; border-radius: 3px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 10; max-width: 80vw; }
.toast.bad { background: #b4232a; }

@media (max-width: 1100px) {
  .groups { grid-template-columns: repeat(2, 1fr); }
  .concepts, .personas { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; }
  .main { padding: 16px; }
  .form, .pcols { grid-template-columns: 1fr; }
}

/* 기획 기준 · 영상 구조 흐름 */
.flow { display: flex; gap: 6px; list-style: none; padding: 0; margin: 8px 0 0; }
.flow li { background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
.flow li b { color: var(--brand); font-size: 13px; }
.flow li span { font-size: 12px; }
.flow li em { font-style: normal; font-size: 11px; color: var(--muted); }
.flowline { font-size: 12px; color: var(--muted); padding: 2px 0; }
.flowline b { color: var(--text); margin-right: 6px; }
.flowpick { display: grid; gap: 2px; }
.flowcard h3 { margin-bottom: 2px; }
.gstruct { display: grid; gap: 8px; margin-top: 12px; background: #fbfcff; }
.gstruct label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.ghead { display: flex; gap: 10px; }
.gname { font-weight: 700; font-size: 15px; }
.beats td input { padding: 4px 6px; }
.beats td.num { width: 110px; }

/* 영상 구조 버튼 */
.chips-row { display: grid; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex !important; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; cursor: pointer; background: #fff; font-weight: 500 !important; }
.chip input { width: auto; margin: 0; }
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* 아이템 발굴 */
.dfilters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dfilters label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.dfilters label.chk { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; color: var(--text); }
.dfilters label.chk input { width: auto; }
.dgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.dcard { display: grid; gap: 8px; align-content: start; }
.dtop { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.stars { color: #f59e0b; white-space: nowrap; letter-spacing: 1px; }
.dbadges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge.c-높음 { background: #fde8e8; color: #b4232a; }
.badge.c-중간 { background: var(--warn-soft); color: var(--warn); }
.badge.c-낮음 { background: #e3f6ea; color: var(--ok); }
.dsum { margin: 0; }
details summary { cursor: pointer; color: var(--brand); }
details .kv { margin-top: 4px; }
.dcard .primary { justify-self: start; }
@media (max-width: 1100px) { .dgrid { grid-template-columns: repeat(2, 1fr); } }

.plat { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; }
.plat b { margin-right: 4px; color: var(--brand); }
.plat span { background: #eef0f3; border-radius: 6px; padding: 1px 7px; }
.platpick { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; }
.platpick summary { cursor: pointer; color: var(--text); }
.pgroup { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.pgroup > b { font-size: 12px; color: var(--muted); min-width: 200px; }

/* 상품 사진 */
.form label.wide, .form .chk { grid-column: 1 / -1; }
.form .chk { display: flex !important; align-items: center; gap: 6px; font-weight: 600; }
.form .chk input { width: auto; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-weight: 400; }
.ph { position: relative; width: 96px; height: 96px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f8f9fb; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button { position: absolute; top: 4px; right: 4px; padding: 0 6px; font-size: 11px; border-radius: 6px; background: rgba(255,255,255,.9); }
.ph.add { display: grid !important; place-items: center; cursor: pointer; color: var(--brand); border-style: dashed; font-size: 12px; }
.photohint { display: grid; gap: 6px; background: #f3f6ff; border-radius: 8px; padding: 8px 10px; }
.photohint .ph { width: 64px; height: 64px; }
button.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.ai label.kw { display: grid; gap: 6px; font-size: 14px; }
.ai label.kw input { font-size: 16px; padding: 11px 14px; border-width: 2px; }

/* 유료 자동 버튼 */
.autorow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.primary.big { font-size: 15px; padding: 11px 22px; font-weight: 700; }
.manual { border-top: 1px dashed var(--line); padding-top: 8px; }
.manual summary { cursor: pointer; color: var(--muted); }
.manual .aisteps { margin-top: 8px; }

/* 제휴 (수수료) */
.aff { display: grid; gap: 6px; border-top: 1px dashed var(--line); padding-top: 8px; }
.affrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.affrow .small { flex: 1; }
.aff .row { display: grid; gap: 6px; }
.aff .row .primary { justify-self: start; }
.affset { display: grid; grid-template-columns: 220px 280px 1fr; gap: 8px; align-items: center; margin-top: 6px; }
.affset .chk { display: flex; align-items: center; gap: 6px; }
.affset .chk input { width: auto; }
.form .affform { grid-column: 1 / -1; }
.affform { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.affform > b { width: 100%; }
.affform .grow { flex: 1; min-width: 320px; }
.affform label { min-width: 200px; }
.affform .wide { width: 100%; }
