:root{
  --bg:#0a0a0a;
  --surface:#131313;
  --surface2:#161616;
  --text:#e5e2e1;
  --muted:#a9a3b3;
  --border:#2a2a2a;
  --primary:#8b5cf6;
  --primary2:#7c3aed;
  --danger:#ef4444;
  --ok:#22c55e;
  --warn:#f59e0b;
  --radius:14px;
  --radius2:10px;
  --gutter:24px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--sans);
  background:var(--bg);
  color:var(--text);
}
a{color:var(--primary);text-decoration:none}
a:hover{color:var(--primary2)}
.container{max-width:1100px;margin:0 auto;padding:0 var(--gutter)}
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:24px;
}
.stack{display:flex;flex-direction:column;gap:16px}
.row{display:flex;gap:12px;align-items:center}
.row-between{display:flex;gap:12px;align-items:center;justify-content:space-between}
.grid{display:grid;gap:16px}
.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.btn{
  appearance:none;border:1px solid var(--border);
  background:var(--surface2);
  color:var(--text);
  border-radius:var(--radius2);
  padding:10px 14px;
  cursor:pointer;
  font-weight:600;
}
.btn:hover{border-color:#3a3a3a}
.btn-primary{background:var(--primary);border-color:transparent;color:#fafafa}
.btn-primary:hover{background:var(--primary2)}
.btn-danger{background:transparent;border-color:#3a3a3a;color:#ffd6d6}
.btn-danger:hover{border-color:var(--danger);color:#fff}
.input, select, textarea{
  width:100%;
  background:var(--surface2);
  border:1px solid #1f1f1f;
  border-radius:var(--radius2);
  padding:10px 12px;
  color:var(--text);
  outline:none;
}
textarea{min-height:120px;resize:vertical}
label{display:block;font-size:12px;letter-spacing:.08em;color:var(--muted);margin-bottom:6px;font-family:var(--mono)}
.help{color:var(--muted);font-size:13px}
.pill{display:inline-flex;align-items:center;gap:8px;border:1px solid var(--border);border-radius:999px;padding:6px 10px;background:rgba(255,255,255,.02)}
.flash{border-radius:var(--radius2);padding:10px 12px;border:1px solid var(--border);background:rgba(255,255,255,.03)}
.flash-ok{border-color:rgba(34,197,94,.35)}
.flash-err{border-color:rgba(239,68,68,.35)}
.flash-warn{border-color:rgba(245,158,11,.35)}
.topbar{padding:18px 0;border-bottom:1px solid rgba(255,255,255,.06);background:rgba(0,0,0,.2);backdrop-filter: blur(10px);position:sticky;top:0}
.nav{display:flex;flex-wrap:wrap;gap:6px 14px}
.nav a{color:var(--text);opacity:.9;font-size:14px}
.nav a.active{color:var(--primary)}
.muted{color:var(--muted)}
.table{width:100%;border-collapse:collapse}
.table th,.table td{padding:10px 8px;border-bottom:1px solid rgba(255,255,255,.06);vertical-align:top}
.table th{color:var(--muted);font-family:var(--mono);font-size:12px;letter-spacing:.08em;text-align:left}
.badge{font-size:12px;border-radius:999px;padding:4px 10px;border:1px solid var(--border);display:inline-block}
.badge-ok{border-color:rgba(34,197,94,.35)}
.badge-err{border-color:rgba(239,68,68,.35)}
.badge-warn{border-color:rgba(245,158,11,.35)}
.dropzone{border:1px dashed rgba(255,255,255,.18);border-radius:var(--radius);padding:16px;background:rgba(255,255,255,.02)}
.thumbs{display:flex;gap:10px;flex-wrap:wrap}
.thumb{width:86px;height:86px;border-radius:12px;border:1px solid rgba(255,255,255,.1);object-fit:cover}
@media (max-width: 900px){
  .grid-3{grid-template-columns:1fr}
  .grid-2{grid-template-columns:1fr}
}

/* --- Designer / Gallery --- */
.designer-shell{
  display:grid;
  grid-template-columns:240px 1fr 280px;
  gap:14px;
  height:calc(100vh - 88px);
  padding:14px 14px 28px;
  max-width:1600px;margin:0 auto;
}
.designer-side{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
  overflow:auto;
}
.designer-side h4{margin:0 0 8px;font-size:12px;letter-spacing:.1em;color:var(--muted);font-family:var(--mono);text-transform:uppercase}
.designer-side .tool-group{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:14px}
.designer-side .tool-btn{
  appearance:none;border:1px solid var(--border);background:var(--surface2);color:var(--text);
  border-radius:10px;padding:10px 8px;cursor:pointer;font-size:13px;font-weight:600;
  display:flex;flex-direction:column;align-items:center;gap:6px;
}
.designer-side .tool-btn:hover{border-color:#3a3a3a}
.designer-side .tool-btn[disabled]{opacity:.4;cursor:not-allowed}
.designer-side .tool-btn .glyph{font-size:18px;line-height:1}
.designer-stage{
  background:#0f0f0f;
  border:1px solid var(--border);
  border-radius:var(--radius);
  display:flex;flex-direction:column;
  overflow:hidden;
}
.designer-toolbar{
  display:flex;gap:8px;align-items:center;flex-wrap:wrap;
  padding:10px 12px;border-bottom:1px solid rgba(255,255,255,.06);
  background:rgba(0,0,0,.2);
}
.designer-toolbar .input{height:34px;padding:6px 10px}
.designer-toolbar .pill{padding:4px 10px;font-size:12px}
.designer-stage .canvas-wrap{
  flex:1;
  display:flex;align-items:center;justify-content:center;
  overflow:auto;
  padding:24px;
  background:
    linear-gradient(45deg,#0c0c0c 25%,transparent 25%),
    linear-gradient(-45deg,#0c0c0c 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#0c0c0c 75%),
    linear-gradient(-45deg,transparent 75%,#0c0c0c 75%);
  background-size:18px 18px;
  background-position:0 0,0 9px,9px -9px,-9px 0px;
}
.canvas-frame{
  background:#fff;
  box-shadow:0 12px 48px rgba(0,0,0,.6);
  position:relative;
}
.layers-list{display:flex;flex-direction:column;gap:6px;max-height:240px;overflow:auto}
.layer-row{
  display:flex;align-items:center;gap:8px;
  padding:6px 8px;border:1px solid var(--border);
  border-radius:8px;background:var(--surface2);
  font-size:13px;cursor:pointer;
}
.layer-row:hover{border-color:#3a3a3a}
.layer-row.active{border-color:var(--primary)}
.layer-row .name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.layer-row .actions{display:flex;gap:4px;flex-shrink:0;align-items:center}
.layer-row .layer-order-btn{min-width:28px;padding:4px 6px;font-size:13px;line-height:1}
.layer-row .layer-order-btn:disabled{opacity:.35;cursor:not-allowed}
.icon-btn{
  appearance:none;border:1px solid var(--border);background:transparent;color:var(--text);
  border-radius:8px;padding:4px 8px;cursor:pointer;font-size:12px;
}
.icon-btn:hover{border-color:#3a3a3a}
.props-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.props-grid label{margin-bottom:2px}
.color-input{
  width:100%;height:34px;background:var(--surface2);border:1px solid #1f1f1f;
  border-radius:var(--radius2);padding:2px;
}
.size-presets{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.size-presets button{font-size:12px;padding:6px 4px}
.gallery-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
.gallery-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;
}
.gallery-card .thumb-wrap{
  aspect-ratio:1/1;background:#0c0c0c;display:flex;align-items:center;justify-content:center;overflow:hidden;
}
.gallery-card .thumb-wrap img{max-width:100%;max-height:100%;object-fit:contain}
.gallery-card .body{padding:10px 12px;display:flex;flex-direction:column;gap:6px}
.gallery-card .body .title{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gallery-card .body .meta{color:var(--muted);font-size:12px}
.gallery-card .actions{display:flex;gap:6px;padding:0 10px 10px;flex-wrap:wrap}
.modal-backdrop{
  position:fixed;inset:0;background:rgba(0,0,0,.65);z-index:50;display:flex;align-items:center;justify-content:center;
}
.modal-backdrop[hidden]{display:none}
.modal-card{
  width:min(960px,92vw);max-height:86vh;display:flex;flex-direction:column;
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;
}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06)}
.modal-body{padding:14px 16px;overflow:auto}
.modal-foot{padding:12px 16px;border-top:1px solid rgba(255,255,255,.06);display:flex;justify-content:flex-end;gap:8px}
.gallery-pick-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px}
.gallery-pick{
  position:relative;cursor:pointer;border-radius:10px;overflow:hidden;
  border:2px solid var(--border);aspect-ratio:1/1;background:#0c0c0c;
  display:flex;align-items:center;justify-content:center;
}
.gallery-pick:hover{border-color:var(--primary)}
.gallery-pick img{max-width:100%;max-height:100%;object-fit:contain}
.gallery-pick .label{
  position:absolute;left:0;right:0;bottom:0;padding:4px 6px;font-size:11px;
  background:linear-gradient(transparent,rgba(0,0,0,.85));overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}

@media (max-width:1100px){
  .designer-shell{grid-template-columns:200px 1fr 240px}
}
@media (max-width:900px){
  .designer-shell{grid-template-columns:1fr;height:auto}
  .designer-side{max-height:none}
}

/* --- Compose wizard --- */
.wizard-progress{
  display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-bottom:8px;
}
.wizard-progress .step-dot{
  display:flex;align-items:center;gap:8px;
  padding:6px 12px;border:1px solid var(--border);border-radius:999px;
  font-size:12px;font-family:var(--mono);letter-spacing:.06em;color:var(--muted);
  background:rgba(255,255,255,.02);
}
.wizard-progress .step-dot.active{
  border-color:var(--primary);color:var(--text);
  background:rgba(139,92,246,.08);
}
.wizard-progress .step-dot.done{
  border-color:rgba(34,197,94,.4);color:var(--text);
}
.wizard-progress .step-num{
  display:inline-flex;align-items:center;justify-content:center;
  width:18px;height:18px;border-radius:999px;
  background:rgba(255,255,255,.08);font-weight:700;font-size:11px;
}
.wizard-progress .step-dot.active .step-num{background:var(--primary);color:#fff}
.wizard-progress .step-dot.done .step-num{background:rgba(34,197,94,.5);color:#fff}
.wizard-step{display:none}
.wizard-step.active{display:flex;flex-direction:column;gap:16px}
.wizard-actions{
  display:flex;gap:10px;justify-content:space-between;align-items:center;
  border-top:1px solid rgba(255,255,255,.06);padding-top:14px;margin-top:6px;
}
.wizard-actions .left{display:flex;gap:8px}
.wizard-actions .right{display:flex;gap:8px}
.connection-pick{
  display:flex;gap:12px;align-items:center;
  border:1px solid rgba(255,255,255,.06);border-radius:10px;padding:12px;
  background:rgba(255,255,255,.02);transition:border-color .15s ease, background .15s ease;
}
.connection-pick.checked{border-color:rgba(139,92,246,.55);background:rgba(139,92,246,.06)}
.connection-pick .meta{flex:1;min-width:0;font-family:var(--sans);letter-spacing:0;color:var(--text);margin:0;font-size:14px}
.connection-pick .platform{font-weight:700;text-transform:capitalize;color:var(--text)}
.connection-pick .display{color:var(--muted);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--sans);letter-spacing:0}
.connection-pick select{min-width:130px}
.group-summary{
  display:flex;gap:14px;align-items:flex-start;flex-wrap:wrap;
  border:1px solid rgba(139,92,246,.25);background:rgba(139,92,246,.06);
  border-radius:12px;padding:14px;
}
.group-summary .gsum-spec{
  display:inline-flex;align-items:center;gap:8px;
  padding:6px 10px;border:1px solid rgba(255,255,255,.1);border-radius:999px;
  font-family:var(--mono);font-size:12px;color:var(--text);
  background:rgba(0,0,0,.25);
}
.group-summary .gsum-targets{display:flex;flex-wrap:wrap;gap:6px}
.group-summary .target-chip{
  font-size:12px;border:1px solid var(--border);border-radius:999px;padding:3px 10px;
  background:rgba(255,255,255,.03);color:var(--text);
}
.thumb-wrap-rm{position:relative}
.thumb-wrap-rm .thumb-rm{
  position:absolute;top:-6px;right:-6px;
  background:#0a0a0a;border:1px solid var(--border);color:var(--text);
  width:22px;height:22px;border-radius:999px;display:flex;align-items:center;justify-content:center;
  cursor:pointer;font-size:13px;line-height:1;padding:0;
}
.thumb-wrap-rm .thumb-rm:hover{border-color:var(--danger);color:#fff}
.thumb-warn{
  outline:2px solid rgba(245,158,11,.7);outline-offset:2px;
}
.aspect-warn{
  background:rgba(245,158,11,.07);
  border:1px solid rgba(245,158,11,.35);
  border-radius:10px;padding:10px 12px;color:var(--text);font-size:13px;
}
.empty-state{
  border:1px dashed rgba(255,255,255,.18);border-radius:12px;
  padding:24px;text-align:center;color:var(--muted);
}

/* Aspect-ratio choice cards */
.aspect-grid{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;
}
.aspect-card{
  appearance:none;cursor:pointer;text-align:left;
  display:flex;flex-direction:column;gap:8px;
  background:var(--surface2);border:1px solid var(--border);
  border-radius:12px;padding:16px;color:var(--text);font-family:var(--sans);
  transition:border-color .15s ease, background .15s ease, transform .1s ease;
}
.aspect-card:hover{border-color:#3a3a3a}
.aspect-card.selected{
  border-color:var(--primary);
  background:linear-gradient(180deg,rgba(139,92,246,.08),rgba(139,92,246,.02));
}
.aspect-card .ar-frame{
  background:rgba(255,255,255,.06);
  border:1px dashed rgba(255,255,255,.2);
  border-radius:8px;
  margin:0 auto;
}
.aspect-card.selected .ar-frame{
  border-color:rgba(139,92,246,.55);
  background:rgba(139,92,246,.12);
}
.aspect-card .ar-square    { aspect-ratio:1/1;   width:80px; }
.aspect-card .ar-horizontal{ aspect-ratio:16/9;  width:120px; }
.aspect-card .ar-vertical  { aspect-ratio:9/16;  height:120px; }
.aspect-card .ar-label{font-weight:700}
.aspect-card .ar-meta{font-family:var(--mono);font-size:12px;color:var(--muted);letter-spacing:.06em}
.aspect-card .ar-desc{font-size:13px;color:var(--muted)}

/* Target row badges */
.connection-pick .badges{margin-top:4px;display:flex;gap:6px;flex-wrap:wrap}
.pill-ok,.pill-warn{
  display:inline-block;font-size:11px;font-family:var(--mono);letter-spacing:.06em;
  border-radius:999px;padding:2px 8px;border:1px solid var(--border);
}
.pill-ok  { color:#a7f3d0; border-color:rgba(34,197,94,.4); background:rgba(34,197,94,.08); }
.pill-warn{ color:#fcd34d; border-color:rgba(245,158,11,.4); background:rgba(245,158,11,.08); }

/* Target chips colored variants */
.target-chip-ok  { border-color:rgba(34,197,94,.4); }
.target-chip-warn{ border-color:rgba(245,158,11,.4); color:#fcd34d; }

