/*
  Docs-style Learning Portal (pages/learning-portal.html + js/docs-portal.js).
  Robodarshan brand: near-black surfaces, electric blue accent. Dark by
  default, with a light theme toggled via <html data-theme="light|dark">.
*/

:root,
:root[data-theme='dark'] {
  --bg: #07090d;
  --bg-elev: #0e1218;
  --bg-elev-2: #151a22;
  --bg-code: #0b0f15;
  --border: #1f2630;
  --border-strong: #2c3542;

  --text: #e6e9ee;
  --text-soft: #b4bcc8;
  --text-muted: #7c8696;

  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --accent-tint: rgba(59, 130, 246, 0.14);
  --accent-tint-strong: rgba(59, 130, 246, 0.24);
  --on-accent: #ffffff;

  --success: #22c55e;
  --success-tint: rgba(34, 197, 94, 0.14);
  --warning: #f2b441;
  --warning-tint: rgba(242, 180, 65, 0.12);
  --danger: #f87171;
  --danger-tint: rgba(248, 113, 113, 0.14);

  --logo-filter: none;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #ffffff;
  --bg-elev: #f7f9fc;
  --bg-elev-2: #eef2f8;
  --bg-code: #f3f6fb;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;

  --text: #1b2430;
  --text-soft: #3d4857;
  --text-muted: #6b7686;

  --accent: #1d5fd8;
  --accent-strong: #1d5fd8;
  --accent-tint: #e4eeff;
  --accent-tint-strong: #cfe0ff;
  --on-accent: #ffffff;

  --success: #15803d;
  --success-tint: #e3f6ea;
  --warning: #9a6a00;
  --warning-tint: #fdf1d6;
  --danger: #c0392b;
  --danger-tint: #fde8e6;

  --logo-filter: invert(1) hue-rotate(180deg);
  --shadow: 0 8px 28px rgba(20, 35, 60, 0.12);
  color-scheme: light;
}

:root {
  --topbar-h: 64px;
  --sidebar-w: 300px;
  --toc-w: 250px;
  --content-w: 820px;
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

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

a {
  color: var(--accent-strong);
}

button {
  font-family: inherit;
}

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

/* =========================================================
   Top bar
   ========================================================= */

.docs-topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.docs-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.docs-logo {
  height: 26px;
  width: auto;
  filter: var(--logo-filter);
  display: block;
}

.docs-brand-tag {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  padding: 3px 10px;
  border: 1px solid var(--accent-tint-strong);
  border-radius: 999px;
  background: var(--accent-tint);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-elev-2);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.docs-menu-btn {
  display: none;
}

.docs-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 440px;
  margin-left: 12px;
}

.docs-search input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 64px 0 40px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.docs-search input::placeholder {
  color: var(--text-muted);
}

.docs-search input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint-strong);
}

.docs-search-icon {
  position: absolute;
  left: 13px;
  top: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.docs-search-hint {
  position: absolute;
  right: 12px;
  top: 10px;
  font: 500 12px var(--font);
  color: var(--text-muted);
  pointer-events: none;
}

.docs-search-results {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
}

.docs-search-result {
  display: block;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.docs-search-result small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.docs-search-result:hover,
.docs-search-result.is-active {
  background: var(--accent-tint);
}

.docs-search-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.docs-topnav {
  margin-left: auto;
  display: flex;
  gap: 28px;
}

.docs-topnav a {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-topnav a:hover {
  color: var(--accent-strong);
}

.theme-toggle {
  position: relative;
  width: 70px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s ease;
  display: grid;
  place-items: center;
}

.theme-toggle-knob::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--on-accent);
  /* moon-ish in dark, sun-ish in light */
  box-shadow: inset -4px -3px 0 0 var(--accent);
}

:root[data-theme='light'] .theme-toggle-knob {
  transform: translateX(36px);
}

:root[data-theme='light'] .theme-toggle-knob::after {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px var(--on-accent);
  width: 8px;
  height: 8px;
}

/* =========================================================
   Three-column shell
   ========================================================= */

.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.docs-sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 18px 14px 40px 18px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: thin;
}

.docs-main {
  min-width: 0;
  padding: 36px clamp(20px, 4vw, 56px) 0;
  outline: none;
}

.docs-article {
  max-width: var(--content-w);
  margin: 0 auto;
  min-height: 70vh;
}

.docs-footer {
  max-width: var(--content-w);
  margin: 64px auto 0;
  padding: 24px 0 32px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.docs-toc {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 34px 20px 40px 8px;
  border-left: 1px solid var(--border);
  scrollbar-width: thin;
}

.docs-loading,
.docs-nav-loading {
  color: var(--text-muted);
}

/* =========================================================
   Sidebar navigation tree
   ========================================================= */

.nav-root-toggle,
.nav-stage-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 8px 6px;
  border-radius: 8px;
}

.nav-root-toggle {
  font-size: 18px;
  font-weight: 600;
}

.nav-stage-toggle {
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

.nav-root-toggle:hover,
.nav-stage-toggle:hover {
  background: var(--bg-elev);
}

.nav-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

[aria-expanded='false']>.nav-chevron {
  transform: rotate(-90deg);
}

.nav-stage-meta {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.nav-children[hidden] {
  display: none;
}

.nav-group-title {
  margin: 14px 0 4px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 8px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14.5px;
  line-height: 1.35;
}

.nav-link:hover {
  background: var(--bg-elev);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-tint-strong);
}

.nav-link-text {
  flex: 1;
  min-width: 0;
}

.nav-done {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--success);
}

.nav-pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

/* =========================================================
   Right-hand "On this page"
   ========================================================= */

.toc-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toc-title::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.toc-link {
  display: block;
  padding: 7px 12px;
  margin: 1px 0;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}

.toc-link.is-sub {
  padding-left: 26px;
  font-size: 13.5px;
}

.toc-link:hover {
  color: var(--text);
}

.toc-link.is-active {
  color: var(--accent-strong);
  border-left-color: var(--accent);
  background: var(--accent-tint);
  border-radius: 0 6px 6px 0;
  font-weight: 500;
}

/* =========================================================
   Article chrome (breadcrumb, title, meta chips)
   ========================================================= */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.crumbs a {
  color: var(--text-muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--accent-strong);
}

.doc-title {
  margin: 0 0 14px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.doc-lead {
  margin: 0 0 18px;
  font-size: 18px;
  color: var(--text-soft);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-soft);
}

.chip svg {
  width: 14px;
  height: 14px;
}

.chip-xp {
  color: var(--accent-strong);
  background: var(--accent-tint);
  border-color: var(--accent-tint-strong);
}

.chip-done {
  color: var(--success);
  background: var(--success-tint);
  border-color: transparent;
}

.chip-pending {
  color: var(--warning);
  background: var(--warning-tint);
  border-color: transparent;
}

.chip-link {
  text-decoration: none;
}

.chip-link:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* =========================================================
   Lesson content ("prose") -- targets the converted PDF HTML
   ========================================================= */

.prose h2,
.doc-section-title {
  margin: 48px 0 16px;
  padding-top: 4px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--accent-strong);
  font-weight: 650;
}

.prose section:first-child>h2:first-child {
  margin-top: 8px;
}

.prose section+section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.prose h3 {
  margin: 28px 0 10px;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
}

.prose h4 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.prose p {
  margin: 0 0 16px;
  color: var(--text-soft);
}

.prose ul,
.prose ol {
  margin: 0 0 18px;
  padding-left: 24px;
  color: var(--text-soft);
}

.prose li {
  margin: 6px 0;
}

.prose li::marker {
  color: var(--accent);
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  white-space: nowrap;
}

.prose pre {
  margin: 0 0 22px;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--bg-code);
  border: 1px solid var(--border-strong);
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: none;
  white-space: pre;
  font-size: 13.5px;
  color: var(--text);
}

.prose figure {
  margin: 24px 0;
  text-align: center;
}

.prose figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
}

.prose figcaption {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.prose .table-wrap {
  margin: 0 0 24px;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.prose th,
.prose td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-soft);
}

.prose th {
  background: var(--bg-elev-2);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.prose tbody tr:last-child td {
  border-bottom: 0;
}

.prose .card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin: 0 0 24px;
}

.prose .info-card {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

.prose .info-card p {
  margin: 0;
  font-size: 15px;
}

/* Soft tinted boxes: one background + one text colour per kind, with a
   line icon before the title (icon is a mask so it takes the text colour). */
.callout {
  --c-bg: #dbe8ff;
  --c-fg: #123f94;
  --c-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='11' x2='12' y2='16'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
  margin: 0 0 22px;
  padding: 16px 20px 6px;
  border-radius: 8px;
  border: 0;
  background: var(--c-bg);
  color: var(--c-fg);
}

.callout p,
.callout li,
.callout strong,
.callout .callout-title {
  color: var(--c-fg);
}

.callout a {
  color: var(--c-fg);
  font-weight: 600;
  text-decoration: underline;
}

.callout code {
  background: rgba(255, 255, 255, 0.55);
  border-color: transparent;
  color: var(--c-fg);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 16px;
}

.callout-title::before {
  content: '';
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: var(--c-icon) center / contain no-repeat;
  mask: var(--c-icon) center / contain no-repeat;
}

.callout-key {
  --c-bg: #dbe8ff;
  --c-fg: #123f94;
}

.callout-tip {
  --c-bg: #cfe9d9;
  --c-fg: #0f5a2c;
  --c-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 16.5c-1.5 1.3-2 5-2 5s3.7-.5 5-2c.7-.8.7-2.1-.1-2.9a2.2 2.2 0 0 0-2.9-.1z'/%3E%3Cpath d='M12 15l-3-3a22 22 0 0 1 2-3.9A12.9 12.9 0 0 1 22 2c0 2.7-.8 7.5-6 11a22.4 22.4 0 0 1-4 2z'/%3E%3Cpath d='M9 12H4s.6-3 2-4c1.6-1.1 5 0 5 0'/%3E%3Cpath d='M12 15v5s3-.6 4-2c1.1-1.6 0-5 0-5'/%3E%3C/svg%3E");
}

.callout-caution {
  --c-bg: #fbe9c3;
  --c-fg: #7a4b00;
  --c-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
}

.callout-note {
  --c-bg: #e6e9ef;
  --c-fg: #2c3544;
  --c-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E");
}

/* Dark theme: same hues, deep tinted backgrounds, light text. */
:root[data-theme='dark'] .callout-key {
  --c-bg: rgba(59, 130, 246, 0.16);
  --c-fg: #a9c8ff;
}

:root[data-theme='dark'] .callout-tip {
  --c-bg: rgba(34, 197, 94, 0.15);
  --c-fg: #8fe3b0;
}

:root[data-theme='dark'] .callout-caution {
  --c-bg: rgba(242, 180, 65, 0.15);
  --c-fg: #f5cd7d;
}

:root[data-theme='dark'] .callout-note {
  --c-bg: rgba(148, 163, 184, 0.14);
  --c-fg: #cbd5e1;
}

:root[data-theme='dark'] .callout code {
  background: rgba(0, 0, 0, 0.3);
}

.video-link {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
}

.video-link::before {
  content: '\25B6';
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e11d48;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
}

.video-link:hover {
  border-color: var(--accent);
}

.pdf-embed {
  width: 100%;
  height: 80vh;
  min-height: 480px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.content-note {
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 15px;
}

/* =========================================================
   Quiz
   ========================================================= */

.quiz-card {
  margin: 0 0 24px;
  padding: 22px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
}

.quiz-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.quiz-history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quiz-history-item {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-soft);
}

.quiz-history-empty {
  margin: 0;
}

.quiz-question {
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.quiz-question-text {
  margin: 0 0 10px;
  font-weight: 600;
  color: var(--text);
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.quiz-option:hover {
  border-color: var(--accent);
}

.quiz-option input {
  margin-top: 4px;
  accent-color: var(--accent);
}

.quiz-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--text);
}

.quiz-option.quiz-correct {
  border-color: var(--success);
  background: var(--success-tint);
  color: var(--text);
}

.quiz-option.quiz-incorrect {
  border-color: var(--danger);
  background: var(--danger-tint);
  color: var(--text);
}

.quiz-option:has(input:disabled) {
  cursor: default;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn[hidden] {
  display: none;
}

.btn-ghost {
  background: transparent;
  color: var(--accent-strong);
}

.quiz-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 9px;
  background: var(--accent-tint);
  font-weight: 600;
  color: var(--text);
}

.quiz-result[hidden] {
  display: none;
}

/* =========================================================
   Completion box, prev/next, progress, cards
   ========================================================= */

.complete-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
}

.complete-box.is-done {
  border-color: var(--success);
  background: var(--success-tint);
}

.complete-check {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  cursor: pointer;
}

.complete-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.complete-check input:disabled {
  cursor: not-allowed;
}

.complete-hint {
  color: var(--text-muted);
  font-size: 14px;
}

.status-ok {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--success);
}

.status-ok svg {
  width: 20px;
  height: 20px;
}

.status-wait {
  font-weight: 600;
  color: var(--warning);
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 40px;
}

.pager a {
  display: block;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
}

.pager a:hover {
  border-color: var(--accent);
}

.pager small {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pager .pager-next {
  text-align: right;
  grid-column: 2;
}

.pager .pager-prev {
  grid-column: 1;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.overview-card {
  margin: 0 0 28px;
  padding: 20px 22px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
}

.overview-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
}

.overview-top span:last-child {
  color: var(--text-muted);
  font-weight: 500;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.stat {
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.stat small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat strong {
  font-size: 20px;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stage-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s, transform 0.12s;
}

.stage-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.stage-card-num {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.stage-card h3 {
  margin: 0;
  font-size: 22px;
}

.stage-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.stage-card .progress-label {
  font-size: 13px;
  color: var(--text-muted);
}

.item-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 12px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  text-decoration: none;
  color: var(--text);
}

.item-row:hover {
  border-color: var(--accent);
}

.item-row .chip,
.item-row .status-ok,
.item-row .status-wait {
  flex-shrink: 0;
  white-space: nowrap;
}

.item-row-main {
  flex: 1;
  min-width: 0;
}

.item-row-main strong {
  display: block;
}

.item-row-main span {
  display: block;
  color: var(--text-muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-row .status-ok svg {
  width: 18px;
  height: 18px;
}

.back-to-top {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 40;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}

.back-to-top[hidden] {
  display: none;
}

.back-to-top svg {
  width: 22px;
  height: 22px;
}

.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.docs-backdrop {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 44;
}

.docs-backdrop[hidden] {
  display: none;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1180px) {
  .docs-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .docs-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .docs-topbar {
    gap: 10px;
    padding: 0 12px;
  }

  .docs-menu-btn {
    display: inline-flex;
  }

  .docs-brand-tag,
  .docs-topnav,
  .docs-search-hint {
    display: none;
  }

  .docs-search {
    margin-left: 0;
  }

  .docs-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: min(86vw, 330px);
    z-index: 45;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .docs-sidebar.is-open {
    transform: none;
  }

  .docs-main {
    padding-top: 24px;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager .pager-next,
  .pager .pager-prev {
    grid-column: 1;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 520px) {
  .docs-topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .docs-brand {
    flex-shrink: 1;
    min-width: 0;
  }

  .docs-logo {
    height: 18px;
    max-width: 120px;
    object-fit: contain;
  }

  .docs-search input {
    padding-right: 10px;
  }

  .theme-toggle {
    width: 58px;
  }

  :root[data-theme='light'] .theme-toggle-knob {
    transform: translateX(24px);
  }
}
