:root {
  --bg: #fcfaf5;
  --surface: #ffffff;
  --surface-alt: #f5f1e8;
  --ink: #1a1d21;
  --muted: #525866;
  --rule: #e2dcd0;
  --accent: #0f766e;
  --accent-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #991b1b;
  --danger-soft: #fef2f2;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--ink);
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.68;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

a:hover {
  color: #115e59;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  padding: 18px 24px;
}

.header-inner {
  max-width: 1220px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.brand-lockup img {
  height: 28px;
  width: auto;
  display: block;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-meta .pill-tag {
  display: none;
}

body.free-edit-mode .editorial-hero h1[contenteditable="true"],
body.free-edit-mode .editorial-hero .article-deck[contenteditable="true"],
body.free-edit-mode .article-main h2[contenteditable="true"] {
  outline: 1.5px dashed rgba(15, 118, 110, 0.36);
  outline-offset: 5px;
  border-radius: 6px;
  cursor: text;
}

body.free-edit-mode .editorial-hero h1[contenteditable="true"]:focus,
body.free-edit-mode .editorial-hero .article-deck[contenteditable="true"]:focus,
body.free-edit-mode .article-main h2[contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  background: rgba(15, 118, 110, 0.04);
}

body.free-edit-mode .article-main h2[data-empty="1"]::before {
  content: "Type section heading...";
  color: #9ca3af;
  font-style: italic;
  font-weight: 500;
  pointer-events: none;
}

.pill-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

/* Flagship Centered Editorial Hero (Title/Deck -> Deep Rotating 3D Bowl -> Intro) */
.editorial-hero {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 24px 28px;
  border-bottom: 1px solid var(--rule);
}

.editorial-hero-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.editorial-hero-copy {
  width: 100%;
  max-width: 720px;
  text-align: left;
}

.editorial-hero-copy h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 4.1vw, 50px);
  line-height: 1.09;
  letter-spacing: -0.025em;
  margin: 8px 0 16px;
  color: var(--ink);
  font-weight: 600;
}

.editorial-hero-copy .article-deck {
  font-size: 20px;
  line-height: 1.56;
  color: #363c45;
  margin: 0 0 16px;
}

.bowl-phrase {
  border-bottom: 1.5px dotted rgba(15, 118, 110, 0.55);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  border-radius: 3px;
  padding: 0 2px;
}

.bowl-phrase:hover,
.bowl-phrase:focus {
  background: rgba(15, 118, 110, 0.10);
  border-bottom-style: solid;
  border-bottom-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.editorial-hero-copy .byline-strip {
  margin: 0 0 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

.hero-controls-bar {
  width: 100%;
  max-width: 720px;
  margin: 6px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero-stage-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 0 0 8px;
}

.hero-stage-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.hero-stage-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.hero-stage-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fcfaf5;
}

.hero-stage-btn[data-bowl-stage="apprentice"].is-active {
  background: #991b1b;
  border-color: #991b1b;
}

.hero-stage-btn[data-bowl-stage="specialist"].is-active {
  background: var(--accent);
  border-color: var(--accent);
}

.hero-query-slider-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 8px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  width: 100%;
}

.hero-query-slider-wrap[hidden] {
  display: none;
}

.hero-query-slider-wrap input[type="range"] {
  flex: 1;
  max-width: 260px;
  accent-color: var(--accent);
  cursor: pointer;
}

.hero-query-val {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  min-width: 78px;
  text-align: left;
}

.hero-bowl-readout {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.48;
  color: var(--muted);
  min-height: 22px;
  max-width: 660px;
}

.editorial-hero .hero-bowl-figure {
  width: 100% !important;
  max-width: 820px !important;
  margin: 4px auto 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.hero-bowl-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1.52 / 1;
  max-height: 510px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.hero-bowl-stage:active {
  cursor: grabbing;
}

.hero-bowl-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hero-bowl-dust {
  pointer-events: none;
}

.editorial-hero .hero-bowl-figure figcaption {
  font-family: var(--sans);
  font-size: 12.4px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 700px;
  margin: 8px auto 0 !important;
  padding: 0 !important;
  border: 0 !important;
  text-align: center;
}

/* Clean Light-Parchment 3-Beat Story Figures inside Article */
.story-figure {
  margin: 30px 0 32px;
  padding: 12px 12px 10px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  clear: right;
}

.story-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.story-figure figcaption {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin: 10px 4px 2px;
}

@media (min-width: 1120px) {
  .story-figure {
    width: calc(100% + 140px);
    max-width: 820px;
  }
}

@media (max-width: 760px) {
  .editorial-hero {
    padding: 24px 18px 20px;
  }
  .hero-bowl-stage {
    max-height: 360px;
    aspect-ratio: 1.26 / 1;
  }
}

/* 3-Column Tufte Editorial Grid */
.page-shell {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 36px 24px 80px;
  display: grid;
  grid-template-columns: 205px minmax(0, 66ch) 260px;
  gap: 32px 46px;
  align-items: start;
}

/* Left Sticky TOC */
.toc-rail {
  position: sticky;
  top: 24px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  border-right: 1px solid var(--rule);
  padding-right: 16px;
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin: 6px 0;
}

.toc-list a {
  color: var(--muted);
  text-decoration: none;
  display: block;
  padding: 2px 0;
  transition: color 0.15s ease;
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--accent);
  font-weight: 600;
}

/* Main Article Spine */
.article-main {
  grid-column: 2;
  min-width: 0;
}

.article-kicker {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 10px;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 3.6vw, 2.75rem);
  line-height: 1.15;
  margin: 0 0 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.article-deck {
  font-size: 1.18rem;
  line-height: 1.55;
  color: #374151;
  margin: 0 0 22px;
}

.byline-strip {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

h2 {
  font-family: var(--sans);
  font-size: 1.44rem;
  line-height: 1.25;
  margin: 50px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-weight: 700;
  color: #8f2424;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1.1em;
}

ul, ol {
  margin: 0 0 1.2em;
  padding-left: 1.35em;
}

li {
  margin-bottom: 0.45em;
}

code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
  overflow-wrap: anywhere;
}

pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  background: #181b20;
  color: #f3f4f6;
  padding: 16px 18px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 18px 0 22px;
  position: relative;
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.code-wrap {
  position: relative;
}

.code-wrap pre {
  padding-right: 76px;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  background: #272c35;
  color: #f9fafb;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Sidenotes (Right Rail on Desktop, Inline on <= 1099px) */
.sidenote-anchor {
  position: relative;
}

.sidenote {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
  margin: 14px 0;
}

/* NCERT Pedagogical Components (Blog-Harmonized) */
.margin-kid {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.48;
  color: #334155;
  background: #fdfaf2;
  border: 1px solid #e5dcc5;
  border-left: 3px solid #c2410c;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 16px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  max-width: 100%;
}

.margin-kid.kid-dev {
  border-left-color: #0f766e;
  background: #f6fbfa;
  border-color: #cce5e1;
}

.margin-kid svg {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: block;
}

.kid-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9a3412;
  margin-bottom: 3px;
}

.margin-kid.kid-dev .kid-name {
  color: #0f766e;
}

@media (min-width: 1100px) {
  .sidenote {
    float: right;
    clear: right;
    width: 260px;
    margin: 4px -296px 16px 24px;
    background: transparent;
    border-left: 2px solid var(--rule);
    border-radius: 0;
    padding: 4px 0 4px 14px;
  }

  .margin-kid {
    float: right;
    clear: right;
    width: 260px;
    margin: 4px -296px 18px 24px;
  }

  figure,
  .table-wrap.wide-breakout {
    clear: right;
  }
}

.bridge-line {
  font-style: italic;
  color: #475569;
  margin: 22px 0 6px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid #d6cbb5;
  font-size: 0.96em;
}

.ncert-box {
  margin: 24px 0 28px;
  padding: 16px 18px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.56;
}

.ncert-box p {
  margin: 0 0 0.75em;
}

.ncert-box p:last-child,
.ncert-box ul:last-child,
.ncert-box ol:last-child {
  margin-bottom: 0;
}

.ncert-box-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ncert-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
}

.ncert-box-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}

.ncert-activity {
  background: #fdf9ee;
  border-color: #eadcb6;
  border-left: 4px solid #b45309;
}

.ncert-activity .ncert-tag {
  background: #fef3c7;
  color: #92400e;
}

.ncert-graph {
  margin: 14px 0 26px;
  padding: 12px 16px;
  background: #f2fbfa;
  border: 1px solid #cce7e3;
  border-left: 4px solid #0f766e;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 13.8px;
  line-height: 1.52;
  color: #1e293b;
}

.ncert-graph .ncert-tag {
  background: #ccfbf1;
  color: #115e59;
  margin-right: 6px;
}

.ncert-discuss {
  background: #fff7f4;
  border-color: #f3d2c6;
  border-left: 4px solid #c2410c;
}

.ncert-discuss .ncert-tag {
  background: #ffedd5;
  color: #9a3412;
}

.debate-voice {
  margin: 8px 0;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #f1dfd7;
  border-radius: 6px;
}

.debate-speaker {
  font-weight: 700;
  color: #9a3412;
}

.ncert-check {
  background: #f4f7fc;
  border-color: #d2dff2;
  border-left: 4px solid #1d4ed8;
}

.ncert-check .ncert-tag {
  background: #dbeafe;
  color: #1e40af;
}

.ncert-check details {
  margin: 12px 0 0;
  background: #ffffff;
  border-color: #d2dff2;
  font-size: 13.5px;
}

.ncert-revisit {
  background: #faf4e6;
  border-color: #dfd0ad;
  border-left: 4px solid #8f2424;
}

.ncert-revisit .ncert-tag {
  background: #fee2e2;
  color: #8f2424;
}

.ncert-glossary {
  background: #fff8fb;
  border-color: #f3d1e0;
  border-left: 4px solid #be185d;
}

.ncert-glossary .ncert-tag {
  background: #fce7f3;
  color: #9d174d;
}

.gloss-term {
  color: #be185d;
  font-weight: 700;
}

.gloss-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: grid;
  gap: 8px;
}

.gloss-list li {
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px dashed #f0cadb;
}

.gloss-list li:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.math-step {
  font-family: var(--mono);
  font-size: 13.5px;
  background: #ffffff;
  border: 1px solid #e7d9b2;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 10px 0;
  color: #1f2937;
  overflow-x: auto;
}

/* Figures & Media */
figure {
  margin: 26px 0 28px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

figure img {
  width: 100%;
  height: auto;
  display: block;
}

figcaption {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 20px 0 24px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.42;
}

th, td {
  padding: 9px 11px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr.row-rejected td {
  background: var(--danger-soft);
}

/* Badges */
.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-exact { background: var(--accent-soft); color: var(--accent); border: 1px solid #99f6e4; }
.badge-var { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; }
.badge-imp { background: var(--blue-soft); color: var(--blue); border: 1px solid #bfdbfe; }
.badge-rej { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

/* Details / Collapsible */
details {
  margin: 18px 0 22px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
}

summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

details[open] summary {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

/* Interactive Widgets */
.widget-box {
  margin: 26px 0 30px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  font-family: var(--sans);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.widget-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.widget-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.widget-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.ctl-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: pointer;
}

.ctl-btn:hover {
  border-color: var(--accent);
}

.ctl-btn.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.ctl-btn.rejected-tab.active {
  background: var(--danger);
  border-color: var(--danger);
}

/* Gate Explorer Bars */
.gate-bars {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.bar-row {
  display: grid;
  grid-template-columns: 78px 1fr 68px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.bar-track {
  height: 20px;
  background: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.bar-fill {
  height: 100%;
  transition: width 0.25s ease;
}

.bar-base { background: #9ca3af; }
.bar-empty { background: #cbd5e1; }
.bar-flipped { background: #d97706; }
.bar-shuffled { background: #3b82f6; }
.bar-learned { background: #0f766e; }
.bar-rejected { background: #b91c1c; }

.gate-meta-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
}

.meta-cell strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Layer Inspector Grid */
.layer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.layer-tile {
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 5px 4px;
  text-align: center;
  font-size: 11px;
  background: var(--surface-alt);
  cursor: pointer;
}

.layer-tile.has-sw {
  border-color: #b91c1c;
  background: #fef2f2;
}

.layer-tile.selected {
  outline: 2px solid var(--accent);
}

.tier-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: 2px;
}

.t-Q8_0 { background: #1d4ed8; color: #fff; }
.t-Q4_K, .t-IQ4_NL { background: #0f766e; color: #fff; }
.t-Q3_K { background: #d97706; color: #fff; }
.t-Q2_K { background: #ea580c; color: #fff; }
.t-IQ2_XS, .t-IQ1_S { background: #7c3aed; color: #fff; }
.t-drop { background: #e5e7eb; color: #4b5563; }

.layer-detail-box {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: 6px;
  font-size: 12.5px;
}

/* Release Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.rel-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rel-card.card-rejected {
  background: var(--danger-soft);
  border-color: #fecaca;
}

.rel-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.rel-card-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
}

.rel-card-file {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.rel-card-fail {
  color: #4b5563;
  font-size: 12px;
  border-top: 1px solid var(--rule);
  padding-top: 6px;
  margin-top: auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 28px 24px 48px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Mobile & Tablet Collapse */
@media (min-width: 1200px) {
  figure {
    width: calc(100% + 220px);
    max-width: 880px;
  }
  .table-wrap.wide-breakout {
    width: calc(100% + 310px);
    max-width: 970px;
  }
  .table-wrap.wide-breakout table {
    font-size: 12px;
  }
  .table-wrap.wide-breakout th {
    white-space: normal;
  }
  .table-wrap.wide-breakout th,
  .table-wrap.wide-breakout td {
    padding: 7px 8px;
  }
}

@media (max-width: 1099px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 20px 14px 60px;
  }

  .toc-rail {
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 0 0 14px;
    min-width: 0;
  }

  .toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
  }

  .article-main {
    grid-column: 1;
    min-width: 0;
    max-width: 100%;
  }

  .page-shell > *,
  .toc-rail,
  .article-main,
  .table-wrap,
  .code-wrap,
  pre,
  details,
  .widget-box,
  .ncert-box,
  .ncert-graph,
  .margin-kid,
  .math-step,
  figure {
    min-width: 0;
    max-width: 100%;
  }

  .code-wrap pre {
    padding-top: 42px;
    padding-right: 16px;
  }
}

/* Paragraph Numbers & Right-Click Annotation UI */
.numbered-para {
  position: relative;
}

.para-num {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  color: #94a3b8;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.para-num:hover {
  color: var(--accent);
}

@media (min-width: 1100px) {
  .article-main > p.numbered-para > .para-num {
    position: absolute;
    left: -40px;
    top: 6px;
    width: 32px;
    text-align: right;
  }

  .ncert-box p.numbered-para > .para-num {
    display: inline-block;
    margin-right: 6px;
    padding: 0 4px;
    border-radius: 3px;
    background: rgba(148, 163, 184, 0.14);
    color: #64748b;
  }
}

@media (max-width: 1099px) {
  .para-num {
    display: inline-block;
    margin-right: 6px;
    padding: 0 4px;
    border-radius: 3px;
    background: rgba(148, 163, 184, 0.14);
    color: #64748b;
  }
}

.para-flash {
  animation: paraFlash 1.4s ease;
}

@keyframes paraFlash {
  0% { background-color: rgba(250, 204, 21, 0.35); border-radius: 4px; }
  100% { background-color: transparent; }
}

.toc-tip {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* Highlights */
mark.user-ann {
  color: inherit;
  padding: 1px 1px;
  border-radius: 3px;
  cursor: pointer;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

mark.user-ann:hover {
  filter: brightness(0.95);
}

mark.user-ann.ann-yellow { background: rgba(253, 224, 71, 0.52); border-bottom: 1.5px solid #ca8a04; }
mark.user-ann.ann-teal { background: rgba(94, 234, 212, 0.42); border-bottom: 1.5px solid #0f766e; }
mark.user-ann.ann-pink { background: rgba(249, 168, 212, 0.45); border-bottom: 1.5px solid #be185d; }
mark.user-ann.ann-blue { background: rgba(147, 197, 253, 0.45); border-bottom: 1.5px solid #1d4ed8; }

mark.user-ann.ann-has-note::after {
  content: "";
}

mark.user-ann.ann-last.ann-has-note::after {
  content: " \270E";
  font-size: 0.72em;
  vertical-align: super;
  opacity: 0.85;
  margin-left: 1px;
}

mark.user-ann.ann-pulse {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.38);
}

/* Inline Editable Spans */
.user-inline-edit {
  background: rgba(20, 184, 166, 0.14);
  border-bottom: 2px dashed #0f766e;
  border-radius: 3px;
  padding: 0 2px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.user-inline-edit:hover {
  background: rgba(20, 184, 166, 0.24);
}

.user-inline-edit.is-editing {
  background: #ffffff;
  outline: 2px solid var(--accent);
  border-bottom: none;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16);
  padding: 1px 4px;
  cursor: text;
}

.user-inline-edit.ann-pulse {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.38);
}

.ann-edit-bar {
  position: fixed;
  z-index: 1260;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  padding: 6px 10px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink);
}

.ann-diff-orig {
  font-family: var(--serif);
  font-size: 13px;
  color: #991b1b;
  background: var(--danger-soft);
  border-left: 3px solid #dc2626;
  padding: 5px 9px;
  border-radius: 0 5px 5px 0;
  margin: 0 0 6px;
  text-decoration: line-through;
  max-height: 70px;
  overflow-y: auto;
}

.ann-diff-new {
  font-family: var(--serif);
  font-size: 13px;
  color: #065f46;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 5px 9px;
  border-radius: 0 5px 5px 0;
  margin: 0 0 10px;
  max-height: 70px;
  overflow-y: auto;
}

.ann-kind-pill {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #99f6e4;
}

/* Free-Edit Mode & Multi-Paragraph Editor */
.edit-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.edit-mode-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.edit-mode-btn.active {
  background: #8f2424;
  color: #ffffff;
  border-color: #8f2424;
}

body.free-edit-mode .article-main p.numbered-para[contenteditable="true"],
body.free-edit-mode .article-main h1[contenteditable="true"],
body.free-edit-mode .article-main h2[contenteditable="true"] {
  border-radius: 6px;
  padding: 4px 8px;
  margin-left: -8px;
  margin-right: -8px;
  min-height: 1.75em;
  transition: background 0.14s ease, box-shadow 0.14s ease;
}

p.numbered-para[data-empty="1"]::before {
  content: "Type or paste your paragraph here...";
  color: #9ca3af;
  font-style: italic;
  pointer-events: none;
}

body.free-edit-mode .article-main p.numbered-para[contenteditable="true"]:hover,
body.free-edit-mode .article-main h1[contenteditable="true"]:hover,
body.free-edit-mode .article-main h2[contenteditable="true"]:hover {
  background: rgba(15, 118, 110, 0.05);
}

body.free-edit-mode .article-main p.numbered-para[contenteditable="true"]:focus,
body.free-edit-mode .article-main h1[contenteditable="true"]:focus,
body.free-edit-mode .article-main h2[contenteditable="true"]:focus {
  background: #ffffff;
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.ann-orphan-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #fde68a;
  margin-left: 4px;
}

.user-draft-changed {
  border-left: 3px solid rgba(15, 118, 110, 0.45);
  padding-left: 10px !important;
}

.user-draft-added {
  border-left: 3px solid #b45309;
  padding-left: 10px !important;
  background: rgba(254, 243, 199, 0.28);
  border-radius: 0 5px 5px 0;
}

.user-draft-hidden {
  display: none !important;
}

.para-hover-tools {
  position: absolute;
  right: 4px;
  top: -12px;
  display: none;
  align-items: center;
  gap: 4px;
  z-index: 20;
  user-select: none;
  -webkit-user-select: none;
}

body.free-edit-mode .numbered-para:hover > .para-hover-tools,
body.free-edit-mode .numbered-para:focus-within > .para-hover-tools {
  display: inline-flex;
}

.para-tool-btn {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.para-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.para-tool-btn.danger {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.25);
}

.para-tool-btn.danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
  color: #dc2626;
}

.free-edit-dock .dock-btn.danger {
  background: rgba(220, 38, 38, 0.18);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
}

.free-edit-dock .dock-btn.danger:hover {
  background: #dc2626;
  color: #ffffff;
}

.ann-deleted-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ann-deleted-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.ann-deleted-snip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.article-main h2 {
  position: relative;
}

.section-hover-tools {
  position: absolute;
  right: 4px;
  top: -16px;
  padding-bottom: 8px;
  display: none;
  align-items: center;
  gap: 4px;
  z-index: 20;
  user-select: none;
  -webkit-user-select: none;
}

body.free-edit-mode .article-main h2:hover > .section-hover-tools,
body.free-edit-mode .article-main h2:focus-within > .section-hover-tools {
  display: inline-flex;
}

/* Visible Between-Block Section / Paragraph Insertion Slots (Edit Mode only) */
.edit-insert-slot {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 18px 0 -22px;
  opacity: 0.68;
  transition: opacity 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  clear: both;
}

.edit-insert-slot.slot-top {
  margin: 0 0 14px;
}

.edit-insert-slot.slot-bottom {
  margin: 22px 0 6px;
}

body.free-edit-mode .edit-insert-slot {
  display: flex;
}

.edit-insert-slot:hover {
  opacity: 1;
}

.edit-insert-slot::before,
.edit-insert-slot::after {
  content: "";
  flex: 1;
  height: 1px;
  border-top: 1px dashed #cbd5e1;
}

.edit-insert-slot:hover::before,
.edit-insert-slot:hover::after {
  border-top-color: rgba(15, 118, 110, 0.55);
}

.slot-btn {
  appearance: none;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #d6d3c9;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.slot-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.slot-btn.slot-sec-btn {
  color: #8f2424;
  border-color: rgba(143, 36, 36, 0.28);
}

.slot-btn.slot-sec-btn:hover {
  background: #fef2f2;
  border-color: #8f2424;
  color: #8f2424;
}

.user-added-section {
  border-top: 1px solid #d6cbb5;
  border-left: 3px solid #b45309;
  padding-left: 10px !important;
  background: rgba(254, 243, 199, 0.22);
  border-radius: 0 6px 6px 0;
}

mark.fmt-hl {
  background: rgba(253, 224, 71, 0.56);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* Floating Rich-Text Formatting Bubble Toolbar */
.fmt-toolbar {
  position: fixed;
  z-index: 1280;
  display: none;
  align-items: center;
  gap: 3px;
  background: #181b20;
  color: #f9fafb;
  padding: 5px 7px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  font-family: var(--sans);
}

.fmt-toolbar.open {
  display: inline-flex;
}

.fmt-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #e5e7eb;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.fmt-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.fmt-btn.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: #14b8a6;
}

.fmt-btn.fmt-mono {
  font-family: var(--mono);
  font-size: 11px;
}

.fmt-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 3px;
}

.fmt-link-row {
  display: none;
  align-items: center;
  gap: 5px;
}

.fmt-toolbar.link-open .fmt-main-row {
  display: none;
}

.fmt-toolbar.link-open .fmt-link-row {
  display: inline-flex;
}

.fmt-main-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.fmt-link-input {
  width: 210px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #272c35;
  color: #f9fafb;
  font-family: var(--sans);
  font-size: 12px;
  padding: 0 8px;
  outline: none;
}

.fmt-link-input:focus {
  border-color: #14b8a6;
}

.dock-fmt-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.free-edit-dock {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 1100;
  display: none;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  background: #181b20;
  color: #f9fafb;
  padding: 7px 12px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  font-family: var(--sans);
  font-size: 12.5px;
}

@media (max-width: 980px) {
  .free-edit-dock {
    flex-wrap: wrap;
    white-space: normal;
    justify-content: center;
    border-radius: 14px;
  }
}

body.free-edit-mode .ann-toast {
  bottom: 84px;
}

body.free-edit-mode .free-edit-dock {
  display: inline-flex;
}

.free-edit-dock .dock-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #8f2424;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 999px;
}

.free-edit-dock .dock-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
}

.free-edit-dock .dock-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.free-edit-dock .dock-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}

.multi-edit-card {
  margin: 14px 0 18px;
  padding: 14px 16px;
  background: #ffffff;
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 118, 110, 0.14);
  font-family: var(--sans);
}

.multi-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.multi-edit-ta {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: var(--ink);
  background: #fcfaf5;
  margin-bottom: 8px;
}

.multi-edit-ta:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  border-color: var(--accent);
  background: #ffffff;
}

.ann-draft-summary {
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  font-size: 12.5px;
  color: #115e59;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ann-draft-summary-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Header & Floating Notes Trigger */
.notes-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.notes-trigger-btn:hover {
  background: #115e59;
}

.notes-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: #181b20;
  color: #f9fafb;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.notes-fab:hover {
  background: var(--accent);
}

/* Custom Right-Click Context Menu */
.ann-ctx-menu {
  position: fixed;
  z-index: 1200;
  min-width: 215px;
  background: #ffffff;
  border: 1px solid #d6d3c9;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 6px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}

.ann-ctx-head {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.ann-ctx-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.ann-ctx-btn:hover {
  background: var(--surface-alt);
  color: var(--accent);
}

.ann-ctx-btn.primary {
  font-weight: 700;
  color: var(--accent);
}

.ann-ctx-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Floating Composer / Viewer Popover */
.ann-popover {
  position: fixed;
  z-index: 1250;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #d6d3c9;
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.2);
  padding: 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}

.ann-pop-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ann-para-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-alt);
  color: #8f2424;
  border: 1px solid var(--rule);
}

.ann-quote-preview {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: #475569;
  background: #faf8f3;
  border-left: 3px solid var(--rule);
  padding: 6px 10px;
  border-radius: 0 5px 5px 0;
  margin: 0 0 10px;
  max-height: 76px;
  overflow-y: auto;
}

.ann-colors {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ann-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.ann-swatch[data-color="yellow"] { background: #fde047; }
.ann-swatch[data-color="teal"] { background: #5eead4; }
.ann-swatch[data-color="pink"] { background: #f9a8d4; }
.ann-swatch[data-color="blue"] { background: #93c5fd; }

.ann-swatch.active {
  border-color: var(--ink);
  transform: scale(1.12);
}

.ann-textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.48;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  margin-bottom: 10px;
}

.ann-textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  border-color: var(--accent);
}

.ann-pop-note {
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 0 0 12px;
  color: var(--ink);
}

.ann-pop-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ann-pop-actions-left,
.ann-pop-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ann-mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ann-mic-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ann-mic-btn svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.ann-mic-btn.recording {
  background: var(--danger-soft);
  border-color: #dc2626;
  color: #b91c1c;
  animation: micPulse 1.2s infinite;
}

.ann-mic-btn.busy {
  background: var(--warn-soft);
  border-color: #d97706;
  color: var(--warn);
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.28); }
  50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
}

.ann-voice-cfg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
}

.ann-voice-cfg-btn:hover,
.ann-voice-cfg-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.ann-voice-cfg-btn svg {
  width: 14px;
  height: 14px;
}

.ann-voice-status {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
  margin: -4px 0 8px;
  min-height: 16px;
}

.ann-voice-status.recording {
  color: #b91c1c;
  font-weight: 600;
}

.ann-voice-status.error {
  color: var(--danger);
}

.ann-voice-panel {
  margin: 0 0 10px;
  padding: 10px 11px;
  background: #faf8f3;
  border: 1px solid var(--rule);
  border-radius: 7px;
  font-size: 12px;
  display: grid;
  gap: 7px;
}

.ann-voice-panel label {
  display: grid;
  gap: 3px;
  font-weight: 600;
  color: #475569;
  font-size: 11px;
}

.ann-voice-panel select,
.ann-voice-panel input {
  width: 100%;
  font-family: var(--sans);
  font-size: 12px;
  padding: 5px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  color: var(--ink);
}

.ann-voice-panel .ann-voice-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
}

.ann-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--surface-alt);
  color: var(--ink);
  cursor: pointer;
}

.ann-btn:hover {
  border-color: var(--accent);
}

.ann-btn.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.ann-btn.primary:hover {
  background: #115e59;
}

.ann-btn.danger {
  color: var(--danger);
  border-color: #fecaca;
  background: var(--danger-soft);
}

/* Slide-Over Notes Drawer */
.ann-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 94vw);
  background: #ffffff;
  border-left: 1px solid var(--rule);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.14);
  z-index: 1150;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  transform: translateX(105%);
  transition: transform 0.2s ease;
}

.ann-drawer.open {
  transform: translateX(0);
}

.ann-drawer-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ann-drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.ann-drawer-bar {
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ann-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ann-drawer-empty {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--rule);
  border-radius: 8px;
  padding: 16px;
}

.ann-card {
  border: 1px solid var(--rule);
  border-left: 4px solid #ca8a04;
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  font-size: 13px;
}

.ann-card[data-color="teal"] { border-left-color: #0f766e; }
.ann-card[data-color="pink"] { border-left-color: #be185d; }
.ann-card[data-color="blue"] { border-left-color: #1d4ed8; }

.ann-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ann-card-quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: #475569;
  margin: 0 0 6px;
  cursor: pointer;
}

.ann-card-quote:hover {
  color: var(--accent);
}

.ann-card-note {
  white-space: pre-wrap;
  color: var(--ink);
  margin: 0 0 8px;
  line-height: 1.48;
}

.ann-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ann-toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  z-index: 1300;
  background: #181b20;
  color: #f9fafb;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  align-items: center;
  gap: 10px;
}

.ann-toast.has-action {
  pointer-events: auto;
}

.ann-toast-btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.ann-toast-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Borderless Editorial Tensor-Grid Diagrams & Extraction Tables */
.stage-diagram {
  margin: 26px 0 30px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  clear: right;
}

.stage-diagram-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0 0 8px 2px;
}

.stage-diagram img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0;
}

.stage-diagram figcaption {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.52;
  color: var(--muted);
  margin: 10px 0 0;
  padding-top: 0;
  border-top: none;
  max-width: 66ch;
}

@media (min-width: 1200px) {
  .stage-diagram {
    width: calc(100% + 290px);
    max-width: 960px;
  }
  .table-footnotes.wide-breakout {
    width: calc(100% + 310px);
    max-width: 970px;
  }
}

.table-caption {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  margin: 22px 0 10px;
}

.table-wrap th.num,
.table-wrap td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table-wrap tr.row-ref td {
  background: #faf8f3;
}

.table-wrap tr.row-highlight td {
  background: #f0fdfa;
}

.table-wrap td.best-val {
  font-weight: 700;
  color: #0f766e;
}

.table-wrap td.bad-val {
  font-weight: 700;
  color: #991b1b;
}

.table-wrap td.muted-cell {
  color: #6b7280;
  font-style: italic;
}

.table-sub {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

.table-footnotes {
  font-family: var(--sans);
  font-size: 12.8px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 15px;
  margin: -12px 0 22px;
}

.table-footnotes p {
  margin: 0 0 6px;
  font-size: inherit;
  line-height: inherit;
}

.table-footnotes p:last-child {
  margin-bottom: 0;
}

.table-footnotes .para-num {
  display: none;
}

/* Pointable Figure & Table Reference Labels */
.ref-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0f766e;
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: 4px;
  padding: 1px 6px;
  text-decoration: none;
  margin-right: 6px;
  vertical-align: 1px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ref-tag:hover {
  background: #d1fae5;
  border-color: #14b8a6;
  color: #115e59;
}

figure[id^="fig-"],
.widget-box[id^="fig-"],
.table-caption[id^="table-"] {
  scroll-margin-top: 28px;
}

figure[id^="fig-"]:target,
.widget-box[id^="fig-"]:target,
.table-caption[id^="table-"]:target {
  outline: 2px solid #14b8a6;
  outline-offset: 6px;
  border-radius: 8px;
}

.table-caption.wide-breakout {
  margin: 24px 0 10px;
}

@media (min-width: 1200px) {
  .table-caption.wide-breakout {
    width: calc(100% + 310px);
    max-width: 970px;
  }
}

.scale-callout {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.62;
  color: var(--ink);
  border-left: 3px solid var(--accent);
  background: #f4faf8;
  padding: 13px 16px;
  border-radius: 0 8px 8px 0;
  margin: 18px 0 24px;
}

@media print {
  .toc-rail, .btn-row, .copy-btn, .notes-trigger-btn, .notes-fab, .ann-drawer, .ann-ctx-menu, .ann-popover {
    display: none !important;
  }
  .page-shell {
    grid-template-columns: 1fr;
  }
  body {
    background: #fff;
    font-size: 11pt;
  }
}
