@font-face { font-family: Pretendard; font-weight: 400; font-display: swap; src: url(fonts/Pretendard-Regular.woff2) format('woff2'); }
@font-face { font-family: Pretendard; font-weight: 700; font-display: swap; src: url(fonts/Pretendard-Bold.woff2) format('woff2'); }

:root {
  --bg: #f3f4f6; --card: #fff; --ink: #1b1f24; --quiet: #6b7280; --line: #e1e4e8;
  --accent: #1f3a5f; --accent-2: #e8eef6; --danger: #c62828; --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* 화면 전체는 움직이지 않고, 미리보기와 작성 칸이 각각 따로 스크롤된다 */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
/* 아이폰에서 화면 전체가 끌려 다니지 않도록 문서를 화면에 붙인다 */
body { position: fixed; inset: 0; width: 100%; touch-action: none; }
.preview-wrap, .editor, .sheet-panel { touch-action: pan-y; }
.top, .actions { touch-action: manipulation; }
/* 아이폰 날짜 칸이 폭을 넘지 않게 */
input[type=date] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; width: 100%; text-align: left; background: #fff; }
.layout, .editor, .preview-wrap, .card { max-width: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
}
body.sheet-open { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
/* 아이폰은 16px보다 작은 입력칸을 누르면 화면을 확대하므로 16px로 맞춘다 */
input, textarea, select { font-size: 16px !important; }
button { touch-action: manipulation; }
html, body { max-width: 100%; }
.sheet-panel, .card, .field, .row2 > *, .wizard .inline > * { min-width: 0; }
.wizard input.num, .card input { min-width: 0; max-width: 100%; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; min-height: 42px; }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
button.ghost { background: transparent; }
button.mini { min-height: 34px; padding: 4px 10px; font-size: 13px; color: var(--accent); white-space: nowrap; }
button.wide { width: 100%; margin-top: 8px; }
[hidden] { display: none !important; }

.top {
  flex: none; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; background: var(--accent); color: #fff;
}
.top h1 { margin: 0; font-size: 18px; }
.top #status { flex: 1; font-size: 13px; opacity: .9; }
.top #status.warn { color: #ffd54f; }
.top .ghost { color: #fff; border-color: rgba(255,255,255,.4); min-height: 36px; padding: 5px 12px; }

.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 1280px; margin: 0 auto; }
.preview-wrap, .editor { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.preview-wrap { flex: none; height: 40%; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.editor { flex: 1; min-height: 0; padding: 12px; }
@media (min-width: 960px) {
  .layout { flex-direction: row; gap: 14px; padding: 0 12px; }
  .preview-wrap { flex: 1.1; height: auto !important; border-bottom: 0; padding: 12px 0; }
  .editor { flex: 0.9; min-width: 380px; padding: 12px 0; }
}
.preview { background: #fff; border-radius: var(--radius); padding: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.preview canvas { display: block; max-width: 100%; height: auto; }

.card { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.field { display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 8px; margin: 6px 0; }
.flabel { font-size: 13px; color: var(--quiet); }
.field input[type=text], .field input[type=date], textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { resize: vertical; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { min-height: 38px; padding: 6px 12px; border-radius: 20px; background: var(--accent-2); border-color: transparent; }
.chips.small .chip { min-height: 32px; padding: 3px 10px; font-size: 13px; }
.chips.phr .chip { border-radius: 10px; text-align: left; }

.line .lhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ltype { font-weight: 700; font-size: 14px; }
.t-product { color: #2e7d32; } .t-extra { color: #6d4c41; } .t-install { color: #ad1457; } .t-text { color: #1565c0; } .t-blank { color: var(--quiet); }
.lbtns { display: flex; gap: 4px; }
.lbtns button { min-height: 34px; min-width: 38px; padding: 4px 8px; }
.lbtns .del { color: var(--danger); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .field { grid-template-columns: 1fr; gap: 2px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { min-width: 42px; padding: 4px; font-size: 18px; }
.stepper .qty { min-width: 32px; text-align: center; font-weight: 700; }
.amount { text-align: right; font-weight: 700; min-height: 1.2em; }
.amount.red { color: var(--danger); }
.opts { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.check input { width: 20px; height: 20px; }
.irows { margin-top: 4px; }
.irow { font-size: 14px; border-radius: 6px; padding: 0 6px; }
.irow.s-머리 { background: #f2dcdb; } .irow.s-추가 { background: #ebf1de; } .irow.s-파랑 { background: #c5d9f1; }
.empty { color: var(--quiet); text-align: center; margin: 18px 0; }

.adders { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.adders button { flex: 1 1 30%; }

.actions {
  flex: none; z-index: 6; display: flex; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line);
}
.actions button { flex: 1; min-height: 50px; font-size: 17px; }

.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-panel {
  width: 100%; max-width: 640px; max-height: 82vh; overflow: auto; background: #fff;
  border-radius: 16px 16px 0 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3 { margin: 6px 0; }
.sheet h4 { margin: 14px 0 6px; font-size: 13px; color: var(--quiet); }

#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: rgba(20,24,30,.92); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.wizard .wstep { padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.wizard .wstep:last-of-type { border-bottom: 0; }
.wizard h4 { margin: 10px 0 6px; font-size: 14px; color: var(--ink); }
.wizard .inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wizard .inline input.num { flex: 1 1 140px; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.wizard .row2 input.num { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.wizard .field input.num { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.hint { font-size: 13px; color: var(--quiet); }
.chip.on { background: var(--accent); color: #fff; font-weight: 700; }
button.big { min-height: 52px; font-size: 17px; margin-top: 14px; }
