/* Quantum Learn — dark academic aesthetic */
:root {
  --bg: #070b16;
  --bg-elev: #0c1224;
  --bg-card: #10182c;
  --bg-card-hover: #152038;
  --navy: #0a1628;
  --cyan: #22d3ee;
  --cyan-dim: #0891b2;
  --violet: #a78bfa;
  --violet-deep: #7c3aed;
  --magenta: #e879f9;
  --text: #e8eef8;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: rgba(34, 211, 238, 0.15);
  --border-strong: rgba(34, 211, 238, 0.35);
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: "Inter", "Noto Sans TC", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
  --sidebar-w: 260px;
  --header-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  font-size: 16px;
}

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

/* Ambient background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124, 58, 237, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(8, 145, 178, 0.14), transparent 45%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(34, 211, 238, 0.06), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--cyan); text-decoration: none; transition: color 0.2s; }
a:hover { color: #67e8f9; }

img, svg { display: block; max-width: 100%; }

/* —— Header —— */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem 0 1rem;
  background: rgba(7, 11, 22, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan-dim), var(--violet-deep));
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.35);
}

.brand-mark svg { width: 22px; height: 22px; }

.brand-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.lang-toggle button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-toggle button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--cyan-dim), var(--violet-deep));
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
}

.menu-btn {
  display: none;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
}

/* —— Layout —— */
.layout {
  display: flex;
  position: relative;
  z-index: 1;
  padding-top: var(--header-h);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 1.25rem 0.85rem 2rem;
  background: rgba(10, 14, 28, 0.92);
  border-right: 1px solid var(--border);
  z-index: 50;
  transition: transform 0.3s var(--ease);
}

.sidebar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 0 0.65rem 0.5rem;
}

.nav-chapters {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-chapters a {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.nav-chapters a:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-chapters a.active {
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.12), rgba(124, 58, 237, 0.08));
  color: var(--cyan);
  border-color: var(--border);
}

.nav-num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--violet);
  margin-top: 1px;
}

.nav-chapters a.active .nav-num {
  background: rgba(34, 211, 238, 0.15);
  border-color: var(--border-strong);
  color: var(--cyan);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  max-width: 920px;
  padding: 0 1.75rem 5rem;
}

/* —— Hero —— */
.hero {
  padding: 3.5rem 0 2.5rem;
  position: relative;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid var(--border);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
  animation: fadeUp 0.7s var(--ease) both;
}

.hero-eyebrow::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: pulse 2s ease infinite;
}

.hero h1 {
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 1rem;
  animation: fadeUp 0.7s 0.08s var(--ease) both;
}

.hero h1 .accent {
  background: linear-gradient(120deg, var(--cyan), var(--violet), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 38em;
  margin-bottom: 1.75rem;
  animation: fadeUp 0.7s 0.16s var(--ease) both;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  animation: fadeUp 0.7s 0.24s var(--ease) both;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.25s var(--ease);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan-dim), var(--violet-deep));
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.5);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--cyan);
}

.honesty-banner {
  margin-top: 2rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: rgba(251, 191, 36, 0.06);
  border: 1px solid rgba(251, 191, 36, 0.25);
  font-size: 0.875rem;
  color: var(--text-muted);
  animation: fadeUp 0.7s 0.32s var(--ease) both;
}

.honesty-banner strong { color: var(--warn); }

/* —— Sections —— */
.chapter {
  padding: 3rem 0 2rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 12px);
}

.chapter-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--violet);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.chapter h2 {
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.chapter-lead {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 1.75rem;
  max-width: 42em;
}

.prose p { margin-bottom: 1rem; color: var(--text-muted); }
.prose p strong, .prose li strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol {
  margin: 0 0 1.25rem 1.25rem;
  color: var(--text-muted);
}
.prose li { margin-bottom: 0.45rem; }
.prose h3 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem;
  color: var(--text);
}
.prose h4 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--cyan);
}

.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--cyan);
  background: rgba(34, 211, 238, 0.06);
  font-size: 0.925rem;
  color: var(--text-muted);
}

.callout.warn {
  border-left-color: var(--warn);
  background: rgba(251, 191, 36, 0.06);
}

.callout.danger {
  border-left-color: var(--danger);
  background: rgba(248, 113, 113, 0.06);
}

.callout.violet {
  border-left-color: var(--violet);
  background: rgba(167, 139, 250, 0.08);
}

.callout-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

/* —— Cards / grids —— */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  transition: border-color 0.25s, transform 0.25s var(--ease), background 0.25s;
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.card h3, .card h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.card p, .card li {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.card .tag {
  display: inline-block;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.875rem;
}

.compare-table th, .compare-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.compare-table th {
  background: var(--bg-elev);
  color: var(--cyan);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compare-table td { color: var(--text-muted); }
.compare-table tr:hover td { background: rgba(34, 211, 238, 0.03); }

/* —— Interactive panels —— */
.lab {
  margin: 1.75rem 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.lab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 24, 44, 0.8);
}

.lab-title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lab-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.lab-body {
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

.lab-body.split {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.lab-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.lab-controls label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.lab-controls input[type="range"] {
  width: 120px;
  accent-color: var(--cyan);
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-family: var(--mono);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover, .chip.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
}

.chip.gate-x:hover, .chip.gate-x.active { border-color: #f87171; color: #f87171; background: rgba(248,113,113,0.1); }
.chip.gate-z:hover, .chip.gate-z.active { border-color: #60a5fa; color: #60a5fa; background: rgba(96,165,250,0.1); }
.chip.gate-h:hover, .chip.gate-h.active { border-color: #a78bfa; color: #a78bfa; background: rgba(167,139,250,0.1); }
.chip.gate-cnot:hover, .chip.gate-cnot.active { border-color: #34d399; color: #34d399; background: rgba(52,211,153,0.1); }

canvas.viz {
  width: 100%;
  max-width: 360px;
  height: auto;
  border-radius: var(--radius-sm);
  background: #060a14;
  margin: 0 auto;
  display: block;
  touch-action: none;
}

.prob-bars {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.prob-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.2rem;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.prob-label { color: var(--violet); }
.prob-track {
  height: 18px;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  overflow: hidden;
}
.prob-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cyan-dim), var(--violet));
  transition: width 0.45s var(--ease);
  min-width: 0;
}
.prob-val { color: var(--text-muted); text-align: right; }

.state-eq {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  text-align: center;
  margin-top: 0.75rem;
}

/* Hardware cards */
.hw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.hw-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.25s var(--ease);
}

.hw-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}

.hw-icon {
  width: 48px; height: 48px;
  margin-bottom: 0.85rem;
  color: var(--cyan);
}

.hw-card h4 {
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

.hw-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.hw-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hw-meta span {
  font-size: 0.65rem;
  font-family: var(--mono);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: rgba(167, 139, 250, 0.12);
  color: var(--violet);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

/* Algorithm steps */
.algo-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0;
  counter-reset: step;
}

.algo-step {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  counter-increment: step;
}

.algo-step::before {
  content: counter(step);
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan-dim), var(--violet-deep));
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.algo-step h4 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.algo-step p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

/* Grover canvas area */
#grover-canvas, #bell-canvas, #bloch-canvas, #gate-canvas {
  cursor: grab;
}
#bloch-canvas:active, #bell-canvas:active { cursor: grabbing; }

.hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.5rem;
}

/* Footer */
.site-footer {
  margin-left: var(--sidebar-w);
  padding: 2.5rem 1.75rem 3rem;
  border-top: 1px solid var(--border);
  max-width: 920px;
  font-size: 0.8rem;
  color: var(--text-dim);
  position: relative;
  z-index: 1;
}

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--cyan); }
.footer-attr { margin-top: 0.75rem; line-height: 1.6; }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main, .site-footer { margin-left: 0; }
  .menu-btn { display: grid; place-items: center; }
  .lab-body.split { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
  }
  .sidebar-backdrop.show { display: block; }
}

@media (max-width: 600px) {
  .main { padding: 0 1rem 4rem; }
  .hero { padding: 2rem 0 1.5rem; }
  .brand-text span:last-child { display: none; }
}


/* gate chips polish */
.lab-controls .chip {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  min-width: 2.5rem;
}

/* —— Mindmaps —— */
.mm-card {
  margin: 1.25rem 0 1.75rem;
  padding: 1rem 1rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mm-card-lg { padding: 1.25rem 1.25rem 1rem; }
.mm-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 0.75rem;
}
.mm-host { width: 100%; overflow-x: auto; }
.mm-wrap { position: relative; }
.mm-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.mm-svg {
  width: 100%;
  height: auto;
  min-height: 280px;
  display: block;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(124, 58, 237, 0.08), transparent 60%),
    linear-gradient(180deg, rgba(16, 24, 44, 0.4), transparent);
  border-radius: var(--radius-sm);
}
.mm-compact .mm-svg { min-height: 240px; }
.mm-edge {
  fill: none;
  stroke: rgba(34, 211, 238, 0.35);
  stroke-width: 1.6;
  transition: stroke 0.2s, opacity 0.2s;
}
.mm-edge.hot { stroke: var(--cyan); stroke-width: 2.2; }
.mm-edge.dim { opacity: 0.2; }
.mm-edge-label {
  fill: var(--text-dim);
  font-size: 9px;
  font-family: var(--font);
  text-anchor: middle;
  pointer-events: none;
}
.mm-node { cursor: pointer; transition: opacity 0.2s; }
.mm-node.dim { opacity: 0.35; }
.mm-node-bg {
  fill: var(--bg-elev);
  stroke: rgba(34, 211, 238, 0.35);
  stroke-width: 1.2;
  transition: fill 0.2s, stroke 0.2s, filter 0.2s;
}
.mm-node-center {
  fill: rgba(124, 58, 237, 0.25);
  stroke: var(--violet);
}
.mm-node.hot .mm-node-bg,
.mm-node:hover .mm-node-bg {
  fill: rgba(8, 145, 178, 0.25);
  stroke: var(--cyan);

}
.mm-node-label {
  fill: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font);
  pointer-events: none;
}
.mm-hint {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
}

/* —— Glossary —— */
.gloss-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 1rem 0 1.25rem;
  position: sticky;
  top: calc(var(--header-h) + 4px);
  z-index: 5;
  padding: 0.85rem 1rem;
  background: rgba(12, 18, 36, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.gloss-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.gloss-search {
  flex: 1;
  min-width: 200px;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gloss-search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}
.gloss-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gloss-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.gloss-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.gloss-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.gloss-chip.active {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.35), rgba(124, 58, 237, 0.35));
  color: var(--text);
  border-color: var(--cyan-dim);
}
.gloss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}
.gloss-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.gloss-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}
.gloss-card:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.gloss-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.gloss-term {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1.3;
}
.gloss-cat-pill {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(167, 139, 250, 0.15);
  color: var(--violet);
  border: 1px solid rgba(167, 139, 250, 0.25);
}
.gloss-plain {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gloss-card.expanded .gloss-plain {
  display: block;
  -webkit-line-clamp: unset;
  color: var(--text);
}
.gloss-extra {
  display: none;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.gloss-card.expanded .gloss-extra { display: block; }
.gloss-also { margin-bottom: 0.4rem; color: var(--text-dim); }
.gloss-also-label { color: var(--text-muted); margin-right: 0.25rem; }
.gloss-also code {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: rgba(34, 211, 238, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--cyan);
  margin-right: 0.25rem;
}
.gloss-chapter {
  display: inline-block;
  margin-top: 0.25rem;
  font-weight: 600;
  color: var(--violet);
}
.gloss-chapter:hover { color: #c4b5fd; }

@media (max-width: 600px) {
  .gloss-toolbar { position: static; }
  .gloss-grid { grid-template-columns: 1fr; }
  .mm-node-label { font-size: 9px; }
}
