:root {
  --ink: #f0ece4;
  --paper: #0e0d0b;
  --warm: #1a1814;
  --card: #141210;
  --border: #2a2620;
  --c1: #e8a250;   /* amber - nouns */
  --c2: #7ec8a4;   /* sage - pronouns */
  --c3: #89b4e8;   /* steel blue - adjectives */
  --c4: #e87c6a;   /* coral - verbs */
  --c5: #b48ee8;   /* lavender - adverbs */
  --c6: #e8d06a;   /* gold - prepositions */
  --c7: #6adde8;   /* cyan - conjunctions */
  --c8: #e86ab4;   /* pink - articles */
  --c9: #a8e86a;   /* lime - determiners */
  --c10: #e86a6a;  /* red - interjections */
  --c11: #6a88e8;  /* indigo - numbers */
  --c12: #6ae8c8;  /* mint - verb tenses */
  --c13: #e8b36a;  /* saffron - modals */
  --c14: #8ae86a;  /* spring - questions */
  --c15: #e86ad6;  /* magenta - conditionals */
  --c16: #6ab6e8;  /* sky - inf./gerund */
  --c17: #e8a26a;  /* apricot - phrasals */
  --c18: #e8526a;  /* crimson - reported speech */
  --c19: #a06ae8;  /* purple - passive voice */
  --c20: #52e88a;  /* green - clauses */
  --c21: #e8d452;  /* yellow - word formation */
  --c22: #52b8e8;  /* sky2 - punctuation */
  --c23: #e89052;  /* orange - negation */
  --c24: #c8e852;  /* chartreuse - comparisons */
  --c25: #52e8d4;  /* teal - word order */
  --c26: #e852c8;  /* fuchsia - discourse */
  --muted: #6a6560;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Syne', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── GRAIN OVERLAY ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ── HERO ── */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 112px 24px 60px; /* top clears 52px ctrl-bar */
  position: relative;
  background:
    radial-gradient(ellipse 60% 40% at 20% 80%, rgba(232,162,80,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 20%, rgba(137,180,232,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 50% 50%, rgba(232,124,106,0.04) 0%, transparent 70%);
}

.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 28px;
  opacity: 0;
  animation: rise 0.8s 0.2s forwards;
}

.hero h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(3.5rem, 9vw, 8rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -2px;
  margin-bottom: 32px;
  opacity: 0;
  animation: rise 0.9s 0.4s forwards;
}

.hero h1 em {
  font-style: italic;
  background: linear-gradient(135deg, var(--c1), var(--c4), var(--c3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 1rem;
  color: var(--muted);
  max-width: 460px;
  line-height: 1.7;
  margin-bottom: 56px;
  font-weight: 400;
  opacity: 0;
  animation: rise 0.9s 0.6s forwards;
}

.hero-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 700px;
  opacity: 0;
  animation: rise 1s 0.8s forwards;
}

.cat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--warm);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--ink);
}

.cat-chip:hover { transform: translateY(-2px); }
.cat-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── LAYOUT ── */
.wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 120px;
}

/* ── SECTION ── */
.gram-section {
  margin-bottom: 100px;
  scroll-margin-top: 100px; /* ctrl-bar 52 + nav ~48 */
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 48px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.section-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
  flex-shrink: 0;
  margin-top: 4px;
}

.section-title-group { flex: 1; }

.section-en {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}

.section-pt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  margin-top: 8px;
  line-height: 1.6;
  opacity: 0.75;
}

.section-bar {
  width: 48px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: center;
}

/* ── CARDS GRID ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.cards-grid.wide {
  grid-template-columns: 1fr;
}

.cards-grid.two {
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
}

/* collapse all grid cards to single column on mobile */
@media (max-width: 700px) {
  .cards-grid,
  .cards-grid.two {
    grid-template-columns: 1fr;
  }
}

/* ── CARD ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.card:hover { border-color: var(--border-hover, #3a3530); }

.card-accent {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 2px;
  border-radius: 6px 6px 0 0;
}

.card-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #fff;
}

.card-sub {
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.5;
  font-weight: 400;
}

/* ── TABLE ── */
.tbl-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  /* thin scrollbar track */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tbl-scroll::-webkit-scrollbar { height: 3px; }
.tbl-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.tbl-scroll::-webkit-scrollbar-track { background: transparent; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tbl th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  white-space: nowrap;
}

.tbl td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(42,38,32,0.6);
  vertical-align: top;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: break-word;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(255,255,255,0.02); }

/* mobile table adjustments */
@media (max-width: 640px) {
  .tbl { font-size: 0.83rem; }
  .tbl th,
  .tbl td { padding: 7px 8px; }
}
@media (max-width: 420px) {
  .tbl { font-size: 0.79rem; }
  .tbl th,
  .tbl td { padding: 6px 7px; }
}

.en { font-weight: 600; color: #fff; }
.pt { color: var(--muted); font-size: 0.82rem; }
.ex { color: #c8c0b4; font-style: italic; font-size: 0.85rem; }

/* ── FORMULA ── */
.formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 12px 0;
  color: #c8c0b4;
  white-space: pre-wrap;
}

/* ── EXAMPLE ── */
.example {
  padding: 10px 14px;
  border-radius: 4px;
  margin: 8px 0;
  font-size: 0.88rem;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid var(--accent-ex, #666);
}

.example .en { display: block; margin-bottom: 3px; font-style: italic; }
.example .pt { display: block; color: var(--muted); font-style: normal; }

/* ── PILL GRID ── */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--ink);
}

.pill .meaning {
  color: var(--muted);
  font-size: 10px;
  margin-left: 6px;
}

/* ── HIGHLIGHT BOX ── */
.highlight {
  border-radius: 4px;
  padding: 16px 18px;
  margin: 16px 0;
  font-size: 0.88rem;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
}

.highlight strong { color: #fff; }

/* ── RULE ROW ── */
.rule-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.rule-row:last-child { border-bottom: none; }
.rule-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.rule-text { color: var(--muted); line-height: 1.5; }
.rule-text strong { color: var(--ink); }

/* ── COMPARISON TABLE ── */
.comp-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.comp-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.comp-cell {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.comp-cell .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

/* ── NAV ── */
.sticky-nav {
  position: sticky;
  top: 52px; /* stack below fixed ctrl-bar */
  z-index: 100;
  background: rgba(14,13,11,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.sticky-nav::-webkit-scrollbar { display: none; }

.nav-item {
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  display: block;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: #fff; border-bottom-color: currentColor; }

/* ── ORDER BOX ── */
.order-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.order-item {
  flex: 1;
  min-width: 80px;
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
  font-size: 0.75rem;
}
.order-item:last-child { border-right: none; }
.order-item .o-num { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--muted); margin-bottom: 4px; }
.order-item .o-name { font-weight: 600; font-size: 0.8rem; }
.order-item .o-ex { color: var(--muted); font-size: 10px; margin-top: 3px; font-style: italic; }

/* ── INTERJECTION CARDS ── */
.interj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.interj-card {
  border-radius: 4px;
  padding: 14px 12px;
  text-align: center;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.interj-word {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: 'Cormorant Garamond', serif;
  display: block;
  margin-bottom: 4px;
}
.interj-pt { font-size: 0.75rem; color: var(--muted); }

/* ── NUMBER DISPLAY ── */
.num-showcase {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.num-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 10px;
  text-align: center;
}

.num-n { font-family: 'JetBrains Mono', monospace; font-size: 1.2rem; font-weight: 500; display: block; }
.num-w { font-size: 0.78rem; color: var(--muted); margin-top: 3px; display: block; }

/* ── SCROLL TOP ── */
#scrollTop {
  position: fixed;
  bottom: 32px; right: 32px;
  width: 46px; height: 46px;
  background: var(--warm);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: all 0.2s;
}
#scrollTop:hover { background: var(--card); transform: translateY(-2px); }
#scrollTop.show { display: flex; }

#roadmapBtn {
  position: fixed;
  bottom: 90px;
  right: 20px;
  font-family: 'Syne', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: var(--warm);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 200;
  transition: border-color 0.2s, transform 0.2s, color 0.2s;
  white-space: nowrap;
}
#roadmapBtn:hover {
  border-color: var(--c12);
  color: var(--c12);
  transform: translateY(-2px);
}

@media (max-width: 640px) {
  .comp-row { grid-template-columns: 1fr; }
  .order-sequence { flex-direction: column; }
  .order-item { border-right: none; border-bottom: 1px solid var(--border); }
  #roadmapBtn { bottom: 88px; right: 12px; font-size: 0.62rem; padding: 6px 10px; }
  #scrollTop  { bottom: 32px; right: 12px; width: 40px; height: 40px; font-size: 16px; }
}

/* ════════════════════════════════════════════
   COLLAPSIBLE EXPLANATIONS — Leigos
════════════════════════════════════════════ */

/* Collapsible container within cards */
.grammar-collapse {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}

.grammar-collapse:hover {
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

/* Collapsible header (always visible) */
.collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  gap: 10px;
}

.collapse-header-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.collapse-term {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.collapse-preview {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Toggle icon */
.collapse-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.3s ease, color 0.2s;
}

.grammar-collapse.open .collapse-icon {
  transform: rotate(180deg);
  color: var(--ink);
}

/* Collapsible body (hidden by default) */
.collapse-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out, padding 0.3s ease;
}

.grammar-collapse.open .collapse-body {
  max-height: 500px;
  transition: max-height 0.35s ease-in;
}

.collapse-content {
  padding: 0 14px 14px 14px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #c8c0b4;
}

.collapse-content p {
  margin-bottom: 10px;
}

.collapse-content p:last-child {
  margin-bottom: 0;
}

.collapse-content strong {
  color: #fff;
  font-weight: 600;
}

/* Example within collapse */
.collapse-example {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  border-left: 2px solid var(--collapse-accent, var(--muted));
}

.collapse-example .en {
  display: block;
  font-style: italic;
  color: #fff;
  margin-bottom: 4px;
  font-size: 0.88rem;
}

.collapse-example .pt {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Tag/label for the term type */
.collapse-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  margin-bottom: 6px;
}

/* Color variations for different sections */
.grammar-collapse.collapse-nouns { --collapse-accent: var(--c1); }
.grammar-collapse.collapse-pronouns { --collapse-accent: var(--c2); }
.grammar-collapse.collapse-adjectives { --collapse-accent: var(--c3); }
.grammar-collapse.collapse-verbs { --collapse-accent: var(--c4); }
.grammar-collapse.collapse-adverbs { --collapse-accent: var(--c5); }
.grammar-collapse.collapse-prepositions { --collapse-accent: var(--c6); }
.grammar-collapse.collapse-conjunctions { --collapse-accent: var(--c7); }
.grammar-collapse.collapse-articles { --collapse-accent: var(--c8); }
.grammar-collapse.collapse-determiners { --collapse-accent: var(--c9); }
.grammar-collapse.collapse-interjections { --collapse-accent: var(--c10); }
.grammar-collapse.collapse-numbers { --collapse-accent: var(--c11); }
.grammar-collapse.collapse-tenses { --collapse-accent: var(--c12); }
.grammar-collapse.collapse-modals { --collapse-accent: var(--c13); }
.grammar-collapse.collapse-questions { --collapse-accent: var(--c14); }
.grammar-collapse.collapse-conditionals { --collapse-accent: var(--c15); }
.grammar-collapse.collapse-infinitive { --collapse-accent: var(--c16); }
.grammar-collapse.collapse-phrasals { --collapse-accent: var(--c17); }
.grammar-collapse.collapse-reported { --collapse-accent: var(--c18); }
.grammar-collapse.collapse-passive { --collapse-accent: var(--c19); }
.grammar-collapse.collapse-clauses { --collapse-accent: var(--c20); }
.grammar-collapse.collapse-wordformation { --collapse-accent: var(--c21); }
.grammar-collapse.collapse-punctuation { --collapse-accent: var(--c22); }
.grammar-collapse.collapse-negation { --collapse-accent: var(--c23); }
.grammar-collapse.collapse-comparisons { --collapse-accent: var(--c24); }
.grammar-collapse.collapse-wordorder { --collapse-accent: var(--c25); }
.grammar-collapse.collapse-discourse { --collapse-accent: var(--c26); }

/* Highlighted term within text that opens collapse */
.term-help {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: help;
  border-bottom: 1px dashed rgba(255,255,255,0.3);
  transition: border-color 0.2s, color 0.2s;
}

.term-help:hover {
  border-bottom-color: var(--ink);
  color: #fff;
}

.term-help::after {
  content: '?';
  font-size: 9px;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* ════════════════════════════════════════════
   CTRL BAR
════════════════════════════════════════════ */
.ctrl-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: rgba(14, 13, 11, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 300;
}

.ctrl-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}

.ctrl-right {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.icon-btn {
  background: var(--warm);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 7px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: border-color 0.2s, transform 0.15s;
}
.icon-btn:hover { border-color: var(--ink); transform: scale(1.08); }

/* ════════════════════════════════════════════
   LIGHT THEME
════════════════════════════════════════════ */
body.light {
  --paper:  #f5f2ec;
  --warm:   #ede9e0;
  --card:   #f0ece2;
  --border: #d8d0c0;
  --ink:    #1a1814;
  --muted:  #8a8070;
}
body.light .ctrl-bar {
  background: rgba(245, 242, 236, 0.94);
}
body.light .sticky-nav {
  background: rgba(245, 242, 236, 0.92);
}
body.light .en { color: #1a1814; }
body.light .hero {
  background:
    radial-gradient(ellipse 60% 40% at 20% 80%, rgba(232,162,80,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 20%, rgba(137,180,232,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 50% 50%, rgba(232,124,106,0.07) 0%, transparent 70%);
}
body.light body::before { opacity: 0.08; }
body.light .tbl tr:hover td { background: rgba(0,0,0,0.03); }
body.light .formula,
body.light .highlight {
  background: rgba(0,0,0,0.04);
  border-color: var(--border);
}
body.light .ex { color: #6a6058; }
body.light #scrollTop,
body.light .icon-btn { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* ════════════════════════════════════════════
   RESPONSIVE CTRL-BAR
════════════════════════════════════════════ */

/* Tablet: Reduzir gaps e tamanhos */
@media (max-width: 900px) {
  .ctrl-bar {
    padding: 0 12px;
    gap: 8px;
  }
  .ctrl-right {
    gap: 4px;
  }
  .ctrl-right .cat-chip {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
  .ctrl-logo {
    font-size: 0.6rem;
  }
}

/* Mobile: Menu compacto com dropdown */
@media (max-width: 768px) {
  .ctrl-bar {
    padding: 0 12px;
    height: 48px;
  }
  .ctrl-right .cat-chip {
    display: none; /* Esconder chips em mobile */
  }
  .ctrl-right .cat-chip:last-of-type {
    display: inline-flex; /* Mostrar apenas o último (Treino) */
  }
  .ctrl-logo {
    font-size: 0.65rem;
  }
  /* Menu hamburger para mobile */
  .ctrl-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--warm);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--ink);
    font-size: 1rem;
    cursor: pointer;
    margin-right: 4px;
  }
}

/* Small mobile: Ajustes finais */
@media (max-width: 480px) {
  .ctrl-bar {
    padding: 0 10px;
  }
  .ctrl-right {
    gap: 4px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}

/* Mobile Menu Styles */
.ctrl-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--warm);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  margin-right: 4px;
  flex-shrink: 0;
  transition: border-color 0.2s;
}
.ctrl-menu-toggle:hover {
  border-color: var(--ink);
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  background: rgba(14, 13, 11, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 299;
  padding: 12px;
  flex-direction: column;
  gap: 8px;
}
.mobile-menu.active {
  display: flex;
}
.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.mobile-menu-item:hover {
  background: var(--warm);
}
body.light .mobile-menu {
  background: rgba(245, 242, 236, 0.98);
}

/* Show mobile toggle on small screens */
@media (max-width: 768px) {
  .ctrl-menu-toggle {
    display: inline-flex;
  }
}

/* ════════════════════════════════════════════
   TOPBAR MOBILE MENU (for question page)
════════════════════════════════════════════ */
.topbar-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  margin-left: auto;
  margin-right: 8px;
}

@media (max-width: 768px) {
  .topbar-menu-toggle {
    display: inline-flex;
  }
  .topbar-links {
    display: none;
  }
}
