/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f5f7fa;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --primary:  #2563eb;
  --primary-dark: #1d4ed8;
  --secondary:#475569;
  --muted:    #94a3b8;
  --text:     #1e293b;
  --text-light: #64748b;
  --success:  #16a34a;
  --warning:  #d97706;
  --danger:   #dc2626;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

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

/* ── Layout ───────────────────────────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 0 2rem; }

/* ── Header ───────────────────────────────────────────────────────────── */
header {
  background: var(--primary);
  color: #fff;
  padding: 1.25rem 0;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}

header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: #fff;
  text-decoration: none;
}
.site-title span { font-weight: 300; opacity: .85; }

nav a {
  color: rgba(255,255,255,.85);
  font-size: .9rem;
  margin-left: 1.25rem;
  transition: color .15s;
}
nav a:hover { color: #fff; text-decoration: none; }

/* ── Hero / Page Title ─────────────────────────────────────────────────── */
.page-hero {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  padding: 2.5rem 0 2rem;
  margin-bottom: 2rem;
}
.page-hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: .4rem; }
.page-hero p  { opacity: .85; font-size: 1.05rem; max-width: 620px; }

/* ── Search ───────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: .5rem;
  margin-top: 1.25rem;
  max-width: 480px;
}
.search-bar input {
  flex: 1;
  padding: .55rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.search-bar button {
  padding: .55rem 1.2rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s;
}
.search-bar button:hover { background: #000; }

/* ── Typeahead Dropdown ───────────────────────────────────────────────── */
.ta-wrapper {
  position: relative;
  display: inline-flex;
}

.ta-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.07);
  z-index: 9999;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}

.ta-dropdown.ta-open { display: block; }

.ta-section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #94a3b8;
  padding: .55rem 1rem .3rem;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}

.ta-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .6rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: background .1s;
  border-bottom: 1px solid #f1f5f9;
  outline: none;
}
.ta-item:hover,
.ta-item:focus {
  background: #f0f9ff;
  text-decoration: none;
  color: var(--text);
}

.ta-item-icon {
  flex-shrink: 0;
  font-size: .95rem;
  margin-top: .1rem;
  opacity: .65;
}

.ta-item-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.ta-item-title {
  font-size: .88rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ta-item-sub {
  font-size: .78rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ta-item-sub mark {
  background: #fef9c3;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.ta-see-all {
  display: block;
  padding: .65rem 1rem;
  font-size: .82rem;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  outline: none;
  transition: background .1s;
}
.ta-see-all:hover,
.ta-see-all:focus {
  background: #eff6ff;
  text-decoration: none;
}

.ta-empty {
  padding: .9rem 1rem;
  font-size: .85rem;
  color: #94a3b8;
  text-align: center;
}

.ta-spinner {
  padding: .9rem 1rem;
  font-size: .85rem;
  color: #94a3b8;
  text-align: center;
}

@keyframes ta-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.ta-spin-icon {
  display: inline-block;
  animation: ta-rotate .7s linear infinite;
}

/* ── Category Section ─────────────────────────────────────────────────── */
.category-section { margin-bottom: 2.25rem; }

.category-heading {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  padding-bottom: .45rem;
  margin-bottom: 1rem;
}

/* ── Event Cards ──────────────────────────────────────────────────────── */
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
@media (min-width: 1200px) {
  .event-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (min-width: 900px) and (max-width: 1199px) {
  .event-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.event-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }

.event-card-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.event-card-category {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
}
.event-card-topic {
  font-size: .83rem;
  color: var(--text-light);
  font-style: italic;
}
.event-card-desc {
  font-size: .88rem;
  color: var(--secondary);
  line-height: 1.5;
  flex: 1;
}
.event-card-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--primary-dark);
  width: fit-content;
}
.event-card-badge.trial { background: #fef3c7; color: #92400e; }

/* ── Breadcrumb ───────────────────────────────────────────────────────── */
.breadcrumb {
  font-size: .85rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Event Detail Layout ─────────────────────────────────────────────── */
.event-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.75rem; align-items: start; }

/* ── Cards / Panels ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: .6rem;
}
.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 .5rem;
  color: var(--text);
}

/* ── Event meta tags ─────────────────────────────────────────────────── */
.meta-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.meta-tag {
  font-size: .8rem;
  font-weight: 600;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--secondary);
}
.meta-tag.category { background: #dbeafe; color: var(--primary-dark); }
.meta-tag.trial { background: #fef3c7; color: #92400e; }

/* ── Study Topics ────────────────────────────────────────────────────── */
.topic-category { margin-bottom: 1.25rem; }
.topic-category-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
  margin-bottom: .6rem;
}
.topic-item {
  padding: .65rem .85rem;
  border-left: 3px solid var(--border);
  margin-bottom: .5rem;
  background: #f8fafc;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.topic-name { font-weight: 600; font-size: .95rem; }
.topic-concepts { font-size: .83rem; color: var(--text-light); margin-top: .2rem; }
.topic-difficulty {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 4px;
  margin-top: .35rem;
  text-transform: capitalize;
}
.diff-beginner  { background: #dcfce7; color: #15803d; }
.diff-intermediate { background: #fef9c3; color: #a16207; }
.diff-advanced  { background: #fee2e2; color: #b91c1c; }

/* ── Practice Questions ──────────────────────────────────────────────── */
.question-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .85rem;
  overflow: hidden;
}
.question-header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
}
.question-header:hover { background: #f1f5f9; }
.question-num {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  padding-top: .1rem;
}
.question-text { flex: 1; font-size: .93rem; font-weight: 500; }
.question-diff { margin-left: auto; }

.question-answer {
  padding: .75rem 1rem .85rem;
  border-top: 1px solid var(--border);
  background: #fff;
  display: none;
}
.question-answer.open { display: block; }
.answer-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--primary); margin-bottom: .25rem; }
.answer-text { font-size: .9rem; color: var(--text); }

/* ── Resources ───────────────────────────────────────────────────────── */
.resource-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.resource-item:last-child { border-bottom: none; }
.resource-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}
.resource-info { flex: 1; min-width: 0; }
.resource-title { font-weight: 600; font-size: .93rem; }
.resource-desc { font-size: .82rem; color: var(--text-light); margin-top: .15rem; }
.resource-type {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-top: .2rem;
}

/* ── Markdown Content ────────────────────────────────────────────────── */
.md-content h1 { font-size: 1.5rem; font-weight: 800; margin: 1.5rem 0 .6rem; color: var(--text); }
.md-content h2 { font-size: 1.2rem; font-weight: 700; margin: 1.25rem 0 .5rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.md-content h3 { font-size: 1rem; font-weight: 700; margin: 1rem 0 .4rem; color: var(--primary-dark); }
.md-content p  { margin: .5rem 0; font-size: .93rem; color: var(--secondary); }
.md-content ul { margin: .5rem 0 .75rem 1.25rem; }
.md-content li { font-size: .93rem; margin-bottom: .2rem; color: var(--secondary); }
.md-content code { background: #f1f5f9; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; font-family: monospace; }
.md-content a  { color: var(--primary); }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar .card { margin-bottom: 1.25rem; }
.sidebar .card h2 { font-size: 1rem; }

/* ── No results ──────────────────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}
.no-results h3 { font-size: 1.2rem; margin-bottom: .5rem; }

/* ── Footer ──────────────────────────────────────────────────────────── */
footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .83rem;
  color: var(--muted);
}

/* ── Responsive ──────────────────────────────────────────────────────── */

/* ── Mock Exam nav link ─────────────────────────────────────────────────── */
.nav-exam {
  background: var(--accent, #2563eb);
  color: #fff !important;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.875rem;
}
.nav-exam:hover { opacity: 0.85; }

/* ── Mock Exam banner ───────────────────────────────────────────────────── */
.exam-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: #fff;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  text-decoration: none;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  transition: opacity .2s;
}
.exam-banner:hover { opacity: 0.92; }
.exam-banner-icon { font-size: 2rem; flex-shrink: 0; }
.exam-banner div { flex: 1; }
.exam-banner strong { display: block; font-size: 1.1rem; }
.exam-banner span { font-size: 0.875rem; opacity: 0.85; }
.exam-banner-cta {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Video Resources Section ─────────────────────────────────────────── */
.video-topic-section {
  margin-bottom: 2rem;
}
.video-topic-section:last-child {
  margin-bottom: 0;
}
.video-topic-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}

/* 2-column responsive grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
@media (max-width: 640px) {
  .video-grid {
    grid-template-columns: 1fr;
  }
}

/* Card */
.video-card {
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s;
}
.video-card:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}

/* 16:9 embed wrapper */
.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #000;
  flex-shrink: 0;
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Non-embeddable thumbnail */
.video-thumb-link {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  flex-shrink: 0;
}
.video-thumb-link img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  opacity: 0;
  transition: opacity .2s;
}
.video-thumb-link:hover .video-play-overlay {
  opacity: 1;
}

/* Card body */
.video-info {
  padding: .75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.video-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: .3rem;
}
.video-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .5rem;
}
.video-channel {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}
.video-duration {
  font-size: .75rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
.video-summary {
  font-size: .82rem;
  color: var(--secondary);
  line-height: 1.55;
  flex: 1;
}
.video-watch-btn {
  display: inline-block;
  margin-top: .75rem;
  background: #ff0000;
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  padding: .4rem .85rem;
  border-radius: 5px;
  text-decoration: none;
  align-self: flex-start;
  transition: background .15s;
}
.video-watch-btn:hover {
  background: #cc0000;
  text-decoration: none;
}


/* ══════════════════════════════════════════════════════════════════
   STUDY GUIDE — /study/water-quality  (study_wq.html)
   ══════════════════════════════════════════════════════════════════ */

/* ── Two-column layout ─────────────────────────────────────────── */
.swq-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
  padding-top: 1.75rem;
  padding-bottom: 3rem;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.swq-sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.swq-sidebar-inner {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem .75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.swq-sidebar-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-light);
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid #e2e8f0;
}
.swq-module-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.swq-mod-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  font-size: .82rem;
  color: var(--text);
  text-decoration: none;
  transition: background .12s, color .12s;
  line-height: 1.3;
}
.swq-mod-link:hover, .swq-mod-link.active {
  background: #e0f2fe;
  color: #0369a1;
  text-decoration: none;
}
.swq-mod-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: #f1f5f9;
  color: #475569;
  font-size: .75rem;
  font-weight: 700;
  border-radius: 5px;
  flex-shrink: 0;
}
.swq-mod-link.active .swq-mod-num {
  background: #0369a1;
  color: #fff;
}
.swq-sidebar-link {
  display: inline-block;
  margin-top: .35rem;
  font-size: .8rem;
  color: #0369a1;
  text-decoration: none;
}
.swq-sidebar-link:hover { text-decoration: underline; }

/* ── Gap banner ────────────────────────────────────────────────── */
.swq-gap-banner {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .9rem;
  color: #92400e;
}
.swq-gap-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem; }
.swq-avail-count { display: block; font-size: .82rem; color: #78350f; margin-top: .2rem; }

/* ── Filter bar ────────────────────────────────────────────────── */
.swq-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.25rem;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: .85rem 1rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.swq-filter-group {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.swq-filter-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
}
.swq-filter-btn {
  padding: .28rem .65rem;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.swq-filter-btn:hover {
  border-color: #0369a1;
  color: #0369a1;
  background: #e0f2fe;
}
.swq-filter-btn.active {
  background: #0369a1;
  color: #fff;
  border-color: #0369a1;
}
.swq-filter-reset {
  padding: .28rem .65rem;
  border-radius: 20px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #dc2626;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  margin-left: auto;
  transition: all .12s;
}
.swq-filter-reset:hover { background: #fee2e2; }
.swq-filter-status {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  padding: .4rem .75rem;
  background: #f0f9ff;
  border-radius: 6px;
}

/* ── Module sections ───────────────────────────────────────────── */
.swq-module-section {
  margin-bottom: 2.5rem;
}
.swq-module-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid #e0f2fe;
}
.swq-module-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #0369a1, #0ea5e9);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(3,105,161,.3);
}
.swq-module-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0c4a6e;
  margin: 0 0 .2rem;
}
.swq-module-desc {
  font-size: .85rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.5;
}

/* ── Topic cards grid ──────────────────────────────────────────── */
.swq-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .85rem;
}
.swq-topic-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: .85rem 1rem;
  transition: box-shadow .15s, border-color .15s;
}
.swq-topic-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,.09);
  border-color: #93c5fd;
}

/* Gap / coming-soon card */
.swq-topic-gap {
  background: #f8fafc;
  border-color: #e2e8f0;
  border-style: dashed;
  opacity: .85;
}
.swq-topic-gap:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
  border-color: #94a3b8;
}

.swq-topic-code {
  font-size: .72rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: .04em;
  margin-bottom: .25rem;
}
.swq-topic-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: .6rem;
}
.swq-topic-gap .swq-topic-title { color: #64748b; }

/* ── Tags ──────────────────────────────────────────────────────── */
.swq-topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .65rem;
}
.swq-tag {
  display: inline-flex;
  align-items: center;
  font-size: .68rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 10px;
  white-space: nowrap;
}
/* Priority badges */
.swq-tag-pri-high    { background: #fee2e2; color: #b91c1c; }
.swq-tag-pri-medium  { background: #fef9c3; color: #854d0e; }
.swq-tag-pri-low     { background: #dcfce7; color: #166534; }
/* Type chip */
.swq-tag-type        { background: #e0f2fe; color: #0369a1; }
/* Difficulty chip */
.swq-tag-diff-beginner     { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.swq-tag-diff-intermediate { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.swq-tag-diff-advanced     { background: #fdf4ff; color: #9333ea; border: 1px solid #e9d5ff; }
/* Exam frequency chip */
.swq-tag-freq { background: #f1f5f9; color: #475569; }

/* ── Topic status row ──────────────────────────────────────────── */
.swq-topic-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: .5rem;
  border-top: 1px solid #f1f5f9;
  font-size: .8rem;
}
.swq-status-available { color: #16a34a; font-weight: 600; }
.swq-status-gap       { color: #92400e; font-weight: 600; }
.swq-study-link {
  color: #0369a1;
  font-weight: 700;
  text-decoration: none;
  font-size: .8rem;
  padding: .2rem .5rem;
  border-radius: 5px;
  background: #e0f2fe;
  transition: background .12s;
}
.swq-study-link:hover { background: #bae6fd; text-decoration: none; }

/* ── Mobile: hide sidebar, show content full-width ─────────────── */
@media (max-width: 768px) {
  .swq-layout {
    grid-template-columns: 1fr;
  }
  .swq-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .swq-sidebar-inner {
    border-radius: 8px;
  }
  .swq-module-nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .swq-mod-link {
    flex-direction: row;
    align-items: center;
    font-size: .82rem;
    padding: .38rem .5rem;
    min-width: 0;
  }
  .swq-mod-short { display: block; }
  .swq-filter-bar {
    flex-direction: column;
    align-items: flex-start;
    position: static;
  }
  .swq-topic-grid {
    grid-template-columns: 1fr;
  }
}
/* ── end study guide ─────────────────────────────────────────── */

/* ── Typography improvements ─────────────────────────────────────────── */
.study-content p,
.key-concepts,
.explanation {
  max-width: 800px;
  line-height: 1.7;
}

/* ── Wider event layout (water_quality.html) ──────────────────────────── */
.event-layout {
  grid-template-columns: 1fr 300px;
}
@media (max-width: 960px) {
  .event-layout { grid-template-columns: 1fr; }
}

/* ── "On This Page" sidebar nav ───────────────────────────────────────── */
.otp-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: .5rem;
}
.otp-nav a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  font-size: .84rem;
  color: #0369a1;
  text-decoration: none;
  transition: background .12s;
}
.otp-nav a:hover {
  background: #e0f2fe;
  text-decoration: none;
}

/* ── Mobile responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 0 1rem; }
  .page-hero h1 { font-size: 1.5rem; }
  .event-grid { grid-template-columns: 1fr; }
}

/* ── Section Progress Tracking ────────────────────────────────────────── */

/* Viewed accordion state */
.sm-accordion.viewed .sm-accordion-btn {
  background: #f0fdf4;
}
.sm-accordion.viewed .sm-accordion-title {
  color: #15803d;
  opacity: 0.8;
}

/* Custom checkbox — hidden input + styled label */
.sm-viewed-cb {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: .5rem;
  position: relative;
  width: 20px;
  height: 20px;
}
.sm-viewed-cb-input {
  position: absolute;
  opacity: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.sm-viewed-cb-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  flex-shrink: 0;
}
.sm-viewed-cb-input:hover + .sm-viewed-cb-label {
  border-color: #86efac;
}
.sm-viewed-cb-input:checked + .sm-viewed-cb-label {
  background: #16a34a;
  border-color: #16a34a;
}
.sm-viewed-cb-input:checked + .sm-viewed-cb-label::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Sidebar module progress bar */
.sm-mod-progress {
  padding: .1rem .45rem .35rem;
  margin-top: .1rem;
}
.sm-mod-progress-text {
  font-size: .72rem;
  color: #64748b;
  font-weight: 500;
}

/* Module nav badges */
.sm-mod-badge {
  flex-shrink: 0;
  font-size: .7rem;
  font-weight: 700;
  min-width: 14px;
  text-align: center;
  margin-left: auto;
}
.sm-mod-badge-progress {
  color: #0369a1;
}
.sm-mod-badge-done {
  color: #16a34a;
}

/* ── Markdown-rendered tables ──────────────────────────────────────────── */
.sm-narrative-prose table,
.module-narrative table,
.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .9rem;
}
.sm-narrative-prose table th,
.module-narrative table th,
.md-content table th {
  background: #0369a1;
  color: #fff;
  padding: .5rem .85rem;
  text-align: left;
  font-weight: 700;
}
.sm-narrative-prose table td,
.module-narrative table td,
.md-content table td {
  padding: .45rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.sm-narrative-prose table tr:nth-child(even) td,
.module-narrative table tr:nth-child(even) td,
.md-content table tr:nth-child(even) td {
  background: #f0f9ff;
}

/* ── Markdown table styles for study content ─────────────────────────── */
.study-content table,
.sm-accordion-body table,
.topic-concepts table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.study-content th,
.sm-accordion-body th,
.topic-concepts th {
  background: #0369a1;
  color: #fff;
  padding: .5rem .85rem;
  text-align: left;
  font-weight: 700;
  border: 1px solid #e2e8f0;
}
.study-content td,
.sm-accordion-body td,
.topic-concepts td {
  border: 1px solid #e2e8f0;
  padding: .45rem .85rem;
  text-align: left;
  vertical-align: top;
}
.study-content tr:nth-child(even),
.sm-accordion-body tr:nth-child(even),
.topic-concepts tr:nth-child(even) {
  background: #f0f9ff;
}

/* ── Subject nav bar (breadcrumb + tabs) ─────────────────────── */
.subject-nav-bar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 90;
}
.subject-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .6rem 0;
}
.subject-breadcrumb {
  font-size: .82rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-shrink: 0;
}
.subject-breadcrumb a {
  color: #0369a1;
  text-decoration: none;
  font-weight: 500;
}
.subject-breadcrumb a:hover { text-decoration: underline; }
.snb-sep { color: #cbd5e1; font-size: .9rem; }
.subject-nav-links {
  display: flex;
  gap: .15rem;
  flex-wrap: wrap;
}
.snb-link {
  padding: .3rem .7rem;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.snb-link:hover { background: #f1f5f9; color: #0369a1; text-decoration: none; }
.snb-link.snb-active {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 700;
}
@media (max-width: 600px) {
  .subject-nav-inner { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .snb-link { font-size: .78rem; padding: .25rem .55rem; }
}
