/* ═══════════════════════════════════════════════════════════════
   Windrose EU Owner's Manual — Service Portal Stylesheet v2
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --hdr-bg: #1a2332;
  --hdr-fg: #f0f4f8;
  --nav-bg: #f5f7fa;
  --nav-border: #dde3ea;
  --nav-active: #0b5ed7;
  --main-bg: #ffffff;
  --text: #222831;
  --text-muted: #5a6577;
  --accent: #0b5ed7;
  --accent-light: #e8f0fe;
  --warning-bg: #fff3cd;
  --warning-border: #e6a817;
  --warning-text: #664d03;
  --notice-bg: #fff3e0;
  --notice-border: #f57c00;
  --notice-text: #7a4100;
  --note-bg: #e3f2fd;
  --note-border: #1976d2;
  --note-text: #0d47a1;
  --env-bg: #e8f5e9;
  --env-border: #43a047;
  --env-text: #1b5e20;
  --table-header: #eef2f7;
  --table-border: #d0d7e0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,.12);
  --radius: 6px;
  --sidebar-w: 300px;
  --header-h: 56px;
  --font-sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: #eef1f5;
}

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--header-h);
  background: var(--hdr-bg);
  color: var(--hdr-fg);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  box-shadow: var(--shadow-md);
}
.header-search { margin-left: auto; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 20px; font-weight: 600; white-space: nowrap; }
.nav-toggle {
  background: transparent; border: 1px solid rgba(255,255,255,.25);
  color: var(--hdr-fg); font-size: 20px; padding: 4px 10px;
  border-radius: 4px; cursor: pointer; display: none;
}
.nav-toggle:hover { background: rgba(255,255,255,.1); }

/* ── AI-powered unified search ─────────────────────────────── */
.header-search { position: relative; flex: 0 1 440px; }
.ai-search-form { display: flex; align-items: center; gap: 6px; }
.header-search input {
  flex: 1; padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  background: rgba(255,255,255,.1);
  color: #fff; font-size: 14px;
  transition: all .2s;
}
.header-search input::placeholder { color: rgba(255,255,255,.5); }
.header-search input:focus {
  outline: none; background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.6); box-shadow: 0 0 0 3px rgba(255,255,255,.15);
}
.ai-search-btn {
  flex-shrink: 0; width: 30px; height: 30px;
  background: rgba(255,255,255,.2); color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ai-search-btn:hover { background: rgba(255,255,255,.35); }
.search-results {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; color: var(--text); border-radius: var(--radius);
  box-shadow: var(--shadow-md); max-height: 400px; overflow-y: auto;
  border: 1px solid var(--nav-border);
}
.ai-answer {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; color: var(--text); border-radius: var(--radius);
  box-shadow: var(--shadow-md); border: 1px solid var(--nav-border);
  overflow: hidden; z-index: 999;
}
.ai-answer-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 600;
}
.ai-close {
  background: none; border: none; color: #fff; font-size: 18px;
  cursor: pointer; line-height: 1; padding: 0;
}
.ai-close:hover { opacity: 0.7; }
.ai-answer-body {
  padding: 12px; font-size: 13px; line-height: 1.6;
  max-height: 300px; overflow-y: auto; white-space: pre-wrap;
}
.ai-thinking { color: var(--text-muted); font-style: italic; }
.sr-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 10px 14px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid #f0f0f0; transition: background .15s;
}
.sr-item:hover { background: var(--accent-light); }
.sr-title { font-weight: 600; flex: 1 1 100%; }
.sr-section { font-size: 12px; color: var(--text-muted); }
.sr-cat {
  font-size: 11px; padding: 1px 8px; border-radius: 10px;
  font-weight: 500; text-transform: uppercase; letter-spacing: .3px;
}
.badge-safety        { background: #fce4ec; color: #b71c1c; }
.badge-procedure     { background: #e3f2fd; color: #0d47a1; }
.badge-charging      { background: #e8f5e9; color: #1b5e20; }
.badge-warning-lamps { background: #fff8e1; color: #e65100; }
.badge-maintenance   { background: #f3e5f5; color: #6a1b9a; }
.badge-technical-data{ background: #e0f2f1; color: #004d40; }
.badge-emergency     { background: #fbe9e7; color: #bf360c; }
.badge-driving-assistance{background:#e8eaf6;color:#283593;}
.badge-controls      { background: #eceff1; color: #37474f; }
.badge-overview      { background: #f5f5f5; color: #424242; }
.badge-troubleshooting{background:#fff3e0;color:#e65100;}
.sr-empty { padding: 20px; text-align: center; color: var(--text-muted); }

/* ── Sidebar / Nav ────────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  overflow-y: auto; overflow-x: hidden;
  z-index: 900;
  transition: transform .25s ease;
}
.sidebar-inner { padding: 0 0 40px; }

.nav-toc-link {
  padding: 8px 14px; border-bottom: 1px solid var(--nav-border);
}
.nav-toc-link a {
  display: block; padding: 6px 10px;
  background: var(--accent-light); color: var(--accent);
  border-radius: 4px; text-decoration: none;
  font-size: 13px; font-weight: 600; text-align: center;
  transition: background .15s;
}
.nav-toc-link a:hover { background: #d0e3ff; }

.nav-filter { padding: 4px 14px 8px; }
.nav-filter input {
  width: 100%; padding: 6px 10px; border: 1px solid var(--nav-border);
  border-radius: 4px; font-size: 13px; background: #fff;
}
.nav-filter input:focus { outline: none; border-color: var(--accent); }

.nav-chapters { list-style: none; }
.nav-chapter { border-bottom: 1px solid var(--nav-border); }
.nav-chapter-title {
  display: block; padding: 10px 14px; font-weight: 600;
  font-size: 13px; color: var(--text); text-decoration: none;
  text-transform: uppercase; letter-spacing: .4px;
  background: transparent; transition: background .15s;
  cursor: pointer;
}
.nav-chapter-title:hover { background: rgba(11,94,215,.06); }
.nav-chapter-title::before {
  content: "▸"; display: inline-block; margin-right: 6px;
  transition: transform .2s; font-size: 11px;
}
.nav-sections.expanded + .nav-chapter-title::before,
.nav-chapter-title:has(+ .nav-sections.expanded)::before {
  transform: rotate(90deg);
}

.nav-sections {
  list-style: none; max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
}
.nav-sections.expanded { max-height: 4000px; }
.nav-sections li a {
  display: block; padding: 5px 14px 5px 28px;
  font-size: 13px; color: var(--text-muted); text-decoration: none;
  border-left: 3px solid transparent; transition: all .15s;
}
.nav-sections li a:hover { color: var(--accent); background: rgba(11,94,215,.04); }
.nav-sections li a.active {
  color: var(--accent); font-weight: 600;
  border-left-color: var(--accent); background: var(--accent-light);
}
.nav-l3 a { padding-left: 40px !important; font-size: 12.5px !important; }
.nav-l4 a { padding-left: 52px !important; font-size: 12px !important; }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 24px 32px 60px;
  max-width: 960px;
  background: var(--main-bg);
  min-height: calc(100vh - var(--header-h));
}

/* ── Sections ──────────────────────────────────────────────── */
.manual-section {
  padding: 20px 0 12px;
  border-bottom: 1px solid #eee;
}
.manual-section:target {
  animation: highlight 1.5s ease;
}
@keyframes highlight {
  0%   { background: var(--accent-light); }
  100% { background: transparent; }
}

/* ── Preamble ──────────────────────────────────────────────── */
.preamble-section blockquote {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  border-left: 4px solid var(--accent);
  padding: 20px 24px;
  border-radius: var(--radius);
  margin: 12px 0;
}

/* ── TOC Page Images ───────────────────────────────────────── */
.toc-section {
  text-align: center;
  padding-bottom: 24px;
}
.toc-section h1 { text-align: left; }
.toc-page-img {
  max-width: 100% !important;
  max-height: none !important;
  width: 100%;
  border: 1px solid var(--table-border);
  border-radius: var(--radius);
  margin: 8px 0;
  box-shadow: var(--shadow-sm);
}

/* ── Typography ──────────────────────────────────────────── */
h1 { font-size: 28px; font-weight: 700; color: var(--hdr-bg); margin: 8px 0 12px; padding-bottom: 8px; border-bottom: 3px solid var(--accent); }
h2 { font-size: 18px; font-weight: 600; color: #2c3e50; margin: 6px 0 10px; }
h3 { font-size: 15px; font-weight: 600; color: #34495e; margin: 4px 0 8px; }
h4 { font-size: 13px; font-weight: 600; color: #4a5568; margin: 4px 0 6px; }
p  { margin: 6px 0; }
blockquote {
  margin: 6px 0; padding: 0;
  border: none;
}

/* ── Lists ─────────────────────────────────────────────── */
ul, ol { margin: 8px 0; padding-left: 28px; }
li { margin: 4px 0; }
li > p { margin: 2px 0; }

/* ── Tables ────────────────────────────────────────────────── */
table {
  width: 100%; border-collapse: collapse;
  margin: 12px 0; font-size: 14px;
  box-shadow: var(--shadow-sm); border-radius: var(--radius);
  overflow: hidden;
}
thead th, thead td {
  background: var(--table-header); padding: 10px 12px;
  text-align: left; font-weight: 600; font-size: 13px;
  border-bottom: 2px solid var(--accent);
  white-space: nowrap;
}
td, th {
  padding: 8px 12px; border-bottom: 1px solid var(--table-border);
  vertical-align: top;
}
tr:nth-child(even) > td { background: #fafbfc; }
tr:hover > td { background: var(--accent-light); }

/* Gradeability tables — keep text wrapping for long cell content */
table td[rowspan], table th[rowspan] {
  vertical-align: middle;
  font-weight: 600;
}

/* ── Images & Figures ──────────────────────────────────────── */
.manual-img {
  max-width: 100%; height: auto;
  border-radius: 4px;
}
figure { margin: 12px 0; text-align: center; }
figcaption {
  font-size: 13px; color: var(--text-muted);
  margin-top: 6px; font-style: italic;
}

/* Icons (small inline indicator images) */
img[src*="image5.png"],
img[src*="image6.png"],
img[src*="image7.png"],
img[src*="image8.png"] {
  width: 16px; height: 16px;
  vertical-align: middle; display: inline;
  margin-right: 4px;
}
img[src*="image9."],
img[src*="image10."],
img[src*="image11."],
img[src*="image12."] {
  width: 20px; height: 20px;
  vertical-align: middle; display: inline;
}
p > img:only-child:not(.toc-page-img) {
  display: block; margin: 10px auto;
  max-width: 680px;
}
img:not(.toc-page-img) { max-height: 600px; }

/* ── Callout Boxes ─────────────────────────────────────────── */
.callout {
  margin: 12px 0; padding: 12px 16px;
  border-left: 4px solid; border-radius: var(--radius);
  font-size: 15px;
}
.callout-title {
  font-weight: 700; font-size: 13px; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 4px;
}
.callout-body { margin: 0; }
.callout.warning {
  background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text);
}
.callout.notice {
  background: var(--notice-bg); border-color: var(--notice-border); color: var(--notice-text);
}
.callout.note {
  background: var(--note-bg); border-color: var(--note-border); color: var(--note-text);
}
.callout.env-protection {
  background: var(--env-bg); border-color: var(--env-border); color: var(--env-text);
}

/* ── Back to Top ───────────────────────────────────────────── */
.back-to-top {
  display: inline-block; margin-top: 8px;
  font-size: 12px; color: var(--text-muted);
  text-decoration: none; opacity: .5;
  transition: opacity .2s;
}
.back-to-top:hover { opacity: 1; color: var(--accent); }

/* ── Links ─────────────────────────────────────────────────── */
a { color: var(--accent); }
a:hover { text-decoration: underline; }

/* ── Underline utility (chapter breadcrumbs from Word) ─────── */
u { text-decoration: none; font-weight: 600; color: var(--text-muted); font-size: 12px; letter-spacing: .3px; text-transform: uppercase; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 960px) {
  :root { --header-h: 190px; }
  .nav-toggle { display: block; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main-content { margin-left: 0; padding: 16px 18px 40px; }
  .site-header { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 6px; }
  .header-left { flex: 1 1 100%; order: 1; }
  .header-left h1 { font-size: 16px; white-space: normal; }
  .header-lang { flex: 1 1 100%; order: 2; }
  .lang-select { width: 100% !important; max-width: 100% !important; }
  #wr-header-chat { flex: 1 1 100%; order: 3; padding: 9px 14px !important; text-align: center; border-radius: 6px !important; font-size: 14px !important; }
  .header-search { flex: 1 1 100%; order: 4; margin-left: 0; }
  img { max-width: 100% !important; height: auto !important; }
  table { font-size: 13px; display: block; overflow-x: auto; }
}
@media (min-width: 961px) {
  #wr-chat-btn { display: none !important; }
}
@media (max-width: 600px) {
  .main-content { padding: 12px 12px 30px; }
  h1 { font-size: 22px; }
  h2 { font-size: 15px; }
  h3 { font-size: 13px; }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  .site-header, .sidebar, .back-to-top, .nav-toggle { display: none !important; }
  .main-content { margin: 0; padding: 0; max-width: 100%; }
  .manual-section { page-break-inside: avoid; border: none; }
  table { page-break-inside: avoid; }
  img { max-width: 100% !important; max-height: none !important; }
  body { font-size: 11pt; background: #fff; }
  .toc-page-img { page-break-after: always; }
}


/* ===== ADAS / self-driving functions — hidden ===== */
/* Sections */
section#adaptive-cruise-control-acc,
section#automatic-emergency-braking-aeb,
section#lane-departure-warning-ldw,
section#blind-spot-information-system-bsis,
section#addw,
section#intelligent-speed-assistance-isa { display: none !important; }

/* Sidebar nav items */
li.nav-chapter:has(> a[href="#adaptive-cruise-control-acc"]),
li.nav-chapter:has(> a[href="#automatic-emergency-braking-aeb"]),
li.nav-chapter:has(> a[href="#lane-departure-warning-ldw"]),
li.nav-chapter:has(> a[href="#blind-spot-information-system-bsis"]),
li.nav-chapter:has(> a[href="#addw"]),
li.nav-chapter:has(> a[href="#intelligent-speed-assistance-isa"]) { display: none !important; }
/* ================================================== */

/* ===== Nav group headers ===== */
li.nav-group-header {
  list-style: none;
  padding: 14px 16px 3px;
  margin-top: 6px;
  border-top: 1px solid var(--border, #ddd);
  pointer-events: none;
}
li.nav-group-header:first-of-type { border-top: none; margin-top: 0; }
li.nav-group-header span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #888);
}
/* ============================== */

/* ── Service manual extras ─────────────────────────────────── */
.nav-l2 { padding-left: 24px !important; font-size: 12.5px !important; }
.nav-l3 { padding-left: 38px !important; font-size: 12px !important; }
.nav-l4 { padding-left: 52px !important; font-size: 11.5px !important; }

/* Table overflow wrapper */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
.tw table { margin: 0; }

/* Numbered procedure steps */
p.step { padding-left: 1.5rem; position: relative; }
p.step::before { content: '▸'; position: absolute; left: 0; color: var(--accent); }

/* h5 sub-label */
h5 { font-size: 13px; font-weight: 600; color: #4a5568; margin: 8px 0 4px; text-transform: uppercase; letter-spacing: .3px; }

/* Figures */
figure { margin: 16px 0; text-align: center; }
figure img { max-width: 100%; border: 1px solid var(--table-border); border-radius: var(--radius); }

/* ── HTML Table of Contents (two-level collapsible) ──────── */
.toc-html {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0;
  text-align: left;
}
[dir="rtl"] .toc-html { text-align: right; }

/* ── Group card (layer 1) ─── */
details.toc-group {
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
summary.toc-group-title {
  background: var(--hdr-bg);
  color: var(--hdr-fg);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
}
summary.toc-group-title::-webkit-details-marker { display: none; }
summary.toc-group-title::after {
  content: "▾";
  margin-left: auto;
  font-size: 13px;
  opacity: 0.7;
  transition: transform 0.2s;
  flex-shrink: 0;
}
details.toc-group:not([open]) > summary.toc-group-title::after {
  transform: rotate(-90deg);
}
[dir="rtl"] summary.toc-group-title::after {
  margin-left: 0;
  margin-right: auto;
}
[dir="rtl"] details.toc-group:not([open]) > summary.toc-group-title::after {
  transform: rotate(90deg);
}

/* ── Chapter list ─── */
.toc-chapters {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-chapters > li {
  border-bottom: 1px solid var(--nav-border);
}
.toc-chapters > li:last-child { border-bottom: none; }

/* Plain chapter (no subsections) */
.toc-chapters > li > a {
  display: block;
  padding: 7px 14px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.toc-chapters > li > a:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Chapter with subsections (layer 2) ─── */
details.toc-chapter {
  width: 100%;
}
summary.toc-chapter-title {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  gap: 0;
}
summary.toc-chapter-title::-webkit-details-marker { display: none; }
summary.toc-chapter-title > a {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  transition: color 0.12s;
}
summary.toc-chapter-title > a:hover { color: var(--accent); }
summary.toc-chapter-title::after {
  content: "▾";
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
details.toc-chapter:not([open]) > summary.toc-chapter-title::after {
  transform: rotate(-90deg);
}
[dir="rtl"] summary.toc-chapter-title::after {
  margin-left: 0;
  margin-right: 6px;
}
[dir="rtl"] details.toc-chapter:not([open]) > summary.toc-chapter-title::after {
  transform: rotate(90deg);
}
summary.toc-chapter-title:hover { background: rgba(11,94,215,.04); }

/* ── Subsection list ─── */
.toc-subsections {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(0,0,0,0.025);
  border-top: 1px solid var(--nav-border);
}
.toc-subsections li {
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.toc-subsections li:last-child { border-bottom: none; }

/* ── Subsection disclosure (toc-sub) ─── */
details.toc-sub { width: 100%; }
summary.toc-sub-title {
  display: flex;
  align-items: center;
  padding: 5px 14px 5px 28px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
summary.toc-sub-title::-webkit-details-marker { display: none; }
summary.toc-sub-title > a {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.12s;
}
summary.toc-sub-title > a:hover { color: var(--accent); }
summary.toc-sub-title::after {
  content: "▾";
  font-size: 9px;
  color: var(--text-muted);
  margin-left: 6px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
details.toc-sub:not([open]) > summary.toc-sub-title::after { transform: rotate(-90deg); }
[dir="rtl"] summary.toc-sub-title { padding: 5px 28px 5px 14px; }
[dir="rtl"] summary.toc-sub-title::after { margin-left: 0; margin-right: 6px; }
[dir="rtl"] details.toc-sub:not([open]) > summary.toc-sub-title::after { transform: rotate(90deg); }
summary.toc-sub-title:hover { background: rgba(11,94,215,.04); }

/* ── Inline content slot ─── */
.toc-content-slot {
  padding: 10px 14px 14px 28px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
  border-top: 1px solid var(--nav-border);
  background: rgba(0,0,0,0.015);
}
.toc-content-slot:empty { display: none; }
.toc-content-slot img { max-width: 100%; height: auto; border-radius: 4px; margin: 4px 0; }
.toc-content-slot table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.toc-content-slot td, .toc-content-slot th {
  padding: 4px 8px;
  border: 1px solid var(--nav-border);
  text-align: left;
}
.toc-content-slot h2, .toc-content-slot h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--text);
}
.toc-content-slot p { margin: 4px 0; }
.toc-content-slot ul, .toc-content-slot ol { margin: 4px 0; padding-left: 18px; }
.toc-content-slot .sec-toggle::after { display: none; }
[dir="rtl"] .toc-content-slot { padding: 10px 28px 14px 14px; }
[dir="rtl"] .toc-content-slot td, [dir="rtl"] .toc-content-slot th { text-align: right; }

/* ── Chapter label badge (e.g. 1A, 3Z) ─── */
.toc-chapter-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 3px;
  padding: 1px 5px;
  margin-right: 7px;
  letter-spacing: 0.02em;
  vertical-align: middle;
  flex-shrink: 0;
  white-space: nowrap;
}
[dir="rtl"] .toc-chapter-label {
  margin-right: 0;
  margin-left: 7px;
}

/* ── Section label badge in body headings ───────────────────── */
.sec-label {
  display: inline-block;
  font-size: 0.52em;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 3px;
  padding: 2px 6px;
  margin-right: 10px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
[dir="rtl"] .sec-label { margin-right: 0; margin-left: 10px; }

/* ── Collapsible body sections ─────────────────────────────── */
.sec-toggle { cursor: pointer; user-select: none; }
.sec-toggle::after {
  content: '▾';
  font-size: 0.6em;
  font-weight: 400;
  opacity: 0.5;
  margin-left: 10px;
  display: inline-block;
  transition: transform 0.18s;
  vertical-align: middle;
}
.sec-toggle:not(.is-open)::after { transform: rotate(-90deg); }
.sec-toggle:hover { opacity: 0.8; }
[dir="rtl"] .sec-toggle::after { margin-left: 0; margin-right: 10px; }
[dir="rtl"] .sec-toggle:not(.is-open)::after { transform: rotate(90deg); }

/* ══════════════════════════════════════════════════════════════
   Nav labels, TOC chapter cards, integrated search/AI panel
   ══════════════════════════════════════════════════════════════ */

/* ── Sidebar chapter labels ─────────────────────────────────── */
.nav-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 3px;
  padding: 1px 5px;
  margin-right: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ── TOC chapter icon ───────────────────────────────────────── */
.toc-chapter-icon {
  font-size: 14px;
  line-height: 1;
  margin-right: 5px;
  flex-shrink: 0;
}

/* ── TOC: full-width groups, chapters as mini-cards ──────────── */
.toc-html { grid-template-columns: 1fr; }

.toc-chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 5px;
  padding: 8px;
  list-style: none;
}
.toc-chapters > li {
  border-bottom: none;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--nav-border);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  transition: box-shadow 0.15s;
}
.toc-chapters > li:hover { box-shadow: var(--shadow-md); }
.toc-chapters > li:last-child { border-bottom: none; }
.toc-chapters > li > a {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
}
details.toc-chapter { width: 100%; }
summary.toc-chapter-title { padding: 8px 10px; }


/* ════════════════════════════════════════════════════════════
   Collapsible TOC (sidebar) + collapsible content (body)
   Added 2026-06 — sidebar chapters and body sections collapse.
   ════════════════════════════════════════════════════════════ */

/* ---- Sidebar: collapsible chapter groups ---- */
.nav-ch-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 11px 14px; border: none; background: transparent;
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text); text-align: left;
  cursor: pointer; transition: background .15s;
}
.nav-ch-toggle:hover { background: rgba(11,94,215,.07); }
.nav-ch-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-ch-toggle::after {
  content: "▸"; margin-left: auto; font-size: 11px; color: var(--text-muted);
  transition: transform .2s;
}
.nav-ch-toggle[aria-expanded="true"]::after { transform: rotate(90deg); }
.nav-ch-num {
  flex: 0 0 auto; min-width: 18px; height: 18px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border-radius: 4px;
  font-size: 11px; font-weight: 700;
}
/* reuse existing .nav-sections collapse; lift cap so big chapters don't clip */
.nav-sections.expanded { max-height: none; }
.nav-sections .nav-item {
  display: block; padding: 5px 14px; color: var(--text-muted);
  text-decoration: none; border-left: 3px solid transparent;
  font-size: 13px; line-height: 1.35; transition: all .12s;
}
.nav-sections .nav-item:hover { color: var(--accent); background: rgba(11,94,215,.05); }
.nav-sections .nav-item.active {
  color: var(--accent); font-weight: 600;
  border-left-color: var(--accent); background: var(--accent-light);
}
.nav-item.lvl1 { padding-left: 16px; font-weight: 600; color: var(--text); }
.nav-item.lvl2 { padding-left: 30px; font-size: 12.5px; }
.nav-item.lvl3 { padding-left: 44px; font-size: 12px; color: #7a8597; }

/* ---- Body: expand/collapse toolbar ---- */
.manual-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--nav-border);
}
.manual-toolbar button {
  padding: 6px 14px; border: 1px solid var(--accent); border-radius: 5px;
  background: #fff; color: var(--accent); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.manual-toolbar button:hover { background: var(--accent); color: #fff; }
.toolbar-hint { font-size: 12.5px; color: var(--text-muted); }
.manual-intro { margin-bottom: 8px; }

/* ---- Body: collapsible chapters ---- */
details.ch-block { border: 1px solid var(--nav-border); border-radius: var(--radius); margin: 0 0 12px; background: #fff; box-shadow: var(--shadow-sm); }
details.ch-block[open] { box-shadow: var(--shadow-md); }
summary.ch-summary {
  display: flex; align-items: center; gap: 10px; list-style: none; cursor: pointer;
  padding: 14px 18px; font-size: 16px; font-weight: 700; color: var(--hdr-fg);
  background: var(--hdr-bg); border-radius: var(--radius);
}
details.ch-block[open] > summary.ch-summary { border-radius: var(--radius) var(--radius) 0 0; }
summary.ch-summary::-webkit-details-marker { display: none; }
summary.ch-summary::after { content: "▸"; margin-left: auto; transition: transform .2s; opacity: .7; }
details.ch-block[open] > summary.ch-summary::after { transform: rotate(90deg); }
summary.ch-summary .ch-num {
  flex: 0 0 auto; min-width: 24px; height: 24px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border-radius: 5px; font-size: 14px;
}
.ch-body { padding: 14px 16px; }

/* ---- Body: collapsible sections ---- */
details.sec-block { border: 1px solid var(--nav-border); border-radius: var(--radius); margin: 0 0 10px; overflow: hidden; }
details.sec-block:last-child { margin-bottom: 0; }
summary.sec-summary {
  list-style: none; cursor: pointer; padding: 12px 16px;
  background: var(--nav-bg); transition: background .15s;
  display: flex; align-items: flex-start; gap: 8px;
}
summary.sec-summary:hover { background: var(--accent-light); }
summary.sec-summary::-webkit-details-marker { display: none; }
summary.sec-summary::before { content: "▸"; color: var(--accent); font-size: 12px; margin-top: 4px; transition: transform .2s; }
details.sec-block[open] > summary.sec-summary { background: var(--accent-light); border-bottom: 1px solid var(--nav-border); }
details.sec-block[open] > summary.sec-summary::before { transform: rotate(90deg); }
summary.sec-summary h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.sec-body { padding: 14px 18px; }
.sec-body > h3:first-child, .sec-body > h4:first-child { margin-top: 0; }

/* ── Go-to-top floating button ─────────────────────────────── */
.to-top {
  position: fixed; right: 22px; bottom: 66px; z-index: 60;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 15px; border: none; border-radius: 22px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .2s, transform .2s, visibility .2s, background .15s;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: #0a4fb5; }
.to-top:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .to-top { transition: opacity .2s; transform: none; } }

/* ── Sign-out floating button (always visible) ─────────────── */
.sign-out {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 15px; border: 1px solid var(--table-border); border-radius: 22px;
  background: #fff; color: var(--ink, #1a1a1a); font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow-md); text-decoration: none;
  transition: background .15s, color .15s;
}
.sign-out:hover { background: #f3f4f6; color: var(--accent); }
.sign-out:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media print { .sign-out { display: none !important; } }
