/* ============================================================
   Insulin Plant Knowledge Base - styles.css
   Costus igneus / Chamaecostus cuspidatus
   ============================================================ */

:root {
  --bg: #f4f7f3;
  --surface: #ffffff;
  --surface-2: #eef4ee;
  --text: #22301f;
  --muted: #5d6b58;
  --border: #dbe5d8;
  --border-strong: #c6d4c2;

  --green: #2e7d43;
  --green-strong: #256a37;
  --green-soft: #e3f0e4;
  --orange: #e07b39;
  --orange-soft: #fbeadb;

  --info-bg: #eef4fb;
  --info-border: #7fa8d9;
  --success-bg: #e9f4ea;
  --success-border: #79b184;
  --warn-bg: #fdf4e5;
  --warn-border: #dfae62;
  --danger-bg: #fdeceb;
  --danger-border: #dd8a83;

  --shadow: 0 1px 2px rgba(34, 48, 31, 0.05), 0 8px 24px rgba(34, 48, 31, 0.07);
  --radius: 12px;
  --sidebar-w: 292px;
  --topbar-h: 60px;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--orange-soft); }

a { color: var(--green-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--green); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 200;
  background: var(--green-strong); color: #fff;
  padding: 8px 14px; border-radius: 8px; font-size: 14px; text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 10px; color: #fff; }

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============ Reading progress ============ */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: transparent; z-index: 120; pointer-events: none;
}
.progress__bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--orange));
  transition: width 0.08s linear;
}

/* ============ Topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h);
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar__menu {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  margin-right: auto;
  white-space: nowrap;
}
.brand__logo { display: inline-flex; }
.brand__logo svg { border-radius: 8px; box-shadow: var(--shadow); }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong {
  font-family: var(--font-heading);
  font-size: 17px; letter-spacing: 0.2px;
}
.brand__text small {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}

.search { position: relative; width: min(360px, 40vw); }
.search__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; height: 38px;
  padding: 0 34px 0 36px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.search input::-webkit-search-cancel-button { display: none; }
.search__clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none; border-radius: 50%;
  background: transparent; color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer;
}
.search__clear:hover { background: var(--surface-2); color: var(--text); }

mark.hit {
  background: #ffe9b8;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}
mark.hit--active { background: var(--orange); color: #fff; }

/* ============ Layout ============ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

/* ============ Sidebar ============ */
.sidebar {
  align-self: start;
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 10px 18px;
  scrollbar-width: thin;
}
.overlay {
  display: none;
  position: fixed; inset: 0; z-index: 90;
  background: rgba(23, 33, 21, 0.45);
  backdrop-filter: blur(1.5px);
}

.toc__group {
  margin: 16px 10px 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--muted);
}
.toc__group:first-child { margin-top: 4px; }
.toc ul { list-style: none; margin: 0; padding: 0; }

.nav-link {
  display: flex; align-items: baseline; gap: 9px;
  padding: 6px 10px;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 13.8px;
  line-height: 1.35;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.nav-link span {
  min-width: 20px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px; text-align: right;
}
.nav-link:hover { background: var(--surface-2); color: var(--green-strong); }
.nav-link.active {
  background: var(--green-soft);
  border-left-color: var(--green);
  color: var(--green-strong);
  font-weight: 600;
}
.nav-link.active span { color: var(--green); }
.nav-hidden { display: none; }

/* ============ Hero ============ */
.hero {
  background:
    radial-gradient(1100px 320px at 85% -80%, rgba(224, 123, 57, 0.14), transparent 60%),
    radial-gradient(900px 340px at -10% -60%, rgba(46, 125, 67, 0.16), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 36px 30px;
  margin-bottom: 26px;
}
.hero__eyebrow {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 2.2px; text-transform: uppercase;
  color: var(--green);
}
.hero h1 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: clamp(28px, 4vw, 42px);
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.15;
}
.hero__common { font-style: normal; font-weight: 500; color: var(--muted); }
.hero__accepted { margin: 0 0 16px; color: var(--muted); font-size: 15px; }
.hero__accepted em { color: var(--green-strong); font-weight: 600; }

.hero__chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  list-style: none; margin: 0 0 18px; padding: 0;
}
.hero__chips li {
  background: var(--green-soft);
  color: var(--green-strong);
  border: 1px solid #cfe3cf;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px; font-weight: 600;
}
.hero__status { margin-bottom: 14px; }
.hero__note { margin: 0; color: var(--muted); font-size: 13.5px; font-style: italic; }

/* ============ Sections ============ */
.kb-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px 24px;
  margin-bottom: 26px;
}

h2, h3 { font-family: var(--font-heading); line-height: 1.25; }
.kb-section h2 {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 24px; font-weight: 650;
}
.sec-num {
  color: var(--orange);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}
.kb-section h3 {
  margin: 22px 0 8px;
  font-size: 18px;
  color: var(--green-strong);
}
.kb-section p { margin: 0 0 13px; }
.kb-section > p:last-child,
.kb-section > *:last-child { margin-bottom: 0; }
em { font-style: italic; }

/* ============ Lists ============ */
.list { margin: 0 0 14px; padding-left: 4px; list-style: none; }
.list li {
  position: relative;
  padding: 3px 0 3px 26px;
}
.list li::before {
  content: "";
  position: absolute; left: 8px; top: 12px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--orange);
}
.check-list li::before {
  content: "";
  top: 11px; left: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.cross-list li::before {
  content: "";
  top: 11px; left: 5px;
  width: 9px; height: 9px;
  border-radius: 2px;
  background: #b3402f;
}
.check-list li, .cross-list li { padding-left: 27px; }

.numbered-list { counter-reset: step; list-style: none; margin: 0 0 8px; padding: 0; }
.numbered-list li {
  counter-increment: step;
  position: relative;
  padding: 6px 0 6px 44px;
}
.numbered-list li::before {
  content: counter(step);
  position: absolute; left: 0; top: 4px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-strong);
  border: 1px solid #cfe3cf;
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 720px) {
  .two-col { column-count: 2; column-gap: 36px; }
  .two-col li { break-inside: avoid; }
}

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 4px 0 14px; padding: 0; }
.chip-list li {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 13px;
  font-size: 13.5px; font-weight: 600;
  color: #43543f;
}

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 4px 0 16px; padding: 0; }
.pill-list li {
  background: var(--warn-bg);
  border: 1px solid #ecd3ab;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13.5px; font-weight: 600;
  color: #7c5417;
}

.grid-list {
  list-style: none; margin: 6px 0 4px; padding: 0;
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.grid-list li {
  background: var(--danger-bg);
  border: 1px solid #f0cdc9;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 14px;
  color: #6e2f26;
}

/* ============ Callouts ============ */
.callout {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 18px 13px;
  margin: 16px 0;
  background: var(--surface-2);
}
.callout p { margin: 0; font-size: 14.6px; }
.callout--info    { background: var(--info-bg);    border-color: #cfdff2; border-left-color: var(--info-border); }
.callout--success { background: var(--success-bg); border-color: #d2e7d4; border-left-color: var(--success-border); }
.callout--warn    { background: var(--warn-bg);    border-color: #f0e0c2; border-left-color: var(--warn-border); }
.callout--danger  { background: var(--danger-bg);  border-color: #f2d3d0; border-left-color: var(--danger-border); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; margin: 6px 0 14px; border: 1px solid var(--border); border-radius: 10px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.4px;
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.table thead th {
  background: var(--surface-2);
  color: var(--green-strong);
  font-family: var(--font-heading);
  font-size: 14.5px;
  white-space: nowrap;
}
.table tbody tr:last-child th,
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcf9; }
.table--kv th[scope="row"] {
  width: 240px;
  font-weight: 650;
  color: #43543f;
  background: #fafcf8;
  white-space: normal;
}
.table--benefits td:nth-child(2) { color: var(--muted); }

.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 12.3px; font-weight: 700;
  white-space: nowrap;
}
.chip--green { background: var(--green-soft);   color: var(--green-strong); border: 1px solid #c4dcc6; }
.chip--blue  { background: #e8f1fa;             color: #2c5d8f;             border: 1px solid #cadff0; }
.chip--amber { background: var(--warn-bg);      color: #8a5d14;             border: 1px solid #eedbb4; }
.chip--red   { background: var(--danger-bg);    color: #96382b;             border: 1px solid #efccc7; }

/* ============ Ratings ============ */
.ratings { display: grid; gap: 16px; margin-top: 6px; }
.rating__head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-bottom: 6px;
}
.rating__label { font-weight: 650; font-size: 14.6px; }
.rating__score {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.rating__track {
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.rating__fill {
  height: 100%; width: var(--w, 0%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #4c9a63);
  transition: width 0.6s ease;
}
.rating__fill--amber { background: linear-gradient(90deg, #d99b2f, #e5b45e); }
.rating__fill--red   { background: linear-gradient(90deg, #c04a3b, #d3776a); }
.rating__note { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

/* ============ Timeline ============ */
.timeline {
  list-style: none;
  margin: 10px 0 4px;
  padding: 0 0 0 8px;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute; left: 47px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border-strong);
}
.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 16px;
  padding: 0 0 22px;
}
.timeline__item:last-child { padding-bottom: 4px; }
.timeline__year {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--green-strong);
  text-align: right;
  padding-top: 2px;
  white-space: nowrap;
}
.timeline__item::after {
  content: "";
  position: absolute; left: 43px; top: 7px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--orange-soft);
}
.timeline__body {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}
.timeline__body p { margin: 0 0 8px; font-size: 14.5px; }

/* ============ Contents / FAQ / References ============ */
.contents {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 22px;
  margin-bottom: 26px;
}
.contents summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--green-strong);
  font-family: var(--font-heading);
  font-size: 17px;
  user-select: none;
}
.contents summary::marker { color: var(--orange); }
.contents__list {
  columns: 2; column-gap: 40px;
  margin: 14px 0 4px; padding-left: 22px;
  font-size: 14.3px;
}
.contents__list li { break-inside: avoid; padding: 2.5px 0; }
.contents__list a { text-decoration: none; }
.contents__list a:hover { text-decoration: underline; }

.faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fbfdfb;
  overflow: hidden;
}
.faq-item summary {
  display: block;
  cursor: pointer;
  list-style: none;
  padding: 13px 44px 13px 18px;
  font-weight: 650;
  font-size: 15px;
  position: relative;
  user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute; right: 16px; top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-strong);
  font-weight: 700; font-size: 15px;
  transition: transform 0.18s ease;
}
.faq-item[open] summary::after {
  content: "-";
  background: var(--orange-soft);
  color: #a3541f;
}
.faq-item[open] summary { color: var(--green-strong); border-bottom: 1px dashed var(--border); }
.faq-item p {
  margin: 0;
  padding: 12px 18px 14px;
  font-size: 14.6px;
}

.ref-list {
  margin: 6px 0 0; padding-left: 24px;
  font-size: 14.3px;
}
.ref-list li { margin-bottom: 11px; }
.ref-list a { white-space: nowrap; font-weight: 600; }

/* ============ Footer ============ */
.site-footer { margin-top: 34px; }
.site-footer__meta {
  margin: 18px 4px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ============ Back to top ============ */
.back-to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 110;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--green-strong);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.back-to-top:hover { transform: translateY(-2px); background: var(--green-soft); }

/* ============ Search feedback ============ */
.no-results {
  display: none;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.no-results.visible { display: block; }

/* ============ Responsive ============ */
@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; padding: 20px 14px 56px; }

  .topbar__menu { display: inline-flex; }

  .sidebar {
    position: fixed;
    z-index: 95;
    top: 0; left: 0; bottom: 0;
    max-height: none;
    width: min(320px, 84vw);
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: none;
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    padding-top: 70px;
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.show { display: block; }

  .search { width: 100%; max-width: none; }
  .brand__text small { display: none; }

  .hero { padding: 26px 22px 24px; }
  .kb-section { padding: 22px 20px 20px; }
  .contents__list { columns: 1; }
  .table--kv th[scope="row"] { width: auto; min-width: 130px; }
}

@media (max-width: 520px) {
  .brand__text { display: none; }
  .timeline { padding-left: 2px; }
  .timeline::before { left: 41px; }
  .timeline__item { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; }
  .timeline__item::after { left: 37px; }
  .hero h1 { font-size: 26px; }
}

/* ============ Page head (subpages) ============ */
.page-head {
  background:
    radial-gradient(900px 260px at 90% -90%, rgba(224, 123, 57, 0.12), transparent 60%),
    radial-gradient(700px 280px at -10% -70%, rgba(46, 125, 67, 0.14), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 32px 22px;
  margin-bottom: 26px;
}
.crumbs {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}
.crumbs a { color: var(--green-strong); font-weight: 600; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { color: var(--border-strong); }
.page-head h1 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 650;
  line-height: 1.2;
}
.page-head__tag { margin: 0; color: var(--muted); font-size: 15px; max-width: 72ch; }

/* ============ Browse cards (home) ============ */
.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  margin-top: 6px;
}
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdfb;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card__eyebrow {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--orange);
}
.card__title {
  font-family: var(--font-heading);
  font-size: 17px;
  color: var(--green-strong);
  line-height: 1.3;
}
.card__desc { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.card__meta { margin-top: auto; padding-top: 10px; font-size: 12px; color: var(--muted); }

/* ============ Pager (prev / next) ============ */
.pager {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 30px;
}
.pager__link {
  flex: 1 1 240px;
  max-width: calc(50% - 7px);
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.pager__link:hover { border-color: var(--green); transform: translateY(-2px); }
.pager__link:last-child { margin-left: auto; text-align: right; }
.pager__link small {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--muted);
}
.pager__link strong {
  font-family: var(--font-heading);
  font-size: 15px;
  color: var(--green-strong);
}

@media (max-width: 520px) {
  .pager__link { max-width: none; }
  .page-head { padding: 20px 20px 18px; }
}

/* ============ Print ============ */
@media print {
  .progress, .topbar, .sidebar, .overlay, .back-to-top, .search { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .hero, .kb-section, .contents {
    box-shadow: none;
    border: 1px solid #bbb;
    break-inside: avoid-page;
  }
  body { background: #fff; font-size: 12pt; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10pt; word-break: break-all; }
}

/* ============ Theme toggle ============ */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface); color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--green-soft); }
.theme-toggle svg { display: none; width: 18px; height: 18px; }
html:not([data-theme="dark"]) .theme-toggle .ico-moon { display: block; }
[data-theme="dark"] .theme-toggle .ico-sun { display: block; }

/* ============ Page-level nav links ============ */
.nav-page {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; margin: 1px 0;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--text);
  font-weight: 600; font-size: 14px;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.nav-page::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background 0.12s ease;
}
.nav-page:hover { background: var(--surface-2); color: var(--green-strong); }
.nav-page.active { background: var(--green-soft); border-left-color: var(--green); color: var(--green-strong); }
.nav-page.active::before { background: var(--orange); }

/* ============ Reviewed badge / supplement chip ============ */
.reviewed-badge {
  margin-top: 18px; padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  color: var(--muted);
  font-size: 12px; font-style: italic;
  text-align: right;
}
.sup-chip {
  margin-left: auto;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: #8a5d14;
  background: var(--warn-bg);
  border: 1px solid #eedbb4;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ============ Study cards ============ */
.study-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin-top: 6px;
}
.study-card {
  background: #fbfdfb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.study-card__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 8px;
}
.study-card__year { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--green-strong); }
.study-card h3 { margin: 0 0 6px; font-size: 15.5px; }
.study-card p { margin: 0; font-size: 13.8px; color: var(--muted); }

/* ============ Glossary ============ */
.gloss-cat {
  margin: 22px 0 6px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--orange);
}
.gloss-list { margin: 0; }
.term { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.gloss-list .term:last-child { border-bottom: none; }
.term dt { font-weight: 700; color: var(--green-strong); }
.term dd { margin: 4px 0 0; font-size: 14.4px; color: var(--muted); }

a.term-tip {
  text-decoration: none;
  border-bottom: 1px dotted var(--orange);
  cursor: help;
}
a.term-tip:hover { background: var(--orange-soft); }

/* ============ Global search results panel ============ */
.global-results {
  position: fixed; z-index: 130;
  top: calc(var(--topbar-h) + 8px);
  left: 50%; transform: translateX(-50%);
  width: min(640px, 92vw);
  max-height: min(62vh, 500px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
  padding: 8px;
}
.gr-head { margin: 6px 10px 8px; font-size: 12.5px; color: var(--muted); }
.gr-item { display: block; padding: 9px 10px; border-radius: 9px; text-decoration: none; color: inherit; }
.gr-item:hover { background: var(--surface-2); }
.gr-item strong { color: var(--green-strong); font-size: 14px; }
.gr-page {
  display: inline-block; margin-right: 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--orange);
}
.gr-snip { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); line-height: 1.45; }
@media (max-width: 1020px) {
  .global-results { left: 12px; right: 12px; transform: none; width: auto; }
}

/* ============ Cite box ============ */
.cite-box { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.cite-box textarea {
  width: 100%; resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-mono); font-size: 13px;
  color: var(--text);
}
.copy-btn {
  align-self: flex-start;
  border: none;
  background: var(--green-strong); color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600; font-size: 13.5px;
  cursor: pointer;
}
.copy-btn:hover { filter: brightness(1.08); }
.cite-note { font-size: 13px; color: var(--muted); }

/* ============ Myths table ============ */
.table--myths td:first-child { font-weight: 650; width: 34%; color: #96382b; }

/* ============ Gallery plates ============ */
.plates {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  margin: 8px 0 6px;
}
.plate {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.plate svg {
  width: 100%; height: auto;
  background: #fbfdfb;
  border-radius: 8px;
}
.plate figcaption { font-size: 13.2px; color: var(--muted); line-height: 1.5; }
.plate figcaption strong { color: var(--green-strong); }

/* ============================================================
   DARK THEME
   ============================================================ */
:root[data-theme="dark"] {
  --bg: #131a12;
  --surface: #1a231a;
  --surface-2: #222d21;
  --text: #e3ebdf;
  --muted: #a2b09c;
  --border: #2c3a2a;
  --border-strong: #40503b;

  --green: #79c08b;
  --green-strong: #93d4a2;
  --green-soft: #203426;
  --orange: #e8935a;
  --orange-soft: #3a2a1c;

  --info-bg: #17222d;    --info-border: #5f8fc4;
  --success-bg: #182619; --success-border: #5f9a70;
  --warn-bg: #292012;    --warn-border: #c9963f;
  --danger-bg: #2b1513;  --danger-border: #cf7367;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] ::selection { background: #3a2a1c; }
[data-theme="dark"] mark.hit { background: #8a6a1c; color: #fff; }

[data-theme="dark"] .topbar { background: rgba(19, 26, 18, 0.92); }
[data-theme="dark"] .table tbody tr:hover { background: #20291f; }
[data-theme="dark"] .table--kv th[scope="row"] { background: #1e271d; }
[data-theme="dark"] .table--myths td:first-child { color: #e59c90; }

[data-theme="dark"] .chip--green { background: #203426; color: #9fd8ad; border-color: #31503a; }
[data-theme="dark"] .chip--blue  { background: #16273a; color: #8ec1ea; border-color: #28455f; }
[data-theme="dark"] .chip--amber { background: #292012; color: #e3b96a; border-color: #4a3a1c; }
[data-theme="dark"] .chip--red   { background: #2b1513; color: #e59c90; border-color: #4d2320; }
[data-theme="dark"] .pill-list li { background: #292012; border-color: #4a3a1c; color: #e3b96a; }
[data-theme="dark"] .grid-list li { background: #2b1513; border-color: #4d2320; color: #eab6ac; }
[data-theme="dark"] .chip-list li { background: #222d21; border-color: #40503b; color: #c3d2bd; }
[data-theme="dark"] .sup-chip { background: #292012; color: #e3b96a; border-color: #4a3a1c; }

[data-theme="dark"] .faq-item,
[data-theme="dark"] .card,
[data-theme="dark"] .study-card,
[data-theme="dark"] .plate svg,
[data-theme="dark"] .cite-box textarea { background: #1e271d; }

[data-theme="dark"] .hero__chips li { background: #203426; border-color: #31503a; }
[data-theme="dark"] .skip-link { background: #2e7d43; color: #fff; }

[data-theme="dark"] .copy-btn { color: #10230f; }
