/* ============================================================
   ExAC Study Textbook — style.css (Refined v2)
   Refined styling for ExAC 2025 Reviewer
   ============================================================ */

html, body {
  overflow-x: hidden;
  max-width: 100%;
  scroll-behavior: smooth;
}

:root {
  --gray-900: #18181b;
  --gray-800: #27272a;
  --gray-700: #3f3f46;
  --gray-600: #52525b;
  --gray-500: #71717a;
  --gray-400: #a1a1aa;
  --gray-300: #d4d4d8;
  --gray-200: #e4e4e7;
  --gray-100: #f4f4f5;
  --gray-50:  #fafafa;

  --slate:    #1e293b;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;

  --text:         #18181b;
  --text-mid:     #52525b;
  --text-muted:   #71717a;

  --bg:       #fafafa;
  --white:    #ffffff;
  --card-bg:  #ffffff;

  --border:       #e4e4e7;
  --divider:      #e4e4e7;
  --border-light: #f0f0f3;

  --accent-gold:  #b8860b;
  --accent-gold-light: #fef9e7;
  --accent-blue:  #2563eb;
  --accent-blue-light: #eff6ff;
  --accent-green: #16a34a;
  --accent-green-light: #f0fdf4;
  --accent-purple: #7c3aed;
  --accent-purple-light: #f5f3ff;

  --shadow-sm:  0 1px 3px rgba(24, 24, 27, 0.05);
  --shadow:     0 2px 12px rgba(24, 24, 27, 0.06);
  --shadow-md:  0 4px 20px rgba(24, 24, 27, 0.08);
  --shadow-lg:  0 8px 40px rgba(24, 24, 27, 0.10);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
  --transition-slow: 0.35s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Source Sans 3", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  background: linear-gradient(180deg, var(--slate) 0%, #0f172a 100%);
  overflow-y: auto;
  z-index: 100;
  padding-bottom: 50px;
  border-right: 1px solid rgba(255,255,255,0.04);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-logo {
  padding: 30px 28px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-logo .exam-label {
  font-family: "Source Code Pro", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--accent-gold);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
.sidebar-logo h1 {
  font-family: "Orbitron", serif;
  font-size: 24px;
  color: var(--white);
  font-weight: 500;
  line-height: 1.2;
}
.sidebar-logo .subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 4px;
  font-weight: 300;
}

.nav-section-label {
  padding: 20px 28px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--slate-400);
  opacity: 0.6;
}

.nav-item {
  display: block;
  padding: 9px 28px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
}
.nav-item:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--accent-gold);
}
.nav-item.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--accent-gold);
}
.nav-item .section-num {
  font-family: "Source Code Pro", monospace;
  font-size: 11px;
  color: var(--slate-400);
  display: block;
  margin-bottom: 1px;
}
.nav-item:hover .section-num,
.nav-item.active .section-num {
  color: var(--accent-gold);
}

.nav-group {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 4px;
}

#main {
  margin-left: 300px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* ── Banner ── */
.top-banner {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 64px 80px 52px;
  position: relative;
  overflow: hidden;
}
.top-banner::before {
  content: "ExAC 2025";
  position: absolute;
  right: 20px;
  bottom: 10px;
  font-family: "Playfair Display", serif;
  font-size: 110px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.04);
  pointer-events: none;
  line-height: 1;
  letter-spacing: 12px;
  user-select: none;
}
.banner-eyebrow {
  font-family: "Source Code Pro", monospace;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 14px;
  opacity: 0.9;
}
.banner-title {
  font-family: "Orbitron", serif;
  font-size: 32px;
  font-weight: 500;
  color: var(--white);
  line-height: 1.15;
  max-width: 500px;
  margin-bottom: 16px;
}
.banner-sub {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
  max-width: 620px;
  font-weight: 300;
  line-height: 1.6;
}
.banner-chips {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.chip {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--white);
  border-radius: 20px;
  padding: 5px 15px;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}
.chip.chip-unlocked {
  background: rgba(22, 163, 74, 0.2);
  border-color: rgba(22, 163, 74, 0.4);
}

.content {
  max-width: 1000px;
  padding: 0 80px 80px;
  margin: 0 auto;
}

.section {
  padding-top: 60px;
}
.section-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.section-badge {
  background: var(--gray-700);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-family: "Source Code Pro", monospace;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  margin-top: 4px;
  flex-shrink: 0;
}
.section-badge.section-badge-gold {
  background: var(--accent-gold);
  color: #fff;
}
.section-badge.section-badge-green {
  background: var(--accent-green);
  color: #fff;
}
.section-header-text h2 {
  font-family: "Orbitron", serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--gray-900);
  line-height: 1.25;
  margin-bottom: 6px;
}
.section-header-text .chop-ref {
  font-family: "Source Code Pro", monospace;
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.objective {
  margin-bottom: 28px;
}
.objective-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.objective-title .obj-num {
  font-family: "Source Code Pro", monospace;
  font-size: 12px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  color: var(--gray-500);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}
.objective-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gray-500);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 22px 26px;
  font-size: 16px;
  line-height: 1.75;
  transition: box-shadow var(--transition);
}
.objective-content:hover {
  box-shadow: var(--shadow-sm);
}
.objective-content p {
  margin-bottom: 12px;
}
.objective-content p:last-child {
  margin-bottom: 0;
}
.objective-content ul {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.objective-content ul li {
  padding: 3px 0 3px 20px;
  position: relative;
  font-size: 15.5px;
}
.objective-content ul li::before {
  content: "\25B8";
  position: absolute;
  left: 0;
  color: var(--gray-400);
  font-size: 12px;
  top: 5px;
}
.objective-content ul li ul {
  margin: 4px 0 4px 18px;
}
.objective-content ul li ul li::before {
  content: "\2013";
  color: var(--text-muted);
}
.objective-content strong {
  color: var(--gray-800);
  font-weight: 700;
}

/* ── Definition / Key / Ref boxes ── */
.def-box {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin: 18px 0;
  transition: box-shadow var(--transition);
}
.def-box:hover {
  box-shadow: var(--shadow-sm);
}
.def-box::before {
  content: "Definition";
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gray-500);
  display: block;
  margin-bottom: 8px;
}
.def-box p {
  font-size: 15.5px;
  color: var(--text);
  font-style: italic;
}

.key-box {
  background: var(--accent-gold-light);
  border: 1px solid #e8d5a0;
  border-left: 4px solid var(--accent-gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 18px 22px;
  margin: 18px 0;
  transition: box-shadow var(--transition);
}
.key-box:hover {
  box-shadow: var(--shadow-sm);
}
.key-box::before {
  content: "\01F511 Key Exam Point";
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-gold);
  display: block;
  margin-bottom: 8px;
}
.key-box p {
  font-size: 15.5px;
  color: var(--text);
}

.ref-box {
  background: var(--accent-blue-light);
  border: 1px solid #bdd7f5;
  border-left: 4px solid var(--accent-blue);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 14px 20px;
  margin: 14px 0;
  font-size: 14px;
  color: var(--accent-blue);
  font-family: "Source Code Pro", monospace;
}

/* ── Tables ── */
.styled-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 15px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.styled-table thead tr {
  background: var(--gray-800);
  color: var(--white);
}
.styled-table thead th {
  padding: 13px 18px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.styled-table tbody tr:nth-child(even) {
  background: var(--gray-100);
}
.styled-table tbody tr:nth-child(odd) {
  background: var(--white);
}
.styled-table tbody tr:hover {
  background: #f0f0f5;
}
.styled-table tbody td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* ── Q&A sections ── */
.qa-section {
  margin-top: 48px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.qa-section:hover {
  box-shadow: var(--shadow);
}
.qa-header {
  background: var(--gray-800);
  padding: 18px 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.qa-header h3 {
  font-family: "Playfair Display", serif;
  font-size: 20px;
  color: var(--white);
  font-weight: 700;
}
.qa-item {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
.qa-item:last-child {
  border-bottom: none;
}
.qa-question {
  position: relative;
  pointer-events: auto !important;
  z-index: 9999;
  padding: 18px 30px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  transition: background var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
}
.qa-question:hover {
  background: var(--gray-100);
}
.qa-question .q-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  flex: 1;
}
.qa-question .q-num {
  font-family: "Source Code Pro", monospace;
  font-size: 12px;
  background: var(--gray-500);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}
.qa-toggle {
  color: var(--gray-400);
  font-size: 18px;
  transition: transform var(--transition);
  flex-shrink: 0;
  margin-top: 2px;
}
.qa-item.open .qa-toggle {
  transform: rotate(180deg);
}
.qa-answer {
  font-size: 15.5px;
  color: var(--text);
  line-height: 1.7;
  border-top: 1px dashed var(--border);
  background: var(--gray-50);
  padding: 0 30px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.3s ease;
}
.qa-item.open .qa-answer {
  max-height: 3000px;
  padding: 18px 30px 22px;
}
.qa-answer p {
  margin-bottom: 8px;
}
.qa-answer p:last-child {
  margin-bottom: 0;
}
.qa-answer ul {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.qa-answer ul li {
  padding: 2px 0 2px 18px;
  position: relative;
  font-size: 15px;
}
.qa-answer ul li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--accent-green);
  font-size: 12px;
  top: 4px;
}

/* ── Visual Diagrams ── */
.diagram {
  margin: 20px 0;
  padding: 16px 18px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.diagram-title {
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.diagram-flow {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}
.diagram-flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.diagram-flow-box {
  background: var(--white);
  border: 2px solid var(--gray-500);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 12px;
  color: var(--gray-800);
  white-space: nowrap;
  line-height: 1.3;
}
.diagram-flow-box.df-highlight {
  background: var(--gray-500);
  color: var(--white);
  border-color: var(--gray-800);
}
.diagram-flow-box.df-bridge {
  background: var(--gray-800);
  color: var(--white);
  border-color: var(--gray-800);
}
.diagram-flow-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 75px;
  line-height: 1.3;
}
.diagram-flow-arrow {
  color: var(--gray-500);
  font-size: 18px;
  padding: 0 2px;
  margin-top: 6px;
  line-height: 1;
}
.diagram-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  line-height: 1.5;
}
.diagram-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.diagram-grid-cell {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.diagram-grid-cell-label {
  font-family: "Source Code Pro", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 3px;
}
.diagram-grid-cell-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 3px;
}
.diagram-grid-cell-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Misc ── */
.subsection-heading {
  font-family: "Playfair Display", serif;
  font-size: 20px;
  color: var(--gray-800);
  font-weight: 700;
  margin: 32px 0 16px;
  padding-left: 14px;
  border-left: 3px solid var(--gray-400);
}
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 40px 0;
}
.version-bar {
  background: var(--slate);
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 16px;
  font-size: 12px;
  font-family: "Source Code Pro", monospace;
  letter-spacing: 1px;
}

/* ── Key Summary Boxes ── */
.key-summary {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius-lg);
  padding: 30px 36px;
  margin: 48px 0 0;
  color: var(--white);
  box-shadow: var(--shadow-md);
}
.key-summary-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 16px;
}
.key-summary-icon {
  font-size: 24px;
}
.key-summary-header h3 {
  font-family: "Playfair Display", serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
  margin: 0;
}
.key-summary-header .ks-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: "Source Code Pro", monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 3px;
}
.ks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 800px) {
  .ks-grid { grid-template-columns: 1fr; }
}
.ks-point {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  transition: background var(--transition);
}
.ks-point:hover {
  background: rgba(255, 255, 255, 0.1);
}
.ks-point .kp-num {
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 6px;
  display: block;
}
.ks-point .kp-fact {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.4;
  margin-bottom: 4px;
}
.ks-point .kp-tip {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
}
.ks-mnemonic {
  background: rgba(184, 134, 11, 0.12);
  border: 1px solid rgba(184, 134, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 4px;
}
.ks-mnemonic .km-label {
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 6px;
  display: block;
}
.ks-mnemonic .km-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
}
.ks-mnemonic .km-text strong {
  color: #f0d070;
}

/* ── ARE Question Blocks ── */
.are-q-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.are-q-num {
  font-family: "Source Code Pro", monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--gray-800);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 10px;
}
.are-q-text {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin: 10px 0 4px;
}
.are-q-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.are-diagram {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0 8px;
  display: flex;
  justify-content: center;
}
.are-diagram svg {
  max-width: 100%;
}
.are-options {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.are-options li {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 15.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.are-options li:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}
.are-options li.correct-opt {
  background: var(--accent-green-light);
  border-color: var(--accent-green);
  font-weight: 600;
}
.are-options li.wrong-opt {
  background: #fef2f2;
  border-color: #f87171;
}
.are-multi-note {
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.are-check-btn {
  margin-top: 10px;
  background: var(--gray-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.are-check-btn:hover {
  background: var(--gray-800);
}
.are-result {
  display: none;
  margin-top: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.6;
}
.are-result.show { display: block; }
.are-result.pass {
  background: var(--accent-green-light);
  border: 1px solid var(--gray-300);
}
.are-result.fail {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}
.are-tag {
  display: inline-block;
  font-family: "Source Code Pro", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.are-tag.theme1 { background: #e8f4d8; color: var(--gray-800); }
.are-tag.theme2 { background: #e4eef8; color: #2a5f8f; }
.are-tag.theme3 { background: #f8f4e8; color: #8f6a2a; }
.are-tag.theme4 { background: #f4e8f8; color: #6a2a8f; }
.are-tag.theme8 { background: #f8e8e8; color: #8f2a2a; }
.are-tag.theme9 { background: #e8eef8; color: #2a4a8f; }
.are-tag.theme10 { background: #f0f8e8; color: #3a6a1a; }
.are-tag.theme13 { background: #e4f8ef; color: #0d6e4e; }
.are-tag.ccdc { background: #e8edf8; color: #2a3f8f; }
.are-calc {
  background: #f8faf5;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.7;
}
.are-calc strong { color: var(--gray-800); }

/* ── Mobile Header ── */
#mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--slate);
  z-index: 200;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
#hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition);
}
#hamburger:hover { background: rgba(255, 255, 255, 0.08); }
#hamburger span {
  display: block;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all 0.3s;
  transform-origin: center;
}
#hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
#mobile-header-title {
  font-family: "Playfair Display", serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.3px;
}
#mobile-header-title span {
  font-family: "Source Code Pro", monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent-gold);
  text-transform: uppercase;
  display: block;
  margin-bottom: 1px;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 18px 0;
  border-radius: var(--radius-md);
}
.table-scroll .styled-table {
  margin: 0;
  border-radius: var(--radius-md);
}

@media print {
  body * { display: none !important; }
  body::after {
    display: block !important;
    content: "Printing this document is not permitted.";
    font-family: sans-serif;
    font-size: 18px;
    text-align: center;
    margin-top: 40vh;
    color: #333;
  }
}

/* ── TABLET ── */
@media (max-width: 1000px) {
  #sidebar { width: 260px; }
  #main { margin-left: 260px; }
  .top-banner {
    padding: 48px 40px 40px;
  }
  .top-banner::before {
    font-size: 80px;
    letter-spacing: 10px;
    right: 15px;
  }
  .banner-title { font-size: 36px; }
  .content { padding: 0 40px 60px; }
}

/* ── MOBILE ── */
@media (max-width: 800px) {
  body { font-size: 16px; }

  #mobile-header { display: flex; }

  #sidebar {
    width: 85vw;
    max-width: 320px;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 300;
    padding-top: 0;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay { display: block; }

  #main {
    margin-left: 0 !important;
    padding-top: 60px;
    width: 100%;
    max-width: 100vw;
  }

  .top-banner {
    padding: 32px 18px 28px;
    width: 100%;
    box-sizing: border-box;
  }
  .top-banner::before {
    font-size: 70px;
    letter-spacing: 8px;
    right: 10px;
    bottom: 6px;
  }
  .banner-eyebrow { font-size: 10px; margin-bottom: 10px; }
  .banner-title { font-size: 26px; max-width: 100%; }
  .banner-sub { font-size: 14px; max-width: 100%; }
  .banner-chips { gap: 7px; margin-top: 20px; }
  .chip { font-size: 12px; padding: 4px 12px; }

  .content {
    padding: 0 14px 48px;
    width: 100%;
    box-sizing: border-box;
  }
  .section { padding-top: 40px; }

  .section-header {
    gap: 12px;
    margin-bottom: 22px;
    flex-wrap: wrap;
  }
  .section-header-text h2 { font-size: 22px; }
  .section-badge { font-size: 12px; padding: 6px 10px; }

  .objective-content {
    padding: 14px;
    font-size: 14.5px;
  }
  .objective-title { font-size: 12px; }

  .key-box { padding: 12px 14px; }
  .key-box p { font-size: 14px; }
  .def-box { padding: 12px 14px; }
  .def-box p { font-size: 14px; }
  .ref-box { font-size: 12px; padding: 10px 12px; }

  .table-scroll { overflow-x: visible; background: none; border-radius: 0; }

  .styled-table,
  .styled-table thead,
  .styled-table tbody,
  .styled-table th,
  .styled-table td,
  .styled-table tr {
    display: block;
    width: 100%;
    min-width: 0 !important;
    box-sizing: border-box;
  }
  .styled-table thead tr { display: none; }
  .styled-table tbody tr {
    background: var(--white) !important;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }
  .styled-table tbody td {
    border-bottom: 1px solid var(--gray-100);
    padding: 9px 12px;
    font-size: 13.5px;
    position: relative;
  }
  .styled-table tbody td:last-child { border-bottom: none; }
  .styled-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--gray-500);
    font-family: "Source Code Pro", monospace;
    margin-bottom: 3px;
  }

  .qa-section { margin-top: 30px; }
  .qa-header { padding: 14px 18px; }
  .qa-header h3 { font-size: 16px; }
  .qa-question {
    padding: 14px 18px;
    gap: 6px;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .qa-question .q-num { order: -1; margin-top: 0; margin-bottom: 3px; }
  .qa-question .q-text { font-size: 14px; flex: 1 1 100%; order: 0; }
  .qa-toggle { order: -1; margin-left: auto; align-self: flex-start; font-size: 16px; }
  .qa-answer { padding: 0 18px; font-size: 13.5px; }
  .qa-item.open .qa-answer { padding: 14px 18px 18px; }
  .qa-answer ul li { font-size: 13px; }

  .ks-grid { grid-template-columns: 1fr; }
  .key-summary { padding: 20px 18px; }
  .key-summary-header h3 { font-size: 17px; }
  .subsection-heading { font-size: 17px; margin: 24px 0 12px; }
}

/* ── SMALL MOBILE ── */
@media (max-width: 480px) {
  .top-banner { padding: 24px 12px 20px; }
  .top-banner::before { font-size: 50px; letter-spacing: 5px; }
  .banner-title { font-size: 22px; }
  .content { padding: 0 10px 40px; }
  .qa-question { padding: 11px 12px; gap: 4px; }
  .qa-question .q-text { font-size: 13px; }
  .qa-answer { padding: 0 12px; font-size: 13px; }
  .qa-item.open .qa-answer { padding: 12px 12px 16px; }
  .key-summary { padding: 16px 14px; }
}

/* ── Flashcards ── */
.fc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 24px;
  padding: 0 20px;
}
.fc-tab {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.fc-tab:hover { border-color: var(--gray-500); color: var(--gray-500); }
.fc-tab.fc-active { background: var(--gray-800); color: var(--white); border-color: var(--gray-800); }

.fc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.fc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 170px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), transform 0.15s ease;
  background: var(--white);
}
.fc-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.fc-front,
.fc-back {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.fc-back {
  display: none;
  background: var(--gray-100);
}
.fc-card.fc-flipped .fc-front { display: none; }
.fc-card.fc-flipped .fc-back  { display: flex; }
.fc-theme-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.fc-q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  flex: 1;
}
.fc-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 12px;
}
.fc-a {
  font-size: 13px;
  color: var(--slate);
  line-height: 1.65;
  flex: 1;
}
.fc-flip-back {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
  text-align: left;
}
.fc-flip-back:hover { color: var(--gray-800); }
.fc-hidden { display: none !important; }

@media (max-width: 800px) {
  .fc-grid { grid-template-columns: 1fr; }
  .fc-tabs { padding: 0; }
}