/* =========================================================
   PixLab — tokens
   ========================================================= */
:root{
  --ink: #1B1430;
  --ink-2: #150F26;
  --panel: #241B42;
  --panel-2: #2D2255;
  --panel-3: #36285F;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);

  --coral: #FF5470;
  --coral-dim: #B83B53;
  --citrus: #FFD23F;
  --mint: #0AEEC1;
  --sky: #4D7CFE;

  --text: #F5F3FF;
  --text-muted: #A99FCB;
  --text-faint: #6F628F;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow: 0 10px 30px rgba(8, 4, 20, 0.45);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--ink-2);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow:hidden;
}
svg{ width:18px; height:18px; stroke:currentColor; fill:none; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
button{ font-family: inherit; cursor:pointer; }
input, select, textarea{ font-family: inherit; }
ul{ margin:0; padding:0; list-style:none; }

#app{
  display:flex;
  flex-direction:column;
  height:100vh;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(255,84,112,0.16), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(77,124,254,0.14), transparent 60%),
    var(--ink);
}

/* =========================================================
   Top bar
   ========================================================= */
.topbar{
  display:flex;
  align-items:center;
  gap:14px;
  padding:10px 16px;
  background: linear-gradient(180deg, var(--panel), var(--panel) 90%);
  border-bottom:1px solid var(--line);
  flex: 0 0 auto;
}
.brand{ display:flex; align-items:center; gap:9px; font-family:var(--font-display); font-weight:700; font-size:18px; letter-spacing:0.2px; }
.brand-mark{
  width:22px; height:22px; border-radius:40% 60% 60% 40% / 50% 50% 50% 50%;
  background: conic-gradient(from 120deg, var(--coral), var(--citrus), var(--mint), var(--sky), var(--coral));
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
  flex-shrink:0;
}
.tabs{ display:flex; align-items:center; gap:6px; overflow-x:auto; max-width:46vw; scrollbar-width:thin; }
.tab{
  display:flex; align-items:center; gap:8px;
  padding:7px 10px 7px 12px;
  background: var(--panel-2);
  border:1px solid transparent;
  border-radius: 999px;
  color: var(--text-muted);
  font-size:13px;
  white-space:nowrap;
  max-width:180px;
}
.tab.active{ color:var(--text); border-color: var(--line-strong); background: var(--panel-3); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04); }
.tab .dot{ width:7px; height:7px; border-radius:50%; background:var(--coral); flex-shrink:0; }
.tab span.label{ overflow:hidden; text-overflow:ellipsis; max-width:110px; }
.tab .tab-close{ border:none; background:none; color:var(--text-faint); width:16px; height:16px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:14px; line-height:1; }
.tab .tab-close:hover{ background: rgba(255,255,255,0.12); color:var(--text); }
.tab-add{
  border:1px dashed var(--line-strong);
  background:transparent; color:var(--text-muted);
  width:30px; height:30px; border-radius:50%;
  font-size:18px; flex-shrink:0;
}
.tab-add:hover{ color:var(--text); border-color: var(--coral); }
.topbar-spacer{ flex:1; }
.topbar-actions{ display:flex; align-items:center; gap:10px; }

.icon-btn{
  width:34px; height:34px; border-radius:10px;
  background: var(--panel-2); border:1px solid var(--line); color: var(--text-muted);
  display:flex; align-items:center; justify-content:center;
}
.icon-btn:hover{ color:var(--text); border-color: var(--line-strong); }
.icon-btn:disabled{ opacity:0.35; cursor:not-allowed; }
.icon-btn.small{ width:26px; height:26px; font-size:16px; }
.icon-btn svg{ width:16px; height:16px; }

.zoom-control{ display:flex; align-items:center; gap:6px; background:var(--panel-2); border:1px solid var(--line); border-radius:10px; padding:3px; }
.zoom-label{ font-family:var(--font-mono); font-size:12px; color:var(--text-muted); width:42px; text-align:center; }
.chip-btn{
  border:1px solid var(--line-strong); background:transparent; color:var(--text-muted);
  border-radius:8px; padding:6px 10px; font-size:12.5px; font-weight:600;
}
.chip-btn:hover{ color:var(--text); border-color: var(--sky); }
.chip-btn.tiny{ padding:4px 8px; font-size:11.5px; }

.btn-primary{
  border:none; border-radius:10px; padding:8px 14px;
  background: linear-gradient(135deg, var(--coral), #ff7a5c);
  color:#1B1430; font-weight:700; font-size:13px;
  display:flex; align-items:center; gap:6px;
  box-shadow: 0 6px 16px rgba(255,84,112,0.35);
}
.btn-primary:hover{ filter:brightness(1.06); }
.btn-primary.full{ width:100%; justify-content:center; margin-top:10px; }
.btn-primary .caret{ width:13px; height:13px; }

.export-wrap{ position:relative; }
.export-menu{
  position:absolute; top:42px; right:0; width:230px;
  background: var(--panel-3); border:1px solid var(--line-strong); border-radius: var(--radius);
  padding:12px; box-shadow: var(--shadow); z-index:40;
}
.export-row{ display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12.5px; color:var(--text-muted); margin-bottom:8px; }
.export-row select, .export-row input[type=range]{ width:120px; }

/* =========================================================
   Workspace layout
   ========================================================= */
.workspace{ flex:1; display:flex; min-height:0; }

.toolrail{
  flex:0 0 58px; display:flex; flex-direction:column; align-items:center; gap:8px;
  padding:14px 8px; background: var(--panel); border-right:1px solid var(--line);
}
.tool-btn{
  width:38px; height:38px; border-radius:11px;
  background:transparent; border:1px solid transparent; color:var(--text-muted);
  display:flex; align-items:center; justify-content:center;
}
.tool-btn:hover{ background:var(--panel-2); color:var(--text); }
.tool-btn[aria-pressed="true"]{
  background: linear-gradient(135deg, rgba(255,84,112,0.22), rgba(77,124,254,0.22));
  border-color: var(--coral); color:#fff;
}
.rail-divider{ width:28px; height:1px; background:var(--line-strong); margin:4px 0; }
.color-swatch{ width:34px; height:34px; border-radius:10px; overflow:hidden; border:2px solid var(--line-strong); cursor:pointer; }
.color-swatch input{ width:150%; height:150%; margin:-25%; border:none; padding:0; cursor:pointer; }
.brush-settings{ display:flex; flex-direction:column; gap:10px; margin-top:6px; width:42px; }
.brush-settings label{ display:flex; flex-direction:column; gap:4px; font-size:8.5px; color:var(--text-faint); text-transform:uppercase; letter-spacing:0.3px; }
.brush-settings input[type=range]{ width:42px; }

.stage-wrap{ flex:1; position:relative; overflow:auto; display:flex; align-items:center; justify-content:center; padding:30px; background:
  linear-gradient(var(--ink-2), var(--ink-2));
}
.stage{ position:relative; display:flex; align-items:center; justify-content:center; min-width:100%; min-height:100%; }
.canvas-frame{ position:relative; box-shadow: var(--shadow); border-radius:4px; transform-origin:center center; }
.canvas-frame::before{
  content:''; position:absolute; inset:-14px; border-radius:16px; pointer-events:none;
  background:
    linear-gradient(var(--ink), var(--ink)) padding-box,
    conic-gradient(from 0deg, var(--coral), var(--citrus), var(--mint), var(--sky), var(--coral)) border-box;
  border: 3px solid transparent;
  opacity:0.0;
  transition: opacity .2s;
}
.canvas-frame.active-edit::before{ opacity:1; }
.canvas-frame::after{
  content:''; position:absolute; inset:-14px; border-radius:16px; pointer-events:none;
  border:1px solid rgba(255,255,255,0.06);
}
#mainCanvas{
  display:block;
  background-image:
    linear-gradient(45deg, #2a2247 25%, transparent 25%),
    linear-gradient(-45deg, #2a2247 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2247 75%),
    linear-gradient(-45deg, transparent 75%, #2a2247 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
  background-color: #1f1838;
}
#overlayCanvas{ position:absolute; top:0; left:0; pointer-events:none; }

.empty-state{
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; gap:8px; padding:40px;
}
.empty-state.hidden{ display:none; }
.empty-mark{
  width:64px; height:64px; border-radius:30% 70% 70% 30% / 40% 40% 60% 60%; margin-bottom:10px;
  background: conic-gradient(from 120deg, var(--coral), var(--citrus), var(--mint), var(--sky), var(--coral));
  box-shadow: var(--shadow);
}
.empty-state h1{ font-family:var(--font-display); font-size:26px; margin:0; }
.empty-state p{ color:var(--text-muted); margin:0 0 12px; max-width:360px; font-size:14px; }

.crop-toolbar, .text-editor{
  position:absolute; bottom:24px; left:50%; transform:translateX(-50%);
  background: var(--panel-3); border:1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding:12px 14px; display:flex; align-items:center; gap:10px; z-index:30;
}
.crop-toolbar span{ font-size:12.5px; color:var(--text-muted); margin-right:6px; }
.text-editor{ flex-direction:column; align-items:stretch; width:min(420px, 90vw); }
.text-editor textarea{
  resize:vertical; background:var(--panel-2); border:1px solid var(--line-strong); border-radius:8px; color:var(--text);
  padding:8px 10px; font-size:15px; font-family:var(--font-display);
}
.text-editor-row{ display:flex; gap:6px; margin-top:8px; align-items:center; }
.text-editor-row select, .text-editor-row input[type=number]{
  background:var(--panel-2); border:1px solid var(--line-strong); color:var(--text); border-radius:6px; padding:5px 6px; font-size:12px;
}
.text-editor-row input[type=number]{ width:54px; }
.text-editor-row input[type=color]{ width:30px; height:28px; border:none; border-radius:6px; background:none; padding:0; }

/* =========================================================
   Right panel
   ========================================================= */
.rightpanel{
  flex:0 0 290px; display:flex; flex-direction:column; gap:1px;
  background: var(--panel); border-left:1px solid var(--line);
  overflow-y:auto;
}
.panel{ padding:14px 14px 16px; border-bottom:1px solid var(--line); }
.panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; font-family:var(--font-display); font-weight:600; font-size:13px; letter-spacing:0.3px; text-transform:uppercase; color:var(--text-muted); }
.panel-head-actions{ display:flex; gap:6px; }

.layers-panel{ max-height:40vh; overflow-y:auto; }
.layers-list{ display:flex; flex-direction:column; gap:6px; }
.layer-item{
  display:flex; align-items:center; gap:8px;
  background:var(--panel-2); border:1px solid var(--line); border-radius:10px; padding:7px 8px;
}
.layer-item.active{ border-color: var(--coral); box-shadow: 0 0 0 1px rgba(255,84,112,0.25) inset; }
.layer-item .swatch{ width:26px; height:26px; border-radius:7px; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:13px; }
.layer-item .swatch.t-image{ background:linear-gradient(135deg, var(--sky), var(--mint)); }
.layer-item .swatch.t-text{ background:linear-gradient(135deg, var(--citrus), var(--coral)); color:#1B1430; }
.layer-item .swatch.t-shape{ background:linear-gradient(135deg, var(--mint), var(--coral)); }
.layer-item .swatch.t-brush{ background:linear-gradient(135deg, var(--coral), var(--sky)); }
.layer-item .meta{ flex:1; min-width:0; }
.layer-item .name{ font-size:12.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; background:none; border:none; color:var(--text); width:100%; padding:0; }
.layer-item .name:focus{ outline:1px solid var(--sky); border-radius:4px; }
.layer-item .sub{ display:flex; align-items:center; gap:6px; margin-top:3px; }
.layer-item select.blend{ background:transparent; border:none; color:var(--text-faint); font-size:10.5px; padding:0; }
.layer-item input[type=range]{ width:54px; height:3px; }
.layer-item .row-actions{ display:flex; gap:2px; }
.layer-item .row-actions button{
  width:22px; height:22px; border-radius:6px; background:transparent; border:none; color:var(--text-faint); display:flex; align-items:center; justify-content:center;
}
.layer-item .row-actions button:hover{ background:rgba(255,255,255,0.08); color:var(--text); }
.layer-item .row-actions svg{ width:13px; height:13px; }
.layer-item.hidden-layer{ opacity:0.45; }

.adjust-sliders{ display:flex; flex-direction:column; gap:10px; }
.adjust-row{ display:flex; flex-direction:column; gap:3px; }
.adjust-row .label-row{ display:flex; justify-content:space-between; font-size:11.5px; color:var(--text-muted); }
.adjust-row .label-row span.val{ font-family:var(--font-mono); color:var(--text-faint); }
.adjust-row input[type=range]{ width:100%; }

input[type=range]{
  -webkit-appearance:none; appearance:none; height:4px; border-radius:4px;
  background: linear-gradient(90deg, var(--sky), var(--coral));
  outline:none;
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; width:14px; height:14px; border-radius:50%;
  background:#fff; border:2px solid var(--coral); cursor:pointer; margin-top:-1px;
}
input[type=range]::-moz-range-thumb{ width:14px; height:14px; border-radius:50%; background:#fff; border:2px solid var(--coral); cursor:pointer; }

.presets-grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap:10px; }
.preset-card{ display:flex; flex-direction:column; align-items:center; gap:6px; background:none; border:none; padding:4px; }
.preset-blob{ width:48px; height:48px; border-radius:46% 54% 58% 42% / 50% 46% 54% 50%; box-shadow: 0 6px 14px rgba(0,0,0,0.35); border:2px solid rgba(255,255,255,0.12); transition: transform .15s; }
.preset-card:hover .preset-blob{ transform: scale(1.08) rotate(4deg); }
.preset-card span{ font-size:10.5px; color:var(--text-muted); text-align:center; }

/* =========================================================
   Status bar
   ========================================================= */
.statusbar{
  flex:0 0 auto; display:flex; align-items:center; gap:18px;
  padding:6px 16px; background:var(--ink-2); border-top:1px solid var(--line);
  font-family:var(--font-mono); font-size:11px; color:var(--text-faint);
}
.statusbar-spacer{ flex:1; }
.statusbar-hint{ font-family:var(--font-body); }

/* scrollbars */
*::-webkit-scrollbar{ width:9px; height:9px; }
*::-webkit-scrollbar-thumb{ background:var(--panel-3); border-radius:6px; }
*::-webkit-scrollbar-track{ background:transparent; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 980px){
  .rightpanel{ flex-basis:240px; }
  .tabs{ max-width:30vw; }
}
@media (max-width: 720px){
  .workspace{ flex-direction:column; }
  .toolrail{ flex-direction:row; flex-basis:auto; width:100%; overflow-x:auto; border-right:none; border-bottom:1px solid var(--line); }
  .rightpanel{ flex-basis:auto; width:100%; max-height:46vh; }
  .stage-wrap{ padding:14px; }
}
