:root {
  --bg: #FFFDF7; --ink: #2B2A26; --butter: #F3D46B; --butter-l: #FBF1CC; --butter-d: #C99A1A;
  --gray: #6E6A60; --line: #E6DFCC; --card: #ffffff; --soft: #F7F3E6;
  --danger: #B8432E; --ok: #3F7D4E; --blue: #3C6BA8;
  --r: 14px; --top: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif; font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
small { font-size: .82em; color: var(--gray); font-weight: 400; }
.muted { color: var(--gray); }
.small { font-size: .85em; }

/* 상단 메뉴 */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; background: rgba(255, 253, 247, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 15px; white-space: nowrap; }
.logo b { font-weight: 700; }
.logo-dot { width: 22px; height: 22px; border-radius: 7px; background: var(--butter); flex: none; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 8px 14px; border-radius: 999px; font-size: 14px; color: var(--gray); white-space: nowrap; }
.nav a:hover { background: var(--soft); color: var(--ink); }
.nav a.on { background: var(--butter-l); color: var(--ink); font-weight: 600; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 24px 80px; }
.wrap.narrow { max-width: 760px; }
.page-h { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 18px; }
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 34px 0 12px; }
.sec-row:first-child { margin-top: 0; }
.sec-row .page-h { margin: 0; }
.sec-row h2 { font-size: 18px; }
.sec-row a { font-size: 14px; color: var(--gray); }
.back { display: inline-block; margin-bottom: 10px; color: var(--gray); text-decoration: none; font-size: 14px; }
.empty { text-align: center; color: var(--gray); padding: 48px 12px; }
.hint { font-size: 12.5px; color: var(--gray); margin: 6px 0 0; }
.hint-link { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--gray); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; background: var(--butter-l); border-radius: var(--r); padding: 14px 18px; margin-bottom: 22px; font-size: 14px; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: #d3c9ae; background: #fffcf1; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #45433c; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; margin-top: 8px; min-height: 50px; }
.btn:disabled { opacity: .5; cursor: default; }
.danger-t { color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.btn-col .btn { min-height: 50px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; font-size: 18px; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--soft); }
.mini { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12.5px; color: var(--gray); flex: none; }
.mini:hover { color: var(--ink); border-color: #d3c9ae; }
.mini.del:hover { color: var(--danger); border-color: #e7b9ae; }
.link-btn { border: 0; background: none; padding: 0; color: var(--gray); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; margin-bottom: 12px; }

/* 세그먼트 버튼 */
.seg { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--gray); font-weight: 500; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(43, 42, 38, .12); }
.seg.big { display: flex; margin: 4px 0 16px; }
.seg.big button { flex: 1; padding: 11px; font-size: 15px; }

/* 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font-size: 13.5px; cursor: pointer; }
.chip:hover { border-color: #d3c9ae; }
.chip.on { background: var(--butter); border-color: var(--butter); font-weight: 600; }
.chip.static { cursor: default; }
.chips.small { margin-top: 6px; }
.chips.small .chip { padding: 3px 10px; font-size: 12.5px; color: var(--gray); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; background: var(--butter-l); border-radius: 6px; padding: 2px 7px; vertical-align: middle; }
.badge.gray { background: #eee9dc; color: var(--gray); }

/* 카드·입력 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 18px 16px; margin-bottom: 14px; }
.card.soft { background: var(--soft); border-color: transparent; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card.soft p { margin: 0; font-size: 14px; }
.card h3 { font-size: 15.5px; margin-bottom: 12px; font-weight: 700; }
.card h3 small { margin-left: 6px; }
.memo-card { background: #FAF8F2; border-style: dashed; }
.fld { display: block; margin-bottom: 12px; min-width: 0; }
.fld .lb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--gray); margin-bottom: 5px; font-weight: 500; }
.fld input, .fld select, .fld textarea, .p1, .items input, .note-row input, .note-row textarea, .step-row input, .filters input, .filters select, .goal-help input {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fff; outline: none; font-size: 15px;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--butter-d); box-shadow: 0 0 0 3px rgba(243, 212, 107, .35); }
input:disabled { background: var(--soft); color: #5d5a52; }
input.manual { background: #FFF8DF; border-color: #E7C861; }
.fld.narrow input { max-width: 120px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0 12px; }
.span2 { grid-column: span 2; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chk input { width: 18px; height: 18px; accent-color: var(--ink); }
.warn { background: #FFF1E5; color: #8A4B12; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px; }
.note { background: var(--soft); color: var(--gray); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px; }

/* 연동 칸 */
.fld.link .lk { border: 0; background: var(--butter-l); color: #6b5512; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; cursor: pointer; font-weight: 600; }
.fld.link.unl .lk { background: #FFE9DF; color: #9A3B1C; }
.fld.link.unl input { border-color: #F0B9A3; }

/* 처음 화면 */
.choose { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.choice {
  position: relative; text-align: left; display: flex; flex-direction: column; gap: 8px;
  padding: 24px 22px; border-radius: 18px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.choice:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(43, 42, 38, .08); border-color: #dccf9f; }
.choice b { font-size: 18px; }
.choice span:not(.choice-ic) { font-size: 14px; color: var(--gray); line-height: 1.55; }
.choice-ic { width: 44px; height: 44px; border-radius: 13px; background: var(--butter-l); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.choice em { position: absolute; top: 18px; right: 18px; font-style: normal; font-size: 12px; font-weight: 700; background: var(--butter); border-radius: 999px; padding: 3px 10px; }

/* 문서 목록 */
.doc-list, .doc-cards { display: flex; flex-direction: column; gap: 8px; }
.doc-row, .doc-card { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; }
.doc-row:hover { border-color: #d3c9ae; }
.doc-open { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; }
.doc-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.kind { flex: none; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.kind-linked { background: var(--butter); }
.kind-quote { background: #E3ECF7; color: #2F5684; }
.kind-plan { background: #E5F1E6; color: #2F6B3D; }
.st, .st-sel { font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.st-sel { border: 1px solid var(--line); min-height: 32px; cursor: pointer; background: #fff; }
.st-draft { color: var(--gray); background: #F2EFE6; }
.st-sent { color: var(--blue); background: #E8F0FA; }
.st-confirmed { color: var(--ok); background: #E6F3E9; }
.st-canceled { color: #9a9488; background: #F2F0EC; text-decoration: line-through; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters input[type=search] { flex: 1 1 240px; width: auto; }
.filters select { width: auto; }
.org-group { margin-bottom: 22px; }
.org-group h3 { font-size: 16px; margin-bottom: 8px; }

/* 수업 목록 */
.cats { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.cat-card.is-hidden { opacity: .62; }
.cat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 6px; }
.cat-name { flex: 1; text-align: left; border: 0; background: none; font-weight: 700; font-size: 15.5px; padding: 8px 10px; cursor: pointer; border-radius: 10px; }
.cat-name:hover { background: var(--soft); }
.tools { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lesson-rows { padding: 2px 14px 14px; border-top: 1px solid var(--line); }
.lesson-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--line); }
.lesson-row.is-hidden .lesson-name { opacity: .55; }
.lesson-name { flex: 1; min-width: 0; text-decoration: none; display: flex; flex-direction: column; }
.lesson-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.lesson-rows > .btn { margin-top: 10px; }

/* 단계·사진·안내 */
.steps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.step-row { display: flex; align-items: center; gap: 5px; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--butter); font-size: 11.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.step-row input { flex: 1; min-width: 0; }
.note-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 6px; margin-bottom: 8px; align-items: start; }
.note-row .mini { margin-top: 6px; }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.thumb { position: relative; width: 78px; height: 78px; border-radius: 12px; border: 2px solid transparent; background: var(--butter-l) center / cover no-repeat; cursor: pointer; padding: 0; }
.thumb.used { border-color: var(--ink); }
.thumb-n { position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.thumb.add { display: flex; align-items: center; justify-content: center; border: 1.5px dashed #d8cc9f; background: #fff; color: var(--gray); font-size: 14px; font-weight: 600; }
.pool.big .thumb { width: 150px; height: 150px; cursor: default; }
.thumb-tools { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px; }
.sliders { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: center; background: var(--soft); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.sliders label { font-size: 12.5px; color: var(--gray); display: flex; flex-direction: column; gap: 2px; }
.sliders input[type=range] { width: 100%; accent-color: var(--ink); }
.slot-seg { margin-top: 2px; }
.seal-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seal-box img { height: 60px; width: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; }
.goal-help { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding: 10px; background: var(--soft); border-radius: 12px; }
.goal-help input { flex: 1 1 220px; width: auto; min-height: 36px; font-size: 14px; }
.gh-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* 견적 품목 */
.items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.item-head, .item-row { display: grid; grid-template-columns: minmax(0, 2.2fr) 58px 84px 104px minmax(0, 1fr) 30px; gap: 5px; align-items: center; }
.item-head-m { display: none; }
.item-head span { font-size: 12px; color: var(--gray); padding-left: 4px; }
.items input { min-height: 38px; padding: 6px 8px; font-size: 14px; }
.amt-wrap { position: relative; }
.amt-wrap .mini { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 26px; min-width: 26px; padding: 0; background: #FFF8DF; }
.total-row { display: flex; align-items: center; gap: 8px; font-weight: 700; flex-wrap: wrap; }
.total-row .total-inp { width: 150px; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-weight: 700; font-size: 16px; text-align: right; }

/* 계획서 디자인 고르기 */
.designs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.design-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; text-align: left; font-size: 13px; }
.design-btn.on { border-color: var(--ink); background: #fffcf0; }
.design-btn small { font-size: 11.5px; }
.dz { position: relative; display: block; width: 100%; aspect-ratio: 297 / 210; background: #FFFDF7; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; overflow: hidden; }
.dz i { position: absolute; background: var(--butter); border-radius: 3px; }
.dz-C i:nth-child(1) { left: 8%; top: 14%; width: 26%; height: 9%; background: var(--ink); opacity: .75; }
.dz-C i:nth-child(2) { left: 42%; top: 12%; width: 24%; height: 52%; }
.dz-C i:nth-child(3) { left: 69%; top: 12%; width: 24%; height: 52%; }
.dz-A i:nth-child(1) { left: 8%; top: 18%; width: 40%; height: 11%; background: var(--ink); opacity: .75; }
.dz-A i:nth-child(2) { left: 64%; top: 10%; width: 28%; height: 37%; }
.dz-A i:nth-child(3) { left: 64%; top: 51%; width: 28%; height: 37%; }
.dz-B i:nth-child(1) { left: 0; top: 0; width: 40%; height: 50%; border-radius: 0; }
.dz-B i:nth-child(2) { left: 0; top: 50%; width: 40%; height: 50%; border-radius: 0; opacity: .7; }
.dz-B i:nth-child(3) { left: 48%; top: 22%; width: 38%; height: 11%; background: var(--ink); opacity: .75; }

/* 계획서 여러 장 */
.page-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.page-card.open { border-color: #d3c9ae; }
.page-card-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 4px; }
.page-card-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 8px; font-weight: 600; cursor: pointer; border-radius: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-card-title:hover { background: var(--soft); }
.pn { flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--butter-l); font-size: 12px; display: flex; align-items: center; justify-content: center; }
.page-card-tools { display: flex; gap: 4px; }
.page-card .page-ed { padding: 4px 12px 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.to-quote { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; background: var(--butter-l); margin: 0 12px 12px; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }

/* ───────── 작성 화면 ───────── */
.view-doc { position: fixed; top: var(--top); left: 0; right: 0; bottom: 0; }
.ed { display: flex; flex-direction: column; height: 100%; }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: #fff; flex: none; }
.ed-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-sel { border: 1px solid var(--line); border-radius: 10px; min-height: 36px; padding: 0 8px; background: #fff; }
.save-state { font-size: 12.5px; color: var(--gray); white-space: nowrap; }
.mtabs { display: none; }
.ed-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(400px, 480px) 1fr; }
.ed-form { overflow-y: auto; padding: 18px 18px 40px; border-right: 1px solid var(--line); }
.ed-preview { display: flex; flex-direction: column; min-width: 0; background: #EFEBE0; }
.pv-bar { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; flex: none; font-size: 13px; }
.pv-pages { flex: 1; overflow-y: auto; padding: 4px 12px 40px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pv-item { position: relative; flex: none; box-shadow: 0 6px 24px rgba(43, 42, 38, .14); border-radius: 2px; overflow: hidden; }
.pv-scale { transform-origin: 0 0; position: absolute; left: 0; top: 0; }
.ed.pv-hidden .ed-body { grid-template-columns: 1fr; }
.ed.pv-hidden .ed-preview { display: none; }
.ed.pv-hidden .ed-form { border-right: 0; }
.ed.pv-hidden .ed-form > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.ed.pv-hidden .ed-form > .seg.big { display: flex; }
.ed-actions { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }

/* 팝업 */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(43, 42, 38, .38); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 18px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
.modal.wide { max-width: 720px; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.confirm-msg { margin: 4px 0 0; font-size: 15px; line-height: 1.6; }
.picker-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.picker-tools input { flex: 1 1 200px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }
.picker-body { overflow-y: auto; max-height: 48vh; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; }
.pk-cat-name { font-size: 12.5px; font-weight: 700; color: var(--gray); margin-bottom: 6px; }
.picker-sel { margin-top: 12px; padding: 10px 12px; background: var(--soft); border-radius: 10px; font-size: 13.5px; }
.pk-mode { margin-top: 10px; display: flex; }
.pk-mode button { flex: 1; }
.busy { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; }
.busy p { margin: 0; font-weight: 600; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--butter-l); border-top-color: var(--butter-d); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); z-index: 200; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 파일 만들 때 쓰는 숨은 무대 */
#render-stage, #print-root { position: fixed; left: -30000px; top: 0; pointer-events: none; }

/* ───────── 휴대폰 ───────── */
@media (max-width: 899px) {
  :root { --top: 104px; }
  .topbar { flex-direction: column; align-items: stretch; height: auto; gap: 6px; padding: 10px 12px 8px; }
  .nav { overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 7px 12px; font-size: 13.5px; }
  .wrap { padding: 20px 16px 80px; }
  .page-h { font-size: 22px; }
  .choose { grid-template-columns: 1fr; }
  .choice { padding: 18px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :first-child { grid-column: span 2; }
  .doc-card { flex-direction: column; align-items: stretch; }
  .doc-tools { justify-content: flex-end; }
  .lesson-row, .cat-head { flex-wrap: wrap; }
  .pool.big .thumb { width: calc(33% - 6px); height: auto; aspect-ratio: 1; }

  .ed-head { padding: 6px 8px; gap: 6px; flex-wrap: wrap; }
  .pv-toggle { display: none; }
  .save-state { order: 5; }
  .mtabs { display: flex; flex: none; background: #fff; border-bottom: 1px solid var(--line); }
  .mtabs button { flex: 1; border: 0; background: none; padding: 11px; font-weight: 600; color: var(--gray); border-bottom: 2.5px solid transparent; cursor: pointer; }
  .mtabs button.on { color: var(--ink); border-bottom-color: var(--butter-d); }
  .ed-body { display: block; overflow: hidden; }
  .ed-form, .ed-preview { height: 100%; }
  .ed-form { border-right: 0; padding: 14px 12px 40px; }
  .ed[data-mtab=form] .ed-preview { display: none; }
  .ed[data-mtab=preview] .ed-form { display: none; }
  .ed.pv-hidden .ed-preview { display: flex; }
  .ed.pv-hidden[data-mtab=form] .ed-preview { display: none; }
  .ed.pv-hidden[data-mtab=preview] .ed-form { display: none; }
  .pv-pages { padding: 4px 8px 40px; }
  .ed-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .ed-actions .btn { padding: 0 6px; font-size: 13.5px; }
  .ed-actions [data-out=print] { display: none; }
  .ed-actions:has([data-out=print]) { grid-template-columns: repeat(3, 1fr); }

  .item-head { display: none; }
  .item-head-m { display: grid; grid-template-columns: 1fr 1fr 1fr 30px; gap: 5px; padding: 0 8px; font-size: 12px; color: var(--gray); }
  .item-row { grid-template-columns: 1fr 1fr 1fr 30px; background: var(--soft); padding: 8px; border-radius: 10px; }
  .item-row > input:first-child { grid-column: 1 / -1; }
  .item-row > input[data-bind$=".note"] { grid-column: 1 / 4; }
  .item-row .del { grid-row: 3; grid-column: 4; }
  .note-row { grid-template-columns: 1fr auto; }
  .note-row textarea { grid-column: 1 / -1; grid-row: 2; }
  .sliders { grid-template-columns: 1fr 1fr 1fr; }
  .sliders .mini { grid-column: 1 / -1; }
  .designs { grid-template-columns: repeat(3, 1fr); }
  .design-btn { padding: 7px; font-size: 12px; }
  .modal.wide { max-height: 92vh; }
  .picker-body { max-height: 50vh; }
  #toast { bottom: 84px; }
}
@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .logo span { font-size: 14px; }
}

/* ───────── 인쇄 ───────── */
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print-root { position: static; left: auto; }
  #print-root .page { break-after: page; page-break-after: always; margin: 0; }
  #print-root .page:last-child { break-after: auto; page-break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
