/* 책공방 관리 화면 — 플랫·보더 기반, 그림자/그라데이션 없음, 오렌지 포인트 */
@font-face { font-family: 'Pretendard'; font-weight: 400; font-display: swap; src: url('../../res/fonts/pretendard/Pretendard-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Pretendard'; font-weight: 600; font-display: swap; src: url('../../res/fonts/pretendard/Pretendard-SemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Pretendard'; font-weight: 700; font-display: swap; src: url('../../res/fonts/pretendard/Pretendard-Bold.woff2') format('woff2'); }

:root {
  --accent: #f26b1d;
  --accent-dark: #c9520e;
  --accent-soft: #fff1e8;
  --ink: #1f1f1f;
  --ink-2: #555;
  --muted: #8a8a8a;
  --line: #e2ded8;
  --line-2: #cfc9c0;
  --bg: #faf8f5;
  --panel: #fff;
  --ok: #2f7d4f;
  --danger: #c23b2a;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Pretendard', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
code { background: #f2efea; padding: 1px 5px; border-radius: 3px; font-size: .9em; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.hint { color: var(--ink-2); font-size: 14px; margin: .4em 0 1em; }

/* 상단 바 */
.topbar { display: flex; align-items: center; gap: 24px; height: 56px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; background: var(--accent); color: #fff; border-radius: 5px; font-size: 15px; }
.topnav { display: flex; gap: 18px; }
.topnav a { color: var(--ink-2); font-weight: 600; }
.topuser { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 14px; }
.topuser form { margin: 0; }

.main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
.main-wide { max-width: none; padding: 20px 24px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head form { margin: 0; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: var(--radius); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 11px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent-dark); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.danger-link { color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

/* 폼 */
.form label, .settings label, .wizard label:not(.choice):not(.theme-card) { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; font: inherit; font-weight: 400; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=color] { display: block; margin-top: 5px; width: 60px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; }
label small { font-weight: 400; color: var(--muted); }
.check, label.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: auto; margin: 0; }
label.inline { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid-2.tight { gap: 0 10px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input[type=text] { width: auto; margin: 0; flex: 1; min-width: 200px; }
.inline-form select { width: auto; margin: 0; }
.compact label { margin-bottom: 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.panel.danger { border-color: #efc9c3; }
.notice { background: var(--accent-soft); border: 1px solid #f6c9a8; color: #8a3d0b; padding: 10px 14px; border-radius: var(--radius); margin: 8px 0 14px; }
.flash { max-width: 1120px; margin: 16px auto 0; padding: 11px 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; }
.flash-success { border-color: #b7dcc5; background: #eff8f2; color: var(--ok); }
.flash-error { border-color: #efc9c3; background: #fdf1ef; color: var(--danger); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-dark); font-size: 12px; font-weight: 600; font-style: normal; }
.tag-ghost { background: #f0ede8; color: var(--ink-2); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table pre { white-space: pre-wrap; font-size: 12px; max-height: 240px; overflow: auto; background: #f7f5f1; padding: 8px; }
.st-done { color: var(--ok); font-weight: 600; } .st-failed { color: var(--danger); font-weight: 600; } .st-running, .st-queued { color: var(--accent-dark); font-weight: 600; }

/* 토스트·모달 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 200; }
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
.modal { position: fixed; inset: 0; background: rgba(20, 20, 20, .45); display: grid; place-items: center; z-index: 150; padding: 20px; }
.modal-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 18px 20px; }
.modal-wide { width: min(1200px, 100%); height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-wide .preview-frame { flex: 1; }

/* 로그인 */
body.bare { background: #fff; }
.auth { display: grid; grid-template-columns: 1.3fr 1fr; min-height: 100vh; }
.auth-art { background: #e8e3dc; overflow: hidden; }
.auth-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-panel { padding: 64px 56px; display: flex; flex-direction: column; justify-content: center; max-width: 480px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 26px; }
.auth-lead { color: var(--ink-2); margin-bottom: 28px; }
.auth-alt { margin-top: 18px; color: var(--ink-2); font-size: 14px; }
.error-page { text-align: center; padding: 120px 20px; }
.error-code { font-size: 64px; font-weight: 700; color: var(--accent); margin: 0; }
.error-msg { color: var(--ink-2); white-space: pre-wrap; }

/* 책 목록 */
.empty { text-align: center; padding: 40px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: #fff; }
.empty img { width: 200px; height: auto; }
.empty p { color: var(--ink-2); }
.book-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.book-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.book-cover { display: block; aspect-ratio: 5 / 8; background: #efebe5; border-bottom: 1px solid var(--line); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; padding: 20px; text-align: center; font-family: 'Gowun Batang', serif; color: var(--ink); gap: 10px; }
.cover-placeholder span { font-size: 20px; font-weight: 700; word-break: keep-all; }
.cover-placeholder small { color: var(--ink-2); }
.book-meta { padding: 12px 14px 14px; }
.book-title { font-weight: 700; color: var(--ink); display: block; margin-bottom: 4px; word-break: keep-all; }
.book-sub { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 4px; font-size: 13px; color: var(--ink-2); }
.book-date { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.book-actions { display: flex; gap: 12px; font-size: 13px; align-items: center; }
.book-actions form { margin: 0; }

/* 책 상단 탭 */
.book-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.book-head h1 { margin: 2px 0 10px; font-size: 22px; }
.crumb { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 2px; }
.tabs a { padding: 10px 16px; color: var(--ink-2); font-weight: 600; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { background: #fff; border-color: var(--line); color: var(--accent-dark); }

/* 새 책 마법사 */
.wizard { display: grid; gap: 18px; }
.wz-step { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.wz-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; margin-right: 10px; }
.choice-row { display: flex; gap: 12px; flex-wrap: wrap; }
.choice { flex: 1; min-width: 200px; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; }
.choice strong { display: block; }
.choice small { color: var(--muted); }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); }
.theme-grid, .theme-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.theme-card { display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px; cursor: pointer; background: #fff; position: relative; }
.theme-card input { position: absolute; opacity: 0; }
.theme-card.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.theme-thumb { display: block; aspect-ratio: 4 / 3; background: #f0ece6; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.theme-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.theme-name { font-weight: 700; }
.theme-desc { font-size: 13px; color: var(--ink-2); margin: 2px 0 6px; }
.theme-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-top: auto; }
.preview-frame { width: 100%; border: 1px solid var(--line); background: #e9e6e1; border-radius: var(--radius); }

/* 원고 편집 */
.writer { display: grid; grid-template-columns: 270px 1fr; gap: 18px; align-items: start; }
.chapters { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
.chapters-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.add-chapter { display: flex; gap: 6px; }
.add-chapter select { margin: 0; padding: 5px 8px; font-size: 13px; }
.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-list li { display: flex; align-items: center; gap: 8px; padding: 8px 8px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-size: 14px; }
.chapter-list li:hover { background: #f7f4f0; }
.chapter-list li.active { background: var(--accent-soft); border-color: #f6c9a8; }
.chapter-list .grip { cursor: grab; color: var(--muted); user-select: none; }
.chapter-list .ch-kind { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; flex-shrink: 0; }
.chapter-list .ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-list .sortable-ghost { opacity: .4; }
.editor-pane { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.chapter-meta .meta-row { display: flex; gap: 8px; margin-bottom: 8px; }
.chapter-meta select, .chapter-meta input { margin: 0; }
.chapter-meta select { width: 140px; flex-shrink: 0; }
.title-input { font-size: 18px !important; font-weight: 700 !important; }
.block-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); margin-top: 4px; }
.block-bar button { border: 1px solid var(--line-2); background: #fff; border-radius: 4px; padding: 4px 9px; font: inherit; font-size: 13px; cursor: pointer; }
.block-bar button:hover { border-color: var(--accent); color: var(--accent-dark); }
.save-state { margin-left: auto; font-size: 13px; color: var(--muted); }
.save-state.dirty { color: var(--accent-dark); }
.save-state.error { color: var(--danger); }
.editor-host { min-height: 60vh; }
.empty-editor { padding: 80px 20px; text-align: center; color: var(--muted); }
.editor-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; }
/* Toast UI 커스텀 블록 카드 */
.toastui-editor-contents .eb-card { border: 1px solid var(--line-2); border-left: 4px solid var(--accent); border-radius: 4px; padding: 10px 12px; background: #fffaf6; font-size: 14px; margin: 4px 0; }
.toastui-editor-contents .eb-card-title { font-size: 12px; font-weight: 700; color: var(--accent-dark); margin-bottom: 6px; letter-spacing: .02em; }
.toastui-editor-contents .eb-card img { max-height: 160px; border-radius: 3px; }
.toastui-editor-contents .eb-card .eb-grid { display: flex; gap: 6px; }
.toastui-editor-contents .eb-card .eb-grid img { width: 23%; height: 90px; object-fit: cover; }
.toastui-editor-contents .eb-card dl { display: grid; grid-template-columns: 80px 1fr; gap: 2px 10px; margin: 0; }
.toastui-editor-contents .eb-card dt { font-weight: 700; }
.toastui-editor-contents .eb-card dd { margin: 0; }
.toastui-editor-contents .eb-card p { margin: 2px 0; }
.toastui-editor-contents ruby rt { font-size: .55em; }
.asset-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; max-height: 260px; overflow: auto; margin: 8px 0 12px; }
.asset-pick button { border: 2px solid transparent; padding: 0; background: #f0ece6; border-radius: 4px; cursor: pointer; aspect-ratio: 1; overflow: hidden; }
.asset-pick button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-pick button.picked { border-color: var(--accent); }
.rows-editor .row { display: flex; gap: 6px; margin-bottom: 6px; }
.rows-editor .row input { margin: 0; }
.rows-editor .row input:first-child { width: 120px; flex-shrink: 0; }

/* 미리보기 */
.preview-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-wrap { height: calc(100vh - 220px); min-height: 500px; }
.preview-wrap .preview-frame { height: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; border-right: 1px solid var(--line-2); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: #fff; }
.seg-full { display: flex; margin-bottom: 10px; }
.seg-full button { flex: 1; padding: 6px 4px; }

/* 출력 */
.export-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.export-card p { color: var(--ink-2); }

/* 표지 편집기 */
.cover-editor { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.cover-side { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; max-height: calc(100vh - 170px); overflow: auto; position: sticky; top: 72px; }
.side-sec { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.side-sec:last-child { border-bottom: 0; }
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.thumb { border: 2px solid transparent; border-radius: 4px; padding: 0; background: #f0ece6; cursor: pointer; aspect-ratio: 5 / 8; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.picked { border-color: var(--accent); }
.file-btn { cursor: pointer; }
.preset-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.preset-list button { border: 1px solid var(--line-2); background: #fff; border-radius: 4px; padding: 8px; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.preset-list button:hover { border-color: var(--accent); }
.preset-list button small { display: block; color: var(--muted); font-size: 11px; }
.props select, .props input { margin-top: 3px; }
.cover-stage { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stage-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.stage-bar .check { margin: 0 !important; }
.spacer { flex: 1; }
.stage { background: #e9e6e1; border-radius: 4px; display: flex; justify-content: center; padding: 20px; min-height: 70vh; }
.stage .canvas-container { border: 1px solid var(--line-2); }

.validate { margin-top: 14px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; }
.validate.ok { border-color: #b7dcc5; background: #eff8f2; }
.validate.fail { border-color: #efc9c3; background: #fdf1ef; }

@media (max-width: 900px) {
  .writer, .cover-editor, .export-cards, .auth { grid-template-columns: 1fr; }
  .chapters, .cover-side { position: static; max-height: none; }
  .auth-art { max-height: 220px; }
  .auth-panel { padding: 32px 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .topnav { display: none; }
}
