:root {
  --bg: #070a12;
  --bg-surface: #0e1424;
  --card-bg: #121a2d;
  --card-border: rgba(168, 85, 247, 0.22);
  --card-hover: rgba(168, 85, 247, 0.45);
  --border-dim: rgba(255, 255, 255, 0.08);
  --accent: #a855f7;
  --accent-glow: rgba(168, 85, 247, 0.25);
  --accent-light: #c084fc;
  --cyan: #38bdf8;
  --gold: #fbbf24;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Underdark Glow */
.glow-bg {
  position: fixed;
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 480px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, rgba(56, 189, 248, 0.04) 50%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 16, 28, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-dim);
  padding: 12px 20px;
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.6));
}
.brand-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
}
.brand-subtitle {
  font-size: 11px;
  color: var(--accent-light);
  font-family: var(--font-mono);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-dim);
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tab-icon {
  font-size: 14px;
}
.tab-label {
  font-size: 12px;
}
.tab-btn:hover { color: #fff; }
.tab-btn.active {
  background: var(--accent);
  color: #070a12;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.35);
}

/* Main Container */
.main-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 80px 20px;
  position: relative;
  z-index: 10;
}

/* View Panels */
.view-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
}
.view-panel.active {
  display: flex;
}

/* ========================================================================= */
/* TRANSLATOR WORKSPACE                                                      */
/* ========================================================================= */
.translator-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.mode-switch-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 20, 36, 0.9);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn.active {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.mode-swap-btn {
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s ease;
}
.mode-swap-btn:hover {
  color: #fff;
  border-color: var(--accent);
  transform: rotate(180deg);
}

.sample-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sample-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.sample-select {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}
.sample-select:focus, .sample-select:hover {
  border-color: var(--accent);
  color: #fff;
}

/* Translator Cards Grid */
.translator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .translator-grid { grid-template-columns: 1fr; }
}

.trans-card {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease;
}
.trans-card:focus-within {
  border-color: var(--accent);
}
.trans-card.output-card {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(18, 26, 45, 0.95);
}

.trans-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.trans-lang-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.trans-lang-tag.accent {
  color: var(--accent-light);
}
.trans-action-link {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.trans-action-link:hover { color: #fff; }

.trans-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
  min-height: 120px;
}
.trans-textarea::placeholder { color: var(--text-dim); }

.trans-output-box {
  min-height: 120px;
  font-size: 15.5px;
  line-height: 1.55;
  color: #fff;
  font-family: var(--font-sans);
  white-space: pre-wrap;
  word-break: break-word;
}
.placeholder-text {
  color: var(--text-dim);
  font-style: italic;
  font-size: 14px;
}

/* Tokens */
.unmatched-token {
  border-bottom: 1.5px dotted var(--gold);
  color: #fde68a;
}
.unmatched-token.phonetic-token {
  border-bottom: 1.5px dashed var(--accent-light);
  color: #e9d5ff;
}
.matched-token {
  color: #c084fc;
  font-weight: 600;
}

/* Single-Word Detailed Definition Spotlight (Feature #2) */
.single-word-spotlight {
  background: rgba(14, 20, 36, 0.85);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 30px rgba(168, 85, 247, 0.15);
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.spotlight-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.spotlight-drow {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-light);
}
.spotlight-pronunciation {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.spotlight-common {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.spotlight-synonym-pill {
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent-light);
}
.spotlight-notes {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.spotlight-source {
  font-size: 11.5px;
  color: var(--text-dim);
  border-top: 1px dashed var(--border-dim);
  padding-top: 6px;
  margin-top: 4px;
}
.token-sources-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-dim);
  font-size: 11.5px;
  color: var(--text-dim);
}
.source-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-dim);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-muted);
}
.dict-source {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* Collapsible Sources Tray (Collapsed by Default) */
.dict-sources-details {
  display: inline-block;
  cursor: pointer;
  position: relative;
  max-width: 100%;
}
.dict-sources-details[open] {
  width: 100%;
}
.dict-sources-summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  outline: none;
  user-select: none;
  cursor: pointer;
}
.dict-sources-summary::-webkit-details-marker {
  display: none;
}
.dict-source-link {
  font-size: 10.5px;
  color: var(--text-dim);
  font-style: italic;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s ease;
  max-width: 100%;
}
.dict-sources-details:hover .dict-source-link,
.dict-sources-details[open] .dict-source-link {
  color: var(--accent-light);
}
.sources-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  font-style: normal;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: var(--accent-light);
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}
.dict-sources-tray {
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(7, 10, 18, 0.95);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: fadeInTray 0.15s ease-out;
  width: 100%;
}
@keyframes fadeInTray {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.dict-sources-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-bottom: 5px;
  font-weight: 700;
}
.dict-sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dict-sources-list li {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.4;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.dict-sources-list li::before {
  content: "•";
  color: var(--accent);
  font-weight: bold;
}

/* Tokens Analysis Section */
.tokens-section {
  background: rgba(14, 20, 36, 0.7);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 12px 16px;
}
.tokens-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.tokens-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.token-chip {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.token-chip-drow { color: var(--accent-light); font-weight: 700; }
.token-chip-common { color: var(--text-muted); }

/* ========================================================================= */
/* TAB 2: NAME & HOUSE ENGINE (Feature #1)                                    */
/* ========================================================================= */
.names-header-card {
  background: linear-gradient(135deg, rgba(20, 28, 48, 0.8) 0%, rgba(14, 20, 36, 0.95) 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 18px 24px;
}
.names-intro h2 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.names-intro p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* 3-Part Sub-Navigation Dock */
.names-subnav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 20, 36, 0.85);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 6px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.names-sub-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 44px;
  white-space: nowrap;
}
.names-sub-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.names-sub-btn.active {
  background: rgba(168, 85, 247, 0.2);
  color: #fff;
  border-color: rgba(168, 85, 247, 0.45);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.25);
  font-weight: 700;
}
@media (max-width: 600px) {
  .names-sub-btn {
    padding: 8px 6px;
    font-size: 11px;
    gap: 4px;
  }
}

.names-subpanel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeInPanel 0.2s ease-out;
}
@keyframes fadeInPanel {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.names-box {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.box-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: 0.04em;
}
.box-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.box-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.form-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.pill-radio-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border-dim);
}
.pill-radio {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill-radio.active {
  background: rgba(168, 85, 247, 0.25);
  color: #fff;
  font-weight: 700;
}

.theme-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}

.btn-generate-main {
  background: var(--accent);
  color: #070a12;
  border: none;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
  transition: all 0.15s ease;
}
.btn-generate-main:hover {
  background: #c084fc;
  transform: translateY(-1px);
}

.generated-results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.name-result-card {
  background: rgba(14, 20, 36, 0.85);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease;
}
.name-result-card:hover {
  border-color: var(--accent);
}
.name-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.name-full {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}
.name-meaning {
  font-size: 12.5px;
  color: var(--accent-light);
  font-style: italic;
}
.name-breakdown {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}
.name-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
  gap: 8px;
}
.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.btn-star-save {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-star-save:hover {
  background: rgba(251, 191, 36, 0.15);
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.4);
}
.btn-star-save.saved {
  background: rgba(251, 191, 36, 0.2);
  color: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
}
.btn-decode-action {
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 8px;
  color: var(--accent-light);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-decode-action:hover {
  background: rgba(168, 85, 247, 0.25);
  color: #fff;
  border-color: var(--accent);
}

/* Quick samples */
.quick-names-samples {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chip-sample {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip-sample:hover {
  color: #fff;
  border-color: var(--accent);
}

.lookup-results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}

/* Noble Houses Showcase */
.houses-showcase-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.showcase-title {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.houses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.house-card {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}
.house-card:hover {
  border-color: var(--card-hover);
  transform: translateY(-2px);
}
.house-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.house-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-light);
}
.house-rank {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}
.house-meaning {
  font-size: 12.5px;
  color: #fff;
  font-weight: 600;
}
.house-motto {
  font-size: 11.5px;
  color: var(--cyan);
  font-style: italic;
}
.house-lore {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ========================================================================= */
/* THE GREAT DROW ARCHIVE & SAVED ROSTER                                     */
/* ========================================================================= */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
@media (max-width: 640px) {
  .archive-grid {
    grid-template-columns: 1fr;
  }
}
.archive-card {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.archive-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.15);
}
.archive-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.archive-name {
  font-family: var(--font-mono);
  font-size: 15.5px;
  font-weight: 800;
  color: #fff;
}
.archive-cat-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2.5px 7.5px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-eilistraee {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.badge-bg3 {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.35);
}
.badge-campaign {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.45);
}
.badge-menzo {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.badge-saved {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
}
.archive-meaning {
  font-size: 12.5px;
  color: var(--accent-light);
  font-style: italic;
  line-height: 1.35;
}
.archive-breakdown {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}
.archive-lore {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
.archive-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}
.btn-archive-lorelink {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  color: #7dd3fc;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-archive-lorelink:hover {
  background: rgba(56, 189, 248, 0.22);
  color: #fff;
  border-color: #38bdf8;
}

/* ========================================================================= */
/* ========================================================================= */
/* TAB 3: DICTIONARY / LEXICON (ONLINE LIST & CARD STYLES)                   */
/* ========================================================================= */
.dict-sticky-header {
  position: sticky;
  top: 64px;
  z-index: 800;
  background: rgba(11, 15, 25, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 8px 0 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 768px) {
  .dict-sticky-header {
    top: 50px;
    padding: 6px 0 10px 0;
    margin-bottom: 12px;
  }
}

/* Direction Bar (Common -> Drow vs Drow -> Common) */
.dict-direction-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dict-dir-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(14, 20, 36, 0.85);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 42px;
}
.dict-dir-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.dict-dir-btn.active {
  background: rgba(168, 85, 247, 0.2);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.25);
  font-weight: 700;
}
.dir-badge {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
}
.dict-dir-btn.active .dir-badge {
  color: var(--accent-light);
  background: rgba(168, 85, 247, 0.3);
}

/* Search Row */
.dict-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}
.search-icon {
  position: absolute;
  left: 14px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0.6;
}
.dict-search-input {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 11px 40px 11px 38px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.dict-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.25);
}
.dict-match-counter {
  position: absolute;
  right: 38px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}
@media (max-width: 580px) {
  .dict-match-counter {
    display: none;
  }
}
.search-clear-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  display: none;
}
.search-clear-btn:hover { color: #fff; }

/* View Toggle (List vs Grid) */
.dict-view-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 3px;
}
.view-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}
.view-toggle-btn.active {
  background: rgba(168, 85, 247, 0.25);
  color: #fff;
}

/* A-Z Scrubber Bar */
.az-scrubber-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  padding: 2px 0 4px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.az-scrubber-bar::-webkit-scrollbar { display: none; }
.az-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.az-btn:hover {
  color: #fff;
  border-color: var(--accent);
}
.az-btn.active {
  background: var(--accent);
  color: #070a12;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* Category Filter Chips */
.filter-chips-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.filter-chips-row::-webkit-scrollbar { display: none; }
.chip-filter {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.chip-filter:hover {
  color: #fff;
  border-color: var(--accent);
}
.chip-filter.active {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  border-color: var(--accent);
  font-weight: 700;
}

/* ------------------------------------------------------------------------- */
/* List-Style Dictionary Container & Rows                                    */
/* ------------------------------------------------------------------------- */
.dict-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dict-alphabet-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 6px 0;
  padding: 4px 0;
}
.dict-alphabet-letter {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-light);
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  padding: 2px 10px;
  border-radius: 8px;
}
.dict-alphabet-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.4) 0%, transparent 100%);
}

.dict-row-entry {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.dict-row-entry:hover {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(18, 25, 44, 0.95);
  transform: translateX(2px);
}
.dict-row-content {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.dict-row-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.dict-term-primary {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
}
.dict-pronounce {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  font-style: italic;
}
.dict-row-center {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.dict-arrow-icon {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}
.dict-term-target {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--accent-light);
}
.dict-row-notes {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}
.dict-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}
.dict-meta-cat {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.dict-meta-src {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dict-copy-btn-sm {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto;
}
.dict-copy-btn-sm:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(168, 85, 247, 0.2);
}

/* Card Mode */
.dict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.dict-card {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s ease;
  content-visibility: auto;
}
.dict-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.dict-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.dict-drow-word {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: 0.02em;
}
.dict-pos-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-dim);
}
.dict-common-def {
  font-size: 14px;
  color: #e2e8f0;
  font-weight: 500;
}
.dict-notes {
  font-size: 11.5px;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.4;
}
.dict-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.dict-source {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dict-copy-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.dict-copy-btn:hover { color: #fff; }

.dict-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 26, 45, 0.95);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 2000;
  display: none;
}

/* Underdark Codex & Cultural Field Guide (Tab 4) */
.lore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 600px) {
  .lore-grid {
    grid-template-columns: 1fr;
  }
}
.lore-card {
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.lore-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.lore-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.lore-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.01em;
}
.lore-card-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}
.lore-card-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-dim);
}
.lore-table-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12.5px;
}
.lore-table-row:last-child {
  border-bottom: none;
}
.lore-term {
  font-family: var(--font-mono);
  color: var(--cyan);
  font-weight: 600;
}
.lore-def {
  color: var(--text-muted);
  text-align: right;
}
.lore-card-source {
  font-size: 10.5px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border-dim);
}

/* ========================================================================= */
/* 📱 MOBILE-FIRST MASTERCLASS (Primary Target: Tabletop Smartphone Play)    */
/* ========================================================================= */
@media (max-width: 768px) {
  /* 1. Bottom Navigation Thumb-Bar (iOS / Android Native Ergonomics) */
  .nav-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(11, 15, 25, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 6px 8px max(10px, env(safe-area-inset-bottom, 12px)) 8px;
    display: flex;
    justify-content: space-around;
    gap: 4px;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7);
  }
  .tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    min-height: 48px; /* Strict 48px touch target */
    border-radius: 10px;
    font-size: 11px;
    letter-spacing: 0.02em;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
  }
  .tab-icon {
    font-size: 19px;
    line-height: 1;
  }
  .tab-label {
    font-size: 10.5px;
    font-weight: 600;
  }
  .tab-btn.active {
    background: rgba(168, 85, 247, 0.18);
    color: #fff;
    box-shadow: none;
    border: 1px solid rgba(168, 85, 247, 0.4);
  }
  .tab-btn.active .tab-icon {
    filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.8));
  }
  .tab-btn:active {
    transform: scale(0.96);
  }

  /* 2. Streamlined Mobile Header */
  header {
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 900;
  }
  .header-inner {
    justify-content: center;
  }
  .brand-wrap {
    text-align: center;
    gap: 8px;
  }
  .brand-icon {
    font-size: 20px;
  }
  .brand-title {
    font-size: 12.5px;
    letter-spacing: 0.06em;
  }
  .brand-subtitle {
    font-size: 9.5px;
  }

  /* 3. Main Container Padding for Thumb Dock & Notches */
  .main-container {
    padding: 14px 12px calc(80px + env(safe-area-inset-bottom, 16px)) 12px;
    gap: 16px;
  }

  /* 4. Elimination of iOS Safari Input Zoom (Strict font-size >= 16px) */
  input, textarea, select, .dict-search-input, .trans-textarea, .sample-select, .form-input, .form-select {
    font-size: 16px !important;
  }

  /* 5. Mobile Translator Toolbar & Direction Swap */
  .translator-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .mode-switch-wrap {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    padding: 4px;
  }
  .mode-btn {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    font-size: 12px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mode-swap-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    font-size: 16px;
  }
  .sample-picker-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .sample-select {
    flex: 1;
    max-width: none;
    padding: 9px 12px;
    height: 42px;
    border-radius: 10px;
  }

  /* 6. Textarea and Output Cards */
  .translator-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .trans-card {
    padding: 14px;
    border-radius: 14px;
  }
  .trans-textarea {
    min-height: 105px;
    line-height: 1.5;
  }
  .trans-output-box {
    min-height: 105px;
    font-size: 15.5px;
  }
  .trans-action-link {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
  }

  /* 7. Word Spotlight Card */
  .single-word-spotlight {
    padding: 14px;
    gap: 6px;
  }
  .spotlight-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .spotlight-word {
    font-size: 20px;
  }
  .token-chips-wrap {
    gap: 6px;
  }
  .token-chip {
    padding: 6px 12px;
    font-size: 12.5px;
  }

  /* 8. Lexicon & Codex Grids */
  .dict-grid, .lore-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .dict-card, .lore-card {
    content-visibility: auto;
    contain-intrinsic-size: 0 95px;
    padding: 14px;
  }
  .dict-card-top {
    gap: 8px;
  }
  .dict-drow-word {
    font-size: 15px;
  }
  .dict-copy-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .filter-chips-row {
    padding-bottom: 6px;
    gap: 6px;
  }
  .chip-filter {
    padding: 8px 14px;
    font-size: 12.5px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
  }
  .dict-sources-summary {
    min-height: 28px;
    padding: 2px 0;
  }
  .dict-sources-tray {
    padding: 8px 10px;
  }

  /* 9. Names & Houses Subdeck */
  .names-subdeck-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .names-box {
    padding: 14px;
    gap: 12px;
  }
  .btn-generate-main {
    min-height: 48px;
    font-size: 14px;
    border-radius: 12px;
  }
  .gender-toggle {
    width: 100%;
  }
  .gender-btn {
    flex: 1;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
  }
  .chip-sample {
    padding: 6px 12px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
  }
  .houses-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* 10. Floating Toast position on mobile (above bottom nav) */
  .toast {
    bottom: calc(75px + env(safe-area-inset-bottom, 16px));
    font-size: 13px;
    padding: 8px 18px;
  }
}


/* ============================================================================
   TAB 4: BARIMAR'S HOLISTIC GUIDE TO THE UNDERDARK (Hitchhiker's Dossier UI)
   ============================================================================ */
.holistic-hero-card {
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(46, 16, 101, 0.35));
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.08);
}
.holistic-dont-panic-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.4);
  padding: 3px 10px;
  border-radius: 99px;
  margin-bottom: 8px;
  text-shadow: 0 0 8px rgba(45, 212, 191, 0.4);
}
.holistic-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}
.bari-preface-details {
  margin-top: 10px;
  background: rgba(8, 12, 22, 0.65);
  border: 1px dashed rgba(168, 85, 247, 0.4);
  border-radius: 10px;
  padding: 8px 12px;
}
.bari-preface-summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: #2dd4bf;
  list-style: none;
  user-select: none;
}
.bari-preface-summary::-webkit-details-marker { display: none; }
.bari-preface-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.bari-quote-lead {
  font-size: 12.5px;
  font-style: italic;
  color: #e2e8f0;
  line-height: 1.55;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid #a855f7;
}
.bari-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.bari-rule-box {
  background: rgba(45, 212, 191, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.bari-rule-box strong {
  color: #2dd4bf;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Holistic Dossier Cards */
.holistic-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.holistic-card:hover {
  border-color: #2dd4bf;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(45, 212, 191, 0.12);
}
.holistic-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.holistic-threat-pill {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
  padding: 2px 7px;
  border-radius: 5px;
}
.holistic-bs-pill {
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #d8b4fe;
  padding: 2px 7px;
  border-radius: 5px;
}
.holistic-epigraph {
  font-size: 12px;
  font-style: italic;
  color: #cbd5e1;
  background: rgba(168, 85, 247, 0.08);
  border-left: 2.5px solid #2dd4bf;
  padding: 7px 10px;
  border-radius: 0 8px 8px 0;
  line-height: 1.45;
}
.holistic-read-btn {
  margin-top: auto;
  align-self: flex-start;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: #2dd4bf;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
}
.holistic-wikilink {
  background: rgba(45, 212, 191, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.4);
  color: #5eead4;
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin: 0 1px;
}
.holistic-wikilink:hover {
  background: rgba(45, 212, 191, 0.28);
  color: #fff;
}

/* Slide-Over Mobile Dossier Reader Drawer */
.lore-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.82);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.lore-drawer {
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  background: #0b101e;
  border-top: 2px solid #2dd4bf;
  border-left: 1px solid rgba(45, 212, 191, 0.3);
  border-right: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
@media (min-width: 768px) {
  .lore-drawer-backdrop { align-items: center; padding: 20px; }
  .lore-drawer { border-radius: 16px; border: 1px solid #2dd4bf; max-height: 85vh; }
}
.lore-drawer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(45, 212, 191, 0.25);
}
.lore-drawer-back, .lore-drawer-close {
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: #2dd4bf;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.lore-drawer-stamp {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.lore-drawer-content {
  padding: 18px 18px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  line-height: 1.65;
  font-size: 14px;
  color: #e2e8f0;
}
.lore-drawer-rules {
  background: rgba(45, 212, 191, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-radius: 10px;
  padding: 12px 14px;
}
.lore-drawer-rules h4 {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #2dd4bf;
  margin: 0 0 8px 0;
  text-transform: uppercase;
}
.lore-drawer-rules ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #cbd5e1;
}

.lore-drawer-content strong,
.holistic-card strong,
.archive-card strong {
  color: #ffffff;
  font-weight: 700;
}

.lore-drawer-content em,
.holistic-card em,
.archive-card em {
  color: #f1f5f9;
  font-style: italic;
}

code.dict-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  color: #a7f3d0;
}

/* ========================================================================= */
/* TAB 5: THE GRAND UNDERDARK TIMELINE                                       */
/* ========================================================================= */
.timeline-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 12px 60px;
  box-sizing: border-box;
}

.timeline-spine {
  position: absolute;
  top: 30px;
  bottom: 60px;
  left: 28px;
  width: 3px;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.6) 0%, rgba(192, 132, 252, 0.6) 30%, rgba(245, 158, 11, 0.6) 60%, rgba(244, 63, 94, 0.6) 80%, rgba(45, 212, 191, 0.6) 100%);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.timeline-nodes-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.timeline-node {
  position: relative;
  padding-left: 54px;
}

.timeline-node-dot {
  position: absolute;
  top: 24px;
  left: 21px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #0f172a;
  border: 3px solid #a855f7;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.8);
  transition: transform 0.2s ease, border-color 0.2s ease;
  z-index: 2;
}

.timeline-node[data-era="antiquity"] .timeline-node-dot { border-color: #38bdf8; box-shadow: 0 0 10px rgba(56, 189, 248, 0.8); }
.timeline-node[data-era="foundations"] .timeline-node-dot { border-color: #c084fc; box-shadow: 0 0 10px rgba(192, 132, 252, 0.8); }
.timeline-node[data-era="crises"] .timeline-node-dot { border-color: #f59e0b; box-shadow: 0 0 10px rgba(245, 158, 11, 0.8); }
.timeline-node[data-era="campaign"] .timeline-node-dot { border-color: #f43f5e; box-shadow: 0 0 10px rgba(244, 63, 94, 0.8); }
.timeline-node[data-era="modern"] .timeline-node-dot { border-color: #2dd4bf; box-shadow: 0 0 10px rgba(45, 212, 191, 0.8); }

.timeline-node:hover .timeline-node-dot {
  transform: scale(1.35);
}

.timeline-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.timeline-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  transform: translateY(-2px);
}

.timeline-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.timeline-year {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.04em;
}

.timeline-year-name {
  font-size: 11.5px;
  color: var(--text-dim);
  font-style: italic;
}

.timeline-title {
  margin: 4px 0 10px;
  font-size: 17px;
  color: #ffffff;
  font-weight: 700;
}

.timeline-summary {
  font-size: 13.5px;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.timeline-bari-box {
  background: rgba(45, 212, 191, 0.07);
  border-left: 3px solid #2dd4bf;
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.timeline-bari-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  color: #2dd4bf;
  font-weight: 700;
  display: block;
  margin-bottom: 3px;
}

.timeline-bari-text {
  margin: 0;
  font-size: 12.5px;
  font-style: italic;
  color: #e2e8f0;
  line-height: 1.5;
}

.timeline-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.timeline-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

