@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;800;900&display=swap");

:root {
  --brand-blue: #0c1eda;
  --ink: #111111;
  --muted: #666666;
  --line: #dfe3ff;
  --soft: #f6f7ff;
  --card: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; background: #ffffff; color: var(--ink); font-family: "Noto Sans KR", system-ui, sans-serif; }
.brick-interactive { width: min(100%, 920px); margin: 0 auto; padding: 72px 30px; }
.builder-hero { text-align: center; margin-bottom: 42px; }
.eyebrow { margin: 0 0 10px; color: var(--brand-blue); font-size: 13px; font-weight: 900; letter-spacing: .08em; }
h1 { margin: 0; color: var(--brand-blue); font-size: clamp(29px, 6vw, 53px); line-height: 1.08; font-weight: 900; letter-spacing: -0.04em; }
.subtitle { max-width: 700px; margin: 18px auto 0; color: #333; font-size: 18px; line-height: 1.65; }
.builder-shell { display: grid; grid-template-columns: 0.95fr 1.05fr; gap: 24px; align-items: start; }
.option-panel, .summary-card, .preview-card, .print-guide { border: 2px solid var(--brand-blue); border-radius: 24px; background: var(--card); box-shadow: 0 18px 50px rgba(12,30,218,.08); }
.option-panel { padding: 20px; position: sticky; top: 20px; height: 882.3px; display: flex; flex-direction: column; }
.panel-heading { display: flex; justify-content: space-between; gap: 12px; align-items: end; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.panel-heading strong { font-size: 22px; font-weight: 900; }
.panel-heading span { color: var(--muted); font-size: 13px; text-align: right; }
.panel-note { margin: 12px 0 0; padding: 12px 13px; border-radius: 16px; background: #f8f9ff; color: #333; font-size: 14px; line-height: 1.55; border: 1px solid var(--line); }
.group-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.group-tab { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 10px 8px; color: var(--ink); font-weight: 800; cursor: pointer; }
.group-tab.is-active { background: var(--brand-blue); color: white; border-color: var(--brand-blue); }
.option-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; flex: 1; min-height: 0; max-height: none; overflow: auto; padding-right: 4px; }
.option-button { min-height: 86px; border: 1px solid #eceeff; border-radius: 16px; background: #fff; cursor: pointer; padding: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.option-button.is-selected { border: 2px solid var(--brand-blue); background: #f8f9ff; }
.option-button img { max-width: 100%; max-height: 52px; object-fit: contain; display: block; }
.option-button span { font-size: 11px; font-weight: 800; color: #333; }
.preview-panel { display: grid; gap: 16px; }
.preview-card { padding: 20px; }
.adjust-toolbar { margin-bottom: 10px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.adjust-heading { display: flex; justify-content: space-between; gap: 8px; align-items: end; padding-bottom: 16px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.adjust-heading strong { display: block; font-size: 20px; font-weight: 900; letter-spacing: -0.04em; }
.adjust-note { margin: 0; padding: 12px 13px; border-radius: 16px; background: #f8f9ff; color: #333; font-size: 14px; line-height: 1.45; border: 1px solid var(--line); }
.preview-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
.preview-action-button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid #fd6400; border-radius: 12px; background: #fd6400; color: #fff; padding: 7px 10px; font-size: 12.5px; line-height: 1; font-weight: 900; cursor: pointer; white-space: nowrap; }
.preview-action-button::before { content: ""; width: 14px; height: 14px; flex: 0 0 14px; background: currentColor; }
.capture-button::before { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 3 7.17 5H4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-3.17L15 3H9Zm3 15a5 5 0 1 1 0-10 5 5 0 0 1 0 10Zm0-2a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 3 7.17 5H4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-3.17L15 3H9Zm3 15a5 5 0 1 1 0-10 5 5 0 0 1 0 10Zm0-2a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z'/%3E%3C/svg%3E") center / contain no-repeat; }
.random-background-button::before { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19 3h-4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Zm-1 5h-2V6h2v2ZM9 13H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2Zm-1 5H6v-2h2v2Zm11-5h-4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2Zm-1 5h-2v-2h2v2ZM9 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2ZM8 8H6V6h2v2Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19 3h-4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Zm-1 5h-2V6h2v2ZM9 13H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2Zm-1 5H6v-2h2v2Zm11-5h-4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2Zm-1 5h-2v-2h2v2ZM9 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2ZM8 8H6V6h2v2Z'/%3E%3C/svg%3E") center / contain no-repeat; }

.capture-button {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 0 0 4px rgba(253, 100, 0, .58), 0 8px 18px rgba(253, 100, 0, .34);
  animation: capturePulse 1.8s ease-in-out infinite;
}
@keyframes capturePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 0 0 4px rgba(253, 100, 0, .58), 0 8px 18px rgba(253, 100, 0, .34); }
  50% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 0 0 7px rgba(253, 100, 0, .78), 0 10px 24px rgba(253, 100, 0, .48); }
}
@media (prefers-reduced-motion: reduce) {
  .capture-button { animation: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 0 0 5px rgba(253, 100, 0, .62), 0 8px 18px rgba(253, 100, 0, .34); }
}
.preview-action-button:hover { filter: brightness(.94); }
.preview-action-button[data-tooltip]::after { content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 9px); z-index: 80; transform: translateX(-50%) translateY(4px); padding: 8px 11px; border-radius: 12px; background: rgba(17,17,17,.78); color: #fff; font-size: 12px; font-weight: 800; line-height: 1; white-space: nowrap; opacity: 0; pointer-events: none; box-shadow: 0 8px 22px rgba(0,0,0,.18); transition: opacity .16s ease, transform .16s ease; }
.preview-action-button[data-tooltip]::before { z-index: 1; }
.preview-action-button[data-tooltip]:hover::after, .preview-action-button[data-tooltip]:focus-visible::after, .preview-action-button[data-tooltip].is-tooltip-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.reset-bottom-button { display: block; width: 100%; margin-top: 12px; border: 1px solid var(--brand-blue); border-radius: 999px; background: var(--brand-blue); color: #fff; padding: 12px 14px; font-size: 14px; font-weight: 900; cursor: pointer; }
.layer-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
.layer-chip { border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 8px 4px; color: #333; font-size: 11px; font-weight: 900; cursor: pointer; }
.layer-chip.is-active { border-color: var(--brand-blue); background: var(--brand-blue); color: #fff; }
.preview-stage { --figure-scale: .5333; position: relative; height: 620px; border-radius: 22px; background: linear-gradient(180deg, #f7f8ff 0%, #ffffff 65%); overflow: hidden; touch-action: none; isolation: isolate; }
.preview-stage.is-editing { outline: 2px dashed rgba(12,30,218,.35); outline-offset: -10px; cursor: grab; }
.preview-stage.is-dragging { cursor: grabbing; }
.stage-background { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; display: none; pointer-events: none; user-select: none; }
.stage-background.has-background { display: block; }
.stage-note { position: absolute; z-index: 30; top: 18px; left: 18px; color: #a6acef; font-size: 12px; font-weight: 900; letter-spacing: .12em; pointer-events: none; }
.part { position: absolute; object-fit: contain; pointer-events: none; user-select: none; filter: drop-shadow(0 16px 18px rgba(0,0,0,.08)); transform: translateX(-50%) scale(var(--figure-scale)) scaleY(var(--part-scale-y, 1)); transform-origin: top center; }
.preview-stage.is-editing .part { pointer-events: auto; cursor: grab; }
.preview-stage.is-editing .part.is-active-layer { outline: none; }
.resize-box { display: none; position: absolute; z-index: 60; border: 2px dashed rgba(12,30,218,.70); border-radius: 8px; pointer-events: none; transform: translateZ(0); }
.resize-box.is-visible { display: block; }
.resize-handle { position: absolute; width: 18px; height: 18px; border: 2px solid #ffffff; border-radius: 6px; background: #40444f; box-shadow: 0 1px 5px rgba(0,0,0,.35); padding: 0; pointer-events: auto; cursor: nwse-resize; }
.resize-handle::after { content: ""; position: absolute; inset: 4px; border: 2px solid #ffffff; border-radius: 2px; opacity: .9; }
.resize-handle-nw { left: -10px; top: -10px; }
.resize-handle-ne { right: -10px; top: -10px; cursor: nesw-resize; }
.resize-handle-sw { left: -10px; bottom: -10px; cursor: nesw-resize; }
.resize-handle-se { right: -10px; bottom: -10px; }
.resize-box.is-resizing { border-color: var(--brand-blue); }
.preview-stage.is-editing .part.is-dragging { cursor: grabbing; filter: drop-shadow(0 20px 22px rgba(12,30,218,.18)); }
/* Layer order, bottom to top: shoes > pants > hand > arm > top > hair > face print */
/* Body baseline: top is the anchor part. Drag mode can override top/width/left in JS. */
.part-shoes { z-index: 1; left: 50%; top: 448px; width: 226px; }
.part-pants { z-index: 2; left: 50%; top: 315px; width: 218px; --part-scale-y: .92; }
.part-hand { z-index: 3; left: 50%; top: 310px; width: 365px; --part-scale-y: 1.15; }
.part-arm { z-index: 4; left: 50%; top: 260px; width: 357px; --part-scale-y: 1.15; }
.part-top { z-index: 5; left: 50%; top: 205px; width: 238px; --part-scale-y: .92; }
.part-hair { z-index: 9; left: 50%; top: 136px; width: 211.5px; }
.print-layer { display: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,.05)); }
.print-layer.has-upload { display: block; }
.part-pants-print { z-index: 3; left: 50%; top: 315px; width: 218px; }
.part-top-print { z-index: 7; left: 50%; top: 206px; width: 238px; }
.part-face-print { z-index: 20; left: 50%; top: 176px; width: 128px; }
.print-guide { margin-top: 28px; padding: 28px; display: grid; grid-template-columns: 1fr; gap: 20px; align-items: center; background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%); }
.print-guide .eyebrow { color: #4d55dd; }
.print-copy { text-align: center; max-width: 760px; margin: 0 auto; }
.print-copy h2 { margin: 0 0 10px; font-size: 30px; letter-spacing: -0.04em; }
.print-subtitle { margin: 0; color: #333; line-height: 1.6; }
.print-instruction { margin: 8px 0 0; color: #fd6400; font-size: 14px; font-weight: 900; line-height: 1.55; }
.print-items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.print-item { border: 1px solid #ccd2ff; border-radius: 16px; padding: 12px; text-align: center; background: #fff; }
.print-item img { width: 100%; height: 78px; object-fit: contain; display: block; }
.print-item strong { display: block; margin-top: 8px; font-size: 13px; font-weight: 900; }
.print-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 700; }
.print-item .print-badge { display: inline; margin-top: 0; color: inherit; font-size: inherit; font-weight: 400; }
.print-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.print-actions a, .upload-label { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; border-radius: 999px; border: 1px solid var(--brand-blue); font-size: 11px; font-weight: 900; text-decoration: none; cursor: pointer; }
.print-actions a { color: var(--brand-blue); background: #fff; }
.upload-label { color: #fff; background: var(--brand-blue); }
.upload-label input { display: none; }
.print-hint { margin-top: 8px; color: #555; font-size: 10px; line-height: 1.35; }
.tile-print-item { display: flex; flex-direction: column; justify-content: space-between; }
.tile-preview-grid { min-height: 78px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; align-items: end; padding: 2px 0 0; }
.tile-preview { margin: 0; display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 4px; }
.tile-preview img { width: 100%; height: 58px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.08)); }
.tile-preview figcaption { color: #333; font-size: 9px; font-weight: 900; line-height: 1; white-space: nowrap; }
.tile-print-copy { margin: 8px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.35; }

@media (max-width: 820px) {
  .brick-interactive { padding: 54px 18px; }
  .builder-shell, .print-guide { grid-template-columns: 1fr; }
  .option-panel { position: static; height: auto; display: block; }
  .preview-stage { --figure-scale: .4667; height: 560px; }
  .option-grid { grid-template-columns: repeat(3, 1fr); max-height: 390px; }
  .print-items { grid-template-columns: repeat(2, 1fr); }
  .adjust-toolbar { align-items: flex-start; }
  .print-actions { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .group-tabs { grid-template-columns: repeat(2, 1fr); }
  .option-grid { grid-template-columns: repeat(2, 1fr); }
  .layer-picker { grid-template-columns: repeat(3, 1fr); }
  .preview-stage { --figure-scale: .3867; height: 480px; }
  .part-shoes { width: 200px; top: 365px; }
  .part-pants { width: 194px; top: 190px; --part-scale-y: .92; }
  .part-hand { width: 320px; top: 225px; --part-scale-y: 1.20; }
  .part-arm { width: 312px; top: 157px; --part-scale-y: 1.20; }
  .part-top { width: 210px; top: 112px; --part-scale-y: .92; }
  .part-hair { width: 180px; top: 50px; }
  .part-pants-print { width: 194px; top: 190px; }
  .part-top-print { width: 210px; top: 112px; }
  .part-face-print { width: 112px; top: 110px; }
}
