/* Word Universe — All Styles */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --deep-space: #0D0D12;
  --nebula-surface: #13131A;
  --nebula-elevated: #181821;
  --star-white: #E4E4E7;
  --cosmic-dust: #71717A;
  --cluster-blue: #6B7FD7;
  --action-orange: #E07A4A;
  --abstract-violet: #9B8ACB;
  --nature-green: #5B9A6B;
  --social-coral: #D47F7F;
  --focused-gold: #C9A84C;
  --wireframe-gray: #2A2A35;
  --whisper-border: rgba(255,255,255,0.05);
  --whisper-border-strong: rgba(255,255,255,0.1);
  --whisper-border-active: rgba(255,255,255,0.18);

  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--deep-space);
  color: var(--star-white);
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button { font-family: inherit; }

/* ── App Layout ─────────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100dvh; }

/* ── Top Bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--whisper-border);
  flex-shrink: 0;
  background: rgba(13,13,18,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 50;
  position: relative;
}

.topbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--star-white);
  text-decoration: none;
}
.topbar-logo svg { width: 22px; height: 22px; flex-shrink: 0; }

/* Stats */
.topbar-stats {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0.75rem;
  background: rgba(255,255,255,0.015);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-pill);
}
.stat-item { display: inline-flex; align-items: baseline; gap: 0.35rem; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--star-white);
  font-variant-numeric: tabular-nums;
}
.stat-num-gold { color: var(--focused-gold); }
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cosmic-dust);
}
.stat-divider {
  width: 1px;
  height: 10px;
  background: var(--whisper-border-strong);
}

/* Right group */
.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Search */
.topbar-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 260px;
  height: 34px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-pill);
  padding: 0 0.5rem 0 0.875rem;
  transition: border-color 0.18s, background 0.18s, width 0.25s var(--ease-out);
}
.topbar-search:focus-within {
  border-color: var(--cluster-blue);
  background: rgba(107,127,215,0.06);
  width: 320px;
}
.search-icon {
  width: 14px; height: 14px;
  color: var(--cosmic-dust);
  flex-shrink: 0;
  margin-right: 0.5rem;
}
.topbar-search:focus-within .search-icon { color: var(--cluster-blue); }
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--star-white);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 400;
  min-width: 0;
}
.search-input::placeholder { color: rgba(228,228,231,0.3); }
.search-kbd {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--cosmic-dust);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--whisper-border);
  padding: 0.1rem 0.375rem;
  border-radius: 4px;
  margin-left: 0.375rem;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.topbar-search:focus-within .search-kbd { opacity: 0; }

/* Search results dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--nebula-elevated);
  border: 1px solid var(--whisper-border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  max-height: 360px;
  overflow-y: auto;
  padding: 0.375rem;
  z-index: 60;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}
.search-result-item:hover,
.search-result-item.active {
  background: rgba(255,255,255,0.05);
}
.result-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.result-text { flex: 1; min-width: 0; }
.result-word {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--star-white);
  letter-spacing: -0.01em;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-def {
  font-size: 0.75rem;
  color: var(--cosmic-dust);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-mastery-pip {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--focused-gold); opacity: 0.85;
  flex-shrink: 0;
}
.search-empty {
  padding: 1rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--cosmic-dust);
  text-align: center;
}

/* Icon buttons */
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--whisper-border);
  border-radius: 50%;
  color: rgba(228,228,231,0.55);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover {
  color: var(--star-white);
  border-color: var(--whisper-border-active);
  background: rgba(255,255,255,0.03);
}
.icon-btn svg { width: 15px; height: 15px; }
.mobile-search-btn { display: none; }

/* Lang toggle */
.lang-toggle {
  background: transparent;
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.05em;
  color: rgba(228,228,231,0.45);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.lang-toggle:hover { color: var(--star-white); border-color: var(--whisper-border-active); }

/* ── Graph Canvas ─────────────────────────────────────────────────────────── */
.graph-canvas { flex: 1; position: relative; overflow: hidden; }
#graph-container { width: 100%; height: 100%; position: relative; }

.graph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  color: var(--cosmic-dust);
  text-align: center;
  pointer-events: none;
  animation: float-seed 3s ease-in-out infinite;
}
@keyframes float-seed {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.graph-empty svg { opacity: 0.55; }
.graph-empty-title { font-size: 0.9375rem; line-height: 1.7; }

/* Nodes */
.node-glow { transition: opacity 0.2s, r 0.2s; }
.node-circle { transition: opacity 0.2s, r 0.2s; }

/* Search highlight on node */
.node-circle.search-hit { stroke: var(--star-white); stroke-width: 2px; }

/* ── Star Tooltip ───────────────────────────────────────────────────── */
.star-tooltip {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  background: var(--nebula-elevated);
  border: 1px solid var(--whisper-border-strong);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  min-width: 180px;
  max-width: 260px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(4px) scale(0.96);
  transition: opacity 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}
.star-tooltip.visible { opacity: 1; transform: translateY(0) scale(1); }
.tooltip-head { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.tooltip-word {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--star-white);
}
.tooltip-lang {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  color: var(--cosmic-dust);
  text-transform: uppercase;
}
.tooltip-meta { margin-bottom: 0.375rem; }
.tooltip-cluster {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tooltip-def {
  font-size: 0.75rem;
  color: rgba(228,228,231,0.65);
  line-height: 1.55;
  margin-bottom: 0.5rem;
}
.tooltip-def:empty { display: none; }
.tooltip-mastery {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.tooltip-pip {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(228,228,231,0.18);
}
.tooltip-pip.filled { background: var(--focused-gold); }

/* ── Zoom Toolbar ───────────────────────────────────────────────────── */
.zoom-toolbar {
  position: absolute;
  right: 1.5rem;
  bottom: 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(19,19,26,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  z-index: 30;
}
.zoom-btn {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: rgba(228,228,231,0.55);
  cursor: pointer;
  transition: all 0.15s;
}
.zoom-btn svg { width: 14px; height: 14px; }
.zoom-btn:hover { color: var(--star-white); background: rgba(255,255,255,0.05); }
.zoom-divider { width: 60%; height: 1px; background: var(--whisper-border); margin: 0.25rem 0; }

/* ── FAB ───────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(19,19,26,0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--star-white);
  border: 1px solid var(--whisper-border-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  transition: all 0.2s var(--ease-spring);
}
.fab:hover {
  transform: translateY(-2px);
  border-color: var(--cluster-blue);
  color: var(--cluster-blue);
  box-shadow: 0 12px 32px rgba(0,0,0,0.55), 0 0 0 4px rgba(107,127,215,0.08);
}
.fab:active { transform: translateY(0) scale(0.96); }
.fab svg { width: 20px; height: 20px; }

/* ── Cluster Filter ───────────────────────────────────────────────────── */
.cluster-filter {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  z-index: 30;
  max-width: calc(100% - 6rem);
}
.cluster-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.625rem 0.3rem 0.5rem;
  background: rgba(19,19,26,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: rgba(228,228,231,0.5);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cluster-chip:hover {
  color: var(--star-white);
  border-color: var(--whisper-border-active);
}
.cluster-chip.active {
  background: rgba(255,255,255,0.06);
  border-color: var(--whisper-border-active);
  color: var(--star-white);
}
.cluster-chip.dimmed { opacity: 0.45; }
.chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-dot-all {
  position: relative;
  width: 10px; height: 10px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: none;
}
.chip-dot-all span {
  width: 100%; height: 100%; border-radius: 50%;
}
.chip-dot-all span:nth-child(1) { background: #6B7FD7; }
.chip-dot-all span:nth-child(2) { background: #9B8ACB; }
.chip-dot-all span:nth-child(3) { background: #5B9A6B; }
.chip-dot-all span:nth-child(4) { background: #E07A4A; }
.chip-dot-all span:nth-child(5) { display: none; }
.chip-label { font-family: var(--font-sans); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0; }
.chip-count {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--cosmic-dust);
  font-variant-numeric: tabular-nums;
  padding-left: 0.125rem;
}
.cluster-chip.active .chip-count { color: rgba(228,228,231,0.75); }
.cluster-chip[data-cluster="__mastered"] .chip-label { color: inherit; }

/* ── Modal Overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(13,13,18,0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-card {
  background: var(--nebula-surface);
  border: 1px solid var(--whisper-border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 2.25rem;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  transform: scale(0.96);
  transition: transform 0.22s var(--ease-spring);
}
.modal-overlay.active .modal-card { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--whisper-border);
  color: rgba(228,228,231,0.5);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.06); color: var(--star-white); border-color: var(--whisper-border-active); }
.modal-close svg { width: 13px; height: 13px; }

.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(228,228,231,0.6);
  margin-bottom: 0.4rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-sm);
  color: var(--star-white);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 0.575rem 0.75rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--cluster-blue);
  background: rgba(107,127,215,0.04);
}
.form-input::placeholder, .form-textarea::placeholder { color: rgba(228,228,231,0.2); }
.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1l4 4 4-4' stroke='%2371717A' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  padding-right: 1.75rem;
}
.form-textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
.form-textarea-sm { min-height: 56px; }

.modal-hint {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: rgba(228,228,231,0.3);
  margin-top: 0.5rem;
  line-height: 1.5;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 0.625rem; margin-top: 1.5rem; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  background: var(--cluster-blue); color: #fff;
  font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 600;
  border: none; border-radius: var(--radius-pill); cursor: pointer;
  transition: all 0.15s;
}
.btn-primary:hover { background: #828fef; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  padding: 0.55rem 1rem;
  background: transparent; color: rgba(228,228,231,0.6);
  border: 1px solid var(--whisper-border);
  font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500;
  border-radius: var(--radius-pill); cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--star-white); border-color: var(--whisper-border-active); }
.btn-ghost-sm { padding: 0.4rem 0.875rem; font-size: 0.75rem; }

/* ── Settings Popover ────────────────────────────────────────────────── */
.popover-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(13,13,18,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 4.25rem 1.25rem 1.25rem;
}
.popover-card {
  background: var(--nebula-surface);
  border: 1px solid var(--whisper-border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 360px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: popoverIn 0.18s var(--ease-spring);
}
@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.popover-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.popover-section {
  padding: 1rem 0;
  border-top: 1px solid var(--whisper-border);
}
.popover-section:first-of-type { border-top: none; padding-top: 0; }

.api-key-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.api-key-row .form-input { flex: 1; }

.shortcuts-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.shortcuts-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: rgba(228,228,231,0.7);
}
.shortcuts-list li span {
  margin-left: auto;
  color: rgba(228,228,231,0.55);
  font-size: 0.75rem;
}
.shortcuts-list kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 0.375rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--whisper-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--star-white);
}

.popover-danger { padding-top: 1rem; }
.popover-danger-btn {
  width: 100%;
  padding: 0.55rem;
  background: transparent;
  border: 1px solid rgba(212,127,127,0.25);
  border-radius: var(--radius-sm);
  color: rgba(212,127,127,0.7);
  font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.popover-danger-btn:hover {
  border-color: rgba(212,127,127,0.6);
  color: var(--social-coral);
  background: rgba(212,127,127,0.05);
}

/* ── Word Detail Panel ────────────────────────────────────────────────────── */
.word-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--nebula-surface);
  border-left: 1px solid var(--whisper-border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s var(--ease-out);
  overflow: hidden;
}
.word-panel.open { transform: translateX(0); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--whisper-border);
  flex-shrink: 0;
}

.panel-word-title { display: flex; align-items: baseline; gap: 0.75rem; min-width: 0; }
.panel-word {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.025em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-lang {
  font-family: var(--font-mono); font-size: 0.5625rem; font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-pill);
  color: var(--cosmic-dust);
}

.panel-close {
  width: 28px; height: 28px;
  background: transparent; border: 1px solid var(--whisper-border);
  border-radius: 50%; color: rgba(228,228,231,0.5);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.panel-close:hover { background: rgba(255,255,255,0.06); color: var(--star-white); }

.panel-swipe-handle { display: none; }

.panel-body { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem; }

.panel-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.5rem; margin-bottom: 1.5rem;
}
.panel-meta-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
}
.panel-meta-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cosmic-dust);
  margin-bottom: 0.25rem;
}
.panel-meta-value { font-size: 0.8125rem; color: var(--star-white); }

.panel-section { margin-bottom: 1.25rem; }
.panel-section-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cosmic-dust);
  margin-bottom: 0.5rem;
}
.panel-section-text { font-size: 0.875rem; color: rgba(228,228,231,0.78); line-height: 1.65; }

/* Mastery dots */
.mastery-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0 1.5rem;
  padding: 0.75rem 0.875rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-sm);
}
.mastery-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cosmic-dust);
}
.mastery-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.mastery-dot {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.dot-pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(228,228,231,0.25);
  background: transparent;
  transition: all 0.15s var(--ease-out);
}
.mastery-dot:hover .dot-pip { border-color: var(--focused-gold); }
.mastery-dot.filled .dot-pip {
  background: var(--focused-gold);
  border-color: var(--focused-gold);
}
.mastery-dot.mastered .dot-pip {
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}
.mastery-level-text {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--focused-gold);
  margin-left: auto;
  letter-spacing: -0.01em;
}

/* Similar Words */
.panel-section-similar { margin-top: 0.5rem; }
.similar-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.similar-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.similar-item:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--whisper-border-active);
  transform: translateX(2px);
}
.similar-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.similar-word { flex: 1; font-size: 0.8125rem; color: var(--star-white); font-weight: 500; }
.similar-score {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--cosmic-dust);
  font-variant-numeric: tabular-nums;
}

.panel-danger { margin-top: auto; padding: 1.25rem 1.5rem; border-top: 1px solid var(--whisper-border); }
.panel-danger-btn {
  width: 100%;
  padding: 0.55rem;
  background: transparent;
  border: 1px solid rgba(212,127,127,0.25);
  border-radius: var(--radius-sm);
  color: rgba(212,127,127,0.65);
  font-family: var(--font-sans); font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
}
.panel-danger-btn:hover {
  border-color: rgba(212,127,127,0.6);
  color: var(--social-coral);
  background: rgba(212,127,127,0.05);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 5.5rem; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--nebula-elevated);
  border: 1px solid var(--whisper-border-strong);
  color: var(--star-white);
  font-size: 0.8125rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-pill);
  opacity: 0; pointer-events: none;
  transition: all 0.25s var(--ease-out);
  z-index: 600; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Guide Overlay ──────────────────────────────────────────────────── */
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(13,13,18,0.92);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.guide-overlay.active { opacity: 1; pointer-events: all; }

.guide-card {
  background: var(--nebula-surface);
  border: 1px solid var(--whisper-border-strong);
  border-radius: 1.5rem;
  padding: 2.25rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 32px 100px rgba(0,0,0,0.8);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s var(--ease-spring);
}
.guide-overlay.active .guide-card { transform: scale(1) translateY(0); }

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.guide-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cluster-blue);
}
.guide-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(228,228,231,0.2);
  letter-spacing: 0.08em;
}
.guide-steps { display: flex; gap: 0.5rem; margin-bottom: 1.75rem; }
.guide-dot {
  width: 24px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  transition: background 0.2s;
}
.guide-dot.active { background: var(--cluster-blue); }

.guide-visual {
  width: 100%;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--whisper-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.guide-visual svg { width: 100%; height: auto; display: block; }
.guide-visual.hidden { display: none; }

.guide-step-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--star-white);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}
.guide-step-desc {
  font-size: 0.9375rem;
  color: rgba(228,228,231,0.5);
  line-height: 1.65;
  margin-bottom: 1.75rem;
}

.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.guide-skip {
  background: transparent;
  border: none;
  color: rgba(228,228,231,0.3);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.15s;
}
.guide-skip:hover { color: rgba(228,228,231,0.6); }

.guide-next {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  background: var(--cluster-blue);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s;
}
.guide-next:hover { background: #828fef; transform: translateY(-1px); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .topbar { gap: 0.75rem; padding: 0.75rem 1rem; }
  .topbar-stats { gap: 0.625rem; padding: 0.2rem 0.625rem; }
  .stat-label { display: none; }
  .stat-divider { height: 8px; }
  .topbar-search { width: 200px; }
  .topbar-search:focus-within { width: 240px; }
}

@media (max-width: 640px) {
  .topbar { gap: 0.5rem; padding: 0.625rem 0.875rem; grid-template-columns: auto 1fr auto; }
  .topbar-brand { display: none; }
  .topbar-stats {
    justify-self: center;
    gap: 0.5rem;
    padding: 0.2rem 0.5rem;
  }
  .topbar-search { display: none; }
  .topbar-search.mobile-open {
    display: inline-flex;
    position: fixed;
    top: 0.625rem; left: 0.875rem; right: 0.875rem;
    width: auto !important;
    z-index: 70;
    height: 38px;
    background: var(--nebula-elevated);
  }
  .topbar-search.mobile-open:focus-within { width: auto !important; }
  .mobile-search-btn { display: inline-flex; }

  .word-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--whisper-border);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    top: auto;
    height: 88dvh;
    transform: translateY(100%);
  }
  .word-panel.open { transform: translateY(0); }
  .panel-swipe-handle {
    display: block;
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 0.5rem auto 0;
  }
  .form-row { grid-template-columns: 1fr; }

  .cluster-filter {
    bottom: 1rem;
    left: 0.875rem;
    right: 5rem;
    max-width: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }
  .cluster-filter::-webkit-scrollbar { display: none; }

  .fab {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
  }
  .zoom-toolbar {
    right: 0.875rem;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }
  .toast { bottom: 5.5rem; }
  .popover-overlay { padding: 4rem 0.875rem 0.875rem; align-items: flex-start; justify-content: center; }
  .popover-card { max-width: none; }
}

@media (max-width: 380px) {
  .stat-num { font-size: 0.75rem; }
  .topbar-stats { gap: 0.375rem; }
}
