:root {
  --bg-primary: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F1F5F9;
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-light: #94A3B8;
  --border-light: #E2E8F0;
  --border-dark: #CBD5E1;

  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;

  --cat-vl: #2563EB;
  --cat-vl-bg: #EFF6FF;
  --cat-vid: #7C3AED;
  --cat-vid-bg: #FAF5FF;
  --cat-aud: #DB2777;
  --cat-aud-bg: #FDF2F8;
  --cat-3d: #0891B2;
  --cat-3d-bg: #ECFEFF;
  --cat-emb: #DC2626;
  --cat-emb-bg: #FEF2F2;
  --cat-doc: #059669;
  --cat-doc-bg: #ECFDF5;
  --cat-dm: #991B1B;
  --cat-dm-bg: #FEF2F2;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.code-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Header */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.badge-sok {
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-btn {
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
  text-decoration: none;
}

.nav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-cta {
  background: #0F172A;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.2s;
}

.nav-cta:hover {
  background: #1E293B;
  text-decoration: none;
}

.icon {
  width: 16px;
  height: 16px;
}

/* Hero */
.hero-section {
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  border-bottom: 1px solid var(--border-light);
  padding: 3.5rem 1.5rem 3rem;
}

.hero-container {
  max-width: 1400px;
  margin: 0 auto;
}

.hero-pill {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  margin-bottom: 1rem;
  border: 1px solid #BFDBFE;
}

.hero-title {
  font-family: 'Inter', sans-serif;
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text-main);
  max-width: 1100px;
  margin-bottom: 0.75rem;
}

.hero-subtitle {
  font-size: 1.12rem;
  color: var(--text-muted);
  max-width: 950px;
  margin-bottom: 1.5rem;
}

.author-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.author-chip {
  display: flex;
  flex-direction: column;
}

.author-name {
  font-weight: 700;
  color: var(--text-main);
  font-size: 1.05rem;
}

.author-inst {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.author-links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
}

.sublink {
  color: var(--primary);
  font-weight: 500;
}

.sep {
  color: var(--text-light);
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Main Body & Tabs */
.main-body {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.section-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title-wrap h2 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.section-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 850px;
}

.table-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-input {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  min-width: 280px;
  outline: none;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-select {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 0.88rem;
  outline: none;
}

.family-legend {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.legend-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
}
.legend-chip.vl { background: var(--cat-vl-bg); color: var(--cat-vl); border: 1px solid #BFDBFE; }
.legend-chip.doc { background: var(--cat-doc-bg); color: var(--cat-doc); border: 1px solid #A7F3D0; }
.legend-chip.vid { background: var(--cat-vid-bg); color: var(--cat-vid); border: 1px solid #DDD6FE; }
.legend-chip.aud { background: var(--cat-aud-bg); color: var(--cat-aud); border: 1px solid #FBCFE8; }
.legend-chip.spatial { background: var(--cat-3d-bg); color: var(--cat-3d); border: 1px solid #A5F3FC; }
.legend-chip.emb { background: var(--cat-emb-bg); color: var(--cat-emb); border: 1px solid #FECACA; }
.legend-chip.dm { background: var(--cat-dm-bg); color: var(--cat-dm); border: 1px dashed #DC2626; }

/* Periodic Grid */
.periodic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 0.6rem;
  margin-bottom: 2.5rem;
}

.pt-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.4rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 90px;
  position: relative;
}

.pt-tile:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.pt-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pt-symbol {
  font-size: 1.25rem;
  font-weight: 800;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  margin: 0.2rem 0;
  line-height: 1;
}

.pt-name {
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.pt-score {
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
}

/* Modality Color Classes for Tiles */
.pt-tile.vl { border-color: #BFDBFE; background: #F8FAFC; }
.pt-tile.vl:hover { border-color: var(--cat-vl); }
.pt-tile.vl .pt-symbol { color: var(--cat-vl); }

.pt-tile.vid { border-color: #DDD6FE; background: #FCFAFF; }
.pt-tile.vid:hover { border-color: var(--cat-vid); }
.pt-tile.vid .pt-symbol { color: var(--cat-vid); }

.pt-tile.aud { border-color: #FBCFE8; background: #FFF9FC; }
.pt-tile.aud:hover { border-color: var(--cat-aud); }
.pt-tile.aud .pt-symbol { color: var(--cat-aud); }

.pt-tile.spatial { border-color: #A5F3FC; background: #F7FEFF; }
.pt-tile.spatial:hover { border-color: var(--cat-3d); }
.pt-tile.spatial .pt-symbol { color: var(--cat-3d); }

.pt-tile.emb { border-color: #FECACA; background: #FFF8F8; }
.pt-tile.emb:hover { border-color: var(--cat-emb); }
.pt-tile.emb .pt-symbol { color: var(--cat-emb); }

.pt-tile.doc { border-color: #A7F3D0; background: #F7FDF9; }
.pt-tile.doc:hover { border-color: var(--cat-doc); }
.pt-tile.doc .pt-symbol { color: var(--cat-doc); }

/* Dark Matter Section */
.dark-matter-section {
  background: #FFF5F5;
  border: 1.5px dashed #DC2626;
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-top: 1rem;
}

.dm-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.dm-badge {
  background: #DC2626;
  color: white;
  font-weight: 800;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.dm-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #991B1B;
}

.dm-desc {
  font-size: 0.92rem;
  color: #7F1D1D;
  margin-bottom: 1.25rem;
}

.dm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
}

.dm-card {
  background: white;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.dm-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.dm-sym {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 1.1rem;
  color: #DC2626;
}

.dm-cat {
  font-size: 0.75rem;
  font-weight: 600;
  color: #B91C1C;
  background: #FEE2E2;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.dm-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: #1F2937;
}

.dm-text {
  font-size: 0.82rem;
  color: #4B5563;
  line-height: 1.45;
}

/* 7x9 Gap Matrix Layout */
.matrix-layout {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.matrix-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.gap-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.gap-matrix-table th, .gap-matrix-table td {
  padding: 0.75rem 0.6rem;
  text-align: center;
  border: 1px solid var(--border-light);
}

.gap-matrix-table th {
  background: var(--bg-elevated);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gap-matrix-table th.row-header {
  text-align: left;
  font-weight: 700;
  color: var(--text-main);
  background: #F8FAFC;
}

.cell-btn {
  cursor: pointer;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  display: block;
  transition: all 0.15s ease;
}

.cell-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-sm);
}

.cell-void {
  background: #FEE2E2;
  color: #DC2626;
  border: 1.5px solid #EF4444;
}

.cell-scarce {
  background: #FEF3C7;
  color: #D97706;
  border: 1px solid #F59E0B;
}

.cell-mod {
  background: #E0E7FF;
  color: #3730A3;
}

.cell-dense {
  background: #DBEAFE;
  color: #1E40AF;
  font-weight: 800;
}

.matrix-legend-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.8rem;
}

.mat-key {
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.mat-key.void { background: #FEE2E2; color: #DC2626; border: 1px solid #EF4444; }
.mat-key.scarce { background: #FEF3C7; color: #D97706; border: 1px solid #F59E0B; }
.mat-key.moderate { background: #E0E7FF; color: #3730A3; }
.mat-key.saturated { background: #DBEAFE; color: #1E40AF; }

.matrix-inspect-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.inspect-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.inspect-icon {
  width: 48px;
  height: 48px;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Pathology Cards */
.pathology-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.pathology-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-badge.trap {
  display: inline-block;
  background: #FEE2E2;
  color: #DC2626;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.pathology-card h3 {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.path-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.path-body {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.55;
}

.solution-box {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: #166534;
}

/* Protocol Generator */
.generator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.generator-form {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  background: #F8FAFC;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.checkbox-grid label {
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-sm {
  background: white;
  border: 1px solid var(--border-dark);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.15s;
}
.btn-sm:hover {
  background: var(--bg-elevated);
}

.generator-preview {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.code-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #334155;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.latex-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  color: #93C5FD;
  line-height: 1.5;
  overflow-y: auto;
  max-height: 500px;
}

/* Gallery */
.gallery-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.g-tab-btn {
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: white;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.g-tab-btn.active {
  background: #0F172A;
  color: white;
  border-color: #0F172A;
}

.gallery-viewer {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.viewer-img-wrap {
  text-align: center;
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.viewer-img-wrap img {
  max-width: 100%;
  max-height: 700px;
  object-fit: contain;
  box-shadow: var(--shadow-md);
  border-radius: 4px;
}

.viewer-caption-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

#viewer-caption-text {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 850px;
}

.viewer-actions {
  display: flex;
  gap: 0.5rem;
}

/* Citation Section */
.citation-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 2.25rem;
  margin-top: 3.5rem;
  box-shadow: var(--shadow-sm);
}

.citation-box {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-top: 1rem;
}

.citation-box pre {
  font-size: 0.88rem;
  line-height: 1.55;
  overflow-x: auto;
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  position: relative;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: none;
  font-size: 1.75rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-symbol {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.85rem;
  font-weight: 800;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid #BFDBFE;
}

.modal-titles h3 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-row {
  display: flex;
  margin-bottom: 0.85rem;
  gap: 1rem;
  font-size: 0.9rem;
}

.m-label {
  width: 160px;
  font-weight: 700;
  color: var(--text-main);
  flex-shrink: 0;
}

.m-value {
  color: var(--text-muted);
}

.m-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.m-badge {
  background: var(--bg-elevated);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
}

.modal-bib-wrap {
  margin-top: 1.5rem;
  background: #0F172A;
  color: #E2E8F0;
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.bib-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

#m-bibtex {
  font-size: 0.78rem;
  white-space: pre-wrap;
  color: #93C5FD;
}

/* Footer */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  padding: 2rem 1.5rem;
  margin-top: 4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (max-width: 1024px) {
  .matrix-layout, .generator-layout {
    grid-template-columns: 1fr;
  }
}


/* --- Dark Theme Variables & Styles --- */
[data-theme="dark"] {
  --bg-primary: #0B0F19;
  --bg-surface: #111827;
  --bg-elevated: #1F2937;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-light: #64748B;
  --border-light: #1F2937;
  --border-dark: #374151;

  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-light: #1E3A8A;

  --cat-vl: #60A5FA;
  --cat-vl-bg: #1E293B;
  --cat-vid: #A78BFA;
  --cat-vid-bg: #2E1065;
  --cat-aud: #F472B6;
  --cat-aud-bg: #4A044E;
  --cat-3d: #22D3EE;
  --cat-3d-bg: #083344;
  --cat-emb: #F87171;
  --cat-emb-bg: #450A0A;
  --cat-doc: #34D399;
  --cat-doc-bg: #022C22;
  --cat-dm: #FCA5A5;
  --cat-dm-bg: #3F0708;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

[data-theme="dark"] .pt-tile {
  background: var(--bg-surface);
  border-color: var(--border-dark);
}
[data-theme="dark"] .stat-card,
[data-theme="dark"] .pathology-card,
[data-theme="dark"] .gallery-card,
[data-theme="dark"] .modal-content {
  background: var(--bg-surface);
  border-color: var(--border-light);
}
[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select,
[data-theme="dark"] .code-box,
[data-theme="dark"] .form-control {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--border-dark);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(1.05);
}

/* PRISMA 2020 Funnel Cascade Ribbon */
.prisma-cascade-bar {
  margin-top: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.prisma-cascade-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.prisma-nodes {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.prisma-node {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.prisma-node .p-num {
  font-size: 0.85rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
}
.prisma-node .p-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}
.prisma-node.excluded {
  border-color: #FECDD3;
  background: #FFF1F2;
}
[data-theme="dark"] .prisma-node.excluded {
  background: #450A0A;
  border-color: #991B1B;
}
.prisma-node.excluded .p-num { color: #BE123C; }
.prisma-node.final {
  border-color: #93C5FD;
  background: #EFF6FF;
}
[data-theme="dark"] .prisma-node.final {
  background: #1E3A8A;
  border-color: #3B82F6;
}
.prisma-node.final .p-num { color: #1D4ED8; font-weight: 900; }
.p-arrow {
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: bold;
}

/* ========================================================
   COMPREHENSIVE RESPONSIVE ARCHITECTURE (Mobile & Tablet)
   ======================================================== */

/* Tablet & Compact Desktop (<= 1024px) */
@media (max-width: 1024px) {
  .header-container {
    padding: 0.75rem 1rem;
  }
  .nav-links {
    gap: 0.4rem;
  }
  .hero-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .periodic-grid {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.4rem;
  }
}

/* Tablets & Large Phones (<= 768px) */
@media (max-width: 768px) {
  .site-header {
    position: static;
  }
  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .brand {
    justify-content: space-between;
  }
  .nav-links {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
    gap: 0.4rem;
  }
  .nav-links::-webkit-scrollbar {
    display: none;
  }
  .nav-btn, .nav-cta, .theme-toggle-btn {
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }
  .hero-section {
    padding: 2rem 1rem;
  }
  .hero-title {
    font-size: clamp(1.4rem, 5vw, 1.85rem);
  }
  .hero-subtitle {
    font-size: 0.95rem;
  }
  .hero-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .stat-card {
    padding: 0.75rem;
  }
  .stat-num {
    font-size: 1.5rem;
  }
  .table-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .search-input, .filter-select {
    width: 100%;
  }
  .family-legend {
    gap: 0.35rem;
  }
  .legend-chip {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
  .periodic-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.35rem;
  }
  .pt-tile {
    padding: 0.35rem;
    min-height: 85px;
  }
  .pt-symbol {
    font-size: 0.95rem;
  }
  .pt-name {
    font-size: 0.62rem;
  }
  .matrix-layout, .generator-layout {
    grid-template-columns: 1fr;
  }
  .matrix-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .gap-matrix-table {
    min-width: 600px;
  }
  .pathology-grid {
    grid-template-columns: 1fr;
  }
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  .modal-content {
    width: 95vw;
    max-height: 90vh;
    padding: 1.25rem;
  }
}

/* Small Phones (<= 480px) */
@media (max-width: 480px) {
  body {
    overflow-x: hidden;
  }
  .hero-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .stat-num {
    font-size: 1.35rem;
  }
  .stat-label {
    font-size: 0.72rem;
  }
  .stat-sub {
    font-size: 0.6rem;
  }
  .prisma-cascade-bar {
    padding: 0.5rem 0.75rem;
  }
  .prisma-node {
    padding: 0.2rem 0.45rem;
  }
  .prisma-node .p-num {
    font-size: 0.75rem;
  }
  .periodic-grid {
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  }
  .pt-tile {
    min-height: 78px;
    padding: 0.25rem;
  }
}


/* ==========================================================================
   SoK Companion Masterclass Suite & Hub Styles
   ========================================================================== */
.companion-hub-bar {
  background: #090D16;
  border-bottom: 1px solid #1E293B;
  color: #F8FAFC;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 0.5rem 1.5rem;
  font-size: 0.82rem;
  position: relative;
  z-index: 60;
}

.companion-hub-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.companion-hub-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #38BDF8;
}

.hub-pulse {
  width: 8px;
  height: 8px;
  background-color: #10B981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: hubPulse 2s infinite;
}

@keyframes hubPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.companion-hub-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hub-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  background: #111827;
  border: 1px solid #1F2937;
  color: #E2E8F0;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.hub-link:hover {
  background: #1E293B;
  color: #FFFFFF;
  text-decoration: none;
  border-color: #38BDF8;
  transform: translateY(-1px);
}

.hub-link.slides:hover { border-color: #60A5FA; }
.hub-link.cheatsheet:hover { border-color: #F87171; }
.hub-link.script:hover { border-color: #FBBF24; }
.hub-link.handout:hover { border-color: #34D399; }
.hub-link.paper:hover { border-color: #C084FC; }

.hub-tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

/* Masterclass Quick Strip in Hero */
.masterclass-quick-strip {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.strip-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.strip-badge {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
}

.strip-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.strip-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.strip-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.strip-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.strip-card.card-slides:hover { border-color: #2563EB; background: #EFF6FF; }
.strip-card.card-cheatsheet:hover { border-color: #DC2626; background: #FEF2F2; }
.strip-card.card-script:hover { border-color: #D97706; background: #FFFBEB; }
.strip-card.card-handout:hover { border-color: #059669; background: #ECFDF5; }
.strip-card.card-paper:hover { border-color: #7C3AED; background: #F5F3FF; }

.sc-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.sc-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.sc-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.sc-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.25;
  margin-top: 0.15rem;
}

.sc-arrow {
  color: var(--text-light);
  font-weight: 700;
  font-size: 1.1rem;
  transition: transform 0.2s ease, color 0.2s ease;
}

.strip-card:hover .sc-arrow {
  color: var(--primary);
  transform: translateX(3px);
}

[data-theme="dark"] .masterclass-quick-strip {
  background: var(--bg-surface);
  border-color: var(--border-light);
}

[data-theme="dark"] .strip-card {
  background: #111827;
  border-color: #1F2937;
}

[data-theme="dark"] .strip-card.card-slides:hover { background: #1E293B; border-color: #3B82F6; }
[data-theme="dark"] .strip-card.card-cheatsheet:hover { background: #1E293B; border-color: #EF4444; }
[data-theme="dark"] .strip-card.card-script:hover { background: #1E293B; border-color: #F59E0B; }
[data-theme="dark"] .strip-card.card-handout:hover { background: #1E293B; border-color: #10B981; }
[data-theme="dark"] .strip-card.card-paper:hover { background: #1E293B; border-color: #A855F7; }
