/* Seam — visual language ported from the Panoramic Carousel Builder design.
   Layout chrome lives here; state-dependent geometry (positions, transforms)
   is applied inline by the UI modules. */

:root {
  --bg-app: #f4f5f9;
  --bg-panel: #ffffff;
  --border: #e9ebf0;
  --border-soft: #eaecf2;
  --ink: #1a1d26;
  --ink-soft: #5a6072;
  --ink-muted: #8a8fa3;
  --ink-faint: #a4a9bc;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --danger: #d9534f;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg-app);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.body { flex: 1; display: flex; min-height: 0; }

/* ---------- scrollbars ---------- */
.scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll::-webkit-scrollbar-thumb { background: #d4d8e0; border-radius: 6px; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ---------- toolbar ---------- */
.toolbar {
  height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .35);
}
.brand-mark span { display: flex; gap: 2px; }
.brand-mark i { width: 4px; height: 14px; background: #fff; border-radius: 1px; display: block; }
.brand-mark i:nth-child(1) { opacity: .95; }
.brand-mark i:nth-child(2) { opacity: .7; }
.brand-mark i:nth-child(3) { opacity: .45; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.02em; }
.brand-name b { color: var(--accent); font-weight: 800; }

.divider { width: 1px; height: 26px; background: var(--border-soft); flex: none; }
.spacer { flex: 1; }

.group { display: flex; align-items: center; gap: 8px; }
.group-label {
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: .06em;
}

.stepper {
  display: flex; align-items: center;
  background: var(--bg-app); border: 1px solid var(--border);
  border-radius: 9px; overflow: hidden;
}
.stepper button {
  border: none; background: transparent; width: 30px; height: 30px;
  font-size: 17px; color: var(--ink-soft); cursor: pointer; font-weight: 600;
}
.stepper .value { width: 26px; text-align: center; font-weight: 700; font-size: 14px; }

.segmented {
  display: flex; background: var(--bg-app); border: 1px solid var(--border);
  border-radius: 9px; padding: 3px; gap: 3px;
}
.seg-btn {
  border: none; border-radius: 7px; padding: 6px 14px; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  background: transparent; color: var(--ink-muted);
}
.seg-btn.active {
  background: #fff; color: var(--accent);
  box-shadow: 0 1px 3px rgba(80, 80, 160, .18);
}

.icon-btn {
  border: 1px solid var(--border); background: #fff;
  width: 32px; height: 32px; border-radius: 8px; font-size: 16px;
  color: var(--ink-soft); cursor: pointer;
}
.icon-btn:disabled { color: #c6cad6; cursor: default; }

.zoom { display: flex; align-items: center; gap: 4px; color: var(--ink-soft); }
.zoom button {
  border: 1px solid var(--border); background: #fff; height: 28px;
  border-radius: 7px; cursor: pointer; font-size: 16px; color: var(--ink-soft);
}
.zoom .step { width: 28px; }
.zoom .pct { font-size: 12px; font-weight: 600; padding: 0 10px; min-width: 54px; }

.btn-export {
  display: flex; align-items: center; gap: 8px; border: none;
  background: linear-gradient(135deg, var(--accent), #7c5cfc); color: #fff;
  font-weight: 700; font-size: 13px; padding: 0 18px; height: 36px;
  border-radius: 10px; cursor: pointer; font-family: inherit;
  box-shadow: 0 3px 12px rgba(99, 102, 241, .4);
}

/* ---------- panels ---------- */
.panel { background: var(--bg-panel); flex: none; }
.library { width: 236px; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.properties { width: 284px; border-left: 1px solid var(--border); overflow-y: auto; }
.panel-title { font-size: 12px; font-weight: 700; color: #3a3f52; letter-spacing: -.01em; }
.panel-sub { font-size: 11px; color: #9ca1b5; }
.section-label { font-size: 11px; font-weight: 600; color: #6b7186; }
.hr { height: 1px; background: #eef0f5; margin: 18px 0; }

/* ---------- library ---------- */
.lib-head { padding: 16px 16px 10px; }
.uploader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; height: 78px; border: 1.5px dashed #c7cbd8; border-radius: 12px;
  cursor: pointer; background: #fafbfe; color: #7077a0; transition: .15s;
}
.uploader:hover { border-color: var(--accent); background: #f2f3ff; color: var(--accent); }
.uploader .plus { font-size: 22px; line-height: 1; }
.uploader .label { font-size: 11.5px; font-weight: 600; }
.lib-body { flex: 1; overflow-y: auto; padding: 4px 14px 16px; }
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.lib-thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px;
  background-size: cover; background-position: center; cursor: pointer;
  border: 1px solid var(--border-soft); transition: .15s;
}
.lib-thumb:hover { transform: scale(1.04); box-shadow: 0 4px 14px rgba(40, 40, 90, .18); }
.lib-del {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border: none;
  border-radius: 50%; background: rgba(20, 20, 40, .55); color: #fff; font-size: 11px;
  line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.lib-hint { margin-top: 14px; font-size: 10.5px; color: var(--ink-faint); line-height: 1.5; text-align: center; }

/* ---------- viewport / stage ---------- */
.viewport {
  flex: 1; position: relative; overflow: hidden; min-width: 0;
  background: #eef0f6;
  background-image: radial-gradient(circle, #dee1eb 1px, transparent 1px);
  background-size: 22px 22px;
}
.stage {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  box-shadow: 0 10px 40px rgba(30, 30, 70, .16);
}
.overlay-layer { position: absolute; inset: 0; pointer-events: none; }
.bg-fill { position: absolute; inset: 0; }
.photo { position: absolute; background-position: center; background-repeat: no-repeat; cursor: move; }
.photo.selected { outline: 3px solid var(--accent); outline-offset: 0; }
.text-item { position: absolute; cursor: move; white-space: pre; }
.text-item.selected { outline: 2px dashed var(--accent); outline-offset: 2px; }
.handle {
  position: absolute; width: 12px; height: 12px; background: #fff;
  border: 2px solid var(--accent); border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2); z-index: 30;
}
.text-handle {
  position: absolute; right: -7px; bottom: -7px; width: 13px; height: 13px;
  background: #fff; border: 2px solid var(--accent); border-radius: 50%;
  cursor: nwse-resize; z-index: 60;
}
.boundary { position: absolute; top: 0; width: 0; pointer-events: none; z-index: 70; }
.slide-label {
  position: absolute; text-align: center; font-size: 11px; font-weight: 700;
  color: #9098b0; letter-spacing: .03em; pointer-events: none;
}
.empty-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; color: #a0a5bc; pointer-events: none;
}
.empty-hint .h { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty-hint .p { font-size: 12.5px; }

/* ---------- properties controls ---------- */
.prop-section { padding: 18px 18px 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.mb-7 { margin-bottom: 7px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-18 { margin-bottom: 18px; }
.mb-20 { margin-bottom: 20px; }

.tiny-btn {
  border: 1px solid var(--border); background: #fff; color: var(--ink-soft);
  border-radius: 8px; padding: 8px 0; font-family: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.tiny-btn.active { border-color: var(--accent); background: #f2f3ff; color: var(--accent); }
.ghost-btn {
  border: 1px solid var(--border); background: #fff; color: #4a4f63;
  border-radius: 9px; padding: 9px 0; font-family: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.ghost-btn:disabled { opacity: .45; cursor: default; }

/* ---------- filter swatches ---------- */
.filter-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px;
  scroll-snap-type: x proximity;
}
.filter-swatch {
  flex: none; width: 58px; border: none; background: transparent; padding: 0;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  scroll-snap-align: start;
}
.filter-thumb {
  width: 54px; height: 54px; border-radius: 9px; border: 2px solid transparent;
  background-color: #eef0f5; background-size: cover; background-position: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.filter-name { font-size: 10.5px; font-weight: 600; color: #8a8fa3; white-space: nowrap; }
.filter-swatch.active .filter-thumb { border-color: var(--accent); }
.filter-swatch.active .filter-name { color: var(--accent); }
.danger-btn {
  border: 1px solid #f3d2d2; background: #fef2f2; color: var(--danger);
  border-radius: 9px; padding: 9px 0; font-family: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.add-text-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--accent); background: #f2f3ff; color: var(--accent);
  font-weight: 700; font-size: 13px; height: 40px; border-radius: 10px;
  cursor: pointer; font-family: inherit;
}
.value-pill { color: #9ca1b5; }

textarea, select, .field-text {
  width: 100%; border: 1px solid #e3e6ee; border-radius: 9px; padding: 9px 10px;
  font-family: inherit; font-size: 13px; color: #23273a; outline: none; background: #fff;
}
textarea { resize: vertical; }
select { padding: 8px 9px; cursor: pointer; }
input[type=color] {
  width: 42px; height: 30px; border: 1px solid #e3e6ee; border-radius: 8px;
  background: #fff; cursor: pointer; padding: 2px;
}
input[type=color].big { width: 46px; height: 32px; }

input[type=range].range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  border-radius: 4px; background: #e3e6ee; outline: none;
}
input[type=range].range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(80, 80, 160, .4);
}
input[type=range].range::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 2px solid #fff;
}

.swatches { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .08); cursor: pointer; }

.export-list { display: flex; flex-direction: column; gap: 6px; }
.export-row {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); background: #fafbfe; border-radius: 9px;
  padding: 9px 12px; cursor: pointer; font-family: inherit; font-size: 12.5px;
  font-weight: 600; color: #3a3f52;
}
.export-row:hover { border-color: var(--accent); color: var(--accent); }
.export-row .dl { color: #9ca1b5; font-size: 14px; }

.tips { font-size: 10.5px; color: var(--ink-faint); line-height: 1.65; }
.tips b { color: #7077a0; }

/* ---------- export overlay ---------- */
.export-overlay {
  position: fixed; inset: 0; background: rgba(20, 22, 40, .42);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100;
}
.export-overlay[hidden] { display: none; }
.export-card {
  background: #fff; border-radius: 16px; padding: 28px 36px;
  box-shadow: 0 16px 50px rgba(20, 20, 60, .3); text-align: center;
}
.spinner {
  width: 34px; height: 34px; border: 3px solid #e3e6ee; border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 14px; animation: spin .8s linear infinite;
}
.export-card .msg { font-weight: 700; font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
