* { box-sizing: border-box; margin: 0; padding: 0; }

/* 시각 언어: seojin-portfolio(variant 01 / CaseStudy) 토큰을 따른다.
   흰 종이 배경, 회색 텍스트, 1px 구분선, 작은 대문자 라벨, 포인트 #2454d6.
   속지 렌더(SVG) 결과는 이 파일과 무관하다 — 편집기 크롬만 다룬다. */
:root {
  --paper: #ffffff;
  --surface: #f5f7f9;
  --ink: #171c24;
  --text: #4f5a68;
  --muted: #626c79;
  --soft: #7a8290;
  --line: #d3d8df;
  --line-soft: #e0e4e9;
  --blue: #2454d6;
  --blue-dark: #1b42ad;
  --blue-soft: #eef2fc;
  --danger: #c2412d;
  --shadow: 0 12px 40px rgba(32, 42, 54, .11);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

html {
  height: 100%;
  overflow: hidden;
  overflow: clip;
  color-scheme: light;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  min-width: 320px;
  height: 100%;
  overflow: hidden;
  overflow: clip;
  font-family: var(--font);
  letter-spacing: -.02em;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; letter-spacing: inherit; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, p { word-break: keep-all; }

/* ── 헤더 ───────────────────────────────── */
.app-header {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-mark { display: none; }
.brand > div { display: flex; align-items: baseline; gap: 14px; }
.brand h1 { font-size: 15px; font-weight: 850; letter-spacing: -.04em; }
.brand p { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
.header-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .1em; }
.header-note span { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }

main {
  height: calc(100% - 64px);
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  overflow: hidden;
  overflow: clip;
}

/* ── 설정 패널 ──────────────────────────── */
#controls {
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 30px 28px 64px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.eyebrow { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .13em; }
.intro { padding: 0 0 30px; }
.intro h2 {
  margin-top: 22px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -.055em;
  font-weight: 700;
}
.intro p { margin-top: 14px; max-width: 320px; color: var(--muted); font-size: 13px; line-height: 1.8; }

.section-heading {
  margin: 0 0 14px;
  padding-top: 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--ink);
}
.section-heading > div { display: flex; align-items: baseline; gap: 10px; }
.section-heading h2 { font-size: 15px; font-weight: 700; letter-spacing: -.04em; }
.step { color: var(--blue); font: 500 10px var(--mono); letter-spacing: .04em; }
.section-caption { color: var(--soft); font-size: 10px; letter-spacing: .02em; }
.recipe-section { padding-bottom: 34px; }
.custom-section { padding-bottom: 4px; }

/* 무드 카드: 1px 격자 */
.recipe-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.recipe-card {
  min-width: 0;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  transition: background .16s ease;
}
.recipe-card:hover { background: var(--surface); }
.recipe-card:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.recipe-card.active { background: var(--blue-soft); box-shadow: inset 0 -2px 0 var(--blue); }
.recipe-card.active strong { color: var(--blue); }
.recipe-card strong, .recipe-card small { display: block; white-space: nowrap; }
.recipe-card strong { font-size: 12px; font-weight: 650; }
.recipe-card small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.recipe-paper {
  position: relative;
  width: 32px;
  height: 40px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(23, 28, 36, .14);
}
.recipe-paper.cream { background: repeating-linear-gradient(#fff9ec 0 7px, #dbcbb5 8px, #fff9ec 9px); }
.recipe-paper.sage { background-color: #f3f5eb; background-image: radial-gradient(#9baa8e 1px, transparent 1.2px); background-size: 7px 7px; }
.recipe-paper.pink { background-color: #fff4f3; background-image: linear-gradient(#e9bfbe 1px, transparent 1px), linear-gradient(90deg, #e9bfbe 1px, transparent 1px); background-size: 9px 9px; }
.recipe-paper.sketch { background: #f1eee8; }
.recipe-paper.sketch i { position: absolute; left: 5px; right: 4px; height: 1px; background: #7c746b; transform: rotate(-2deg); }
.recipe-paper.sketch i:nth-child(1) { top: 11px; }.recipe-paper.sketch i:nth-child(2) { top: 21px; }.recipe-paper.sketch i:nth-child(3) { top: 31px; }

/* 조정 그룹: 카드 대신 1px 구분선 목록 */
.control-card { border-bottom: 1px solid var(--line); background: transparent; }
.control-card summary, .control-title {
  min-height: 58px;
  padding: 14px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
}
.control-card summary { cursor: pointer; }
.control-card summary:hover strong { color: var(--blue); }
.control-card summary::-webkit-details-marker { display: none; }
.control-card summary > span:nth-child(2), .control-title > div { flex: 1; }
.control-card strong, .control-card small { display: block; }
.control-card strong { font-size: 13px; font-weight: 650; letter-spacing: -.03em; transition: color .16s; }
.control-card small { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.control-icon {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.paper-icon::after { content: ""; width: 12px; height: 15px; border: 1.25px solid currentColor; }
.margin-icon::after { content: ""; width: 13px; height: 16px; border: 1.25px dashed currentColor; }
.edge-icon::before { content: "•••"; position: absolute; left: 1px; font-size: 8px; letter-spacing: -1px; transform: rotate(90deg); }
.edge-icon::after { content: ""; width: 12px; height: 15px; border: 1.25px solid currentColor; border-radius: 3px; }
.pencil-icon { font: 20px/1 Georgia, serif; }
.shadow-icon::before, .shadow-icon::after { content: ""; position: absolute; width: 12px; height: 15px; border: 1.25px solid currentColor; background: var(--paper); }
.shadow-icon::before { transform: translate(3px, 3px); opacity: .35; }.shadow-icon::after { transform: translate(-2px, -2px); }
.bookmark-icon::after { content: ""; display: block; width: 10px; height: 13px; margin: auto; background: currentColor; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.chevron { width: 7px; height: 7px; margin-right: 4px; flex: 0 0 auto; border-right: 1.25px solid var(--soft); border-bottom: 1.25px solid var(--soft); transform: rotate(45deg); transition: transform .18s ease; }
details[open] .chevron { transform: rotate(225deg); }
.control-body { padding: 2px 0 20px 34px; }
.field-label { margin-top: 10px; display: block; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .1em; }
.paper-label { margin-top: 16px; }

.layout-picker { margin-top: 8px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.layout-picker label { cursor: pointer; }
.layout-picker input { position: absolute; opacity: 0; pointer-events: none; }
.layout-picker label > span { min-height: 66px; padding: 7px 3px 6px; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--muted); border: 1px solid var(--line); background: var(--paper); }
.layout-picker b { font-size: 10px; font-weight: 600; }
.layout-picker input:checked + span { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.layout-picker input:focus-visible + span { outline: 2px solid var(--blue); }

/* 분할 선택 */
.grid-size-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; margin-top: 8px; }
.grid-size-controls fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.grid-size-controls legend { margin-bottom: 6px; color: var(--soft); font-size: 10px; }
.grid-times { padding-bottom: 7px; color: var(--soft); font-size: 12px; }
.segment-picker { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); }
.segment-picker label { cursor: pointer; }
.segment-picker input { position: absolute; opacity: 0; pointer-events: none; }
.segment-picker span { display: grid; min-height: 30px; place-items: center; border-right: 1px solid var(--line); background: var(--paper); font-size: 12px; font-variant-numeric: tabular-nums; transition: background .14s, color .14s; }
.segment-picker label:hover span { background: var(--surface); }
.segment-picker label:last-child span { border-right: 0; }
.segment-picker input:checked + span { color: #fff; background: var(--ink); font-weight: 650; }
.segment-picker input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: -2px; }
.grid-help { margin: 9px 0 6px; color: var(--soft); font-size: 11px; line-height: 1.6; }
.area-editor-head { margin: 16px 0 2px; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); }
.area-editor-head span { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .1em; }
.area-editor-head strong { color: var(--blue); font-size: 11px; font-weight: 650; }
.area-editor-actions { display: flex; align-items: center; gap: 10px; }
.area-editor-actions button { padding: 4px 9px; color: var(--ink); font-size: 10px; font-weight: 650; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; transition: color .14s, border-color .14s; }
.area-editor-actions button:hover, .area-editor-actions button:focus-visible { color: var(--blue); border-color: var(--blue); outline: none; }
.region-editor { margin-top: 7px; display: grid; gap: 6px; }
.region-row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; }
.region-row[hidden] { display: none; }
.region-row label { color: var(--muted); font-size: 11px; }
.region-row select { width: 100%; padding: 7px 9px; font-size: 11px; }

/* 행 공통 */
.row { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.row > label:first-child { min-width: 68px; color: var(--text); }
.row input[type="range"] { flex: 1; min-width: 0; }
.slider-row .value {
  min-width: 34px;
  text-align: right;
  color: var(--ink);
  font: 500 11px var(--mono);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--line); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 1px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5.5px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  transition: background .14s, border-color .14s;
}
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--paper); }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:focus-visible::-webkit-slider-thumb { border-color: var(--blue); background: var(--blue); }
input[type="range"]:hover::-moz-range-thumb { border-color: var(--blue); background: var(--blue); }
input[type="range"]:focus-visible { outline: none; }

.color-control { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--soft); font-size: 10px; }
input[type="color"] { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; }
input[type="color"]:hover { border-color: var(--ink); }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }

.segmented { margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { padding: 7px 3px; display: block; text-align: center; color: var(--text); font-size: 11px; border-right: 1px solid var(--line); background: var(--paper); }
.segmented label:last-child span { border-right: 0; }
.segmented label:hover span { background: var(--surface); }
.segmented input:checked + span { color: #fff; font-weight: 650; background: var(--ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: -2px; }
.edge-style-picker { grid-template-columns: repeat(2, 1fr); }

.check-row { justify-content: flex-start; }
.switch-label { display: flex; align-items: center; gap: 10px; color: var(--text); cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; }
.switch { position: relative; width: 28px; height: 16px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); transition: background .16s, border-color .16s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--soft); transition: transform .16s, background .16s; }
.switch-label input:checked + .switch { border-color: var(--blue); background: var(--blue); }
.switch-label input:checked + .switch::after { background: #fff; transform: translateX(12px); }
.switch-label input:focus-visible + .switch { outline: 2px solid var(--blue); outline-offset: 2px; }

#marginGrid { padding-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#marginGrid[hidden] { display: none; }
#marginGrid .mg-mid { display: flex; align-items: center; gap: 8px; }
#marginGrid input[type="number"] { width: 50px; padding: 5px; text-align: center; font-size: 12px; border: 1px solid var(--line); border-radius: 2px; background: var(--paper); }
#marginGrid input[type="number"]:focus { border-color: var(--blue); outline: none; }
.mg-page { width: 30px; height: 38px; border: 1px dashed var(--soft); background: var(--surface); }

input[type="text"], select {
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  outline: none;
}
input[type="text"] { flex: 1; }
input[type="text"]::placeholder { color: var(--soft); }
input[type="text"]:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.small-btn { padding: 8px 10px; color: var(--ink); border: 1px solid var(--line); border-radius: 2px; background: var(--paper); cursor: pointer; font-size: 11px; font-weight: 600; transition: border-color .14s, color .14s, background .14s; }
.small-btn:hover { color: var(--blue); border-color: var(--blue); }
.small-btn:disabled { opacity: .4; cursor: default; color: var(--ink); border-color: var(--line); }
.small-btn.danger { color: var(--danger); }
.small-btn.danger:hover { border-color: var(--danger); }
.small-btn.primary-soft { color: #fff; border-color: var(--ink); background: var(--ink); }
.small-btn.primary-soft:hover { border-color: var(--blue); background: var(--blue); }
.button-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.button-grid .small-btn { padding-inline: 4px; white-space: nowrap; }

/* 보관함 목록 */
.preset-select-tools { margin-top: 14px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.preset-select-tools .text-btn { padding: 0 0 2px; color: var(--ink); font-size: 10px; font-weight: 650; border: 0; border-bottom: 1px solid var(--ink); background: transparent; cursor: pointer; }
.preset-select-tools .text-btn:hover { color: var(--blue); border-color: var(--blue); }
.preset-select-tools .text-btn:disabled { opacity: .4; cursor: default; }
.preset-select-tools .drag-hint { margin-left: auto; color: var(--soft); }
#presetItems { margin-top: 10px; max-height: 190px; overflow-y: auto; list-style: none; border-top: 1px solid var(--line); }
#presetItems li { padding: 3px 4px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line-soft); transition: background .1s; }
#presetItems li.selected { box-shadow: inset 2px 0 var(--blue); }
#presetItems li.selected .preset-name { color: var(--blue); font-weight: 650; }
#presetItems li.batch-selected { background: var(--blue-soft); }
#presetItems li.empty { padding: 14px 8px; color: var(--soft); font-size: 11px; text-align: center; }
#presetItems .preset-name { flex: 1; min-width: 0; padding: 6px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; border: 0; background: transparent; cursor: pointer; font-size: 12px; }
#presetItems input { accent-color: var(--blue); }
#presetItems .preset-drag-handle { width: 22px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; color: var(--soft); font-size: 12px; border: 0; background: transparent; cursor: grab; touch-action: none; user-select: none; }
#presetItems .preset-drag-handle:hover { color: var(--blue); }
#presetItems .preset-drag-handle:active { cursor: grabbing; }
#presetItems.drag-selecting, #presetItems.drag-selecting * { cursor: grabbing !important; user-select: none; }
#editBanner { margin-bottom: 20px; padding: 12px 14px; color: var(--ink); border: 1px solid var(--blue); border-left-width: 3px; background: var(--blue-soft); font-size: 12px; }
#editBanner .row { margin-top: 10px; }

/* ── 미리보기 ───────────────────────────── */
#preview-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  overflow: clip;
  overflow-anchor: none;
  padding: 26px clamp(24px, 4vw, 60px) 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface);
}
.preview-top { padding-bottom: 14px; display: flex; align-items: end; justify-content: space-between; border-bottom: 1px solid var(--line); }
.preview-top h2 { margin-top: 10px; font-size: 22px; font-weight: 700; letter-spacing: -.055em; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.guide-toggle { padding: 6px 12px; color: var(--ink); font-size: 11px; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; transition: background .16s, color .16s, border-color .16s; }
.guide-toggle:hover { border-color: var(--ink); }
.guide-toggle[aria-pressed="false"] { color: #fff; border-color: var(--ink); background: var(--ink); }
.ratio-badge { padding: 6px 12px; color: var(--muted); font: 500 11px var(--mono); letter-spacing: .1em; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.desk { position: relative; min-height: 0; padding: 22px; display: flex; align-items: center; justify-content: center; flex-direction: column; }
#preview { position: relative; height: min(100%, calc((100vw - 500px) * 1.05)); max-height: 100%; aspect-ratio: 4 / 5; z-index: 1; }
#preview.transparent-bg { background: repeating-conic-gradient(#e2e6eb 0 25%, #fff 0 50%) 0 0 / 18px 18px; }
#preview svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 18px 28px rgba(32, 42, 54, .14)); }

.region-handle {
  position: absolute;
  z-index: 6;
  margin: 0;
  padding: 0;
  color: var(--blue);
  border: 0;
  outline: 0;
  background: transparent;
  touch-action: none;
}
.region-handle::before { content: ""; position: absolute; opacity: .5; transition: opacity .14s; }
.region-handle::after {
  content: "";
  position: absolute;
  border: 1.5px solid var(--blue);
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(32, 42, 54, .16);
  opacity: .85;
  transition: opacity .14s, transform .14s, background .14s;
}
.region-handle.horizontal { height: 18px; transform: translateY(-50%); cursor: ns-resize; }
.region-handle.horizontal::before { left: 0; right: 0; top: 8px; height: 1px; background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px); }
.region-handle.horizontal::after { left: 50%; top: 4px; width: 26px; height: 10px; transform: translateX(-50%); }
.region-handle.vertical { width: 18px; transform: translateX(-50%); cursor: ew-resize; }
.region-handle.vertical::before { top: 0; bottom: 0; left: 8px; width: 1px; background: repeating-linear-gradient(0deg, currentColor 0 4px, transparent 4px 8px); }
.region-handle.vertical::after { top: 50%; left: 4px; width: 10px; height: 26px; transform: translateY(-50%); }
.region-handle:hover::before, .region-handle:focus-visible::before, .region-handle.dragging::before { opacity: 1; }
.region-handle:hover::after, .region-handle:focus-visible::after, .region-handle.dragging::after { opacity: 1; background: var(--blue); transform: translateX(-50%) scale(1.08); }
.region-handle.vertical:hover::after, .region-handle.vertical:focus-visible::after, .region-handle.vertical.dragging::after { transform: translateY(-50%) scale(1.08); }
.region-handle:focus-visible { box-shadow: 0 0 0 2px rgba(36, 84, 214, .3); }

.region-hotspot {
  position: absolute;
  z-index: 5;
  padding: 0;
  color: var(--blue);
  border: 1px dashed transparent;
  background: transparent;
  cursor: pointer;
}
.region-hotspot::after {
  content: "SELECT";
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 6px;
  color: #fff;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: .1em;
  background: var(--blue);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .14s, transform .14s;
}
.region-hotspot:hover, .region-hotspot:focus-visible { border-color: rgba(36, 84, 214, .6); background: rgba(36, 84, 214, .03); outline: none; }
.region-hotspot:hover::after, .region-hotspot:focus-visible::after { opacity: 1; transform: translateY(0); }
.region-hotspot.active { border-style: solid; border-color: var(--blue); background: rgba(36, 84, 214, .05); }
.region-hotspot.active::after { content: "SELECTED"; opacity: 1; transform: translateY(0); }
.region-hotspot.selecting { border-style: solid; border-color: var(--blue); background: rgba(36, 84, 214, .08); }
.region-hotspot.merged::before {
  content: "MERGED";
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 5px;
  color: var(--blue);
  font-size: 7px;
  font-weight: 650;
  letter-spacing: .1em;
  border: 1px solid rgba(36, 84, 214, .35);
  background: rgba(255, 255, 255, .85);
}

.preview-element-fab {
  position: absolute;
  z-index: 8;
  top: 38%;
  right: 0;
  min-width: 36px;
  min-height: 66px;
  padding: 9px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: #fff;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: var(--shadow);
  transform: translateX(58%);
  cursor: pointer;
  transition: background .16s, transform .16s;
}
.preview-element-fab span { font-size: 13px; line-height: 1; }
.preview-element-fab strong { font-size: 9px; font-weight: 650; line-height: 1; writing-mode: vertical-rl; letter-spacing: .1em; }
.preview-element-fab:hover, .preview-element-fab:focus-visible { background: var(--blue); outline: none; transform: translateX(58%) scale(1.05); }
.cell-selection-bar {
  position: absolute;
  z-index: 9;
  bottom: 34px;
  left: 50%;
  padding: 6px 6px 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  border-radius: 99px;
  background: var(--ink);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.cell-selection-bar[hidden] { display: none; }
.cell-selection-bar span { font-size: 11px; white-space: nowrap; }
.cell-selection-bar button { padding: 6px 12px; color: #fff; font-size: 11px; font-weight: 650; border: 0; border-radius: 99px; background: var(--blue); cursor: pointer; }
.cell-selection-bar button:hover { background: var(--blue-dark); }
.cell-selection-bar #cancelCellSelectionBtn { width: 26px; height: 26px; padding: 0; color: #c3cad4; font-size: 16px; background: transparent; }
.cell-selection-bar #cancelCellSelectionBtn:hover { color: #fff; }
.preview-caption { position: absolute; bottom: 0; z-index: 2; color: var(--soft); font-size: 11px; letter-spacing: -.01em; }
.tape { display: none; }

/* 내보내기 */
.export-bar {
  min-height: 60px;
  padding: 12px 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
}
.export-bar label { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .1em; white-space: nowrap; }
.export-bar select { flex: 1; max-width: 260px; margin-right: auto; }
#exportBtn {
  padding: 12px 22px;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  cursor: pointer;
  transition: background .16s;
}
#exportBtn:hover { background: var(--blue); }
#exportBtn:active { transform: translateY(1px); }
#exportBtn span { margin-right: 6px; }

/* 보관함 오버레이 */
.preset-drawer {
  position: absolute;
  z-index: 20;
  top: 50%;
  right: 0;
  width: 330px;
  max-height: calc(100% - 36px);
  padding-left: 40px;
  transform: translate(calc(100% - 40px), -50%);
  transition: transform .22s ease;
}
.preset-drawer.open { transform: translate(-16px, -50%); }
.preset-drawer-toggle {
  position: absolute;
  inset: 50% auto auto 0;
  width: 40px;
  min-height: 112px;
  padding: 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-right: 0;
  background: var(--paper);
  box-shadow: -6px 10px 24px rgba(32, 42, 54, .08);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color .16s;
}
.preset-drawer-toggle:hover, .preset-drawer.open .preset-drawer-toggle { color: var(--blue); }
.preset-drawer-toggle strong { font-size: 11px; font-weight: 650; writing-mode: vertical-rl; letter-spacing: .12em; }
.preset-drawer-toggle .bookmark-icon { width: 16px; height: 16px; display: grid; }
.preset-drawer-arrow { font-size: 17px; line-height: 1; transition: transform .2s; }
.preset-drawer.open .preset-drawer-arrow { transform: rotate(180deg); }
.preset-drawer-content {
  max-height: calc(100vh - 130px);
  padding: 20px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(32, 42, 54, .16);
}
.preset-drawer-head { margin-bottom: 16px; padding-bottom: 14px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--ink); }
.preset-drawer-head strong, .preset-drawer-head small { display: block; }
.preset-drawer-head strong { font-size: 17px; font-weight: 700; letter-spacing: -.05em; }
.preset-drawer-head small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.preset-drawer-head button { width: 28px; height: 28px; color: var(--muted); font-size: 18px; line-height: 1; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; }
.preset-drawer-head button:hover { color: var(--ink); border-color: var(--ink); }
.preset-drawer .row { display: flex; gap: 6px; }
.preset-drawer #presetName { min-width: 0; flex: 1; }

/* ── 영역 요소 다이얼로그 ───────────────── */
.region-dialog {
  width: min(520px, calc(100vw - 32px));
  margin: auto;
  padding: 24px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 28px 80px rgba(32, 42, 54, .22);
}
.region-dialog::backdrop { background: rgba(23, 28, 36, .32); backdrop-filter: blur(3px); }
.region-dialog-head { padding-bottom: 14px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--ink); }
.region-dialog h2 { margin-top: 10px; font-size: 21px; font-weight: 700; letter-spacing: -.055em; }
.region-dialog > p { margin-top: 12px; color: var(--muted); font-size: 12px; }
.dialog-close { width: 30px; height: 30px; color: var(--muted); font-size: 20px; line-height: 1; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; }
.dialog-close:hover { color: var(--ink); border-color: var(--ink); }
.region-element-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.region-element-grid button { min-height: 56px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; text-align: left; color: var(--ink); border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); cursor: pointer; transition: background .14s, color .14s; }
.region-element-grid button:hover { background: var(--surface); }
.region-element-grid button.active { color: var(--blue); background: var(--blue-soft); box-shadow: inset 2px 0 var(--blue); }
.region-element-grid strong { font-size: 12px; font-weight: 600; }
.unmerge-region-btn { width: 100%; margin-top: 12px; padding: 11px; color: var(--ink); font-size: 12px; font-weight: 650; border: 1px solid var(--ink); background: var(--paper); cursor: pointer; }
.unmerge-region-btn:hover { color: #fff; background: var(--ink); }
.element-preview { width: 36px; height: 28px; flex: 0 0 auto; display: block; color: var(--muted); border: 1px solid var(--line); background-color: var(--paper); }
.region-element-grid button:hover .element-preview, .region-element-grid button.active .element-preview { color: var(--blue); border-color: rgba(36, 84, 214, .4); }
.element-preview.blank { background: var(--paper); }
.element-preview.date { background: linear-gradient(currentColor 0 0) 4px 7px / 10px 3px no-repeat, linear-gradient(currentColor 0 0) 4px 20px / 29px 3px no-repeat; }
.element-preview.lined { background: repeating-linear-gradient(to bottom, transparent 0 6px, currentColor 6px 7px); }
.element-preview.dashed { background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 7px) 0 6px / 100% 1px repeat-y; }
.element-preview.dots { background-image: radial-gradient(currentColor 1px, transparent 1.2px); background-size: 7px 7px; }
.element-preview.grid { background-image: linear-gradient(currentColor 1px, transparent 1px), linear-gradient(90deg,currentColor 1px,transparent 1px); background-size: 8px 8px; }
.element-preview.cross { background-image: linear-gradient(currentColor 1px, transparent 1px), linear-gradient(90deg,currentColor 1px,transparent 1px); background-size: 12px 12px; background-position: 5px 5px; }
.element-preview.checklist { background: linear-gradient(currentColor 0 0) 4px 5px / 5px 5px no-repeat, linear-gradient(currentColor 0 0) 13px 14px / 19px 1px no-repeat, linear-gradient(currentColor 0 0) 4px 17px / 5px 5px no-repeat, linear-gradient(currentColor 0 0) 13px 26px / 19px 1px no-repeat; }
.element-preview.bold-rule { background: linear-gradient(currentColor 0 0) 3px 12px / 31px 4px no-repeat; }
.element-preview.half-rule { background: linear-gradient(currentColor 0 0) 3px 12px / 17px 4px no-repeat; }

/* ── 좁은 화면 ──────────────────────────── */
@media (max-width: 820px) {
  html { height: auto; overflow: auto; }
  body { position: static; inset: auto; width: auto; height: auto; min-height: 100vh; overflow: auto; }
  .app-header { height: 56px; padding: 0 18px; position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .96); backdrop-filter: blur(16px); }
  .brand p, .header-note { display: none; }
  main { height: auto; display: flex; flex-direction: column-reverse; }
  #controls { overflow: visible; padding: 30px 18px 70px; border-right: 0; }
  /* 아래쪽 여백은 보관함 시트 탭(40px)이 내보내기 줄을 가리지 않게 확보한다 */
  #preview-wrap { height: min(84vh, 720px); min-height: 580px; padding: 20px 18px 54px; border-bottom: 1px solid var(--line); }
  .preview-top h2 { font-size: 20px; }
  #preview { height: 100%; max-width: 92%; }
  .export-bar { gap: 8px; }
  .export-bar label { display: none; }
  .export-bar select { max-width: none; }
  #exportBtn { padding-inline: 16px; }
  .preset-drawer {
    position: absolute;
    top: auto;
    right: 14px;
    bottom: 0;
    left: 14px;
    width: auto;
    max-height: calc(100% - 14px);
    padding: 40px 0 0;
    transform: translateY(calc(100% - 40px));
  }
  .preset-drawer.open { transform: translateY(-14px); }
  .preset-drawer-toggle {
    inset: 0 0 auto;
    width: 100%;
    min-height: 40px;
    padding: 7px 14px;
    flex-direction: row;
    border: 1px solid var(--line);
    border-bottom: 0;
    transform: none;
  }
  .preset-drawer-toggle strong { writing-mode: horizontal-tb; }
  .preset-drawer-arrow { margin-left: auto; transform: rotate(90deg); }
  .preset-drawer.open .preset-drawer-arrow { transform: rotate(-90deg); }
  .preset-drawer-content { max-height: calc(80vh - 90px); }
}

@media (max-width: 390px) {
  .recipe-grid { grid-template-columns: 1fr; }
  .recipe-card { padding: 10px 14px; }
  .button-grid { grid-template-columns: repeat(2, 1fr); }
  .export-bar select { width: 120px; }
  .control-body { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
