/* Trade In-Up Builder — BF Content Banner Builder 의 4분할 셸.
   토큰(폰트·웜 그레이·Active Red)은 style.css 의 :root 를 그대로 쓴다.
   폭: 레일 64 / 팔레트 320 / Edit panel 384 (BF ContentTemplateBuilder 와 동일). */

body.tb { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--page); }

/* ── 헤더 ───────────────────────────────────────────── */
.tb-header { position: relative; flex-shrink: 0; gap: 16px; }
.tb-header .brand { color: inherit; text-decoration: none; border-radius: 6px; transition: opacity .15s; }
.tb-header .brand:hover { opacity: .7; }

.tb-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--gray-300);
  background: transparent; font-size: 13px; font-weight: 500; color: var(--gray-600);
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.tb-pill.outline-brand { border-color: var(--brand); color: var(--brand); }
.tb-pill.outline-brand:hover:not(:disabled) { background: var(--brand); color: #fff; }
.tb-pill:disabled { opacity: .4; pointer-events: none; }

/* 스텝 표시 — 헤더 전체 폭의 가운데 */
.tb-steps {
  position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; min-width: 0;
}
.tb-step { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tb-step-num {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1.6px solid var(--gray-300); color: var(--gray-400); font-size: 15px; font-weight: 500;
}
.tb-step-label { font-size: 15px; color: var(--gray-400); white-space: nowrap; }
.tb-step.active .tb-step-num { border-style: dashed; border-color: var(--brand); color: var(--brand); }
.tb-step.active .tb-step-label { color: var(--brand); font-weight: 500; }
.tb-step-line { height: 1px; width: clamp(10px, 4vw, 110px); margin: 0 16px; background: var(--gray-300); flex-shrink: 1; }
@media (max-width: 1279px) {
  .tb-step-label { display: none; }
  .tb-step-line { margin: 0 8px; }
}

/* ── 본문 ───────────────────────────────────────────── */
.tb-body { flex: 1; display: flex; overflow: hidden; }

/* 내비 레일 */
.tb-rail { position: relative; flex-shrink: 0; width: 64px; }
.tb-rail-inner {
  position: absolute; top: 0; bottom: 0; left: 0; z-index: 40;
  width: 64px; overflow: hidden; padding: 12px 0;
  display: flex; flex-direction: column;
  background: #fff; border-right: 1px solid var(--gray-200);
  transition: width .2s ease-out, box-shadow .2s ease-out;
}
.tb-rail:hover .tb-rail-inner { width: max-content; min-width: 240px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1); }
.tb-rail-row {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 44px; padding: 0 22px; flex-shrink: 0;
  white-space: nowrap; color: var(--gray-500); text-decoration: none; transition: background .15s, color .15s;
}
.tb-rail-row:hover { background: var(--gray-50); color: var(--gray-900); }
.tb-rail-row.active { color: var(--brand); background: rgb(253 49 46 / .08); }
.tb-rail-row svg { flex-shrink: 0; }
.tb-rail-row span { font-size: 14px; font-weight: 500; opacity: 0; transition: opacity .15s; }
.tb-rail:hover .tb-rail-row span { opacity: 1; }

/* 사이드 패널 */
.tb-side { flex-shrink: 0; background: #fff; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
.tb-left { width: 320px; border-right: 1px solid var(--gray-200); }
.tb-right { width: 384px; border-left: 1px solid var(--gray-200); }
.tb-side-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--gray-100); flex-shrink: 0; }
.tb-side-title { margin: 0; font-size: 17px; font-weight: 700; color: var(--gray-900); }
.tb-side-sub { margin: 2px 0 0; font-size: 12px; color: var(--gray-400); }

.tb-drag { width: 4px; flex-shrink: 0; cursor: col-resize; background: transparent; transition: background .15s; }
.tb-drag:hover { background: rgb(253 49 46 / .4); }
.tb-drag:active, .tb-drag.dragging { background: rgb(253 49 46 / .6); }

/* 팔레트 — 대주제당 2열 */
.tb-palette { padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.tb-group { display: flex; flex-direction: column; gap: 8px; }
.tb-group-label { margin: 0; padding: 0 4px; font-size: 12px; font-weight: 500; color: var(--gray-400); letter-spacing: .025em; }
.tb-grid { display: grid; grid-template-columns: repeat(2, 140px); gap: 8px; }

.tb-cell { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: left; }
.tb-tile {
  display: flex; align-items: center; justify-content: center;
  width: 140px; height: 64px; border-radius: 4px;
  border: 1px dashed var(--gray-300); background: var(--gray-50); color: var(--gray-400);
  transition: border-color .15s, box-shadow .15s;
}
/* 아트가 있는 타일은 테두리·바탕 없이 이미지만 — 투명 테두리 밑으로 바탕색이 비쳐 선처럼 보였다 */
.tb-tile.has-art { border: 0; background: none; overflow: hidden; }
.tb-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.tb-cell:hover .tb-tile { border-color: var(--gray-400); }
.tb-cell:hover .tb-tile.has-art { box-shadow: 0 0 0 1px var(--gray-300); }
.tb-cell.selected .tb-tile { border-color: transparent; box-shadow: 0 0 0 2px var(--brand); }
.tb-cell.selected .tb-tile.has-art { border: 0; }
.tb-caption { min-height: 12px; font-size: 10px; line-height: 12px; text-align: center; color: var(--gray-600); transition: color .15s; }
.tb-cell.selected .tb-caption { color: var(--brand); font-weight: 500; }

/* 캔버스 */
.tb-canvas { flex: 1; overflow-y: auto; padding: 24px; background: var(--canvas); }
.tb-empty { height: 100%; display: flex; align-items: center; justify-content: center; padding: 0 48px; text-align: center; }
.tb-empty-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--gray-700); }
.tb-empty p { margin: 0; font-size: 14px; color: #8A8078; }

.tb-preview { margin: 0 auto; width: 100%; max-width: 980px; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .05); }
.tb-preview-art {
  aspect-ratio: 980 / 464; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: var(--gray-100); color: var(--gray-400); font-size: 13px;
  background-image: repeating-linear-gradient(45deg, transparent 0 14px, rgb(0 0 0 / .025) 14px 28px);
}
.tb-preview-art { position: relative; overflow: hidden; }
.tb-preview-art:has(img) { background: none; }
.tb-preview-art img { width: 100%; height: 100%; object-fit: cover; }
/* 합성 장면 — 바탕 전체 크기로 키워 놓고 미리보기 창만큼 박스 안으로 당겨 넣는다 (left/top/width/height 는 JS) */
.tb-scene { position: absolute; user-select: none; }
.tb-scene #comp { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tb-preview-foot { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.tb-preview-foot .name { margin: 0; font-size: 14px; font-weight: 500; color: var(--gray-900); }
.tb-preview-foot .meta { margin: 0; font-size: 12px; color: var(--gray-400); }

/* Edit panel */
.tb-edit-body { flex: 1; display: flex; flex-direction: column; padding-bottom: 24px; }
.tb-edit-asset { padding: 20px 20px 4px; }
.tb-edit-asset .name { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.tb-edit-asset .meta { margin: 0; font-size: 12px; color: var(--gray-400); }
.tb-edit-frame { margin-top: 16px; aspect-ratio: 1; border-radius: 8px; overflow: hidden; }
.tb-edit-frame img, .tb-edit-frame canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
/* 접이식 기능 박스 — 머리를 누르면 아래로 펼쳐진다 (grid 0fr→1fr 로 높이 전환) */
.tb-acc { margin: 16px 20px 0; border: 1px solid var(--gray-200); border-radius: 8px; background: #fff; transition: border-color .15s; }
.tb-acc:hover { border-color: var(--gray-300); }
.tb-acc.open { border-color: var(--gray-300); }
.tb-acc-head {
  width: 100%; padding: 16px; border: 0; background: none; text-align: left;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.tb-acc-text { display: flex; flex-direction: column; gap: 4px; }
.tb-acc-title { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.tb-acc.open .tb-acc-title { color: var(--brand); }
.tb-acc-desc { font-size: 12px; line-height: 1.6; color: var(--gray-500); }
.tb-acc-chev { flex-shrink: 0; margin-top: 1px; color: var(--gray-400); transition: transform .2s ease, color .15s; }
.tb-acc.open .tb-acc-chev { transform: rotate(180deg); color: var(--brand); }
.tb-acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.tb-acc.open .tb-acc-body { grid-template-rows: 1fr; }
.tb-acc-inner { overflow: hidden; }
.tb-acc-item { margin: 0 16px; padding: 14px 0; border-top: 1px solid var(--gray-100); display: flex; flex-direction: column; gap: 8px; }
.tb-acc-item:last-child { margin-bottom: 4px; }
.tb-acc-item-label { margin: 0; font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .02em; }
.tb-acc-slot {
  display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 8px 12px;
  border: 1px dashed var(--gray-300); border-radius: 6px; background: var(--gray-50);
  font-size: 11px; color: var(--gray-400); text-align: center;
}

/* Product & Shadow 박스 안 컨트롤 — 모양은 style.css(studio 와 공용)를 그대로 쓰고 간격만 맞춘다 */
.tb-acc-item > .list { gap: 8px; }
.tb-acc-item .status:empty { display: none; }
.tb-acc-item .group-row { display: flex; align-items: center; justify-content: space-between; }
.tb-acc-item .fx-card[hidden] { display: none; }
.tb-acc-item .tabs[hidden] { display: none; }
.tb-drop-slot { margin-left: auto; color: var(--gray-500); }

/* 제품 선택 테두리는 숨긴다 — 손잡이(끌기)는 그대로 동작하고, 커서만 grab 으로 알려준다 */
.tb-scene .product.active { outline: none; }

/* Scene Color — 화면 영역 모서리 (infill.css 에서 옮김) */
.tb-scene .overlay.picking .product { pointer-events: none; }
.tb-scene .overlay.picking { cursor: crosshair; }
.tb-scene #quadSvg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.tb-scene #quadSvg polygon { fill: rgb(253 49 46 / .08); stroke: var(--brand); stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.tb-scene .handle {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand); box-shadow: 0 1px 4px rgb(0 0 0 / .35);
  cursor: grab; touch-action: none; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: var(--brand);
}
.tb-scene .handle:active { cursor: grabbing; }
/* 화면 가이드(점선 사각형·모서리 점)는 Scene Color 박스를 열었을 때만 */
.tb-scene .overlay:not(.screen-guides) #quadSvg, .tb-scene .overlay:not(.screen-guides) .handle { display: none; }
.tb-acc-item .btn.ghost.active { background: var(--brand); border-color: var(--brand); color: #fff; }
#moodPanel.off > :not(.group-row) { opacity: .4; pointer-events: none; }

/* Screen Area — 영역을 고르는 두 방법 카드. 지금 쓰는 쪽(.on)에 브랜드 테두리 */
.tb-method { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--gray-200); border-radius: 10px; transition: border-color .15s, background .15s; }
.tb-method.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 3%, #fff); }
.tb-method-head { display: flex; align-items: center; gap: 8px; }
.tb-method-head p { margin: 0; font-size: 12px; font-weight: 600; color: var(--gray-900); }
.tb-method-head p span { font-weight: 400; color: var(--gray-500); }
.tb-method-num { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--gray-300); font-size: 11px; font-weight: 600; color: var(--gray-500); }
.tb-method.on .tb-method-num { border-color: var(--brand); background: var(--brand); color: #fff; }
.tb-clear-screen { align-self: flex-start; color: var(--gray-500); }
.tb-clear-screen[hidden] { display: none; }

/* Color Mood 머리의 Before / After 비교 토글 */
.tb-ba { flex-shrink: 0; }
.tb-ba button { flex: none; height: 26px; padding: 0 10px; font-size: 11px; }

/* 팔레트 맨 위 Trade In / Trade Up 전환 */
.tb-version { flex-shrink: 0; }
.tb-version button { height: 34px; font-size: 12px; font-weight: 600; }

/* 줄 제목 오른쪽 Light / Dark — 원 안 아이콘 + 라벨, 고른 쪽에 브랜드 링 */
.tb-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tb-tones { display: flex; gap: 10px; }
.tb-tone { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; font-size: 11px; color: var(--gray-400); transition: color .15s; }
.tb-tone:hover { color: var(--gray-700); }
.tb-tone-dot {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px var(--gray-300); transition: box-shadow .15s;
}
.tb-tone-light .tb-tone-dot { background: #F3EFE8; color: #B08A3E; }
.tb-tone-dark .tb-tone-dot { background: #3A3633; color: #E6E1D6; }
.tb-tone.on { color: var(--gray-900); font-weight: 600; }
.tb-tone.on .tb-tone-dot { box-shadow: 0 0 0 1.5px #fff, 0 0 0 3px var(--brand); }

/* 기능 박스 제목 아래 상태 표시 (예: 보류중) */
.tb-acc-badge { align-self: flex-start; padding: 2px 8px; border-radius: 999px; background: #FFF4E5; color: #B26A00; font-size: 11px; font-weight: 600; }
