.help-tip {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--primary-400);
  font: 700 12px/1 var(--font-sans);
  cursor: pointer;
  vertical-align: middle;
}
.help-tip:hover,
.help-tip:focus-visible {
  border-color: var(--primary-400);
  outline: 2px solid rgba(37, 99, 235, 0.2);
}
.help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
  padding: 24px;
  display: grid;
  place-items: center;
}
.help-backdrop[hidden],
.tour-backdrop[hidden],
.tour-popover[hidden] {
  display: none;
}
.help-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(1180px, 100%);
  height: min(820px, calc(100vh - 48px));
  overflow: hidden;
  background: #0f172a;
  background: var(--bg-base, #0f172a);
  border: 1px solid #1e293b;
  border: 1px solid var(--border, #1e293b);
  border-radius: 16px;
  border-radius: var(--radius-xl, 16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.help-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 22px 26px;
  border-bottom: 1px solid #1e293b;
  border-bottom: 1px solid var(--border, #1e293b);
  background: #1e293b;
  background: var(--bg-card, #1e293b);
}
.help-header .mtbf-kicker {
  margin: 0 0 4px;
  color: #60a5fa;
  color: var(--primary-400, #60a5fa);
}
.help-header h2 {
  font-size: 1.25rem;
  font-size: var(--text-xl, 1.25rem);
  color: #f1f5f9;
  color: var(--text-base, #f1f5f9);
}
.help-header p {
  color: #94a3b8;
  color: var(--text-muted, #94a3b8);
  font-size: 0.75rem;
  font-size: var(--text-xs, 0.75rem);
  margin-top: 4px;
}
.help-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.help-close:hover {
  color: var(--text-base);
}
.help-search-wrap {
  display: grid;
  grid-template-columns: auto minmax(220px, 560px) 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 26px;
  border-bottom: 1px solid #1e293b;
  border-bottom: 1px solid var(--border, #1e293b);
  background: #1e293b;
  background: var(--bg-card, #1e293b);
}
.help-search-wrap label {
  font-size: var(--text-sm);
  font-weight: 700;
}
.help-search-wrap span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.help-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 0;
}
.help-nav {
  overflow: auto;
  padding: 12px;
  border-right: 1px solid #1e293b;
  border-right: 1px solid var(--border, #1e293b);
  background: #0f172a;
  background: var(--bg-alt, #0f172a);
}
.help-nav button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-sub);
  text-align: left;
  font: 600 var(--text-sm)/1.3 var(--font-sans);
  cursor: pointer;
}
.help-nav button:hover {
  background: var(--bg-hover);
  color: var(--text-base);
}
.help-nav button.active {
  background: rgba(37, 99, 235, 0.13);
  color: var(--primary-400);
}
.help-nav .help-no-results {
  padding: 20px 10px;
  color: var(--text-faint);
  font-size: var(--text-sm);
}
.help-content {
  overflow: auto;
  padding: 28px 34px;
  scroll-behavior: smooth;
}
.help-content h2 {
  font-size: var(--text-xl);
  margin-bottom: 8px;
}
.help-content h3 {
  font-size: var(--text-md);
  margin: 26px 0 8px;
}
.help-content h4 {
  margin: 18px 0 6px;
}
.help-content p,
.help-content li {
  color: var(--text-sub);
  line-height: 1.75;
}
.help-content ul,
.help-content ol {
  padding-left: 22px;
  margin: 8px 0;
}
.help-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: var(--text-sm);
}
.help-content th,
.help-content td {
  padding: 10px;
  border: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}
.help-content th {
  background: var(--bg-alt);
}
.help-callout {
  padding: 14px 16px;
  margin: 16px 0;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-left: 4px solid var(--primary-400);
  border-radius: var(--radius-md);
  background: rgba(37, 99, 235, 0.07);
  color: var(--text-sub);
}
.help-callout.warning {
  border-color: rgba(245, 158, 11, 0.3);
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.07);
}
.help-diagram {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 18px 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--bg-alt), var(--bg-card));
  color: var(--text-faint);
  text-align: center;
  padding: 20px;
}
.help-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #1e293b;
  border-top: 1px solid var(--border, #1e293b);
  background: #1e293b;
  background: var(--bg-card, #1e293b);
}
.tour-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10020;
  background: rgba(2, 6, 23, 0.62);
  pointer-events: none;
}
.tour-popover {
  position: fixed;
  z-index: 10022;
  width: min(380px, calc(100vw - 32px));
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--primary-400);
  border-radius: var(--radius-xl);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.5);
}
.tour-popover > span {
  color: var(--primary-400);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.tour-popover h3 {
  margin: 6px 0 8px;
}
.tour-popover p {
  color: var(--text-sub);
  line-height: 1.6;
}
.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.tour-highlight {
  position: relative;
  z-index: 10021 !important;
  outline: 3px solid var(--primary-400);
  outline-offset: 5px;
  border-radius: var(--radius-lg);
}
@media (max-width: 760px) {
  .help-backdrop {
    padding: 0;
  }
  .help-panel {
    height: 100vh;
    border-radius: 0;
  }
  .help-search-wrap {
    grid-template-columns: 1fr;
    padding: 10px 16px;
  }
  .help-search-wrap label {
    display: none;
  }
  .help-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .help-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px;
  }
  .help-nav button {
    width: auto;
    white-space: nowrap;
  }
  .help-content {
    padding: 22px 18px;
  }
  .help-footer {
    padding: 12px;
    flex-wrap: wrap;
  }
  .help-header {
    padding: 18px;
  }
  .help-content table {
    display: block;
    overflow-x: auto;
  }
}
@media print {
  .help-backdrop,
  .tour-backdrop,
  .tour-popover,
  .help-tip {
    display: none !important;
  }
}

/* ── Light-mode overrides: ensure readable colours regardless of variable loading ── */
html[data-theme='light'] .help-panel {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.1);
}
html[data-theme='light'] .help-header {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.1);
}
html[data-theme='light'] .help-header .mtbf-kicker {
  color: #2563eb;
}
html[data-theme='light'] .help-header h2 {
  color: #0f172a;
}
html[data-theme='light'] .help-header p {
  color: #475569;
}
html[data-theme='light'] .help-close {
  color: #64748b;
}
html[data-theme='light'] .help-close:hover {
  color: #0f172a;
}
html[data-theme='light'] .help-search-wrap {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.1);
}
html[data-theme='light'] .help-search-wrap label {
  color: #0f172a;
}
html[data-theme='light'] .help-search-wrap span {
  color: #64748b;
}
html[data-theme='light'] .help-nav {
  background: #f1f5f9;
  border-right-color: rgba(0, 0, 0, 0.1);
}
html[data-theme='light'] .help-nav button {
  color: #334155;
}
html[data-theme='light'] .help-nav button:hover {
  background: #e2e8f0;
  color: #0f172a;
}
html[data-theme='light'] .help-nav button.active {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}
html[data-theme='light'] .help-nav .help-no-results {
  color: #64748b;
}
html[data-theme='light'] .help-content h2,
html[data-theme='light'] .help-content h3,
html[data-theme='light'] .help-content h4 {
  color: #0f172a;
}
html[data-theme='light'] .help-content p,
html[data-theme='light'] .help-content li {
  color: #334155;
}
html[data-theme='light'] .help-content th {
  background: #f1f5f9;
  color: #0f172a;
}
html[data-theme='light'] .help-content td {
  color: #334155;
}
html[data-theme='light'] .help-footer {
  background: #ffffff;
  border-top-color: rgba(0, 0, 0, 0.1);
}
html[data-theme='light'] .tour-popover {
  background: #ffffff;
  color: #0f172a;
}
html[data-theme='light'] .tour-popover h3 {
  color: #0f172a;
}
html[data-theme='light'] .tour-popover p {
  color: #334155;
}
html[data-theme='light'] .tour-popover > span {
  color: #2563eb;
}
.manual-page {
  max-width: 1050px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 36px) 24px 80px;
}
.manual-cover {
  min-height: 62vh;
  display: grid;
  align-content: center;
  padding: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 85% 15%, rgba(37, 99, 235, 0.18), transparent 36%), var(--bg-card);
}
.manual-cover .mtbf-kicker {
  margin: 0 0 12px;
}
.manual-cover h1 {
  font-size: clamp(2.5rem, 7vw, 5rem);
  max-width: 800px;
}
.manual-cover p {
  max-width: 720px;
  color: var(--text-sub);
  font-size: var(--text-lg);
  line-height: 1.7;
  margin-top: 18px;
}
.manual-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.manual-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 30px;
}
.manual-toc,
.manual-section {
  margin-top: 34px;
  padding: 34px;
}
.manual-toc ol {
  columns: 2;
  column-gap: 40px;
  padding-left: 22px;
}
.manual-toc li {
  margin: 8px 0;
}
.manual-toc a {
  color: var(--primary-400);
}
.manual-section h2 {
  font-size: var(--text-2xl);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.manual-section h3 {
  font-size: var(--text-lg);
  margin: 28px 0 8px;
}
.manual-section h4 {
  margin: 20px 0 6px;
}
.manual-section p,
.manual-section li,
.manual-section dd {
  color: var(--text-sub);
  line-height: 1.8;
}
.manual-section ul,
.manual-section ol {
  padding-left: 24px;
}
.manual-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: var(--text-sm);
}
.manual-section th,
.manual-section td {
  padding: 11px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.manual-section th {
  background: var(--bg-alt);
}
.manual-section dt {
  font-weight: 800;
  margin-top: 16px;
}
.manual-callout {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-left: 4px solid var(--primary-400);
  background: rgba(37, 99, 235, 0.07);
  margin: 18px 0;
  color: var(--text-sub);
}
.manual-callout.warning {
  border-color: rgba(245, 158, 11, 0.3);
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.07);
}
.manual-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 26px;
  margin: 18px 0;
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
}
.manual-flow span {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}
@media (max-width: 700px) {
  .manual-page {
    padding-left: 12px;
    padding-right: 12px;
  }
  .manual-cover {
    padding: 32px 22px;
  }
  .manual-toc,
  .manual-section {
    padding: 22px 16px;
  }
  .manual-toc ol {
    columns: 1;
  }
  .manual-section table {
    display: block;
    overflow-x: auto;
  }
}
@media print {
  .manual-page {
    max-width: none;
    padding: 0;
    color: #111;
  }
  .manual-cover {
    min-height: 95vh;
    border: 0;
    page-break-after: always;
    background: #fff;
  }
  .manual-actions,
  #global-nav,
  #global-footer,
  #global-bottom-nav {
    display: none !important;
  }
  .manual-toc {
    page-break-after: always;
  }
  .manual-toc,
  .manual-section {
    border: 0 !important;
    box-shadow: none !important;
    margin: 0;
    padding: 20mm 15mm;
  }
  .manual-section {
    page-break-before: always;
  }
  .manual-section h2,
  .manual-section h3,
  .manual-section table {
    break-after: avoid;
  }
  .manual-section table,
  .manual-callout {
    break-inside: avoid;
  }
  .manual-section p,
  .manual-section li,
  .manual-section td,
  .manual-section dd {
    color: #222;
  }
  .manual-section a {
    color: #111;
    text-decoration: none;
  }
}
