/* ============================================================================
   PyData-inspired theme for thesis HTML export
   ============================================================================ */

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

/* ---------------------------------------------------------------------------
   CSS Variables — Light theme (default)
   --------------------------------------------------------------------------- */

:root {
  --color-bg: #fff;
  --color-text: #333;
  --color-text-muted: #6c757d;
  --color-link: #0366d6;
  --color-link-hover: #024ea4;
  --color-border: #e1e4e8;
  --color-sidebar-bg: #f7f8fa;
  --color-sidebar-active: #0366d6;
  --color-sidebar-active-bg: #e8f0fe;
  --color-nav-part: #555;
  --color-code-bg: #f6f8fa;
  --color-topbar-bg: #f7f8fa;
  --color-search-bg: #fff;
  --color-backdrop: rgba(0, 0, 0, 0.4);
  --sidebar-width: 280px;
  --toc-width: 260px;
  --content-max-width: 820px;
  --topbar-height: 3.5rem;
  --font-body: "New Computer Modern", "Computer Modern", Georgia, serif;
  --font-heading: system-ui, -apple-system, sans-serif;
  --font-mono: "Fira Code", "Consolas", monospace;

  /* TOC indentation — single source of truth.
     Every level step adds exactly this amount. */
  --toc-indent: 0.85rem;
  --toc-base-pl: 0.5rem;  /* left padding shared by all items */
}

/* ---------------------------------------------------------------------------
   CSS Variables — Dark theme
   --------------------------------------------------------------------------- */

[data-theme="dark"] {
  --color-bg: #15171a;
  --color-text: #d4d4d8;
  --color-text-muted: #9ca3af;
  --color-link: #60a5fa;
  --color-link-hover: #93c5fd;
  --color-border: #2d3139;
  --color-sidebar-bg: #1a1d23;
  --color-sidebar-active: #60a5fa;
  --color-sidebar-active-bg: #1e293b;
  --color-nav-part: #a0a0a0;
  --color-code-bg: #1e1e2e;
  --color-topbar-bg: #1a1d23;
  --color-search-bg: #1e2028;
  --color-backdrop: rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------------------
   Reset & Base
   --------------------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 1rem);
}

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

a {
  color: var(--color-link);
  text-decoration: none;
}

a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

/* ---------------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 1rem;
  background: var(--color-topbar-bg);
  border-bottom: 1px solid var(--color-border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title:hover {
  color: var(--color-link);
  text-decoration: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Topbar buttons — shared style */
.topbar .sidebar-toggle-btn,
.topbar .theme-toggle,
.topbar .github-link,
.topbar .lang-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 0.35rem;
  transition: background 0.15s, color 0.15s;
}

.topbar .sidebar-toggle-btn:hover,
.topbar .theme-toggle:hover,
.topbar .github-link:hover,
.topbar .lang-switch:hover {
  background: var(--color-sidebar-active-bg);
  color: var(--color-text);
  text-decoration: none;
}

/* Search trigger */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.search-trigger:hover {
  border-color: var(--color-link);
  background: var(--color-sidebar-active-bg);
}

.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-sidebar-bg);
}

/* Language switch badge */
.lang-switch {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem !important;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

/* Hide sidebar toggles on desktop */
#sidebar-toggle-left,
#sidebar-toggle-right {
  display: none;
}

/* ---------------------------------------------------------------------------
   3-Column Layout
   --------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
  min-height: calc(100vh - var(--topbar-height));
}

/* ---------------------------------------------------------------------------
   Sidebar Left (Global Navigation)
   --------------------------------------------------------------------------- */

.sidebar-left {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  padding: 1rem 0;
  font-size: 0.9rem;
}

.sidebar-header {
  padding: 0.5rem 1rem 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.5rem;
}

.site-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
  display: block;
}

.site-title:hover {
  color: var(--color-link);
  text-decoration: none;
}

.global-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.global-nav li a {
  display: block;
  padding: 0.35rem 1rem;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.global-nav li a:hover {
  background: var(--color-sidebar-active-bg);
  color: var(--color-text);
  text-decoration: none;
}

.global-nav li.active>a {
  color: var(--color-sidebar-active);
  font-weight: 600;
  border-left-color: var(--color-sidebar-active);
  background: var(--color-sidebar-active-bg);
}

.global-nav .nav-item-row {
  display: flex;
  align-items: stretch;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.global-nav .nav-item-row>a {
  flex: 1;
  min-width: 0;
  border-left: none;
}

.global-nav .nav-collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.global-nav .nav-collapse-toggle::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-135deg);
}

.global-nav .nav-item-row:hover .nav-collapse-toggle,
.global-nav .nav-collapse-toggle:hover {
  background: var(--color-sidebar-active-bg);
  color: var(--color-text);
}

.global-nav li.active>.nav-item-row {
  background: var(--color-sidebar-active-bg);
  border-left-color: var(--color-sidebar-active);
}

.global-nav li.active>.nav-item-row>a {
  color: var(--color-sidebar-active);
  font-weight: 600;
  background: transparent;
  border-left-color: transparent;
}

.global-nav li.active>.nav-item-row>.nav-collapse-toggle {
  background: transparent;
  color: var(--color-sidebar-active);
}

.global-nav li.collapsed>.nav-item-row .nav-collapse-toggle::before {
  transform: rotate(45deg);
}

.global-nav .nav-children {
  overflow: hidden;
}

.nav-part {
  padding: 0.8rem 1rem 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-nav-part);
}

.global-nav li:not(.nav-sub)>a {
  font-weight: 600;
  color: var(--color-text);
}

.global-nav li:not(.nav-sub)>.nav-item-row>a {
  font-weight: 600;
  color: var(--color-text);
}

.global-nav .nav-children>ul {
  margin-left: 0.9rem;
}

.global-nav .nav-children .nav-children>ul {
  margin-left: 0.9rem;
}

.global-nav li.nav-sub a {
  padding-left: 1rem;
  font-size: 0.85em;
}

.global-nav li.nav-depth-2 a {
  font-size: 0.8em;
}

/* ---------------------------------------------------------------------------
   Main Content
   --------------------------------------------------------------------------- */

.content {
  max-width: var(--content-max-width);
  padding: 2rem 3rem;
  width: 100%;
  justify-self: center;
}

/* ---------------------------------------------------------------------------
   Sidebar Right (Local TOC)
   --------------------------------------------------------------------------- */

.sidebar-right {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  border-left: 1px solid var(--color-border);
}

.local-toc h3 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
}

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

/* ---------------------------------------------------------------------------
   Local TOC — uniform indentation system
   ============================================================
   Every level step adds exactly --toc-indent.
   Levels are:
     toc-l2  →  0 extra indents  (top-level h2 headings)
     toc-l3  →  1 extra indent   (h3 headings or theorems under h2)
     toc-l4  →  2 extra indents  (h4 headings or theorems under h3)
     toc-l5  →  3 extra indents  (h5 headings or theorems under h4)

   Theorem entries carry a toc-lN class where N is their parent
   heading level + 1, so they naturally sit one step deeper than
   the heading they belong to — no special-case overrides needed.
   --------------------------------------------------------------------------- */

.local-toc li a {
  display: block;
  padding-top: 0.22rem;
  padding-bottom: 0.22rem;
  padding-right: 0;
  padding-left: var(--toc-base-pl);
  color: var(--color-text-muted);
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border-radius: 0 6px 6px 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.local-toc li a:hover {
  background: var(--color-sidebar-active-bg);
  color: var(--color-text);
  text-decoration: none;
}

.local-toc li a.active {
  background: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active);
  border-left-color: var(--color-sidebar-active);
}

/* Level 2 — base level, no extra indent */
.local-toc .toc-l2 a {
  padding-left: var(--toc-base-pl);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-text);
}

/* Level 3 — 1 step in */
.local-toc .toc-l3 a {
  padding-left: calc(var(--toc-base-pl) + var(--toc-indent));
  font-size: 0.80rem;
  font-weight: 400;
}

/* Level 4 — 2 steps in */
.local-toc .toc-l4 a {
  padding-left: calc(var(--toc-base-pl) + 2 * var(--toc-indent));
  font-size: 0.77rem;
}

/* Level 5 — 3 steps in */
.local-toc .toc-l5 a {
  padding-left: calc(var(--toc-base-pl) + 3 * var(--toc-indent));
  font-size: 0.74rem;
}

/* Level 6 — 4 steps in */
.local-toc .toc-l6 a {
  padding-left: calc(var(--toc-base-pl) + 4 * var(--toc-indent));
  font-size: 0.72rem;
}

/* Theorem entries — same indent as their toc-lN class dictates,
   just slightly muted. No italic, no special offset. */
.local-toc .toc-theorem a {
  font-weight: 400;
  font-style: normal;
  color: var(--color-text-muted);
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}

/* ---------------------------------------------------------------------------
   Typography — Headings
   --------------------------------------------------------------------------- */

h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin: 2rem 0 1rem;
  line-height: 1.3;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0.5rem;
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin: 2rem 0 0.75rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.3rem;
}

h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin: 1.5rem 0 0.5rem;
}

h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.25rem 0 0.4rem;
  color: var(--color-text);
}

h5 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1rem 0 0.35rem;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

h6 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0.75rem 0 0.3rem;
  color: var(--color-text-muted);
}

p {
  margin: 0 0 1em;
  text-align: justify;
  hyphens: auto;
}

dt {
  font-weight: bold;
}

dd {
  margin-bottom: 0.5em;
}

blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--color-border);
  color: var(--color-text-muted);
  font-style: italic;
}

blockquote.epigraph {
  width: 55%;
  margin-left: auto;
  margin-right: 0;
  border-left: none;
  font-style: italic;
  font-size: 0.95em;
  padding: 0;
}

blockquote.epigraph footer {
  text-align: right;
  font-style: normal;
  margin-top: 0.3em;
}

blockquote.epigraph footer::before {
  content: "— ";
}

.lettrine::first-letter {
  font-size: 2.5em;
  float: left;
  line-height: 1;
  margin-right: 2px;
  font-variant: small-caps;
}

/* ---------------------------------------------------------------------------
   Footnotes
   --------------------------------------------------------------------------- */

.footnotes {
  margin-top: 2em;
  font-size: 0.9em;
  color: var(--color-text-muted);
}

.footnotes hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-bottom: 1em;
}

.footnotes ol {
  padding-left: 0;
}

.footnotes li {
  margin-bottom: 0.5em;
}

.footnotes a[role="doc-backlink"] {
  text-decoration: none;
  margin-right: 0.3em;
}

sup {
  font-size: 0.75em;
}

.paper-header {
  text-align: center;
  padding: 0;
}

.paper-header .paper-misc {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.paper-header .paper-title {
  font-size: 2rem;
  border: none;
  margin: 1rem 0;
}

.paper-header .author {
  text-align: center;
  font-size: 1.2rem;
  margin: 0.5rem 0;
}

.paper-header .date {
  color: var(--color-text-muted);
  text-align: center;
}

.paper-header .abstract {
  text-align: justify;
  max-width: 600px;
  margin: 2rem auto 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* PDF download button */
.pdf-download {
  text-align: center;
  margin-top: 1.5rem;
}

.btn-pdf {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border: 2px solid var(--color-link);
  border-radius: 8px;
  color: var(--color-link);
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.2s, color 0.2s;
}

.btn-pdf:hover {
  background: var(--color-link);
  color: #fff;
  text-decoration: none;
}

[data-theme="dark"] .btn-pdf:hover {
  color: var(--color-bg);
}

/* ---------------------------------------------------------------------------
   Figures & Images
   --------------------------------------------------------------------------- */

figure {
  margin: 1.5em 0;
  text-align: center;
}

figcaption {
  font-size: 0.9em;
  color: var(--color-text-muted);
  margin-top: 0.5em;
  text-align: left;
}

/* SVG frames from Typst html.frame */
.typst-frame {
  display: block;
  margin-left: auto;
  margin-right: auto;
  align-self: center;
}

svg.typst-frame {
  max-width: 100%;
  height: auto;
}

/* Dark mode: invert SVGs and rotate hue to preserve colors */
[data-theme="dark"] svg.typst-frame {
  filter: invert(1) hue-rotate(180deg);
}

/* Dark mode: invert inline SVG images (PDFs rendered as base64 SVG by Typst) */
[data-theme="dark"] figure img[src^="data:image/svg+xml"] {
  filter: invert(1) hue-rotate(180deg);
}

ul.itemize-ul-list {
  list-style: none;
  padding-left: var(--marker-slot, 2.5em);
}

.data-marker-item {
  position: relative;
}

.data-marker-item::before {
  content: attr(data-marker);
  position: absolute;
  left: calc(-1 * var(--marker-slot, 2.5em));
  width: calc(var(--marker-slot, 2.5em) - 8px);
  text-align: right;
  top: 0;
}

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */

table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.9em;
  width: 100%;
}

th,
td {
  padding: 0.5em 0.75em;
  border: 1px solid var(--color-border);
  text-align: left;
}

th {
  background: var(--color-sidebar-bg);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Theorem Boxes — Light theme
   --------------------------------------------------------------------------- */

.thm-box {
  padding: 1em;
  margin: 1em 0;
  border-left: 4px solid;
  border-radius: 4pt;
  text-align: left;
}

.thm-head {
  margin: 0 0 0.5em;
}

.thm-theorem {
  background: #e8f4f8;
  border-color: #2196F3;
}

.thm-lemma {
  background: #f0f8e8;
  border-color: #4CAF50;
}

.thm-proposition {
  background: #fff8e8;
  border-color: #FF9800;
}

.thm-corollary {
  background: #f8f0f8;
  border-color: #9C27B0;
}

.thm-definition {
  background: #f5f5f5;
  border-color: #607D8B;
}

.thm-remark {
  background: #f8f7e8;
  border-color: #d4b400;
}

.thm-example {
  background: #eef4ea;
  border-color: #7aa95c;
}

/* Theorem Boxes — Dark theme */
[data-theme="dark"] .thm-theorem {
  background: #1a2733;
}

[data-theme="dark"] .thm-lemma {
  background: #1a2a1a;
}

[data-theme="dark"] .thm-proposition {
  background: #2a2418;
}

[data-theme="dark"] .thm-corollary {
  background: #271a2a;
}

[data-theme="dark"] .thm-definition {
  background: #1e2124;
}

[data-theme="dark"] .thm-remark {
  background: #2a2918;
}

[data-theme="dark"] .thm-example {
  background: #1d2619;
}

/* Proofs */
.thm-proof {
  margin: 1em 0;
}

.proof-head {
  margin: 0 0 0.5em;
}

.qed {
  display: block;
  text-align: right;
}

/* ---------------------------------------------------------------------------
   Code & Algorithms
   --------------------------------------------------------------------------- */

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--color-code-bg);
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
}

/* ---------------------------------------------------------------------------
   Page Navigation (prev/next)
   --------------------------------------------------------------------------- */

.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.page-nav a {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}

.page-nav a:hover {
  background: var(--color-sidebar-bg);
  border-color: var(--color-link);
  text-decoration: none;
}

/* ---------------------------------------------------------------------------
   Bibliography
   --------------------------------------------------------------------------- */

.bibliography {
  font-size: 0.9em;
}

/* ---------------------------------------------------------------------------
   Sidebar Backdrop (mobile overlays)
   --------------------------------------------------------------------------- */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 149;
  background: var(--color-backdrop);
}

.sidebar-backdrop.visible {
  display: block;
}

/* ---------------------------------------------------------------------------
   Search Modal
   --------------------------------------------------------------------------- */

.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--color-backdrop);
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.search-overlay.visible {
  display: flex;
}

.search-dialog {
  width: 90%;
  max-width: 600px;
  background: var(--color-search-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.search-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  gap: 0.5rem;
}

.search-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 1.1rem;
  font-family: var(--font-body);
  color: var(--color-text);
  outline: none;
}

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

.search-close {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-sidebar-bg);
  color: var(--color-text-muted);
  cursor: pointer;
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-results:empty::after {
  content: "";
  display: none;
}

.search-result {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: var(--color-text);
  transition: background 0.1s;
}

.search-result:hover {
  background: var(--color-sidebar-active-bg);
  text-decoration: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.search-result-excerpt {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

.search-result-page {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.1rem;
}

.search-result-excerpt mark {
  background: rgba(255, 213, 79, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

.search-no-results {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------------------
   Responsive Design
   --------------------------------------------------------------------------- */

/* Medium screens: hide right sidebar */
@media (max-width: 1200px) {
  .sidebar-right {
    display: none;
  }

  .layout {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  #sidebar-toggle-right {
    display: inline-flex;
  }

  /* Right sidebar as overlay when toggled */
  .sidebar-right.open {
    display: block;
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    width: var(--toc-width);
    height: calc(100vh - var(--topbar-height));
    z-index: 150;
    background: var(--color-bg);
    border-left: 1px solid var(--color-border);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  }
}

/* Small screens: hide both sidebars */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-left {
    display: none;
  }

  #sidebar-toggle-left {
    display: inline-flex;
  }

  /* Left sidebar as overlay */
  .sidebar-left.open {
    display: block;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    z-index: 150;
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  }

  .content {
    padding: 2rem 1.5rem;
  }

  /* Hide Ctrl+K label on small screens */
  .search-trigger kbd {
    display: none;
  }
}

/* Very small screens */
@media (max-width: 600px) {
  .topbar-title {
    font-size: 0.8rem;
    max-width: 40vw;
  }

  .content {
    padding: 1.5rem 1rem;
  }
}

/* ---------------------------------------------------------------------------
   Print
   --------------------------------------------------------------------------- */

@media print {

  .topbar,
  .sidebar-left,
  .sidebar-right,
  .page-nav,
  .sidebar-backdrop,
  .search-overlay {
    display: none !important;
  }

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

  .content {
    max-width: 100%;
  }
}