:root {
  --paper: #f7f3ed;
  --paper-deep: #eee6dc;
  --ink: #2f2924;
  --muted: #766b62;
  --line: #ded4c9;
  --brown: #5b4636;
  --brown-dark: #423125;
  --white: #fff;
  --danger: #a5443d;
  --shadow: 0 18px 50px rgba(66, 49, 37, .11);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100%; margin: 0; color: var(--ink); background: linear-gradient(145deg, #fbf9f5 0%, var(--paper) 55%, #efe7dd 100%); font-family: "Pretendard", "Noto Sans KR", Arial, sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.work-header { height: 68px; display: flex; align-items: center; padding: 0 28px; border-bottom: 1px solid rgba(91, 70, 54, .12); background: rgba(255, 255, 255, .76); backdrop-filter: blur(14px); }
.work-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-family: Georgia, "Noto Serif KR", serif; font-size: 20px; font-weight: 700; text-decoration: none; }
.work-brand img { width: 220px; max-width: 65vw; height: 38px; object-fit: cover; object-position: center; }
.work-main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0 72px; }
.work-card { width: min(570px, 100%); margin: 7vh auto 0; padding: clamp(28px, 5vw, 48px); border: 1px solid rgba(91, 70, 54, .12); border-radius: 24px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); }
.work-card--center { text-align: center; }
.eyebrow { margin: 0 0 9px; color: var(--brown); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 40px); line-height: 1.2; letter-spacing: -.04em; }
.intro { margin: 15px 0 30px; color: var(--muted); line-height: 1.7; word-break: keep-all; }
label, legend { display: block; margin: 0 0 8px; font-size: 14px; font-weight: 750; }
input[type="text"], input[type="tel"], textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 14px 15px; color: var(--ink); background: #fff; outline: none; transition: border-color .18s, box-shadow .18s; }
input[type="text"]:focus, input[type="tel"]:focus, textarea:focus { border-color: var(--brown); box-shadow: 0 0 0 3px rgba(91, 70, 54, .12); }
.verify-card label:not(:first-of-type) { margin-top: 18px; }
.form-hint, .selected-file, .control-copy { margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.form-error { margin: 18px 0 0; padding: 12px 14px; border-radius: 9px; color: #812f2a; background: #fbe9e6; font-size: 14px; line-height: 1.55; }
.primary-button, .secondary-button, .danger-button, .file-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; padding: 12px 20px; font-weight: 750; text-align: center; text-decoration: none; transition: transform .15s, opacity .15s, background .15s; }
.primary-button { border: 1px solid var(--brown); color: #fff; background: var(--brown); }
.primary-button:hover { background: var(--brown-dark); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.danger-button { border: 1px solid var(--danger); color: #fff; background: var(--danger); }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { cursor: wait; opacity: .55; transform: none; }
.verify-card .primary-button { width: 100%; margin-top: 22px; }
.loading-mark { width: 38px; height: 38px; margin: 0 auto 18px; border: 3px solid var(--paper-deep); border-top-color: var(--brown); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.editor-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.item-meta, .step-text { color: var(--muted); }
.item-meta { margin: 9px 0 0; }
.step-text { margin: 0; font-size: 14px; font-weight: 700; white-space: nowrap; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 28px; align-items: start; }
.preview-panel, .control-panel { padding: clamp(18px, 3vw, 28px); border: 1px solid rgba(91, 70, 54, .12); border-radius: 20px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); }
.preview-panel { position: static; background: #fff; overflow: visible; }
.canvas-wrap { position: relative; width: 100%; max-height: calc(100svh - 220px); margin: auto; display: grid; place-items: center; overflow: hidden; border-radius: 6px; background-color: #e7dfd5; background-image: linear-gradient(45deg, #dcd2c7 25%, transparent 25%), linear-gradient(-45deg, #dcd2c7 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #dcd2c7 75%), linear-gradient(-45deg, transparent 75%, #dcd2c7 75%); background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0; }
#workCanvas { display: block; max-width: 100%; max-height: calc(100svh - 260px); width: auto; height: auto; background: #fff; box-shadow: 0 5px 18px rgba(47, 41, 36, .15); touch-action: none; cursor: grab; }
#workCanvas.is-dragging { cursor: grabbing; }
.canvas-wrap { background: transparent; }
.canvas-wrap.is-floating { position: fixed; z-index: 10; margin: 0; pointer-events: none; max-height: none; overflow: visible; align-items: start; }
.canvas-wrap.is-floating #workCanvas { pointer-events: auto; }
#workCanvas { border: 4px solid #b5aaa0; box-sizing: content-box; max-width: calc(100% - 20px); box-shadow: 0 2px 6px rgba(47, 41, 36, .12); }
.preview-caption { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.template-direction { margin: 0 0 8px; color: var(--brown-dark); font-size: 13px; font-weight: 750; text-align: center; }
#orientationControls button[aria-pressed="true"] { color: #fff; border-color: var(--brown-dark); background: var(--brown); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3); }
#orientationControls button[aria-pressed="true"]::before { content: "✓"; margin-right: 5px; }
.canvas-empty { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: 80%; margin: 0; padding: 13px; border-radius: 10px; color: var(--muted); background: rgba(255, 255, 255, .9); text-align: center; pointer-events: none; }
.preview-help { margin: 13px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.control-group + .control-group { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.control-group h2 { margin: 0 0 16px; font-size: 18px; }
#photoInput { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-button { width: 100%; border: 1px dashed var(--brown); color: var(--brown); background: #fbf7f2; cursor: pointer; }
.range-label { display: flex; justify-content: space-between; margin-top: 20px; }
input[type="range"] { width: 100%; accent-color: var(--brown); }
fieldset { min-width: 0; margin: 17px 0 0; padding: 0; border: 0; }
.position-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.position-button { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #fff; font-size: 13px; font-weight: 700; }
.position-button[aria-pressed="true"] { border-color: var(--brown); color: #fff; background: var(--brown); }
.editor-actions, .review-actions, .dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 24px; }

.review-card { width: min(680px, 100%); }
.review-list { display: grid; gap: 10px; }
.review-item { width: 100%; display: grid; grid-template-columns: 72px 1fr auto; gap: 13px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; text-align: left; }
.review-thumb { width: 72px; height: 72px; display: block; border-radius: 8px; object-fit: contain; background: var(--paper); }
.review-item strong, .review-item small { display: block; }
.review-item small { margin-top: 4px; color: #fff; }
.review-edit { color: #fff; font-size: 13px; font-weight: 750; }
.done-icon { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 24px; border-radius: 50%; color: #fff; background: var(--brown); font-size: 34px; }
.done-card > p:not(.eyebrow):not(.done-order) { color: var(--muted); line-height: 1.8; }
.done-order { margin: 24px 0 0; padding-top: 20px; border-top: 1px solid var(--line); font-weight: 700; }
.confirm-dialog { width: min(470px, calc(100% - 32px)); padding: 30px; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 90px rgba(0, 0, 0, .25); }
.confirm-dialog::backdrop { background: rgba(35, 28, 23, .55); backdrop-filter: blur(3px); }
.confirm-dialog h2 { margin: 0 0 12px; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.7; word-break: keep-all; }

@media (max-width: 840px) {
  .work-main { padding-top: 30px; }
  .editor-grid { grid-template-columns: 1fr; }
  .preview-panel { padding: 12px; }
  .preview-panel .canvas-wrap { max-height: min(40dvh, 340px); }
  .preview-panel #workCanvas { max-height: min(calc(40dvh - 20px), 320px); }
  .preview-panel .range-label { margin-top: 8px; }
  .preview-panel .secondary-button { min-height: 32px; padding: 6px 12px; }
  .preview-panel .control-copy { margin: 5px 0 0; font-size: 12px; }
  .preview-panel .preview-help { display: none; }
  .preview-panel #orientationControls { margin-bottom: 8px; }
  .preview-panel #orientationControls h2 { display: inline; margin-right: 8px; font-size: 13px; }
}
@media (max-width: 520px) {
  .work-header { height: 58px; padding: 0 16px; }
  .work-main { width: min(100% - 20px, 1180px); padding: 22px 0 44px; }
  .work-card { margin-top: 2vh; padding: 24px 18px; border-radius: 18px; }
  .editor-heading { align-items: start; }
  .editor-heading h1 { font-size: 25px; }
  .preview-panel, .control-panel { padding: 13px; border-radius: 15px; }
  .editor-actions, .review-actions, .dialog-actions { grid-template-columns: 1fr; }
  .review-item { grid-template-columns: 58px 1fr; }
  .review-thumb { width: 58px; height: 58px; }
  .review-edit { display: none; }
  .step-text { margin-top: 5px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

.demo-notice{padding:16px 20px;margin-bottom:20px;border:1px solid #d8bd7b;border-radius:12px;background:#fff5dc;color:#604c21;font-size:14px;line-height:1.7}.demo-notice a{color:inherit;font-weight:700}

#messageText { resize: none; overflow: hidden; min-height: 52px; line-height: 1.6; }

.editor-tool-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.editor-tool-tabs button { flex: 1; padding: 8px; border-radius: 8px; border: 0; }
.drag-guide { margin: 4px 0 0; font-size: 14px; text-align: center; color: #285b43; }
.mobile-editor-progress { display: none; }
.save-status { position: fixed; z-index: 30; bottom: 24px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 24px)); margin: 0; padding: 14px 18px; border: 1px solid #9cbdab; border-radius: 12px; color: #285b43; background: #f3faf5; box-shadow: 0 4px 20px #00000018; font-size: 14px; line-height: 1.6; text-align: center; pointer-events: none; }
@media (max-width: 840px) { .save-status { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.message-font-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.message-input-heading { display: flex; justify-content: space-between; align-items: center; }
#finishMessageButton { display: none; }
.message-style-row { display: grid; grid-template-columns: auto minmax(50px, 1fr) auto 38px; gap: 8px; align-items: center; margin-top: 8px; }
.message-style-row label { margin: 0; white-space: nowrap; }
#messageColor { width: 38px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
@media (max-width: 840px) {
  .work-main { padding-top: 16px; }
  .editor-heading { padding: 0 8px; margin-bottom: 12px; align-items: center; }
  .editor-heading .eyebrow { display: none; }
  .editor-heading h1 { font-size: 21px; }
  .item-meta { margin: 5px 0 0; font-size: 12px; }
  .editor-grid { gap: 12px; padding-bottom: 104px; }
  .preview-panel { position: sticky; top: 0; z-index: 10; padding: 10px 12px; border-radius: 12px; box-shadow: 0 3px 12px #00000008; }
  .preview-panel .canvas-wrap { max-height: min(40dvh, 360px); }
  .preview-panel #workCanvas { max-height: min(calc(40dvh - 12px), 348px); border: 1px solid #ded4c9; box-shadow: none; }
  .preview-panel .control-copy { display: none; }
  .preview-caption { font-size: 10px; line-height: 1.4; }
  .template-direction { font-size: 11px; margin-bottom: 5px; }
  .control-panel { padding: 12px; border-radius: 12px; box-shadow: none; }
  .editor-tool-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: #f2f4f1; border-radius: 10px; }
  .preview-panel .editor-tool-tabs { margin: 10px 0 0; }
  .zoom-controls { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
  .zoom-controls .range-label { grid-column: 1 / -1; margin-bottom: 0; font-size: 12px; }
  .zoom-controls input[type="range"] { margin: 0; }
  .zoom-controls #fitPhotoButton { min-height: 36px; font-size: 12px; }
  .editor-tool-tabs button { flex: 1; min-height: 44px; border-radius: 8px; border: 0; font-weight: 750; }
  .tool-panel:not(.is-active) { display: none; }
  .control-group { padding: 0; margin: 0; border: 0; }
  .control-group h2 { font-size: 15px; }
  .control-group .control-copy { font-size: 12px; line-height: 1.6; }
  #orientationControls { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
  #orientationControls h2 { font-size: 14px; }
  .editor-actions { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0; padding: 12px max(12px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(90px, 1fr) 2fr; gap: 10px; background: #fffdf9; border-top: 1px solid #e6e7e1; box-shadow: 0 -3px 12px #00000008; }
  .editor-actions button { min-height: 48px; font-size: 14px; }
  body.is-editing { position: fixed; inset: 0; height: var(--editor-viewport, 100dvh); overflow: hidden; }
  .is-editing #demoNotice { display: none; }
  .is-editing .work-header { height: 44px; justify-content: space-between; gap: 8px; }
  .is-editing .work-brand img { width: 160px; max-width: 45vw; height: 32px; }
  .is-editing .mobile-editor-progress { display: block; font-size: 12px; font-weight: 700; white-space: nowrap; }
  .is-editing .work-main { height: calc(100% - 44px); padding: 4px 0 calc(64px + env(safe-area-inset-bottom)); }
  .is-editing #editorView { height: 100%; }
  .is-editing .editor-heading { display: none; }
  .is-editing .editor-grid { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 0; gap: 6px; }
  .is-editing .preview-panel { position: static; display: flex; flex-direction: column; flex: 1; min-height: 0; align-self: stretch; padding: 6px 8px; }
  .is-editing #photoSlot { flex: 1; min-height: 0; }
  .is-editing .preview-panel #workCanvas { max-height: var(--photo-slot-height, 30dvh); max-width: calc(100% - 2px); }
  .is-editing .preview-panel .canvas-wrap { height: 100%; max-height: none; }
  .is-editing .control-panel { display: grid; flex: 0 0 auto; height: auto; min-height: 0; align-self: stretch; overflow: visible; padding: 8px 10px; }
  .is-editing .tool-panel { margin: 0; padding: 0; border: 0; }
  .is-editing .tool-panel { grid-area: 1 / 1; }
  .is-editing .tool-panel:not(.is-active) { display: block; visibility: hidden; pointer-events: none; }
  .is-editing .control-group > h2 { display: none; }
  .is-editing .control-group > .control-copy:not(#photoUploadStatus):not(#qrStatus):not(#fontStatus) { display: none; }
  .is-editing .control-copy:empty { display: none; }
  .is-editing .control-group label, .is-editing .control-group legend { margin-bottom: 3px; font-size: 14px; }
  .is-editing .control-group input, .is-editing .control-group select, .is-editing .control-group textarea { margin-bottom: 0; }
  .is-editing .control-group select { padding: 6px 10px; height: 38px; font-size: 14px; }
  .is-editing #messageText { padding: 6px 10px; min-height: 38px; font-size: 15px; line-height: 1.35; }
  .is-editing #messageColor { height: 38px; }
  .is-editing .message-font-row { margin-bottom: 5px; }
  .is-editing #fontStatus:not(.font-error) { display: none; }
  .is-editing .message-style-row { margin-top: 5px; }
  .is-editing .control-group fieldset { margin-top: 5px; }
  .is-editing .position-grid { gap: 4px; }
  .is-editing #messagePositions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .is-editing #messagePositions button { font-size: 10px; }
  .is-editing .position-button { min-height: 30px; padding: 4px; font-size: 12px; }
  .is-editing #orientationControls { padding-bottom: 5px; margin-bottom: 5px; }
  .is-editing #orientationControls h2 { display: inline; margin-right: 8px; font-size: 14px; }
  .is-editing #orientationControls button { min-height: 38px; padding: 5px 18px; font-size: 14px; }
  .is-editing .file-button { min-height: 38px; padding: 6px 10px; margin-bottom: 4px; font-size: 14px; }
  .is-editing .selected-file { margin: 2px 0 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .is-editing .control-copy { margin: 3px 0 0; font-size: 13px; line-height: 1.4; }
  .is-editing .range-label { margin-top: 0; }
  .is-editing .zoom-controls { flex: 0 0 auto; margin-top: 4px; grid-template-columns: 1fr auto; gap: 0 8px; }
  .is-editing .zoom-controls .range-label { display: none; }
  .is-editing .zoom-controls #fitPhotoButton { min-height: 34px; padding: 4px 8px; font-size: 13px; }
  .is-editing .preview-caption { margin: 3px 0 0; font-size: 9px; }
  .is-editing .template-direction { flex: 0 0 auto; margin-bottom: 3px; }
  .is-editing .drag-guide { flex: 0 0 36px; height: 36px; line-height: 18px; }
  .is-editing .editor-tool-tabs { flex: 0 0 auto; margin-top: 4px; padding: 3px; }
  .is-editing .editor-tool-tabs button { min-height: 38px; padding: 4px; font-size: 14px; }
  .is-editing .editor-actions { position: absolute; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .is-editing .editor-actions button { min-height: 46px; padding: 8px; font-size: 15px; }
  .is-editing #editorError:not([hidden]) { position: absolute; left: 10px; right: 10px; bottom: 66px; z-index: 21; margin: 0; }
  .is-editing.is-typing .zoom-controls, .is-editing.is-typing .preview-caption, .is-editing.is-typing .template-direction,
  .is-editing.is-typing .message-font-row, .is-editing.is-typing .message-style-row, .is-editing.is-typing #messageControls fieldset,
  .is-editing.is-typing #fontStatus { display: none; }
  .is-editing.is-typing .drag-guide { display: none; }
  .is-editing.is-typing .tool-panel:not(.is-active) { display: none; }
  .is-editing.is-typing #finishMessageButton { display: block; padding: 3px 10px; margin-bottom: 3px; border: 0; border-radius: 6px; font-size: 11px; }
}
@media (max-width: 840px) and (max-height: 700px) {
  .is-editing .preview-caption { font-size: 8px; line-height: 1.1; }
  .is-editing #messageText { font-size: 14px; line-height: 1.2; padding: 4px 8px; }
  .is-editing .template-direction { display: none; }
}
@media (max-width: 840px) and (orientation: landscape) {
  .is-editing .editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
  .is-editing .control-panel { align-self: start; }
}

.photo-preparing:not([hidden]) { z-index: 2; display: flex; align-items: center; justify-content: center; gap: 12px; background: #fff; }
.photo-preparing::before { content: ""; flex: 0 0 22px; height: 22px; border: 3px solid #e7dfd5; border-top-color: #5b4636; border-radius: 50%; animation: spin .8s linear infinite; }
@media (min-width: 841px) {
  .is-editing .control-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .is-editing .editor-tool-tabs { grid-area: 1 / 1; margin: 0; padding: 4px; background: #f2f4f1; border-radius: 10px; }
  .is-editing .editor-tool-tabs button { min-height: 44px; font-size: 15px; font-weight: 750; }
  .is-editing .tool-panel { grid-area: 2 / 1; margin: 0; padding: 0; border: 0; }
  .is-editing .tool-panel:not(.is-active) { visibility: hidden; pointer-events: none; }
  .is-editing .tool-panel > h2 { display: none; }
  .is-editing #orientationControls { margin-bottom: 16px; }
  .is-editing #orientationControls h2 { font-size: 14px; margin-bottom: 8px; }
  .is-editing #photoControls > .control-copy:not(#photoUploadStatus) { display: none; }
  .is-editing #photoControls .file-button { margin-bottom: 10px; }
  .is-editing .message-font-row { margin-bottom: 16px; }
  .is-editing #fontStatus:not(.font-error) { display: none; }
  .is-editing .message-style-row { margin-top: 12px; }
  .is-editing #messageColor { height: 38px; }
  .is-editing #editorError { grid-area: 3 / 1; margin: 0; }
  .is-editing .editor-actions { grid-area: 4 / 1; margin: 0; padding-top: 16px; border-top: 1px solid var(--line); }
}
