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

:root {
  --bg: #0d1117;
  --surface: #161b27;
  --surface2: #1f2535;
  --border: #2a3050;
  --accent: #a855f7;
  --accent-lo: rgba(168, 85, 247, .22);
  --accent-hi: #c084fc;
  --proton: #ff7a4d;
  --proton-lo: rgba(255, 122, 77, .22);
  --neutron: #9aa3b8;
  --neutron-lo: rgba(154, 163, 184, .22);
  --electron: #22d3ee;
  --electron-lo: rgba(34, 211, 238, .22);
  --green: #3ddc84;
  --red: #ff5555;
  --gold: #f5c842;
  --text: #dde3f0;
  --text-dim: #6b7a99;
  --font: 'Segoe UI', system-ui, sans-serif;
  --mono: 'Courier New', monospace;
  --radius: 12px;
}

body {
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  min-height: 100vh; padding: 16px;
  overflow-x: hidden;
}

#app { max-width: 1400px; margin: 0 auto; }

.logo-fixed { position: fixed; top: 14px; left: 14px; z-index: 50; }
.logo-fixed img { display: block; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }

.site-nav { padding: 6px 0 14px; }
.site-nav-back {
  color: var(--text-dim); text-decoration: none;
  font-size: 0.85rem; padding: 6px 10px; border-radius: 8px;
  transition: background .15s, color .15s;
}
.site-nav-back:hover { background: var(--surface2); color: var(--accent); }

header { text-align: center; padding: 8px 0 18px; }
header h1 {
  font-size: clamp(1.4rem, 3vw, 2.1rem); font-weight: 800;
  background: linear-gradient(120deg, var(--accent) 0%, var(--electron) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.02em;
}
.subtitle { color: var(--text-dim); margin-top: 4px; font-size: .92rem; }

/* ─── Controls bar / pill tabs ─── */
.controls-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.ctrl-group { display: flex; gap: 8px; align-items: center; }
.ctrl-label {
  font-size: .72rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em;
}
.pill-tabs {
  display: inline-flex; gap: 2px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.pill {
  border: none; background: transparent; color: var(--text-dim);
  padding: 10px 16px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
  min-height: 44px;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--accent); color: #fff; }

.btn {
  padding: 8px 16px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  border-radius: 8px; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px;
}
.btn:hover { background: var(--accent-lo); color: var(--accent); border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hi); color: #fff; border-color: var(--accent-hi); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 12px 26px; font-size: 1rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }
.btn-guide {
  margin-left: auto; padding: 6px 14px;
  background: var(--gold); color: #1a1a2e;
  border: none; border-radius: 8px;
  font-size: .82rem; font-weight: 700; text-decoration: none;
  transition: filter .15s;
}
.btn-guide:hover { filter: brightness(1.1); }

/* ─── SIMULATE LAYOUT ─── */
.sim-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 14px;
}

.canvas-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  overflow-x: clip;
  position: relative;
}
#atom-canvas {
  display: block; width: 100%; height: auto;
  background: radial-gradient(ellipse at center, #11162a 0%, #0a0d18 80%);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}

/* ─── Live element/atom info panel (right side) ─── */
.info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.element-card {
  background: linear-gradient(140deg, var(--surface2), var(--bg));
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  position: relative;
  transition: border-color .25s, box-shadow .25s;
}
.element-card.matched {
  border-color: var(--accent);
  box-shadow: 0 0 28px var(--accent-lo);
}
.element-card.undefined { border-style: dashed; border-color: var(--text-dim); }
.ec-z {
  position: absolute; top: 8px; left: 12px;
  font-size: .78rem; color: var(--text-dim);
  font-family: var(--mono); font-weight: 700;
}
.ec-mass {
  position: absolute; top: 8px; right: 12px;
  font-size: .78rem; color: var(--gold);
  font-family: var(--mono); font-weight: 700;
}
.ec-symbol {
  font-size: 2.6rem; font-weight: 800; line-height: 1;
  margin: 6px 0;
  color: var(--accent);
  letter-spacing: -.02em;
}
.ec-symbol.undefined { color: var(--text-dim); font-size: 1.4rem; }
.ec-name {
  font-size: 1rem; color: var(--text);
  font-weight: 600;
}
.ec-name-sub {
  font-size: .76rem; color: var(--text-dim);
  margin-top: 2px;
}
.ec-notation {
  margin-top: 8px; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono); font-size: 1rem; font-weight: 700;
  color: var(--electron);
  letter-spacing: .04em;
}

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.stat-cell {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 9px;
}
.sc-label {
  font-size: .65rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700;
}
.sc-val {
  font-family: var(--mono); font-size: .95rem; font-weight: 700;
  margin-top: 2px;
}
.sc-val.proton { color: var(--proton); }
.sc-val.neutron { color: var(--neutron); }
.sc-val.electron { color: var(--electron); }
.sc-val.charge { color: var(--gold); }
.sc-val.charge.pos { color: #ff7043; }
.sc-val.charge.neg { color: #29b6f6; }
.sc-val.charge.neutral { color: var(--green); }
.sc-val.stable { color: var(--green); }
.sc-val.unstable { color: var(--red); }

.config-row {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px;
  font-family: var(--mono); font-size: .82rem;
  color: var(--accent-hi);
  text-align: center;
  word-spacing: 4px;
}
.config-row .cl { color: var(--text-dim); }

/* Mini periodic table */
.pt-mini-wrap {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px;
}
.pt-mini-title {
  font-size: .68rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 6px; display: flex; justify-content: space-between;
}
.pt-mini {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 1px;
}
.pt-cell {
  aspect-ratio: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .55rem; font-weight: 700;
  background: var(--surface2); color: var(--text-dim);
  border-radius: 2px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.pt-cell.empty { background: transparent; cursor: default; }
.pt-cell:not(.empty):hover { background: var(--accent-lo); color: var(--text); }
.pt-cell.cat-nm { background: #1e3a3a; color: #5dd9d9; }
.pt-cell.cat-m  { background: #3a2e1e; color: #ffd089; }
.pt-cell.cat-mm { background: #2a3a1e; color: #aed581; }
.pt-cell.cat-ng { background: #3a1e3a; color: #f3a3ff; }
.pt-cell.cat-am { background: #3a2a1e; color: #ffb070; }
.pt-cell.cat-tm { background: #2a2a3a; color: #b8b5e0; }
.pt-cell.cat-pt { background: #3a2a2a; color: #ff9a85; }
.pt-cell.cat-ln { background: #2a3a2a; color: #88e0a3; }
.pt-cell.cat-ac { background: #3a2a3a; color: #c894e0; }
.pt-cell.cat-h  { background: #2a3a3a; color: #7de2e8; }
.pt-cell.match {
  background: var(--accent) !important;
  color: #fff !important;
  transform: scale(1.18);
  z-index: 2; position: relative;
  box-shadow: 0 0 12px var(--accent-hi), 0 0 24px var(--accent-lo);
  animation: ptBlink 1s ease-in-out infinite;
}
@keyframes ptBlink {
  0%, 100% { box-shadow: 0 0 8px var(--accent-hi), 0 0 16px var(--accent-lo); transform: scale(1.15); }
  50%      { box-shadow: 0 0 22px var(--accent-hi), 0 0 36px var(--accent-lo); transform: scale(1.25); }
}

/* ─── Particle bin / drop area ─── */
.particle-bins {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 12px; margin-top: 12px;
}
.bin {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
  transition: border-color .15s, background .15s;
}
.bin[data-type="proton"]   { border-top: 3px solid var(--proton); }
.bin[data-type="neutron"]  { border-top: 3px solid var(--neutron); }
.bin[data-type="electron"] { border-top: 3px solid var(--electron); }
.bin-head {
  display: flex; justify-content: space-between; align-items: center;
}
.bin-title {
  font-weight: 700; font-size: .92rem;
  display: flex; align-items: center; gap: 8px;
}
.bin-title .dot {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-block;
}
.bin[data-type="proton"]   .dot { background: var(--proton);  box-shadow: 0 0 10px var(--proton-lo); }
.bin[data-type="neutron"]  .dot { background: var(--neutron); box-shadow: 0 0 10px var(--neutron-lo); }
.bin[data-type="electron"] .dot { background: var(--electron); box-shadow: 0 0 10px var(--electron-lo); }
.bin-count {
  font-family: var(--mono); font-weight: 800; font-size: 1.1rem;
  color: var(--text);
  background: var(--bg); padding: 2px 10px; border-radius: 6px;
  border: 1px solid var(--border);
  min-width: 44px; text-align: center;
}
.bin-pile {
  height: 64px;
  background: var(--bg); border-radius: 8px;
  border: 1px dashed var(--border);
  position: relative; overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.bin-pile:active { cursor: grabbing; }
.bin-pile canvas { width: 100%; height: 100%; display: block; }
.bin-buttons { display: flex; gap: 6px; }
.bin-btn {
  flex: 1; min-height: 38px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 1.2rem; font-weight: 700;
  border-radius: 8px; cursor: pointer;
  transition: all .15s;
  user-select: none;
  touch-action: manipulation;
}
.bin-btn:hover { background: var(--accent-lo); color: var(--accent); border-color: var(--accent); }
.bin-btn:active { transform: scale(.92); }
.bin-btn.minus { background: transparent; }

/* ─── Sliders (kept for design system) ─── */
.sim-slider {
  flex: 1; -webkit-appearance: none; appearance: none; height: 6px;
  background: rgba(255,255,255,.12); border-radius: 3px; outline: none;
  border: 1px solid rgba(255,255,255,.1);
}
.sim-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent-lo), rgba(255,255,255,.12));
}
.sim-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  box-shadow: 0 0 8px var(--accent-lo);
  border: 2px solid rgba(255,255,255,.2);
}

/* ─── Action bar on canvas card ─── */
.action-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 4px 0;
}
.action-bar .btn { padding: 6px 12px; font-size: .78rem; min-height: 32px; }

.readout-badges {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.readout-badge {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px;
  font-size: .76rem; font-family: var(--mono);
  display: flex; align-items: center; gap: 6px;
  color: var(--text);
}
.rb-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ─── Context menu ─── */
.ctx-menu {
  position: absolute; z-index: 100; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.ctx-item {
  display: block; width: 100%; padding: 8px 16px; border: none;
  background: transparent; color: var(--text); font-size: .82rem;
  text-align: left; cursor: pointer; transition: background .12s;
}
.ctx-item:hover { background: var(--accent-lo); color: var(--accent); }

/* ─── Mode sections ─── */
.mode-section { display: none; }
.mode-section.active { display: block; }

/* ─── EXPLORE mode ─── */
.explore-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px;
  margin-bottom: 14px;
}
.explore-tab {
  border: none; background: transparent;
  color: var(--text-dim);
  padding: 7px 14px; border-radius: 999px;
  cursor: pointer; font-size: .82rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.explore-tab:hover { color: var(--text); }
.explore-tab.active { background: var(--accent); color: #fff; }
.explore-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.explore-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  border-left: 3px solid var(--accent);
}
.explore-card h3 {
  font-size: 1rem; margin-bottom: 8px;
  color: var(--accent);
}
.explore-card p { font-size: .88rem; line-height: 1.55; color: var(--text); }
.explore-card .formula {
  display: block; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px;
  font-family: var(--mono); font-size: .82rem;
  color: var(--accent-hi);
  margin-top: 8px;
}
.explore-card .note {
  margin-top: 8px; padding: 7px 10px;
  background: var(--accent-lo); border-radius: 6px;
  font-size: .78rem; color: var(--text);
  border-left: 2px solid var(--accent);
}

/* ─── PRACTICE / QUIZ panels ─── */
.practice-bar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 12px;
}
.practice-target {
  flex: 1; font-size: .92rem;
}
.practice-target strong { color: var(--accent); }
.practice-score {
  font-family: var(--mono); font-weight: 700;
  background: var(--bg); padding: 4px 10px;
  border-radius: 8px; border: 1px solid var(--border);
  color: var(--green);
}
.practice-feedback {
  font-size: .85rem; padding: 6px 10px; border-radius: 8px;
  display: none;
}
.practice-feedback.ok    { display: block; background: rgba(61,220,132,.12); color: var(--green); border: 1px solid var(--green); }
.practice-feedback.err   { display: block; background: rgba(255,85,85,.12);  color: var(--red);   border: 1px solid var(--red); }

.quiz-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; max-width: 720px; margin: 0 auto;
}
.quiz-progress {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; font-size: .82rem; color: var(--text-dim);
}
.quiz-progress-bar {
  height: 6px; background: var(--bg); border-radius: 3px;
  overflow: hidden; margin: 10px 0 18px;
}
.quiz-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--electron));
  width: 0%; transition: width .35s;
}
.quiz-q {
  font-size: 1.05rem; font-weight: 600; margin-bottom: 14px;
  line-height: 1.5;
}
.quiz-options { display: grid; gap: 8px; }
.quiz-opt {
  padding: 12px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: all .15s;
  font-size: .92rem; text-align: left;
  font-family: var(--font); color: var(--text);
}
.quiz-opt:hover { border-color: var(--accent); background: var(--accent-lo); }
.quiz-opt.correct { border-color: var(--green); background: rgba(61,220,132,.12); }
.quiz-opt.wrong   { border-color: var(--red);   background: rgba(255,85,85,.12); }
.quiz-opt:disabled { cursor: default; }
.quiz-explain {
  margin-top: 14px; padding: 10px 14px;
  background: var(--bg); border-left: 3px solid var(--accent);
  border-radius: 8px; font-size: .88rem; color: var(--text); line-height: 1.5;
  display: none;
}
.quiz-explain.show { display: block; }
.quiz-result-stars {
  font-size: 2.2rem; text-align: center; margin: 8px 0 12px;
  color: var(--gold); letter-spacing: 4px;
}
.quiz-result-score {
  text-align: center; font-size: 1.4rem; font-weight: 700;
  margin-bottom: 14px;
}

/* ─── USER GUIDE ─── */
.user-guide {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  margin-top: 28px;
}
.user-guide-title {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 10px;
  color: var(--accent);
}
.user-guide details {
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; overflow: hidden;
}
.user-guide summary {
  padding: 10px 14px; cursor: pointer; font-weight: 600;
  background: var(--surface2);
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.user-guide summary::-webkit-details-marker { display: none; }
.user-guide details[open] summary { background: var(--accent-lo); color: var(--accent); }
.guide-section-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent); color: #fff;
  font-size: .78rem; font-weight: 700;
}
.guide-content {
  padding: 12px 14px; font-size: .9rem; line-height: 1.65; color: var(--text);
}
.guide-content ol, .guide-content ul { margin: 6px 0 6px 22px; }
.guide-content li { margin-bottom: 4px; }

/* ─── SEO Article ─── */
.seo-article {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  margin-top: 28px;
  font-size: .92rem; line-height: 1.7; color: var(--text);
}
.seo-article h2 {
  font-size: 1.4rem; margin-bottom: 12px; color: var(--accent);
}
.seo-article h3 {
  font-size: 1.05rem; margin: 18px 0 8px; color: var(--accent-hi);
}
.seo-article p { margin-bottom: 10px; }
.seo-article a { color: var(--electron); text-decoration: none; }
.seo-article a:hover { text-decoration: underline; }
.author-byline {
  display: flex; gap: 12px; align-items: center;
  background: var(--bg); padding: 10px 14px;
  border-radius: 8px; margin-bottom: 14px;
  border: 1px solid var(--border);
}
.author-byline img { border-radius: 50%; }
.byline-text { font-size: .8rem; line-height: 1.45; color: var(--text-dim); }
.byline-row1 { color: var(--text); font-weight: 600; }
.byline-row1 a { color: var(--accent); text-decoration: none; }
.byline-row3 a { color: var(--electron); text-decoration: none; }

/* ─── Drag particle (floating) ─── */
.drag-particle {
  position: fixed; pointer-events: none; z-index: 2000;
  width: 30px; height: 30px; border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: .78rem;
  font-family: var(--mono);
}
.drag-particle.proton   { background: radial-gradient(circle at 30% 30%, #ffb380, var(--proton)); }
.drag-particle.neutron  { background: radial-gradient(circle at 30% 30%, #c8cee0, var(--neutron)); }
.drag-particle.electron { background: radial-gradient(circle at 30% 30%, #87f5ff, var(--electron)); width: 22px; height: 22px; }

/* ─── Responsive ─── */
@media (max-width: 980px) {
  .sim-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  body { padding: 10px; }
  header h1 { font-size: 1.4rem; }
  .particle-bins { grid-template-columns: 1fr; }
  .pt-mini { font-size: .5rem; }
  .pt-cell { font-size: .48rem; }
}
@media (max-width: 500px) {
  .sim-layout { gap: 10px; }
  .canvas-card { padding: 6px; }
  .info-panel { padding: 10px; }
  .ec-symbol { font-size: 2.1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn { font-size: .78rem; padding: 6px 12px; }
  .pt-mini-wrap { padding: 5px; }
  .quiz-panel { padding: 12px; }
}

/* ═══════════════════ UPGRADE PASS v2 ═══════════════════ */

/* Focus-visible (a11y) — never suppress, gold ring on accent-colored bg */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
button:focus-visible, .pill:focus-visible, .ct-chip:focus-visible,
.bin-btn:focus-visible, .pt-cell:focus-visible, .bin-count:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.btn:focus:not(:focus-visible),
.pill:focus:not(:focus-visible) { outline: none; }

/* Element search bar */
.el-search {
  flex: 1 1 240px; min-width: 200px; max-width: 360px;
  padding: 6px 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  border-radius: 8px; font-size: .82rem; font-family: var(--font);
  min-height: 36px; outline: none;
  transition: border-color .15s, background .15s;
}
.el-search:focus { border-color: var(--accent); background: #1a1f2e; }
.el-search::-webkit-search-cancel-button { -webkit-appearance: none; cursor: pointer; }
.el-search-results {
  position: absolute; z-index: 60;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 8px; padding: 4px;
  max-height: 280px; overflow-y: auto;
  min-width: 240px; max-width: 380px;
  display: none; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.el-search-results.show { display: block; }
.el-result-item {
  padding: 6px 10px; cursor: pointer; border-radius: 6px;
  font-size: .85rem; display: flex; align-items: center; gap: 10px;
  color: var(--text);
}
.el-result-item:hover, .el-result-item.active { background: var(--accent-lo); color: var(--accent); }
.el-result-sym {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--mono); font-weight: 700; font-size: .82rem;
  color: var(--accent);
}
.el-result-z { color: var(--text-dim); font-size: .72rem; margin-left: auto; }

/* Canvas feature toggles bar */
.canvas-toggles {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 4px 0;
  align-items: center;
}
.ct-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .74rem; color: var(--text-dim);
  cursor: pointer; transition: all .15s;
  user-select: none;
  min-height: 30px;
}
.ct-chip:hover { color: var(--text); border-color: var(--accent-lo); }
.ct-chip input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface2);
  cursor: pointer; margin: 0; position: relative;
}
.ct-chip input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.ct-chip input[type="checkbox"]:checked::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700;
}
.ct-chip:has(input:checked) { color: var(--accent); border-color: var(--accent); background: var(--accent-lo); }
.ct-spacer { flex: 1; }
.ct-speed {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .74rem; color: var(--text-dim);
  min-width: 160px;
}
.ct-speed .sim-slider { width: 90px; height: 4px; }
.ct-speed .sim-slider::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; }

/* Editable bin-count */
.bin-count {
  cursor: pointer; transition: background .15s, color .15s;
}
.bin-count:hover { background: var(--accent-lo); color: var(--accent); border-color: var(--accent); }
.bin-count.editing { padding: 0; }
.bin-count input {
  width: 100%; padding: 2px 10px; border: none; background: transparent;
  font: inherit; color: var(--accent); text-align: center;
  font-family: var(--mono); font-weight: 800; outline: none;
  -moz-appearance: textfield;
}
.bin-count input::-webkit-outer-spin-button,
.bin-count input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Isotope chips row */
.iso-row { display: flex; flex-direction: column; gap: 4px; }
.iso-row[hidden] { display: none; }
.iso-row-title {
  font-size: .68rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
}
.iso-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.iso-chip {
  padding: 4px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; font-family: var(--mono);
  font-size: .76rem; color: var(--text); cursor: pointer;
  transition: all .15s;
  min-height: 28px;
}
.iso-chip:hover { background: var(--accent-lo); color: var(--accent); border-color: var(--accent); }
.iso-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.iso-chip .iso-half { color: var(--text-dim); font-size: .68rem; margin-left: 4px; }
.iso-chip.active .iso-half { color: rgba(255,255,255,.7); }

/* Collapsible learning panels */
.learn-panels {
  margin-top: 16px; padding: 14px;
  background: linear-gradient(180deg, rgba(30,38,66,0.55), rgba(20,26,46,0.55));
  border: 1px solid var(--border); border-radius: 12px;
}
.learn-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding-bottom: 10px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.learn-head-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.learn-head-actions { display: flex; gap: 8px; }
.learn-toggle-all {
  padding: 6px 12px;
  background: var(--accent-lo); border: 1px solid var(--accent);
  color: var(--accent-hi); border-radius: 6px;
  font-size: .76rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
  min-height: 32px;
}
.learn-toggle-all:hover { background: var(--accent); color: #fff; }
.learn-card {
  border: 1px solid var(--border); border-radius: 10px;
  background: rgba(13,17,30,.55);
  margin-bottom: 10px; overflow: hidden;
}
.learn-card:last-child { margin-bottom: 0; }
.learn-card[open] { border-color: var(--accent); }
.learn-card > summary {
  list-style: none; cursor: pointer;
  padding: 10px 14px; display: flex; align-items: center;
  gap: 10px; flex-wrap: wrap;
  font-size: .88rem; font-weight: 700; color: var(--text);
  user-select: none; min-height: 44px;
}
.learn-card > summary::-webkit-details-marker { display: none; }
.learn-card > summary:hover { background: var(--accent-lo); }
.learn-card > summary::after {
  content: '▾'; margin-left: auto; color: var(--text-dim);
  font-size: .8rem; transition: transform .2s;
}
.learn-card[open] > summary::after { transform: rotate(180deg); color: var(--accent); }
.lp-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent-lo); color: var(--accent-hi);
  font-size: .9rem;
}
.lp-sub { color: var(--text-dim); font-weight: 500; font-size: .76rem; }
.learn-body { padding: 12px 14px 14px; }

/* Element properties grid */
.props-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}
.props-empty { color: var(--text-dim); font-size: .85rem; padding: 12px; text-align: center; grid-column: 1/-1; }
.prop-cell {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.prop-cell .pl {
  font-size: .68rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 700;
}
.prop-cell .pv {
  font-family: var(--mono); font-size: .92rem; font-weight: 700;
  color: var(--text); margin-top: 2px;
}
.prop-cell .pv.accent { color: var(--accent-hi); }
.prop-cell .pv.gold { color: var(--gold); }
.prop-cell .pu { font-size: .72rem; color: var(--text-dim); font-weight: 500; }
.prop-uses {
  grid-column: 1/-1;
  background: var(--accent-lo); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 8px 12px;
  font-size: .85rem; color: var(--text); line-height: 1.5;
}

/* Isotope panel */
.iso-panel {
  font-size: .88rem; line-height: 1.55; color: var(--text);
}
.iso-panel .iso-line { margin-bottom: 6px; }
.iso-panel .iso-line strong { color: var(--accent-hi); }
.iso-nz {
  display: block; margin-top: 10px;
  width: 100%; max-width: 460px; height: 180px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}

/* Keyboard list */
.kbd-list { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.kbd-list li { padding: 4px 0; color: var(--text); }
.kbd-list kbd {
  display: inline-block; padding: 2px 8px; min-width: 24px; text-align: center;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; font-family: var(--mono); font-size: .78rem;
  color: var(--accent-hi); font-weight: 700;
  box-shadow: 0 2px 0 var(--border);
}

/* Drag-to-remove flash */
.canvas-card.drag-out-zone { box-shadow: inset 0 0 0 3px var(--red); }
.canvas-card.drag-out-zone::after {
  content: 'Release to remove ↗';
  position: absolute; top: 10px; right: 18px;
  background: var(--red); color: #fff;
  padding: 4px 10px; border-radius: 8px;
  font-size: .78rem; font-weight: 700;
  z-index: 4; pointer-events: none;
}

/* Stability mini-chart on PT panel */
.stability-mini {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px;
}
.stability-mini-title {
  font-size: .68rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.stability-mini canvas { width: 100%; height: 100px; display: block; border-radius: 4px; }

@media (max-width: 768px) {
  .el-search { min-width: 160px; max-width: 100%; }
  .canvas-toggles { gap: 4px; }
  .ct-chip { font-size: .68rem; padding: 4px 8px; }
  .ct-speed { font-size: .68rem; min-width: 140px; }
  .props-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .props-grid { grid-template-columns: 1fr; }
  .pill { padding: 10px 12px; min-height: 44px; }
  .learn-panels { padding: 10px; }
  .iso-chip { font-size: .72rem; }
}

