:root {
  --bg:         #0c0c10;
  --surface:    #141418;
  --surface2:   #1e1e26;
  --surface3:   #26263a;
  --border:     #2a2a38;
  --border2:    #3a3a50;
  --text:       #eeeef4;
  --text2:      #7878a0;
  --text3:      #4e4e70;
  --accent:     #7c6fff;
  --accent-dim: rgba(124,111,255,.12);
  --accent2:    #ff6b8a;
  --success:    #22d3a0;
  --danger:     #ff4d6a;
  --sidebar-w:  220px;
  --panel-w:    296px;
  --toolbar-h:  52px;
  --radius:     10px;
  --radius-sm:  6px;
  --radius-xs:  4px;
  --transition: .15s ease;
  --shadow:     0 4px 24px rgba(0,0,0,.5);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* ── Buttons ─────────────────────────────────────────────── */
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13px;
  transition: opacity var(--transition), transform .1s ease;
  user-select: none;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.97); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  transition: border-color var(--transition), background var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); background: var(--surface3); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 12px;
  transition: background var(--transition), color var(--transition);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  color: var(--text2);
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--surface2); }
.icon-btn:disabled { opacity: .25; cursor: default; }

.w100 { width: 100%; }

/* ── Toolbar ─────────────────────────────────────────────── */
#toolbar {
  height: var(--toolbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; gap: 8px;
  flex-shrink: 0;
  position: relative; z-index: 10;
}

.toolbar-left, .toolbar-right {
  display: flex; align-items: center; gap: 6px;
}

.toolbar-sep {
  width: 1px; height: 20px; background: var(--border);
  flex-shrink: 0; margin: 0 2px;
}

/* Seed group */
.seed-group {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 8px 0 10px;
  height: 32px;
}
.seed-group label {
  color: var(--text3); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; flex-shrink: 0;
}
.seed-group input {
  width: 72px; background: none; border: none; outline: none;
  color: var(--text); font: inherit; font-variant-numeric: tabular-nums;
}
.seed-group input::-webkit-inner-spin-button,
.seed-group input::-webkit-outer-spin-button { -webkit-appearance: none; }

.shuffle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  color: var(--text3);
  transition: color var(--transition), background var(--transition);
}
.shuffle-btn:hover { color: var(--accent); background: var(--accent-dim); }

.export-group { display: flex; align-items: center; gap: 4px; }

.btn-svg {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-weight: 600;
  transition: border-color var(--transition), background var(--transition);
}
.btn-svg:hover { border-color: var(--accent); background: var(--surface3); }

.btn-png {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
  transition: opacity var(--transition);
}
.btn-png:hover { opacity: .85; }

/* ── Main area ───────────────────────────────────────────── */
#main {
  display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
  background: var(--bg);
}

#canvas-wrap {
  flex: 1; overflow: hidden; position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124,111,255,.04) 0%, transparent 60%),
    repeating-conic-gradient(var(--surface2) 0% 25%, var(--bg) 0% 50%)
    0 0 / 20px 20px;
}

#canvas-container {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

#canvas-preview {
  box-shadow: 0 12px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06);
  overflow: hidden; border-radius: var(--radius-sm);
  line-height: 0; flex-shrink: 0;
  transition: width .18s cubic-bezier(.4,0,.2,1), height .18s cubic-bezier(.4,0,.2,1);
}
#canvas-preview svg {
  display: block; width: 100%; height: 100%;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.modal-box {
  position: relative; background: var(--surface);
  border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 24px; min-width: 320px; max-width: 90vw; z-index: 1;
  box-shadow: var(--shadow);
}
.modal-sm { max-width: 380px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h2 { font-size: 15px; font-weight: 700; }
.modal-close { font-size: 20px; color: var(--text2); line-height: 1; padding: 2px 6px; border-radius: var(--radius-xs); }
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-body label { color: var(--text2); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.modal-body input[type=text] {
  width: 100%; padding: 9px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; outline: none;
}
.modal-body input[type=text]:focus { border-color: var(--accent); }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text2); font-size: 12px; }
.checkbox-label input { accent-color: var(--accent); }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); font-size: 13px; box-shadow: var(--shadow);
  animation: toast-in .2s ease; pointer-events: none;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.hidden { display: none !important; }
