:root {
  --bg: #0b0e14;
  --surface: #131822;
  --surface-2: #1a2130;
  --border: #263044;
  --text: #e6edf3;
  --muted: #93a1b5;
  --gold: #f0b429;
  --gold-dim: rgba(240, 180, 41, 0.14);
  --accent: #58a6ff;
  --accent-dim: rgba(88, 166, 255, 0.14);
  --success: #3fb950;
  --danger: #f85149;
  --radius: 10px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); line-height: 1.5; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 14, 20, 0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0.65rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.brand-sigil { font-size: 1.4rem; }
.brand-title { font-weight: 700; font-size: 1rem; color: var(--gold); letter-spacing: 0.02em; }
.brand-sub { font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono); }

.nav-tabs { display: flex; gap: 0.35rem; }
.nav-tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 0.45rem 0.85rem; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.9rem;
  min-height: 40px; transition: 0.15s;
}
.nav-tab:hover { color: var(--text); background: var(--surface); }
.nav-tab.active { color: var(--gold); background: var(--gold-dim); border-color: rgba(240, 180, 41, 0.35); }
.pill-count {
  background: var(--surface-2); color: var(--text); padding: 0.1rem 0.45rem;
  border-radius: 999px; font-size: 0.75rem; margin-left: 0.25rem;
}

.topbar-toggles { display: flex; gap: 0.4rem; }
.toggle-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 0.4rem 0.7rem; border-radius: 8px; cursor: pointer; font-size: 0.82rem; font-weight: 600; min-height: 38px;
}
.toggle-btn.active { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

.container { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.campaign-banner {
  background: linear-gradient(90deg, rgba(240, 180, 41, 0.14), rgba(88, 166, 255, 0.08));
  border: 1px solid rgba(240, 180, 41, 0.4); border-radius: var(--radius);
  padding: 0.65rem 1rem; margin-bottom: 1rem; font-size: 0.88rem;
}

/* Omnibox */
.hero-search { max-width: 780px; margin: 1.5rem auto 1.25rem; text-align: center; }
.hero-search h1 { margin: 0 0 0.35rem; font-size: 1.65rem; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }
kbd {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.1rem 0.4rem; font-family: var(--font-mono); font-size: 0.8rem;
}

.omnibox-wrap { position: relative; display: flex; gap: 0.4rem; }
.omnibox-input {
  flex: 1; background: var(--surface); border: 1.5px solid var(--border); color: var(--text);
  padding: 0.85rem 2.5rem 0.85rem 1rem; border-radius: var(--radius); font-size: 1rem; outline: none;
}
.omnibox-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.omnibox-clear {
  position: absolute; right: 5.5rem; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0.4rem;
}
.omnibox-btn {
  background: var(--gold); color: #0b0e14; border: none; border-radius: var(--radius);
  padding: 0 1.25rem; font-weight: 700; cursor: pointer; min-height: 44px;
}
.omnibox-btn:hover { filter: brightness(1.08); }

.autocomplete-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55); text-align: left; max-height: 360px; overflow-y: auto;
}
.ac-item {
  padding: 0.65rem 1rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(38, 48, 68, 0.5); font-size: 0.92rem;
}
.ac-item:hover, .ac-item.selected { background: var(--surface-2); }
.ac-cat { font-size: 0.72rem; font-family: var(--font-mono); color: var(--gold); text-transform: uppercase; }

.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin-top: 0.85rem; align-items: center; }
.chip-label { font-size: 0.8rem; color: var(--muted); }
.quick-chip {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 0.3rem 0.65rem; border-radius: 999px; font-size: 0.8rem; cursor: pointer;
}
.quick-chip:hover { border-color: var(--gold); color: var(--gold); }

/* Search Results & Cards */
.search-meta { max-width: 900px; margin: 0 auto 0.75rem; font-size: 0.82rem; color: var(--muted); font-family: var(--font-mono); }
.bridge-box, .hub-box, .result-box, .fts-box { max-width: 900px; margin: 0 auto 1rem; }
.bridge-box {
  background: var(--accent-dim); border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.9rem;
}
.hub-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem;
}
.hub-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.5rem; }
.hub-chip {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 0.4rem 0.75rem; border-radius: 8px; cursor: pointer; font-size: 0.85rem;
}
.hub-chip:hover { border-color: var(--gold); color: var(--gold); }

.entity-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.entity-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 0.85rem; margin-bottom: 0.9rem; }
.entity-title { margin: 0; font-size: 1.35rem; color: var(--gold); }
.entity-alt-title { font-size: 0.88rem; color: var(--muted); margin-top: 0.15rem; }
.badge {
  display: inline-block; padding: 0.18rem 0.55rem; border-radius: 6px; font-size: 0.75rem;
  font-family: var(--font-mono); background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.badge.gold { color: var(--gold); border-color: rgba(240, 180, 41, 0.4); background: var(--gold-dim); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.55rem; margin-bottom: 1rem; }
.kv-item { background: var(--surface-2); padding: 0.5rem 0.7rem; border-radius: 6px; font-size: 0.86rem; }
.kv-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; display: block; }
.entity-desc { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.6; color: var(--text); }

/* Browse Layout (Fixed Header, Sidebar, Filters & A-Z Rail; List-Only Scroll) */
.browse-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; height: calc(100dvh - 96px); overflow: hidden; }
.cat-sidebar { display: flex; flex-direction: column; gap: 0.25rem; overflow-y: auto; scrollbar-width: none; padding-right: 0.2rem; }
.cat-sidebar::-webkit-scrollbar { display: none; }
.browse-main { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; min-width: 0; }
.browse-filters { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.45rem; flex-shrink: 0; position: relative; z-index: 30; }
.active-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.45rem; flex-shrink: 0; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--gold-dim); border: 1px solid rgba(240, 180, 41, 0.45); color: var(--gold);
  padding: 0.18rem 0.55rem; border-radius: 999px; font-size: 0.76rem; font-weight: 600;
}
.filter-chip button {
  background: transparent; border: none; color: var(--gold); cursor: pointer;
  font-size: 0.85rem; line-height: 1; padding: 0 0.1rem;
}
.multi-panel {
  position: fixed; z-index: 90; width: min(440px, 92vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75); padding: 0.65rem;
}
.multi-group-label {
  grid-column: 1 / -1; font-size: 0.72rem; color: var(--gold); font-weight: 700;
  text-transform: uppercase; padding: 0.25rem 0.2rem 0.1rem; border-bottom: 1px solid var(--border);
}
.browse-body-wrap { flex: 1; display: flex; overflow: hidden; gap: 0.4rem; min-height: 0; }
.browse-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; padding-right: 0.2rem; }
.browse-scroll::-webkit-scrollbar { display: none; }
.scroll-sentinel { height: 28px; text-align: center; font-size: 0.78rem; color: var(--muted); padding: 0.4rem; }

.alpha-rail {
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  flex-shrink: 0; width: 24px; height: 100%; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px 0;
}
.alpha-rail::-webkit-scrollbar { display: none; }
.alpha-btn {
  background: transparent; border: none; color: var(--muted); font-size: 0.65rem; font-weight: 700;
  font-family: var(--font-mono); cursor: pointer; padding: 0; width: 100%; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.alpha-btn:hover, .alpha-btn.active { color: var(--gold); background: var(--gold-dim); }

@media (max-width: 820px) {
  .browse-layout { grid-template-columns: 1fr; height: calc(100dvh - 110px); }
  .cat-sidebar { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex-shrink: 0; padding-bottom: 0.35rem; }
}
.cat-btn {
  text-align: left; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 0.45rem 0.7rem; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between;
  font-size: 0.84rem; white-space: nowrap; gap: 0.5rem;
}
.cat-btn.active { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

.filter-input, .filter-select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 0.45rem 0.7rem; border-radius: 8px; font-size: 0.86rem; min-height: 38px;
}
.filter-input { flex: 1; min-width: 160px; }
.filter-input.small { flex: 0 0 88px; min-width: 88px; }
.browse-status { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; font-family: var(--font-mono); flex-shrink: 0; }
.col-header-bar {
  display: grid; grid-template-columns: minmax(160px, 1.4fr) minmax(105px, 0.85fr) minmax(150px, 1.45fr) minmax(110px, 0.95fr);
  gap: 0.65rem; padding: 0.25rem 0.75rem; margin-bottom: 0.35rem; margin-right: 28px;
  border-bottom: 1px solid var(--border); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); flex-shrink: 0;
}
.col-header-bar span:last-child { text-align: right; }
@media (max-width: 640px) { .col-header-bar { display: none; } }
.browse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0.75rem; }
.browse-list { display: flex; flex-direction: column; gap: 0.28rem; }
.list-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.38rem 0.75rem; cursor: pointer; transition: 0.1s;
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(105px, 0.85fr) minmax(150px, 1.45fr) minmax(110px, 0.95fr);
  align-items: center; gap: 0.65rem; min-height: 36px;
}
.list-row:hover { border-color: var(--gold); background: var(--surface-2); }
.list-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.84rem; }
.list-cell.title { font-weight: 700; color: var(--text); font-size: 0.9rem; }
.list-cell.school { color: var(--muted); }
.list-cell.levels { color: var(--gold); font-family: var(--font-mono); font-size: 0.76rem; }
.list-cell.source { color: var(--muted); font-family: var(--font-mono); font-size: 0.74rem; text-align: right; }
@media (max-width: 640px) {
  .list-row { grid-template-columns: 1fr auto; gap: 0.25rem 0.5rem; padding: 0.4rem 0.6rem; }
  .list-cell.source { text-align: right; }
}
.mini-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem; cursor: pointer; transition: 0.12s; display: flex; flex-direction: column; justify-content: space-between; gap: 0.5rem;
}
.mini-card:hover { border-color: var(--gold); transform: translateY(-1px); }
.mini-card-title { font-weight: 700; color: var(--text); font-size: 0.98rem; }
.mini-card-sub { font-size: 0.8rem; color: var(--muted); }
.mini-card-meta { font-size: 0.75rem; color: var(--gold); font-family: var(--font-mono); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 0.75rem; margin-top: 1.25rem; }
.btn-secondary, .btn-ghost, .btn-danger {
  padding: 0.45rem 0.85rem; border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600; min-height: 38px;
}
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-danger { background: rgba(248, 81, 73, 0.14); border: 1px solid rgba(248, 81, 73, 0.4); color: var(--danger); }

/* Pinboard */
.pinboard-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pinboard-actions { display: flex; gap: 0.5rem; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; z-index: 101; width: 100%; max-width: 820px; max-height: 88vh;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.65);
}
.modal-header {
  padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
}
.modal-actions { display: flex; gap: 0.4rem; }
.modal-body { padding: 1.2rem; overflow-y: auto; }

.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200;
  background: var(--surface-2); border: 1px solid var(--gold); color: var(--text);
  padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.88rem; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* Calculators & Feat Tree */
.calc-pills { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1rem; }
.calc-grid { display: grid; grid-template-columns: 360px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .calc-grid { grid-template-columns: 1fr; } }
.form-row { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.75rem; }
.form-row label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.form-row input, .form-row select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 0.5rem 0.7rem; border-radius: 8px; font-size: 0.9rem; min-height: 38px;
}
.tree-section { margin-bottom: 1rem; }
.tree-nodes { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.4rem; }
.tree-node {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 0.4rem 0.75rem; border-radius: 8px; cursor: pointer; font-size: 0.84rem;
}
.tree-node:hover { border-color: var(--gold); color: var(--gold); }

/* Multi-select Manuali Checklist */
.multi-wrap { position: relative; }
.multi-panel-head { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.55rem; padding-bottom: 0.45rem; border-bottom: 1px solid var(--border); }
.multi-panel-head :last-child { margin-left: auto; }
.multi-panel-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 0.35rem; max-height: 260px; overflow-y: auto;
}
.multi-chk-item {
  display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; padding: 0.3rem 0.4rem;
  border-radius: 6px; cursor: pointer; background: var(--surface-2);
}
.multi-chk-item:hover { color: var(--gold); }

/* Mobile-First Responsive Hardening */
@media (max-width: 640px) {
  .topbar-inner { padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .brand-sub { display: none; }
  .nav-tabs { width: 100%; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; order: 3; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { padding: 0.45rem 0.7rem; font-size: 0.84rem; white-space: nowrap; flex-shrink: 0; }
  .topbar-toggles { margin-left: auto; }
  .toggle-btn { padding: 0.35rem 0.55rem; font-size: 0.78rem; }
  .hero-search { margin: 0.75rem auto 1rem; }
  .hero-search h1 { font-size: 1.3rem; }
  .omnibox-wrap { gap: 0.35rem; }
  .omnibox-input, .filter-input, .filter-select, .form-row input, .form-row select { font-size: 16px; }
  .omnibox-input { padding: 0.75rem 2.2rem 0.75rem 0.85rem; }
  .omnibox-clear { right: 4.8rem; }
  .omnibox-btn { padding: 0 0.9rem; font-size: 0.9rem; }
  .kv-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .browse-grid { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-width: 100%; max-height: 92dvh; border-radius: 14px 14px 0 0; }
  .modal-header { padding: 0.75rem 1rem; }
  .modal-body { padding: 1rem; }
}
