/* ───────── Write — 작가용 작업실 테마 (종이 느낌, 큰 글씨) ───────── */
:root {
  --paper: #f6f1e8; --surface: #fffdf8; --surface2: #f1ebe0; --border: #e3dbcd;
  --ink: #2b2622; --ink2: #514941; --muted: #857a70;
  --accent: #2f4f7f; --accent-soft: #e6edf7; --warm: #b0643a; --warm-soft: #f7e8dd;
  --ok: #3c7a4a; --danger: #b23a3a; --danger-soft: #f7e4e4;
  --sans: "Noto Sans KR", "Pretendard", "Malgun Gothic", -apple-system, sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", Georgia, serif;
  --side: 250px; --radius: 12px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.65 var(--sans); }
.serif { font-family: var(--serif); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 22px; margin-bottom: 12px; }
h3 { font-size: 16px; color: var(--ink2); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h3 small { font-weight: 400; }
p { margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); white-space: pre-wrap; font-size: 14px; }
.error:empty { display: none; }
[hidden] { display: none !important; }

/* 레이아웃 */
.shell { display: flex; min-height: 100vh; }
#sidebar { width: var(--side); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 24px; font-weight: 600; padding: 4px 8px 16px; }
.brand .logo { font-size: 22px; }
.side-section { margin-bottom: 18px; }
.side-label { font-size: 12px; color: var(--muted); letter-spacing: .06em; padding: 8px 10px 4px; text-transform: uppercase; }
#nav button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; border-radius: 8px; color: var(--ink2); font: inherit; cursor: pointer; }
#nav button span { width: 22px; text-align: center; }
#nav button:hover { background: var(--surface2); }
#nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.project-list .proj { padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list .proj:hover { background: var(--surface2); }
.project-list .proj.active { background: var(--warm-soft); color: var(--warm); font-weight: 600; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 28px 10px; }
.topbar > div { flex: 1; }
.topbar .hint { margin: 0; }
main { padding: 8px 28px 40px; max-width: 1240px; width: 100%; }
.page { display: none; }
.page.active { display: block; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }
.grid-2.narrow-left { grid-template-columns: 300px 1fr; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 18px; }

/* 카드·폼 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
label { display: block; margin: 10px 0; color: var(--ink2); font-size: 14px; font-weight: 500; }
label small { font-weight: 400; display: block; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.inline input { width: auto; margin: 0; }
input, textarea, select { width: 100%; background: #fff; color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font: inherit; margin-top: 4px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.55; }
button { background: var(--surface2); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; cursor: pointer; font: inherit; font-weight: 500; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.big { font-size: 18px; padding: 14px 26px; border-radius: 12px; }
button.ghost, a.ghost { background: none; border: 1px solid var(--border); color: var(--ink2); text-decoration: none; display: inline-block; text-align: center; }
button.ghost.danger, button.danger { color: var(--danger); }
button.small, .small { font-size: 13px; padding: 5px 10px; }
.wide { width: 100%; }
.icon-btn { background: none; border: none; font-size: 20px; padding: 4px 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.row input { width: auto; flex: 1; margin: 0; }
.row-right { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 6px 0; }
.seg button { border: none; border-radius: 0; background: none; padding: 8px 14px; }
.seg button.active { background: var(--accent); color: #fff; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; border-radius: 11px; background: var(--border); position: relative; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 21px; }
.switch small { color: var(--muted); }

/* 상태 */
.status-pill { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; white-space: nowrap; }
.status-pill::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 7px; }
.status-pill.idle::before { background: var(--ok); }
.status-pill.running::before { background: var(--warm); animation: pulse 1s infinite; }
.status-pill.error::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.badge { background: var(--warm); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-style: normal; margin-left: auto; }
.badge:empty { display: none; }

/* 진행 카드 */
.hero { background: linear-gradient(180deg, #fffdf8, #faf6ee); }
.hero-status { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.hero-clock b { display: block; font-family: var(--serif); font-size: 22px; }
.hero-nums { display: flex; gap: 22px; }
.hero-nums div { text-align: center; }
.hero-nums b { display: block; font-size: 26px; font-family: var(--serif); }
.hero-nums span { font-size: 13px; color: var(--muted); }
.hero-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--warm); font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--warm-soft); border-top-color: var(--warm); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin: 6px 0 10px; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.checklist { background: var(--warm-soft); border: 1px solid #ecd3c1; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px; }
.checklist a { color: var(--warm); font-weight: 600; cursor: pointer; }

/* 목록 */
.list .item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; background: #fff; transition: border-color .15s; }
.list .item:hover, .list .item.sel { border-color: var(--accent); }
.list .item .meta { color: var(--muted); font-size: 13px; }
.list .item.new { border-left: 4px solid var(--warm); }
.list.compact .item { padding: 6px 10px; margin-bottom: 4px; font-size: 14px; }
.pill { display: inline-block; padding: 0 8px; border-radius: 10px; background: var(--surface2); font-size: 12px; color: var(--muted); margin-left: 4px; vertical-align: middle; }
.pill.hi { color: var(--danger); background: var(--danger-soft); }
.pill.ok { color: var(--ok); background: #e5f0e7; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 4px; }

/* 문서·원고 */
.doc { white-space: pre-wrap; line-height: 1.75; max-height: 72vh; overflow: auto; }
.doc h4 { color: var(--accent); margin: 14px 0 4px; font-size: 15px; }
.doc.small { font-size: 13px; }
.turn { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--border); background: #fff; border-radius: 0 8px 8px 0; }
.turn .who { color: var(--warm); font-weight: 600; }
.turn .mood { color: var(--muted); font-size: 13px; margin-left: 6px; }
.turn.event { border-left-color: var(--danger); background: var(--danger-soft); }
.turn .thought { color: var(--muted); font-style: italic; font-size: 13px; }
.turn .say { font-family: var(--serif); }
.ms-layout { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start; }
.ms-toc { position: sticky; top: 16px; }
.manuscript { font-family: var(--serif); font-size: 17px; line-height: 1.95; padding: 40px 48px; max-width: 820px; }
.manuscript h2 { font-size: 20px; margin: 36px 0 18px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.manuscript h2:first-child { margin-top: 0; }
.manuscript p { margin: 0 0 1.1em; white-space: pre-wrap; }
.manuscript .ms-meta { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: -12px; margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* 환영·마법사·모달 */
.welcome { text-align: center; padding: 60px 20px; max-width: 560px; margin: 0 auto; }
.welcome-art { font-size: 56px; margin-bottom: 10px; }
.welcome h2 { font-size: 28px; }
.welcome p { color: var(--ink2); margin: 14px 0 26px; }
.welcome .ghost { margin-left: 8px; }
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 16px; padding: 26px 28px; width: min(640px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(40,30,20,.45); }
dialog.wizard { width: min(720px, 94vw); }
.wiz-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.wiz-steps span { flex: 1; text-align: center; font-size: 13px; padding: 6px; border-radius: 8px; background: var(--surface2); color: var(--muted); }
.wiz-steps span.on { background: var(--accent); color: #fff; }
.wiz-nav { margin-top: 20px; }
.wz-char { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: #fff; }
.wz-char .row-between h4 { margin: 0; font-size: 15px; }
.wz-char label { margin: 6px 0; }
.rel-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.rel-row .name { min-width: 80px; font-weight: 500; }
.rel-row input { margin: 0; }
dialog.help { width: min(680px, 92vw); }
.help-steps li { margin-bottom: 10px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; font-size: 14px; z-index: 50; }
#toast.show { opacity: 1; }

/* 로그인 */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 40px 36px; width: min(420px, 92vw); text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.08); }
.auth-logo { font-size: 44px; }
.auth-card h1 { font-size: 34px; }
.auth-sub { color: var(--muted); margin-bottom: 22px; }
.auth-form { text-align: left; }
.auth-intro { font-size: 14px; color: var(--ink2); }
.auth-msg { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* 모바일 */
.only-mobile { display: none; }
@media (max-width: 900px) {
  .grid-2, .grid-2.narrow-left, .grid-3, .ms-layout { grid-template-columns: 1fr; }
  .ms-toc { position: static; }
  .manuscript { padding: 24px 20px; font-size: 16px; }
  main, .topbar { padding-left: 16px; padding-right: 16px; }
  .only-mobile { display: inline-block; }
  #sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  #sidebar.open { transform: none; }
  .brand { justify-content: space-between; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  button.big { width: 100%; }
}
