/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  --bg:           #f9f7f4;
  --surface:      #ffffff;
  --surface-alt:  #f3f1ed;
  --border:       #e0ddd8;
  --border-strong:#c8c4be;
  --text:         #1a1a18;
  --text-muted:   #5c5955;
  --text-faint:   #9a9692;
  --accent:       #3d5a80;
  --accent-light: #eaf0f7;
  --accent-hover: #2d4a6e;
  --verified:     #2e7d32;
  --verified-bg:  #e8f5e9;
  --font-serif:   Georgia, 'Times New Roman', serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --radius:       4px;
  --max-width:    860px;
  --nav-height:   56px;
}

[data-theme="dark"] {
  --bg:           #181816;
  --surface:      #222220;
  --surface-alt:  #2a2a28;
  --border:       #383834;
  --border-strong:#50504a;
  --text:         #e8e4de;
  --text-muted:   #a09b94;
  --text-faint:   #6a6560;
  --accent:       #7aadcf;
  --accent-light: #1e2d3a;
  --accent-hover: #9bc4e0;
  --verified:     #66bb6a;
  --verified-bg:  #1a2e1b;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ===== LAYOUT ===== */
.site-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

main { flex: 1; }

/* ===== NAVIGATION ===== */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
}

.site-nav .container {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
}

.nav-logo {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  text-transform: lowercase;
}
.nav-logo:hover { color: var(--accent); text-decoration: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: 32px;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
  text-transform: lowercase;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--text); }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Dark mode toggle */
.dark-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-transform: lowercase;
}
.dark-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

/* Hamburger: hidden on desktop, shown via mobile media query */
.nav-hamburger { display: none; }

/* ===== FOOTER ===== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 80px;
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  gap: 40px;
}

.footer-disclaimer {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 560px;
}

.footer-links {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.footer-links a {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.footer-links a:hover { color: var(--accent); text-decoration: none; }

/* ===== HOMEPAGE ===== */
.home-hero {
  padding: 72px 0 64px;
  border-bottom: 1px solid var(--border);
}

.home-hero h1 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: normal;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 20px;
  max-width: 640px;
}

.home-hero .lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 580px;
  margin-bottom: 32px;
}

.btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-secondary:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

.home-sections {
  padding: 56px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
}

.home-section h2 {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.home-section p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.home-cta {
  display: flex;
  gap: 12px;
  padding: 40px 0 56px;
  border-top: 1px solid var(--border);
}

/* ===== DISCLAIMER BANNER ===== */
.disclaimer-banner {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 24px 0;
  line-height: 1.5;
}

/* ===== PAGE HEADER ===== */
.page-header {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: normal;
  color: var(--text);
  margin-bottom: 8px;
}

.page-header .subtitle {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-muted);
}

/* ===== DIRECTORY PAGE ===== */
.directory-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 48px;
  padding: 40px 0 0;
}

.filter-sidebar {
  padding-top: 4px;
}

.filter-section {
  margin-bottom: 28px;
}

.filter-label {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

.filter-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  padding: 5px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-align: left;
  text-transform: lowercase;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
  font-weight: 600;
}
.chip.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--surface);
}
.chip.active::after {
  content: ' ×';
  font-weight: 400;
  opacity: 0.75;
  margin-left: 2px;
}

.search-box {
  margin-bottom: 28px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus {
  border-color: var(--accent);
}
.search-input::placeholder { color: var(--text-faint); }
[data-theme="dark"] .search-input::placeholder,
[data-theme="dark"] .form-input::placeholder,
[data-theme="dark"] .form-textarea::placeholder { color: var(--text-muted); }

.filter-reset {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-top: 8px;
  text-decoration: underline;
}
.filter-reset:hover { color: var(--accent); }

/* Institute list */
.institute-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.result-count {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.institute-list {
  list-style: none;
}

/* View toggle */
.view-toggle {
  display: flex;
  gap: 0;
  background: var(--surface-alt);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.view-toggle button {
  background: none;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Card view */
.institute-list.card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.institute-list.card-view .institute-list-item {
  border-bottom: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.institute-list.card-view .institute-list-item:first-child { border-top: 1px solid var(--border); }
.institute-list.card-view .institute-list-link { padding: 20px; }
.institute-list.card-view .inst-desc-preview { display: block; }

.institute-list-item {
  border-bottom: 1px solid var(--border);
}
.institute-list-item:first-child { border-top: 1px solid var(--border); }

.institute-list-link {
  display: block;
  padding: 20px 0;
}

.inst-name-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.inst-name-link:hover { text-decoration: none; }
.inst-name-link:hover .inst-name { color: var(--accent); }

.inst-name {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  color: var(--text);
  margin-bottom: 6px;
  transition: color 0.15s;
}

.inst-abbr {
  font-size: 0.8em;
  font-weight: normal;
  color: var(--text-faint);
}

.inst-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.inst-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}

.inst-meta-row:empty {
  display: none;
}

.inst-meta-row + .inst-meta-row {
  margin-top: 2px;
}

.tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.03em;
  text-transform: lowercase;
}

.tag-orientation, .tag-program-type, .tag-lp, .tag-affiliation {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tag-certificate {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tag-verified {
  background: var(--verified-bg);
  color: var(--verified);
  border: 1px solid #c8e6c9;
  font-size: 0.625rem;
  letter-spacing: 0.05em;
}
[data-theme="dark"] .tag-verified {
  border-color: #2e4e2e;
}

button.tag, a.tag {
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
}
button.tag:hover, a.tag:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Hidden in list view; shown in card view (see below) */
.inst-desc-preview {
  display: none;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* List view: hide verified badge (shown in card view only) */
#institute-list:not(.card-view) .tag-verified { display: none; }

.no-results {
  padding: 48px 0;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== INSTITUTE PAGE ===== */
.institute-header {
  padding: 40px 0 0;
}

.institute-header h1 {
  font-family: var(--font-serif);
  font-size: 1.875rem;
  font-weight: normal;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 12px;
  max-width: 680px;
}

.institute-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.institute-header-programs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.institute-header-links {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.external-link {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--accent);
}
.external-link::after { content: ' ↗'; font-size: 0.75em; }

.inst-meta-small {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.tab-panel {
  display: none;
  padding: 36px 0;
}
.tab-panel.active { display: block; }

/* Overview tab */
.overview-description {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 680px;
  margin-bottom: 32px;
}

.overview-sidebar-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  align-items: baseline;
}
.overview-sidebar-row:last-child { border-bottom: 1px solid var(--border); }

.row-label {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.row-value {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text);
}

/* Programs tab */
.program-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 20px;
  background: var(--surface);
}

.program-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.program-name {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  color: var(--text);
  flex: 1;
  min-width: 200px;
}

.program-tags {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.program-description {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.65;
}

.program-req-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.program-req {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Events tab */
.events-list {
  list-style: none;
}

.event-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.event-item:first-child { border-top: 1px solid var(--border); }

.event-date {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  flex-shrink: 0;
  min-width: 130px;
}

.event-past {
  opacity: 0.5;
}

.event-past-label {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-left: auto;
  flex-shrink: 0;
}

.event-title {
  font-size: 0.9375rem;
  color: var(--text);
}

.events-link-out {
  display: inline-block;
  margin-top: 20px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--accent);
}

.tab-empty-state,
.no-events {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-muted);
  padding: 24px 0;
}

/* Affiliations tab */
.affil-list {
  list-style: none;
}

.affil-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  color: var(--text);
}
.affil-item:first-child { border-top: 1px solid var(--border); }

/* Discussion tab */
.discussion-intro {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  padding: 12px 16px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.discussion-post {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.discussion-post:first-of-type { border-top: 1px solid var(--border); }

.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.post-author {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.post-date {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  margin-left: auto;
}

.post-body {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.7;
}

/* Post form */
.post-form {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.post-form h3 {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-label {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.form-input, .form-textarea {
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  min-height: 38px;
}
.form-input:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

.form-note {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 16px;
}

/* Edit suggestion button */
.suggest-edit-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 14px;
  margin-top: 24px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  justify-content: center;
  margin-top: 12px;
  padding: 14px 20px;
  background: var(--accent-light);
  border-radius: var(--radius);
}

.suggest-edit-link {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--accent);
  padding: 3px 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
}
.suggest-edit-link:hover { color: var(--accent-hover); text-decoration: underline; }

/* ===== GLOSSARY ===== */
.glossary-sections {
  padding: 24px 0 8px;
}

.glossary-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.glossary-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  user-select: none;
  border-radius: 8px;
  gap: 12px;
}
.glossary-section-summary::-webkit-details-marker { display: none; }
.glossary-section-summary:hover { background: var(--surface-alt); }
.glossary-section[open] > .glossary-section-summary {
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}
.glossary-section[open] > .glossary-section-summary:hover {
  border-radius: 8px 8px 0 0;
}

.glossary-section-count {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-faint);
  margin-right: auto;
}

.glossary-section-summary::after {
  content: '';
  display: block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-top: -3px;
}
.glossary-section[open] > .glossary-section-summary::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.glossary-grid {
  padding: 0 20px 8px;
}

.glossary-term {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: baseline;
}
.glossary-term:first-child { border-top: none; }
.glossary-term:last-child  { border-bottom: none; }

.glossary-term dt {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.glossary-term dd {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  padding: 16px 0 0;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  display: flex;
  gap: 6px;
  align-items: center;
}
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb-sep { color: var(--border-strong); }

/* ===== SUGGEST EDIT PAGE ===== */
.edit-form-wrap {
  max-width: 560px;
  padding: 48px 0;
}

.edit-form-wrap h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: normal;
  margin-bottom: 8px;
}

.edit-form-wrap .subtitle {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-select {
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}
.form-select:focus { border-color: var(--accent); }
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a09b94' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

/* Inline-styled form elements (e.g. edit-program dropdowns) inherit text color in dark mode */
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] input {
  color: var(--text);
}

/* ===== SUGGEST-EDIT IDENTITY CARD ===== */
.iw-identity-card {
  padding: 16px 20px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.iw-identity-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.iw-identity-badge {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text-muted);
}
.iw-identity-verified {
  background: color-mix(in srgb, var(--verified) 20%, transparent);
  color: var(--verified);
}

/* ===== SUBMISSION SUMMARY ===== */
#iw-submission-summary {
  padding: 16px 20px;
  background: color-mix(in srgb, var(--verified) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--verified) 30%, var(--border));
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}
.iw-summary-item {
  padding: 4px 0;
}
.iw-summary-item + .iw-summary-item {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}

/* ===== SUBMITTED BADGE ===== */
.iw-submitted-badge {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--verified);
  padding: 2px 8px;
  background: color-mix(in srgb, var(--verified) 15%, transparent);
  border-radius: 10px;
}

/* ===== INLINE FIELD EDITOR ===== */
.field-editor-inline {
  padding: 16px;
  margin: 0 0 2px;
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
}
.field-row-btn:hover:not(.field-row-submitted) {
  background: var(--surface-alt);
}
.field-row-btn.field-row-open {
  background: var(--surface-alt);
}
.field-row-btn.field-row-submitted {
  opacity: 0.5;
  cursor: default;
}

/* ===== SUCCESS STATE ===== */
.iw-success-state {
  padding: 20px;
  background: color-mix(in srgb, var(--verified) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--verified) 30%, var(--border));
  border-radius: var(--radius);
}
.iw-success-msg {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  margin-bottom: 12px;
}
.iw-cross-tab {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.iw-cross-tab a {
  color: var(--accent);
  text-decoration: underline;
}

/* ===== INLINE ERROR ===== */
.iw-inline-error {
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--danger, #c0392b);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--danger, #c0392b);
  margin-bottom: 12px;
}

/* ===== SUGGEST-EDIT CROSS-TAB NAV ===== */
.iw-suggest-tabnav {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.iw-suggest-tabnav a {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

.iw-suggest-tabnav a:last-child { border-right: none; }

.iw-suggest-tabnav a:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.iw-suggest-tabnav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  pointer-events: none;
}

/* ===== RETURN LINK ===== */
.suggest-edit-return {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.875rem;
}
.suggest-edit-return a {
  color: var(--accent);
}

/* ===== MY CONTRIBUTIONS ===== */
.iw-contrib-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}
.iw-contrib-table th,
.iw-contrib-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.iw-contrib-table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-alt);
}
.iw-contrib-table td { color: var(--text); }
.iw-contrib-table a { color: var(--accent); }

.iw-status-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status-pending  { background: var(--accent-light); color: var(--accent); }
.status-review   { background: var(--accent-light); color: var(--accent); }
.status-approved { background: var(--verified-bg);  color: var(--verified); }
.status-rejected { background: color-mix(in srgb, #c0392b 12%, transparent); color: #c0392b; }
.status-reverted { background: color-mix(in srgb, #e67e22 12%, transparent); color: #e67e22; }
[data-theme="dark"] .status-rejected { color: #e57373; background: color-mix(in srgb, #e57373 15%, transparent); }
[data-theme="dark"] .status-reverted { color: #ffb74d; background: color-mix(in srgb, #ffb74d 15%, transparent); }

/* ===== UTILITIES ===== */
.mt-4  { margin-top: 16px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Mobile-only elements — hidden on desktop, shown via media query below */
.mobile-bottom-nav,
.mobile-drawer { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .container { padding: 0 16px; }

  /* Allow nav to expand vertically when drawer is open */
  .site-nav { height: auto; min-height: var(--nav-height); }
  .site-nav .container { flex-wrap: wrap; height: auto; min-height: var(--nav-height); }

  /* Hamburger button */
  .nav-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 32px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
  }
  .nav-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }
  /* Animate to X when open */
  .site-nav.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
  .site-nav.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
  .site-nav.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

  /* Hide nav links and right section behind the hamburger by default */
  .nav-links,
  .nav-right { display: none; }

  /* Drawer: full-width rows below the 56px rail */
  .site-nav.nav-open .nav-links,
  .site-nav.nav-open .nav-right {
    display: none; /* Hide drawer content in top nav; moving to bottom nav/drawer */
  }

  /* Hamburger button - Hidden because we use bottom nav now */
  .nav-hamburger {
    display: none !important;
  }

  /* MOBILE BOTTOM NAV */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: 64px;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }

  .mobile-bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none !important;
  }

  .mobile-bottom-nav .nav-item svg {
    width: 22px;
    height: 22px;
  }

  .mobile-bottom-nav .nav-item span {
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: lowercase;
  }

  .mobile-bottom-nav .nav-item.active {
    color: var(--accent);
  }

  /* MOBILE DRAWER (BOTTOM SHEET) */
  .mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none;
    align-items: flex-end;
  }

  .mobile-drawer.open {
    display: flex;
  }

  .mobile-drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-drawer.open .mobile-drawer-backdrop {
    opacity: 1;
  }

  .mobile-drawer-content {
    position: relative;
    width: 100%;
    max-height: 85vh;
    background: var(--bg);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
  }

  .mobile-drawer.open .mobile-drawer-content {
    transform: translateY(0);
  }

  .mobile-drawer-handle {
    width: 36px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 12px auto;
    flex-shrink: 0;
  }

  .mobile-drawer-body {
    padding: 0 20px 40px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* FAB for Filters */
  .filter-fab {
    position: fixed;
    right: 20px;
    bottom: 84px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 900;
    border: none;
    cursor: pointer;
  }

  .filter-fab svg { width: 24px; height: 24px; }

  .filter-fab .fab-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    background: #ff5252;
    border-radius: 9px;
    border: 2px solid #fff;
    display: none;
  }

  .filter-fab.active .fab-badge { display: block; }

  /* INSTITUTE SINGLE - MOBILE APP UI */
  .institute-header-mobile-sticky {
    position: sticky;
    top: 56px;
    z-index: 90;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.2s, opacity 0.2s;
    pointer-events: none;
  }

  .institute-header-mobile-sticky.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .sticky-title {
    font-family: var(--font-serif);
    font-size: 0.9375rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }

  /* TAB NAV - SEGMENTED CONTROL */
  .tab-nav {
    display: flex;
    background: var(--surface-alt);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-top: 24px;
    gap: 4px;
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }

  .tab-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: none;
    margin-bottom: 0;
    text-align: center;
    color: var(--text-muted);
  }

  .tab-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-bottom: none;
  }

  /* UTILS */
  .mobile-only { display: block; }
  .desktop-only { display: none; }
  body { padding-bottom: 64px; } /* Room for bottom nav */
  .site-footer { padding-bottom: 100px; } /* Extra room for footer */

  /* Ensure the filter sidebar is hidden on mobile, but its logic is used for the drawer */
  .filter-sidebar {
    display: none;
  }

  .home-hero { padding: 48px 0 40px; }
  .home-hero h1 { font-size: 1.625rem; }
  .home-hero .lead { font-size: 1rem; }
  .home-sections { grid-template-columns: 1fr; gap: 32px; }
  .home-cta { flex-direction: column; }

  .directory-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 24px 0 0;
  }

  .filter-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 24px;
    overflow: hidden;
  }

  /* Collapsible sidebar on mobile */
  .filter-sidebar-details {
    padding: 0;
  }
  .filter-sidebar-summary {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .filter-sidebar-summary::-webkit-details-marker { display: none; }
  .filter-sidebar-summary::after {
    content: '▾';
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.15s;
  }
  .filter-sidebar-details[open] .filter-sidebar-summary::after {
    transform: rotate(180deg);
  }
  .filter-sidebar-details .search-box,
  .filter-sidebar-details .filter-section,
  .filter-sidebar-details .filter-reset {
    padding-left: 16px;
    padding-right: 16px;
  }
  .filter-sidebar-details .search-box { padding-top: 4px; }
  .filter-sidebar-details .filter-reset { padding-bottom: 16px; }

  /* Larger touch targets */
  .chip { padding: 7px 12px; min-height: 44px; }
  .dark-toggle { padding: 8px 10px; min-height: 36px; }

  .filter-chips { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .filter-chips--affiliation { max-height: 176px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

  .institute-header h1 { font-size: 1.375rem; }

  /* Tab nav: fade right edge to signal horizontal scroll on narrow screens */
  .tab-nav {
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 36px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 36px), transparent 100%);
    padding-right: 36px; /* keep last tab reachable under the fade */
  }

  .tab-btn { padding: 10px 14px; font-size: 0.8125rem; }

  .overview-sidebar-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .glossary-term {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .footer-inner { flex-direction: column; gap: 20px; }
  .footer-links { margin-left: 0; flex-direction: row; flex-wrap: wrap; gap: 12px; }

  /* Breadcrumb: don't wrap (prevents orphaned › separator); truncate last crumb */
  .breadcrumb { flex-wrap: nowrap; overflow: hidden; }
  .breadcrumb a,
  .breadcrumb-sep { flex-shrink: 0; white-space: nowrap; }
  .breadcrumb > *:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  /* Program card: stack name above tags on narrow screens */
  .program-card-header { flex-direction: column; gap: 8px; }
  .program-name { min-width: 0; }
  .program-tags { flex-shrink: 1; }

  .form-row { grid-template-columns: 1fr; }

  /* Larger touch targets for form inputs and tag buttons */
  .form-input { padding: 11px 12px; min-height: 44px; }
  .tag { padding: 5px 10px; min-height: 30px; }
}

/* ===== TAG POPOVER ===== */
#iw-tag-popover {
  position: fixed;
  z-index: 9999;
  width: min(280px, calc(100vw - 16px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .12);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}
#iw-tag-popover.iw-popover-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.iw-popover-def {
  padding: 12px 15px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text);
}
.iw-popover-def a {
  color: var(--accent);
  text-decoration: underline;
}
[data-theme="dark"] #iw-tag-popover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, .4);
}
