* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0f1e;
  --bg2: #111827;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.18);
  --glass: rgba(255,255,255,0.04);
  --glass-hover: rgba(255,255,255,0.08);
  --gold: #f5c842;
  --purple: #a78bfa;
  --text: #f1f5f9;
  --muted: rgba(255,255,255,0.38);
  --radius: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bg {
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(167,139,250,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(245,200,66,0.04) 0%, transparent 55%),
    var(--bg);
}

/* ── NAV ──────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,15,30,0.7);
  backdrop-filter: blur(16px);
  flex-shrink: 0;
  gap: 12px;
  z-index: 20;
}

.back-btn {
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.back-btn:hover { color: var(--text); }

.nav-title {
  font-size: 16px; font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.element-count {
  font-size: 13px; font-weight: 600;
  color: var(--muted);
}

.btn-reset {
  background: rgba(255,90,90,0.1);
  border: 1px solid rgba(255,90,90,0.25);
  border-radius: 8px;
  color: #f87171;
  font-family: 'Outfit', sans-serif;
  font-size: 12px; font-weight: 700;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-reset:hover { background: rgba(255,90,90,0.18); }

/* ── LAYOUT ───────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────── */
.sidebar {
  position: relative;
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(10,15,30,0.5);
  overflow: hidden;
}

.sidebar.drop-target {
  background: rgba(248,113,113,0.06);
  border-right-color: rgba(248,113,113,0.35);
}
.sidebar.drop-target::after {
  content: '🗑️ Drop to remove';
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  font-size: 12px; font-weight: 600;
  color: #f87171;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-search input {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.sidebar-search input::placeholder { color: var(--muted); }
.sidebar-search input:focus { border-color: var(--border-hover); }

.elements-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.elements-list::-webkit-scrollbar { width: 4px; }
.elements-list::-webkit-scrollbar-track { background: transparent; }
.elements-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.element-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: grab;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  user-select: none;
}
.element-pill:hover {
  background: var(--glass-hover);
  border-color: var(--border);
  transform: translateX(2px);
}
.element-pill:active { cursor: grabbing; transform: scale(0.97); }

.element-pill.is-new {
  background: rgba(167,139,250,0.1);
  border-color: rgba(167,139,250,0.3);
  animation: newPill 0.4s var(--ease);
}
@keyframes newPill {
  from { opacity:0; transform:translateX(-8px); }
  to   { opacity:1; transform:translateX(0); }
}

.pill-emoji { font-size: 18px; flex-shrink: 0; }
.pill-name  { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── CANVAS ───────────────────────────── */
.canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(167,139,250,0.03) 0%, transparent 70%);
}

/* Subtle dot grid */
.canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

.canvas-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  z-index: 1;
  pointer-events: none;
}

.canvas-items {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* ── CANVAS ITEMS ─────────────────────── */
.canvas-item {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 8px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 2;
}
.canvas-item:hover {
  border-color: var(--border-hover);
  box-shadow: 0 6px 22px rgba(0,0,0,0.4);
}

.canvas-item.selected {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(167,139,250,0.3), 0 6px 22px rgba(0,0,0,0.4);
  transform: scale(1.04);
}

.canvas-item.combining {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245,200,66,0.3);
  animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(245,200,66,0.3); }
  50%      { box-shadow: 0 0 0 4px rgba(245,200,66,0.15), 0 0 16px rgba(245,200,66,0.2); }
}

.item-emoji { font-size: 20px; flex-shrink: 0; }
.item-name  { font-size: 13px; font-weight: 700; }

.item-remove {
  background: none; border: none;
  color: var(--muted);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  padding: 0 0 0 4px;
  transition: color 0.12s;
  flex-shrink: 0;
}
.item-remove:hover { color: #f87171; }

/* ── RESULT TOAST ─────────────────────── */
.result-toast {
  position: absolute;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 22px;
  font-size: 14px; font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 50;
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}

.result-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.result-toast.new-discovery {
  border-color: rgba(167,139,250,0.5);
  background: rgba(167,139,250,0.1);
  color: #c4b5fd;
  box-shadow: 0 0 24px rgba(167,139,250,0.2), 0 8px 28px rgba(0,0,0,0.4);
}

/* ── RESPONSIVE ───────────────────────── */
@media (max-width: 600px) {
  .sidebar { width: 160px; }
  .pill-name { font-size: 12px; }
  .nav-title { font-size: 14px; }
}