:root {
  color-scheme: dark;
  --bg: #070a0f;
  --panel: #0d1219;
  --panel-2: #111924;
  --panel-3: #172130;
  --line: #223044;
  --line-soft: #1a2636;
  --text: #edf3fb;
  --muted: #8d9bad;
  --muted-2: #6f7d8f;
  --accent: #4ea1ff;
  --accent-strong: #137fec;
  --accent-soft: rgba(78, 161, 255, 0.14);
  --green: #4ed18b;
  --gold: #f2b84b;
  --danger: #ff6f7d;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(19, 127, 236, 0.16), transparent 60%),
    radial-gradient(600px 380px at 8% 0%, rgba(242, 184, 75, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.app { display: flex; flex-direction: column; height: 100vh; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 68px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 12, 18, 0.82);
  backdrop-filter: blur(14px);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #2a8cff, #0c5fbe);
  box-shadow: 0 8px 24px rgba(19, 127, 236, 0.3);
  flex: none;
}
.brand-mark svg { width: 24px; height: 24px; }
.brand strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.domain-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.domain-control select {
  min-width: 150px; max-width: 220px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px;
}
.status {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 12px; white-space: nowrap;
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted-2); flex: none;
}
.status[data-state="ok"]::before { background: var(--green); box-shadow: 0 0 10px rgba(78, 209, 139, 0.6); }
.status[data-state="busy"]::before { background: var(--gold); animation: pulse 1.1s ease-in-out infinite; }
.status[data-state="error"]::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.35; } }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #2e4461; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(145deg, #2c92ff, #0f6fd5); border-color: #3d9eff; color: #fff; box-shadow: 0 8px 24px rgba(19, 127, 236, 0.28); }
.btn.primary:hover { background: linear-gradient(145deg, #48a1ff, #1579e4); }
.btn.ghost { background: transparent; }
.btn.subtle { background: var(--panel-2); color: var(--text); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.full { width: 100%; }
.link {
  border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer;
  font-weight: 650; text-decoration: none;
}
.link:hover { text-decoration: underline; }
.link.small { font-size: 12px; }

.workspace {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 348px;
  gap: 14px;
  padding: 14px;
  flex: 1;
  min-height: 0;
}
.panel {
  background: linear-gradient(180deg, rgba(17, 25, 36, 0.96), rgba(11, 16, 23, 0.96));
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 16px 16px 10px;
}
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; padding: 0 12px 10px; border-bottom: 1px solid var(--line-soft); }
.tab {
  flex: 1; border: 1px solid transparent; background: transparent;
  color: var(--muted); border-radius: 9px; padding: 8px 6px; cursor: pointer;
  font-size: 12px; font-weight: 650;
}
.tab span { color: var(--muted-2); font-weight: 600; margin-left: 4px; }
.tab.active { color: var(--text); background: var(--accent-soft); border-color: rgba(78, 161, 255, 0.22); }
.pane { display: none; padding: 12px; min-height: 0; overflow: auto; }
.pane.active { display: block; }

.drop-zone {
  display: flex; flex-direction: column; gap: 10px;
  border: 1px dashed #2b405b; border-radius: 13px;
  background: rgba(78, 161, 255, 0.04);
  padding: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone.drag { border-color: var(--accent); background: rgba(78, 161, 255, 0.11); }
.drop-icon { width: 30px; height: 30px; color: var(--accent); }
.drop-icon svg { width: 100%; height: 100%; }
.drop-copy { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; font-size: 12px; color: var(--muted); }
.drop-copy strong { color: var(--text); font-size: 13px; }
.drop-copy span { width: 100%; color: var(--muted-2); font-size: 11px; }
.upload-options { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.upload-options label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; }
.upload-options select { padding: 6px 8px; min-width: 90px; }
.check { flex-direction: row !important; align-items: center; gap: 6px !important; font-size: 11px; color: var(--muted); }
.check input { accent-color: var(--accent); }

.asset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.ai-open { margin-top: 10px; }
.hint { margin: 6px 0 0; color: var(--muted-2); font-size: 10.5px; line-height: 1.45; }
.element-toggles {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px;
  margin: 9px 0 7px;
}
.element-toggles .check { font-size: 11px; }
.element-presets { display: flex; flex-wrap: wrap; gap: 10px; }
.asset-card {
  border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden;
  background: var(--panel-2); min-width: 0;
}
.asset-card.assigned { border-color: rgba(78, 161, 255, 0.6); box-shadow: 0 0 0 1px rgba(78, 161, 255, 0.18); }
.asset-thumb {
  display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0;
  background: repeating-conic-gradient(#1b2634 0 25%, #141d28 0 50%) 0 0 / 16px 16px;
  cursor: pointer; overflow: hidden;
}
.asset-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.asset-body { padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.asset-name { font-size: 11px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-meta { font-size: 10px; color: var(--muted-2); }
.asset-assign { width: 100%; padding: 4px 5px; font-size: 10px; border-radius: 6px; background: #0e1620; }
.asset-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.asset-actions button {
  border: 1px solid var(--line-soft); background: #0e1620; border-radius: 6px;
  color: var(--muted); font-size: 10px; padding: 4px 5px; cursor: pointer;
  flex: 1 1 auto; white-space: nowrap;
}
.asset-actions button:hover { color: var(--text); border-color: var(--line); }
.asset-actions .danger:hover { color: var(--danger); border-color: rgba(255, 111, 125, 0.4); }
.empty-note { color: var(--muted-2); font-size: 12px; line-height: 1.5; padding: 8px 2px; }

.draft-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.draft-card {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line-soft); background: var(--panel-2);
  border-radius: 11px; padding: 10px; cursor: pointer;
}
.draft-card.active { border-color: rgba(78, 161, 255, 0.6); background: var(--accent-soft); }
.draft-card div { min-width: 0; }
.draft-card strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-card span { display: block; color: var(--muted-2); font-size: 10px; margin-top: 2px; }
.draft-card button {
  border: 0; background: transparent; color: var(--muted-2); cursor: pointer;
  font-size: 15px; padding: 3px 5px; border-radius: 6px;
}
.draft-card button:hover { color: var(--danger); background: rgba(255, 111, 125, 0.1); }

.canvas-column { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 10px; }
.canvas-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 0 4px;
}
.format-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.format-tab {
  border: 1px solid var(--line-soft); background: rgba(13, 18, 25, 0.7);
  color: var(--muted); padding: 5px 8px 5px 6px; border-radius: 9px;
  font-size: 11px; font-weight: 650; display: inline-flex; align-items: center; gap: 5px;
}
.format-tab input { width: 12px; height: 12px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.format-name { border: 0; background: none; color: inherit; font: inherit; font-weight: 650; cursor: pointer; padding: 2px 2px; }
.format-tab.on { color: var(--text); }
.format-tab.active { color: var(--text); border-color: rgba(78, 161, 255, 0.5); background: var(--accent-soft); }
.format-tab.has-layout { border-color: rgba(242, 184, 75, 0.45); }
.format-tab.has-layout .format-name::after { content: " •"; color: var(--gold); }
.format-meta { color: var(--muted-2); font-size: 11px; white-space: nowrap; }
.canvas-actions { display: flex; align-items: center; gap: 6px; }

.stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(18, 26, 37, 0.5), rgba(8, 12, 18, 0.5)),
    repeating-conic-gradient(#111924 0 25%, #0c131c 0 50%) 0 0 / 24px 24px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), var(--shadow);
}
.stage.busy::after {
  content: ""; position: absolute; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(78, 161, 255, 0.2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.canvas-wrap {
  position: relative;
  display: flex;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.46);
  background: #0b1017;
  max-width: calc(100% - 48px);
  max-height: calc(100% - 48px);
}
.canvas-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 9px;
}
.layout-overlay { position: absolute; inset: 0; pointer-events: none; }
.layout-box {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed rgba(78, 161, 255, 0.55);
  background: rgba(78, 161, 255, 0.05);
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}
.layout-box:hover { border-color: rgba(78, 161, 255, 0.9); background: rgba(78, 161, 255, 0.1); }
.layout-box.selected {
  border: 2px solid #4ea1ff;
  background: rgba(78, 161, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.layout-box.hidden-element { border-style: dotted; opacity: 0.38; }
.layout-box .layout-label {
  position: absolute; left: -1px; top: -17px;
  background: #0d1219; color: #cfe3ff; border: 1px solid rgba(78, 161, 255, 0.4);
  border-radius: 5px; padding: 1px 5px; font-size: 9px; line-height: 1.5;
  white-space: nowrap; pointer-events: none; opacity: 0;
}
.layout-box:hover .layout-label, .layout-box.selected .layout-label { opacity: 1; }
.layout-handle {
  position: absolute; width: 9px; height: 9px;
  background: #fff; border: 1px solid #2a8cff; border-radius: 2px;
  pointer-events: auto;
}
.layout-handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.layout-handle.n { left: 50%; top: -5px; margin-left: -4px; cursor: ns-resize; }
.layout-handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.layout-handle.e { right: -5px; top: 50%; margin-top: -4px; cursor: ew-resize; }
.layout-handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.layout-handle.s { left: 50%; bottom: -5px; margin-left: -4px; cursor: ns-resize; }
.layout-handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.layout-handle.w { left: -5px; top: 50%; margin-top: -4px; cursor: ew-resize; }
.layout-guide { position: absolute; background: rgba(78, 209, 139, 0.85); pointer-events: none; }
.layout-guide.vertical { top: 0; bottom: 0; width: 1px; }
.layout-guide.horizontal { left: 0; right: 0; height: 1px; }
.layout-elements { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.layout-element-btn {
  border: 1px solid var(--line-soft); background: #0e1620; color: var(--muted);
  border-radius: 7px; padding: 4px 7px; font-size: 10px; cursor: pointer;
}
.layout-element-btn.active { color: var(--text); border-color: rgba(78, 161, 255, 0.6); background: var(--accent-soft); }
.layout-element-btn.hidden-element { opacity: 0.5; text-decoration: line-through; }
.stage-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); text-align: center; padding: 20px; }
.stage-empty strong { color: var(--text); font-size: 15px; }
.stage-empty span { font-size: 12px; }

.warnings {
  border: 1px solid rgba(242, 184, 75, 0.3); background: rgba(242, 184, 75, 0.08);
  border-radius: 12px; padding: 10px 13px; color: #f3cd8b; font-size: 12px;
  line-height: 1.5;
}
.warnings ul { margin: 5px 0 0; padding-left: 18px; }
.result-panel {
  border: 1px solid rgba(78, 209, 139, 0.3); background: rgba(78, 209, 139, 0.07);
  border-radius: 13px; padding: 12px 14px; font-size: 12px;
}
.result-panel h4 { margin: 0 0 6px; font-size: 13px; color: #9df0c2; }
.result-panel .result-links { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 7px; }
.result-panel a { color: #9df0c2; }
.result-panel code { color: #c7f7db; }
.result-panel .muted { color: var(--muted); }
.result-panel .creative-link { display: inline-flex; align-items: center; gap: 3px; }
.result-panel .creative-link button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 0 2px; border-radius: 4px;
}
.result-panel .creative-link button:hover { color: #9df0c2; background: rgba(78, 209, 139, 0.1); }
.progress {
  height: 6px; margin-top: 9px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}
.progress span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #2a8cff, #4ed18b);
  transition: width 0.3s ease;
}

.inspector { overflow: hidden; }
.inspector-scroll { overflow: auto; padding: 0 14px 18px; min-height: 0; }
.group { border-top: 1px solid var(--line-soft); padding: 14px 0; }
.group:first-child { border-top: 0; padding-top: 2px; }
.group h3, .group-head h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.group-head { display: flex; align-items: center; justify-content: space-between; }
.group-head h3 { margin-bottom: 10px; }
.group-block + .group-block {
  margin-top: 12px;
  border-top: 1px dashed var(--line-soft);
  padding-top: 12px;
}
.group-sub {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}
.group-block .field:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type="text"], textarea, select {
  width: 100%;
  background: #0c141e;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  font-size: 12px;
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.35; }
select { appearance: auto; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0 10px; }
.range-row { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.range-row output { color: var(--text); font-variant-numeric: tabular-nums; }
.platforms { display: flex; flex-wrap: wrap; gap: 6px; }
.platform {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-soft); background: #0c141e; border-radius: 9px;
  padding: 7px 9px; font-size: 11px; color: var(--muted); cursor: pointer;
}
.platform input { accent-color: var(--accent); margin: 0; }
.platform:has(input:checked) { color: var(--text); border-color: rgba(78, 161, 255, 0.45); background: var(--accent-soft); }
.chips-block { margin-top: 4px; }
.chips-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.chips-label small { color: var(--muted-2); font-size: 10px; font-weight: 400; margin-left: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line-soft); background: #0c141e; border-radius: 999px;
  padding: 4px 5px 4px 4px; font-size: 10px; color: var(--muted); max-width: 100%;
}
.chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: #16202d; flex: none; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.chip button { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; padding: 0 3px; font-size: 12px; }
.chip button:hover { color: var(--danger); }
.chip-empty { color: var(--muted-2); font-size: 10px; padding: 3px 0; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; border: 1px solid var(--line-soft); border-radius: 8px; padding: 5px 7px; background: #0c141e; }
.color-field input[type="color"] { width: 34px; height: 26px; border: 1px solid var(--line); border-radius: 5px; background: transparent; padding: 0; cursor: pointer; }

.product-picker {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: #0c141e; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; text-align: left;
  cursor: pointer; min-width: 0;
}
.product-picker:hover { border-color: #2e4461; }
.product-picker img {
  width: 28px; height: 28px; flex: none; object-fit: contain;
  border-radius: 5px; background: #16202d;
}
.product-picker span:not(.product-picker-chevron) {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.product-picker-chevron { color: var(--muted); flex: none; }
#productBgBtn { margin-bottom: 9px; }

.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(3px);
}
.modal-panel {
  position: relative; display: flex; flex-direction: column;
  width: min(940px, calc(100vw - 40px)); max-height: min(82vh, 780px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-count { display: block; color: var(--muted-2); font-size: 11px; margin-top: 2px; }
.ai-panel { width: min(620px, calc(100vw - 40px)); }
.ai-body { padding: 14px 16px 4px; overflow: auto; }
.ai-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line-soft);
}
.ai-foot .hint { margin: 0; }
.ai-config {
  margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--line-soft); border-radius: 10px;
  background: #0c141e;
}
.ai-config summary { cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 650; }
.ai-config .field { margin-top: 10px; }
.ai-config code { color: var(--accent); font-size: 10px; }
.ai-config-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.field-inline { display: flex; align-items: center; gap: 6px; }
.field-inline input { flex: 1; min-width: 0; }
.field-inline .btn { flex: none; }
.ai-model-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 104px;
  overflow: auto;
  margin: 2px 0 4px;
}
.ai-edit-modal { padding: 0; }
.ai-edit-panel {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  border: 0;
}
.ai-edit-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  min-height: 0;
}
.ai-edit-preview-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #05080c;
  border-right: 1px solid var(--line-soft);
}
.ai-edit-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: repeating-conic-gradient(#141b25 0 25%, #0b1016 0 50%) 0 0 / 28px 28px;
}
.ai-edit-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 16px 40px rgba(0, 0, 0, 0.5));
}
.ai-edit-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
}
.ai-edit-preview-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}
.ai-edit-preview-meta span { color: var(--muted-2); white-space: nowrap; }
.ai-edit-controls { min-height: 0; overflow: auto; padding: 16px; background: var(--panel); }
.ai-edit-controls .field:last-of-type { margin-bottom: 0; }
.ai-edit-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ai-edit-success {
  margin: 0 16px 10px;
  padding: 9px 11px;
  border: 1px solid rgba(78, 209, 139, 0.45);
  border-radius: 9px;
  background: rgba(78, 209, 139, 0.1);
  color: #b9f5d5;
  font-size: 11.5px;
  line-height: 1.45;
}
.ai-edit-panel .ai-error { margin: 0 16px 10px; }
@media (max-width: 900px) {
  .ai-edit-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 42vh) minmax(0, 1fr);
  }
  .ai-edit-preview-column { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .ai-edit-stage { padding: 12px; }
}
.model-chip {
  border: 1px solid var(--line-soft);
  background: #0c141e;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10.5px;
  cursor: pointer;
}
.model-chip:hover { border-color: #2e4461; color: var(--text); }
.model-chip.active {
  border-color: rgba(78, 161, 255, 0.6);
  background: var(--accent-soft);
  color: var(--text);
}
.model-chip.recommended::after {
  content: " · recomendado";
  color: var(--accent);
  font-weight: 650;
}
.model-info {
  margin: 6px 0 2px;
  padding: 7px 9px;
  border-left: 2px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: rgba(98, 168, 255, 0.06);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.model-info.danger {
  border-left-color: var(--danger);
  background: rgba(255, 107, 122, 0.08);
  color: #ffc6cc;
}
.ai-error {
  margin: 0 16px 12px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 111, 125, 0.5);
  border-radius: 9px;
  background: rgba(255, 60, 80, 0.1);
  color: #ffc6cc;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
#productSearch {
  margin: 12px 16px; width: calc(100% - 32px);
  background: #0c141e; border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: 8px 10px; font-size: 12px;
}
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px; padding: 0 16px 16px; overflow: auto; min-height: 120px;
}
.product-card {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 8px; color: var(--text);
  text-align: left; cursor: pointer;
}
.product-card:hover { border-color: #2e4461; }
.product-card.selected { border-color: rgba(78, 161, 255, 0.7); background: var(--accent-soft); }
.product-card-media {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  background: #0b1017; border-radius: 8px; overflow: hidden;
}
.product-card-media img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; display: block;
}
.product-card-initials {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 24px; font-weight: 800; letter-spacing: -0.04em;
}
.product-card strong {
  font-size: 11px; line-height: 1.3; min-height: 28px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card small { font-size: 10px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-card small.price { color: var(--text); font-weight: 650; }
.product-empty { grid-column: 1 / -1; color: var(--muted-2); font-size: 12px; padding: 20px 0; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  max-width: min(420px, calc(100vw - 36px));
  background: #131c27; border: 1px solid #2a3d55; color: var(--text);
  border-radius: 12px; padding: 11px 14px; font-size: 12px; line-height: 1.45;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.error { border-color: rgba(255, 111, 125, 0.5); color: #ffc6cc; }
.toast a { color: var(--accent); }

@media (max-width: 1240px) {
  .workspace { grid-template-columns: 248px minmax(0, 1fr) 320px; gap: 10px; padding: 10px; }
  .asset-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1040px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr) 300px; }
  .brand span { display: none; }
  .status { display: none; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .topbar { flex-wrap: wrap; }
  .workspace { display: flex; flex-direction: column; }
  .library, .inspector { min-height: 320px; }
  .canvas-column { min-height: 60vh; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .stage { min-height: 45vh; }
}

/* Editor de recorte manual */
/* Pantalla completa: el lienzo necesita todo el espacio disponible. */
.recorte-modal { padding: 0; }
.recorte-modal .recorte-panel {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  border: 0;
  padding: 14px 16px 12px;
  gap: 10px;
  box-sizing: border-box;
}
.recorte-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.recorte-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recorte-title h3 { margin: 0; font-size: 15px; }
.recorte-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.recorte-tools {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.recorte-tool {
  background: transparent;
  border: 0;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.recorte-tool + .recorte-tool { border-left: 1px solid var(--line); }
.recorte-tool.active { background: var(--accent); color: #fff; }
.recorte-slider { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.recorte-slider[hidden] { display: none; }
.recorte-slider input[type="range"] { width: 110px; }
.recorte-slider output { min-width: 22px; font-variant-numeric: tabular-nums; }
.recorte-actions { display: flex; gap: 6px; margin-left: auto; }
.recorte-viewport {
  position: relative;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  border-radius: 10px;
  background: repeating-conic-gradient(#26262b 0% 25%, #1d1d21 0% 50%) 50% / 20px 20px;
  /* Reserva el espacio de la barra: sin esto, al hacer zoom aparece la barra,
     se recalcula el ajuste y la imagen "salta" encogiéndose. */
  scrollbar-gutter: stable;
}
.recorte-stage {
  position: relative;
  width: max-content;
  margin: 0 auto;
  transform-origin: top center;
  cursor: none;
  touch-action: none;
}
/* Con el lazo se usa el cursor nativo: se necesita ver con precisión dónde se hace clic. */
.recorte-stage.is-lasso,
.recorte-stage.is-cross { cursor: crosshair; }
.recorte-stage canvas { display: block; }
#recorteBase { position: relative; }
#recortePaint { position: absolute; left: 0; top: 0; opacity: 0.45; pointer-events: none; }
.recorte-lasso {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.recorte-lasso polyline { fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.recorte-lasso circle { fill: #fff; stroke: rgba(0, 0, 0, 0.55); stroke-width: 1; vector-effect: non-scaling-stroke; r: 4; }
.recorte-lasso rect { fill: rgba(255, 255, 255, 0.08); stroke: #fff; stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.recorte-cursor {
  position: absolute;
  border: 1px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.recorte-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  background: rgba(18, 18, 21, 0.8);
}
.recorte-loading[hidden] { display: none; }
.recorte-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

#recortePaint[hidden] { display: none; }
#recortePreview.active {
  border-color: rgba(78, 161, 255, 0.7);
  background: var(--accent-soft);
  color: var(--text);
}
.asset-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.02em;
  background: rgba(78, 161, 255, 0.16);
  color: var(--accent);
  vertical-align: middle;
}

/* En pantallas bajas el editor necesita más alto útil */
@media (max-height: 760px) {
  .recorte-panel { padding: 10px 14px 8px; gap: 8px; }
  .recorte-toolbar { gap: 10px; }
}

/* Paneles de avisos y resultados: se pueden cerrar */
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.panel-close {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
}
.panel-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.result-panel { position: relative; }
.result-panel > .panel-close { position: absolute; top: 8px; right: 8px; }
.toast { cursor: pointer; }

/* ==========================================================================
   Rediseño denso y responsive · Marketing Studio
   Objetivo: más área de trabajo en pantallas pequeñas, controles compactos
   y una jerarquía visual más limpia sin cambiar la lógica del panel.
   ========================================================================== */

:root {
  --bg: #070a0f;
  --panel: #0d131b;
  --panel-2: #111923;
  --panel-3: #18222f;
  --line: #223044;
  --line-soft: #1a2433;
  --text: #e9eef7;
  --muted: #95a3b6;
  --muted-2: #7e8ca0;
  --accent: #62a8ff;
  --accent-strong: #1f6fe0;
  --accent-soft: rgba(98, 168, 255, 0.13);
  --green: #45d19a;
  --gold: #f0b85c;
  --danger: #ff6b7a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --topbar-h: 56px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 500px at 82% -12%, rgba(47, 134, 246, 0.1), transparent 62%),
    var(--bg);
  overflow: hidden;
}
::selection { background: rgba(98, 168, 255, 0.28); color: #fff; }
.app { height: 100dvh; min-height: 0; }

/* Topbar compacta */
.topbar {
  min-height: var(--topbar-h);
  height: var(--topbar-h);
  padding: 0 14px;
  gap: 12px;
  background: rgba(8, 11, 16, 0.88);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(16px);
  z-index: 10;
}
.brand { gap: 9px; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, #3f93ff, #1d63d0);
  box-shadow: none;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand strong { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.brand span { font-size: 11px; margin-top: 1px; }
.topbar-actions { gap: 6px; }
.domain-control { gap: 6px; font-size: 11px; }
.domain-control select {
  min-width: 128px;
  max-width: 210px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--panel-2);
  font-size: 11.5px;
}
.status { gap: 6px; font-size: 11px; }

.btn {
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn:hover { background: var(--panel-3); border-color: #2c4058; }
.btn:active { transform: none; }
.btn.primary {
  background: var(--accent-strong);
  border-color: transparent;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 6px 18px rgba(31, 111, 224, 0.22);
}
.btn.primary:hover { background: #2d82f2; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.045); }
.btn.small { padding: 5px 8px; font-size: 11px; }
.icon-btn { display: inline-flex; align-items: center; gap: 5px; }
.icon-btn svg { width: 14px; height: 14px; flex: none; }
.panel-toggles {
  display: none;
  align-items: center;
  gap: 4px;
  padding-right: 4px;
  margin-right: 2px;
  border-right: 1px solid var(--line-soft);
}
.panel-toggles .icon-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: rgba(98, 168, 255, 0.45);
  background: var(--accent-soft);
}
.panel-head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.drawer-close { display: none; }

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(3, 6, 10, 0.66);
  backdrop-filter: blur(2px);
}

/* Workspace y paneles */
.workspace {
  grid-template-columns: clamp(220px, 16vw, 272px) minmax(0, 1fr) clamp(300px, 22vw, 380px);
  gap: 10px;
  padding: 10px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
}
.panel-head { padding: 12px 12px 8px; }
.panel-head > div:first-child { min-width: 0; }
.panel-head h2 { font-size: 13px; font-weight: 700; }
.panel-head p {
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tabs { padding: 0 10px 8px; gap: 2px; }
.tab { padding: 6px 6px; font-size: 11px; border-radius: 7px; }
.pane { padding: 10px; }
.pane.active { display: block; flex: 1; min-height: 0; }

/* Biblioteca */
.drop-zone {
  gap: 7px;
  padding: 10px;
  border-radius: 10px;
  border-color: var(--line);
  background: rgba(98, 168, 255, 0.035);
}
.drop-icon { width: 22px; height: 22px; }
.drop-copy { font-size: 11px; }
.drop-copy strong { font-size: 12px; }
.drop-copy span { font-size: 10px; }
.upload-options label { font-size: 10px; }
.upload-options select { padding: 5px 7px; font-size: 11px; }
.ai-open { margin-top: 7px; }
.asset-grid { gap: 6px; margin-top: 9px; }
.asset-card { border-radius: 9px; }
.asset-card.assigned { box-shadow: none; }
.asset-body { padding: 6px; gap: 4px; }
.asset-name { font-size: 10.5px; }
.asset-meta { font-size: 10px; }
.asset-assign { padding: 3px 4px; font-size: 9.5px; border-radius: 5px; }
.asset-actions { gap: 3px; }
.asset-actions button { font-size: 10px; padding: 3px 4px; border-radius: 5px; }
.draft-list { gap: 6px; margin-top: 8px; }
.draft-card { padding: 8px; border-radius: 8px; }
.draft-card strong { font-size: 11px; }
.draft-card span { font-size: 10px; }
.empty-note { font-size: 11px; }

/* Lienzo */
.canvas-column { gap: 6px; }
.canvas-toolbar { min-height: 34px; gap: 8px; padding: 0; }
.format-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 4px;
  padding-bottom: 1px;
  scrollbar-width: none;
}
.format-tabs::-webkit-scrollbar { display: none; }
.format-tab { flex: none; padding: 4px 7px; border-radius: 7px; font-size: 10.5px; }
.format-name { padding: 1px; }
.format-meta { font-size: 10px; }
.canvas-actions { gap: 4px; flex: none; }
.stage {
  border-radius: var(--radius);
  min-height: 220px;
  background:
    linear-gradient(180deg, rgba(15, 22, 31, 0.7), rgba(7, 10, 15, 0.7)),
    repeating-conic-gradient(#101720 0 25%, #0b1118 0 50%) 0 0 / 22px 22px;
  box-shadow: none;
}
.canvas-wrap {
  max-width: calc(100% - 20px);
  max-height: calc(100% - 20px);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.canvas-wrap img { border-radius: 6px; }
.stage-empty strong { font-size: 13px; }
.stage-empty span { font-size: 11px; }
.warnings, .result-panel { border-radius: 9px; padding: 8px 10px; font-size: 11px; }

/* Inspector denso */
.inspector-scroll { flex: 1; padding: 0 12px 14px; }
.group { padding: 10px 0; }
.group:first-child { padding-top: 0; }
.group h3, .group-head h3 { font-size: 10.5px; margin-bottom: 7px; letter-spacing: 0.07em; }
.group-block + .group-block { margin-top: 9px; padding-top: 9px; }
.group-sub { font-size: 10px; margin-bottom: 6px; }
.field { gap: 4px; font-size: 11px; margin-bottom: 7px; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="url"], textarea, select {
  background: #0a1119;
  border-color: var(--line);
  border-radius: 6px;
  padding: 6px 7px;
  font-size: 12px;
}
textarea { line-height: 1.4; }
input[type="range"] { margin: 0 0 7px; }
.grid-2 { gap: 6px; }
.platforms { gap: 4px; }
.platform { padding: 5px 7px; font-size: 10.5px; border-radius: 7px; }
.chips-label { font-size: 10px; }
.chip { font-size: 10px; padding: 3px 4px 3px 3px; }
.chip img { width: 18px; height: 18px; }
.chip span { max-width: 96px; }
.color-grid { gap: 6px; }
.color-field { font-size: 10px; padding: 4px 6px; border-radius: 6px; }
.color-field input[type="color"] { width: 30px; height: 23px; }
.product-picker { padding: 5px 7px; font-size: 11px; border-radius: 6px; }
.product-picker img { width: 24px; height: 24px; }
#productBgBtn { margin-bottom: 7px; }
.element-toggles { gap: 4px 8px; margin: 7px 0 5px; }
.element-toggles .check { font-size: 10.5px; }
.element-presets { gap: 8px; }
.link.small { font-size: 10.5px; }
.hint { font-size: 10px; margin-top: 4px; }
.check { font-size: 10.5px; }

/* Modales y componentes */
.modal-backdrop { background: rgba(2, 5, 9, 0.78); }
.modal-panel { border-radius: 12px; border-color: var(--line); }
.modal-head { padding: 11px 14px; }
.modal-head h3 { font-size: 14px; }
.ai-panel { width: min(560px, calc(100vw - 28px)); }
.ai-body { padding: 12px 14px 2px; }
.ai-foot { padding: 10px 14px; }
.ai-config { padding: 8px 10px; border-radius: 8px; }
.ai-error, .ai-edit-success { border-radius: 7px; }
.product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 0 14px 14px; }
#productSearch { margin: 10px 14px; width: calc(100% - 28px); padding: 7px 9px; font-size: 11.5px; }
.toast { border-radius: 9px; font-size: 11.5px; padding: 9px 12px; }
.ai-edit-panel { background: var(--bg); }
.ai-edit-controls { padding: 14px; }
.ai-edit-preview-meta { min-height: 38px; padding: 8px 14px; }

/* Scroll fino */
* { scrollbar-width: thin; scrollbar-color: #263447 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #263447; border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
.pane, .inspector-scroll, .ai-body, .ai-edit-controls, .product-grid { overscroll-behavior: contain; }

/* Responsive: paneles como drawers para liberar el lienzo */
@media (max-width: 1280px) {
  .workspace { gap: 8px; padding: 8px; }
  .status { display: none; }
}
@media (max-width: 1380px) {
  .panel-toggles { display: flex; }
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 8px;
  }
  .library, .inspector {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 40;
    width: min(360px, 88vw);
    max-width: 100%;
    border-radius: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 0 44px rgba(0, 0, 0, 0.5);
    transform: translateX(-102%);
    transition: transform 0.22s var(--ease), visibility 0s linear 0.22s;
  }
  .library { left: 0; border-left: 0; }
  .inspector { right: 0; transform: translateX(102%); border-right: 0; }
  body.library-open .library,
  body.inspector-open .inspector {
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.22s var(--ease);
  }
  body.library-open .library { transform: translateX(0); }
  body.inspector-open .inspector { transform: translateX(0); }
  .drawer-close { display: inline-flex; }
  .library .panel-head, .inspector .panel-head { padding-top: 14px; }
  .canvas-column, .stage { min-height: 0; }
  .panel-backdrop[hidden] { display: none !important; }
}
@media (min-width: 1381px) {
  .panel-backdrop { display: none !important; }
  .library, .inspector { position: relative; transform: none; }
}
@media (max-width: 860px) {
  body { overflow: hidden; }
  .app { height: 100dvh; min-height: 0; }
  .topbar { flex-wrap: nowrap; min-height: 52px; height: 52px; padding: 0 10px; gap: 8px; }
  .brand span { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .domain-control span { display: none; }
  .domain-control select { min-width: 0; width: 128px; max-width: 34vw; }
  .status { display: none; }
  .topbar-actions { gap: 4px; }
  .btn { padding: 6px 9px; font-size: 11px; }
  .btn.small { padding: 4px 7px; font-size: 10.5px; }
  .workspace { display: grid; grid-template-columns: minmax(0, 1fr); flex-direction: row; padding: 6px; }
  .library, .inspector { min-height: 0; }
  .canvas-column { min-height: 0; }
  .stage { min-height: 0; }
  .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .canvas-toolbar { flex-wrap: wrap; min-height: 32px; }
  .format-tabs { width: 100%; }
  .canvas-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 0; padding: 8px 10px; row-gap: 7px; }
  .brand { flex: 1; }
  .topbar-actions {
    order: 2;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions #generateBtn { order: -1; }
  .panel-toggles { border-right: 0; padding-right: 0; margin-right: 0; }
  .panel-toggles .icon-btn span { display: none; }
  .panel-toggles .icon-btn { width: 30px; justify-content: center; padding: 5px; }
  .workspace { padding: 6px; }
  .library, .inspector { width: min(92vw, 380px); }
  .modal-panel { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .ai-edit-panel { width: 100vw; height: 100dvh; max-height: none; }
}
@media (min-width: 761px) and (max-height: 700px) {
  .topbar { min-height: 48px; height: 48px; }
  .canvas-toolbar { min-height: 30px; }
  .stage { min-height: 160px; }
  .panel-head { padding-top: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
