:root {
  --bg: #f6f7fb; --panel: #fff; --line: #e5e7ef; --text: #1f2330; --muted: #6b7280; --accent: #4f46e5; --accent-2: #eef0ff;
  --ok: #16a34a; --bad: #dc2626; --warn: #d97706;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
#app { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }
#side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.ver { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 1px 6px; border-radius: 10px; font-weight: 400; }
.side-title { font-size: 12px; color: var(--muted); margin-top: 8px; }
#postList { list-style: none; margin: 0; padding: 0; flex: 1; }
#postList li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
#postList li:hover { background: var(--accent-2); }
#postList li.active { background: var(--accent-2); font-weight: 600; }
#postList .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#postList .s { font-size: 11px; color: var(--muted); }
#postList li .del { opacity: 0; font-size: 12px; color: var(--muted); }
#postList li:hover .del { opacity: 1; }
.side-foot { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.muted { color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }
.warn { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; padding: 10px; border-radius: 8px; font-size: 12px; line-height: 1.6; }
code { background: #f1f1f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

#main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
#head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px 8px; }
.head-title { font-size: 18px; font-weight: 700; }
#steps { display: flex; gap: 6px; padding: 0 24px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
#steps button { background: transparent; border: 1px solid transparent; padding: 8px 14px; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--muted); font-size: 13px; }
#steps button.active { background: var(--panel); border-color: var(--line); border-bottom-color: var(--panel); color: var(--accent); font-weight: 600; margin-bottom: -1px; }
#steps button:disabled { opacity: .45; cursor: default; }
#panel { flex: 1; overflow: auto; padding: 20px 24px 120px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 16px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea, .input { font: inherit; font-size: 14px; color: var(--text); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
textarea { resize: vertical; line-height: 1.6; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
label.check input { width: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row.end { justify-content: flex-end; }
.btn { font: inherit; font-size: 13px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text); }
.btn:hover { border-color: #c7c9d6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #4338ca; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

.titles label { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); padding: 6px 0; }
.titles input[type=radio] { width: auto; }
.section { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fafbff; }
.section .sec-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.section .sec-head .n { font-weight: 700; color: var(--accent); width: 22px; }
.section .sec-head input { flex: 1; }
.section textarea { width: 100%; }
.section .mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.editor { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.editor .body-area { min-height: 520px; font-family: Consolas, "Malgun Gothic", monospace; font-size: 13.5px; line-height: 1.7; }
.preview { border: 1px solid var(--line); border-radius: 10px; padding: 8px 22px; background: #fff; line-height: 1.8; min-height: 520px; }
.preview h2 { font-size: 1.2em; margin-top: 1.6em; border-left: 4px solid var(--accent); padding-left: 10px; }
.preview h3 { font-size: 1.05em; }
.preview .img-slot { border: 2px dashed #bbb; padding: 10px; color: #777; text-align: center; }
.gate { position: sticky; top: 0; }
.score { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.score .num { font-size: 34px; font-weight: 800; }
.score .num.ok { color: var(--ok); } .score .num.bad { color: var(--bad); } .score .num.mid { color: var(--warn); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: #166534; } .badge.bad { background: #fee2e2; color: #991b1b; } .badge.mid { background: #fef3c7; color: #92400e; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; }
.checks li .ic { width: 16px; flex: none; }
.checks li.ok .ic { color: var(--ok); } .checks li.bad .ic { color: var(--bad); }
.checks li .fix { color: var(--muted); display: block; }
.checks .grp { font-size: 11px; color: var(--muted); margin-top: 10px; font-weight: 600; }
.stats { font-size: 12px; color: var(--muted); line-height: 1.7; margin-top: 10px; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kv { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fafbff; }
.kv .k { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.kv .v { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.chips span { display: inline-block; background: var(--accent-2); color: var(--accent); padding: 2px 8px; border-radius: 10px; margin: 2px 4px 2px 0; font-size: 12px; }
.faq dt { font-weight: 600; margin-top: 8px; } .faq dd { margin: 2px 0 0; color: #333; }
table.slots { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.slots th, table.slots td { border-top: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.checklist li { margin: 4px 0; }
.research details { margin-top: 8px; }
.research summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.research ol { padding-left: 20px; line-height: 1.7; font-size: 13px; }
.research a { color: var(--muted); font-size: 11px; }

#logbar { position: fixed; left: 260px; right: 0; bottom: 0; background: #111827; color: #e5e7eb; border-top: 1px solid #374151; z-index: 20; max-height: 42vh; display: flex; flex-direction: column; }
#logbar.collapsed #logBody { display: none; }
.logbar-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px; font-size: 13px; background: #0b1220; }
.logbar-head .btn { color: #e5e7eb; border-color: #374151; }
#logBody { margin: 0; padding: 10px 16px; overflow: auto; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; font-family: Consolas, monospace; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid #6b7280; border-top-color: #fff; border-radius: 50%; animation: sp 1s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }

#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 70vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }

.modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .5); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal-box { background: #fff; border-radius: 14px; width: min(960px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-box.wide { width: min(1180px, 96vw); }
.modal-body { display: grid; grid-template-columns: 250px 1fr; gap: 18px; padding: 16px 18px; overflow: auto; }
.voice-left { display: flex; flex-direction: column; gap: 6px; }
.voice-left ul { list-style: none; margin: 0 0 6px; padding: 0; }
.voice-left li { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
.voice-left li .src { font-size: 10px; color: var(--muted); }
.voice-left li.active, .voice-left li:hover { background: var(--accent-2); }
.preset-cat { font-size: 11px; color: var(--muted); margin: 8px 0 2px; font-weight: 600; }
.preset { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; margin-bottom: 5px; background: #fff; }
.preset:hover, .preset.active { border-color: var(--accent); background: var(--accent-2); }
.preset b { font-size: 13px; }
.preset .one { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.voice-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.vtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.vtabs button { background: none; border: 1px solid transparent; border-bottom: 0; padding: 8px 14px; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--muted); font: inherit; font-size: 13px; }
.vtabs button.active { color: var(--accent); font-weight: 600; border-color: var(--line); background: #fff; margin-bottom: -1px; }
.vt { display: flex; flex-direction: column; gap: 10px; }
.sample-box { position: relative; }
.sample-box textarea { width: 100%; font-size: 13px; }
.sample-box .cnt { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: var(--muted); background: #fff; padding: 0 4px; }
.report { border: 1px solid #c7d2fe; background: #f5f6ff; border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.7; }
.report h4 { margin: 0 0 6px; font-size: 13px; color: var(--accent); }
.report .ex { margin: 6px 0 0; padding-left: 18px; }
.report .ex li { margin: 2px 0; }
.preview-box { border-left: 4px solid var(--accent); background: #fafbff; padding: 10px 14px; border-radius: 0 10px 10px 0; white-space: pre-wrap; line-height: 1.8; font-size: 13.5px; }
.voice-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.voice-form .full { grid-column: 1 / -1; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0 2px; border-top: 1px solid var(--line); }

.settings-body { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.settings-body h4 { margin: 0 0 6px; font-size: 14px; }
.settings-body a { color: var(--accent); }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  #side { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  #postList { max-height: 150px; overflow: auto; flex: none; }
  .side-foot { flex-direction: row; flex-wrap: wrap; align-items: center; }
  #main { overflow: visible; }
  #head, #steps, #panel { padding-left: 16px; padding-right: 16px; }
  #steps { overflow-x: auto; }
  #steps button { white-space: nowrap; }
  .titles input.input { width: 100% !important; }
  #logbar { left: 0; }
  .editor, .grid2, .grid3, .meta-grid, .modal-body, .voice-form { grid-template-columns: 1fr; }
}
