/* ── Inline wikilink spans ──────────────────────────────────────────────────── */

.wikilink {
  color: var(--contextdocs-concept-text, #4a90d9);
  text-decoration: none;
  cursor: pointer;
  border-radius: 2px;
  padding: 0 1px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.wikilink--highlighted {
  animation: wikilink-flash 2.5s ease-out forwards;
}

@keyframes wikilink-flash {
  0%   { background-color: var(--contextdocs-concept-flash-background, color-mix(in srgb, #4a90d9 35%, transparent)); outline: 2px solid var(--contextdocs-concept-flash-outline, #4a90d9); outline-offset: 2px; }
  100% { background-color: transparent; outline-color: transparent; }
}

/* Block-level highlight — applied to the li/p/heading containing the clicked keyword.
   Covers the entire sentence and any nested sub-bullets.
   Uses the same amber as the pane <mark> so the page highlight matches the pane highlight. */
.wikilink--block-highlighted {
  animation: wikilink-block-flash 2s ease-out forwards;
  border-radius: 3px;
}

@keyframes wikilink-block-flash {
  0%   { background-color: var(--contextdocs-block-highlight-background, rgba(245, 196, 114, 0.55)); outline: 2px solid var(--contextdocs-block-highlight-outline, #f5c472); outline-offset: 3px; }
  60%  { background-color: var(--contextdocs-block-highlight-mid-background, rgba(245, 196, 114, 0.35)); outline-color: var(--contextdocs-block-highlight-outline, #f5c472); }
  100% { background-color: transparent; outline-color: transparent; }
}

.wikilink:hover,
.wikilink:focus-visible {
  background-color: var(--contextdocs-concept-hover-background, color-mix(in srgb, #4a90d9 10%, transparent));
  text-decoration: underline;
}

.hashtag {
  color: var(--contextdocs-hashtag-text, #b54708);
  background-color: var(--contextdocs-hashtag-background, color-mix(in srgb, #f79009 10%, transparent));
  text-decoration: none;
  cursor: pointer;
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 650;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.hashtag:hover,
.hashtag:focus-visible {
  background-color: var(--contextdocs-hashtag-hover-background, color-mix(in srgb, #f79009 18%, transparent));
  text-decoration: underline;
}

.hashtag[data-hashtag="#code"] {
  color: #175cd3;
  background-color: color-mix(in srgb, #2e90fa 13%, transparent);
}

.hashtag[data-hashtag="#code"]:hover,
.hashtag[data-hashtag="#code"]:focus-visible {
  background-color: color-mix(in srgb, #2e90fa 22%, transparent);
}

.hashtag[data-hashtag="#output"] {
  color: #067647;
  background-color: color-mix(in srgb, #12b76a 13%, transparent);
}

.hashtag[data-hashtag="#output"]:hover,
.hashtag[data-hashtag="#output"]:focus-visible {
  background-color: color-mix(in srgb, #12b76a 22%, transparent);
}

.hashtag[data-hashtag="#interpretation"] {
  color: #93370d;
  background-color: color-mix(in srgb, #f79009 15%, transparent);
}

.hashtag[data-hashtag="#interpretation"]:hover,
.hashtag[data-hashtag="#interpretation"]:focus-visible {
  background-color: color-mix(in srgb, #f79009 24%, transparent);
}

.wikilink-nav-tags {
  padding: 0.2rem 0.6rem 0.45rem;
}

.wikilink-nav-tags__wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.15rem 0;
}

.wikilink-nav-tags__chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  border: 0;
  font-size: 0.68rem;
  line-height: 1.2;
  white-space: nowrap;
}

/* Inline wikilinks rendered inside pane card context text */
.wikilink--inline {
  color: var(--contextdocs-concept-text, #4a90d9);
  text-decoration: none;
  cursor: pointer;
  border-radius: 2px;
}
.wikilink--inline:hover {
  text-decoration: underline;
  background-color: var(--contextdocs-concept-hover-background, color-mix(in srgb, #4a90d9 10%, transparent));
}

.hashtag--inline {
  color: var(--contextdocs-hashtag-text, #b54708);
}

.hashtag-mark {
  background: var(--contextdocs-hashtag-mark-background, rgba(247, 144, 9, 0.22));
  color: var(--contextdocs-hashtag-mark-text, #93370d);
  border-radius: 3px;
  padding: 0 2px;
}

/* ── Backlinks pane ─────────────────────────────────────────────────────────── */

.wikilink-pane {
  position: fixed;
  top: 0;
  right: 0;
  width: min(var(--wikilink-pane-width, 560px), 100vw);
  max-width: 100vw;
  height: 100vh;
  background-color: var(--md-default-bg-color);
  border-left: 1px solid var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12));
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;

  /* Slide-in animation */
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none; /* focus managed programmatically */
}

.wikilink-pane--open {
  transform: translateX(0);
}

/* ── Pane header ────────────────────────────────────────────────────────────── */

.wikilink-pane__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12));
  flex-shrink: 0;
  background-color: var(--md-default-bg-color);
  position: sticky;
  top: 0;
}

.wikilink-pane__heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wikilink-pane__title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--md-default-fg-color);
  word-break: break-word;
  font-family: var(--md-code-font, monospace);
}

.wikilink-pane__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.wikilink-pane__meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-primary-fg-color) 10%, var(--md-default-bg-color, #fff));
  color: var(--md-default-fg-color--light);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

/* Edge pane: highlight both keyword names without a yellow background */
.wikilink-pane__title--edge mark {
  background: none;
  color: var(--md-primary-fg-color, #4051b5);
  font-weight: 700;
}

/* Secondary label shown after · in page→kw edge titles */
.wikilink-pane__edge-sub {
  font-weight: 400;
  color: var(--md-default-fg-color--light);
}

.wikilink-pane__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--md-default-fg-color--light);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.wikilink-pane__close:hover,
.wikilink-pane__close:focus-visible {
  background-color: var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.08));
  color: var(--md-default-fg-color);
  outline: 2px solid var(--md-primary-fg-color);
}

/* ── "See it on concept map" action bar ─────────────────────────────────────── */

.wikilink-pane__actions {
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12));
  flex-shrink: 0;
  background-color: var(--md-default-bg-color);
}

.wikilink-pane__concept-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--md-primary-fg-color);
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--md-primary-fg-color);
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.wikilink-pane__concept-map-btn:hover,
.wikilink-pane__concept-map-btn:focus-visible {
  background-color: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color, #fff);
  outline: none;
}

/* ── Cards container ────────────────────────────────────────────────────────── */

.wikilink-pane__cards {
  overflow: visible;
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wikilink-pane__empty {
  color: var(--md-default-fg-color--light);
  font-style: italic;
  font-size: 0.875rem;
  text-align: center;
  margin-top: 2rem;
}

/* ── Module groups ───────────────────────────────────────────────────────────── */

.wikilink-module {
  --wl-module-accent: #4a90d9;
  border: 1px solid color-mix(in srgb, var(--wl-module-accent) 28%, var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12)));
  border-radius: 10px;
  padding: 0;
  background-color: color-mix(in srgb, var(--wl-module-accent) 4%, var(--md-default-bg-color, #fff));
  overflow: hidden;
}

.wikilink-pane__cards > .wikilink-module:nth-of-type(4n + 1) { --wl-module-accent: #4a90d9; }
.wikilink-pane__cards > .wikilink-module:nth-of-type(4n + 2) { --wl-module-accent: #d49b2a; }
.wikilink-pane__cards > .wikilink-module:nth-of-type(4n + 3) { --wl-module-accent: #d86c8e; }
.wikilink-pane__cards > .wikilink-module:nth-of-type(4n + 4) { --wl-module-accent: #3aa6a0; }

.wikilink-module__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.75rem 1rem 0.65rem;
  background-color: color-mix(in srgb, var(--wl-module-accent) 12%, var(--md-default-bg-color, #fff));
  border-bottom: 1px solid color-mix(in srgb, var(--wl-module-accent) 24%, var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12)));
}

.wikilink-module__page {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  color: color-mix(in srgb, var(--wl-module-accent) 78%, var(--md-default-fg-color));
  text-decoration: none;
  word-break: break-word;
}

.wikilink-module__page:hover,
.wikilink-module__page:focus-visible {
  text-decoration: underline;
}

.wikilink-module__minimize {
  flex-shrink: 0;
  background: none;
  border: 1.5px solid var(--md-default-fg-color--light, rgba(0,0,0,0.4));
  border-radius: 3px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-default-fg-color);
  padding: 0;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.wikilink-module__minimize:hover {
  background-color: color-mix(in srgb, var(--wl-module-accent) 14%, var(--md-default-bg-color));
  border-color: var(--wl-module-accent);
  color: color-mix(in srgb, var(--wl-module-accent) 82%, var(--md-default-fg-color));
}

.wikilink-module__body {
  padding: 0.55rem 0.55rem 0.6rem;
  background-color: color-mix(in srgb, var(--wl-module-accent) 3%, var(--md-default-bg-color, #fff));
}

.wikilink-module--minimized .wikilink-module__body {
  display: none;
}

.wikilink-module__cards {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Individual card ────────────────────────────────────────────────────────── */

.wikilink-card {
  border: 1px solid color-mix(in srgb, var(--wl-module-accent) 14%, transparent);
  border-radius: 5px;
  padding: 0.6rem 0.75rem 0.65rem;
  background-color: color-mix(in srgb, var(--wl-module-accent) 7%, var(--md-default-bg-color, #fff));
  box-shadow: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.wikilink-module__cards > .wikilink-card:nth-child(2) {
  background-color: color-mix(in srgb, var(--wl-module-accent) 5%, var(--md-default-bg-color, #fff));
}

.wikilink-module__cards > .wikilink-card:nth-child(n + 3) {
  background-color: color-mix(in srgb, var(--wl-module-accent) 3.5%, var(--md-default-bg-color, #fff));
}

.wikilink-card:hover {
  border-color: color-mix(in srgb, var(--wl-module-accent) 30%, transparent);
  box-shadow: none;
}

.wikilink-module__cards > .wikilink-card + .wikilink-card {
  position: relative;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
}

.wikilink-module__cards > .wikilink-card + .wikilink-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: color-mix(in srgb, var(--wl-module-accent) 32%, var(--md-default-fg-color--light, rgba(0, 0, 0, 0.28)));
}

/* Card header: title + minimize button on one row */
.wikilink-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
}

.wikilink-card__header-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  flex-shrink: 0;
}

.wikilink-card__page {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  color: color-mix(in srgb, var(--wl-module-accent) 78%, var(--md-default-fg-color));
  text-decoration: none;
  word-break: break-word;
}

.wikilink-card__page:hover {
  text-decoration: underline;
}

.wikilink-card__page--section {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--md-default-fg-color);
}

/* Minimize button (−/+) */
.wikilink-card__minimize {
  flex-shrink: 0;
  background: none;
  border: 1.5px solid var(--md-default-fg-color--light, rgba(0,0,0,0.4));
  border-radius: 3px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-default-fg-color);
  padding: 0;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.wikilink-card__minimize:hover {
  background-color: var(--md-default-fg-color--lightest, rgba(0,0,0,0.08));
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
}

/* Card body — hidden when card is minimized */
.wikilink-card__body {
  margin-top: 0.35rem;
}

.wikilink-card--minimized .wikilink-card__controls {
  display: none;
}

.wikilink-card--minimized .wikilink-card__body {
  display: none;
}

/* Content area — no height clip; extended lines are revealed incrementally */
.wikilink-card__content {
  overflow: visible;
}

/* Controls row (↑↓) — bottom-right of card body */
.wikilink-card__controls {
  display: flex;
  gap: 0.2rem;
}

.wikilink-card__ctx-btn {
  background: none;
  border: 1.5px solid var(--md-default-fg-color--light, rgba(0,0,0,0.4));
  border-radius: 3px;
  font-size: 1rem;
  font-weight: 700;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-default-fg-color);
  padding: 0;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.wikilink-card__ctx-btn:hover {
  background-color: var(--md-default-fg-color--lightest, rgba(0,0,0,0.08));
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
}

.wikilink-card__ctx-btn:disabled,
.wikilink-card__ctx-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
}

.wikilink-card__ctx-btn:disabled:hover,
.wikilink-card__ctx-btn[aria-disabled="true"]:hover {
  background: none;
  border-color: var(--md-default-fg-color--light, rgba(0,0,0,0.4));
  color: var(--md-default-fg-color);
}

.wikilink-card__context {
  display: block;
  font-size: 0.8rem;
  color: var(--md-default-fg-color--light);
  line-height: 1.5;
  margin: 0 0 0.3rem;
  word-break: break-word;
  text-decoration: none;
  border-radius: 3px;
  padding: 2px 0;
  transition: color 0.15s;
  cursor: pointer;
}

.wikilink-card__context:hover {
  color: var(--md-default-fg-color);
}

.wikilink-card__context:focus-visible {
  outline: 2px solid var(--md-primary-fg-color);
  outline-offset: 3px;
}

.wikilink-card__context--edge-anchor + .wikilink-card__gap-toggle,
.wikilink-card__gap-body + .wikilink-card__context--edge-anchor,
.wikilink-card__context + .wikilink-card__continuation-toggle,
.wikilink-card__continuation-body + .wikilink-card__context {
  margin-top: 0.35rem;
}

.wikilink-card__gap-toggle,
.wikilink-card__continuation-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  min-height: 1.7rem;
  padding: 0.22rem 0.72rem 0.22rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--md-primary-fg-color) 28%, transparent);
  border-radius: 999px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--md-primary-fg-color) 12%, var(--md-default-bg-color, #fff)),
      color-mix(in srgb, var(--md-accent-fg-color, var(--md-primary-fg-color)) 8%, var(--md-default-bg-color, #fff)));
  color: var(--md-primary-fg-color);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.wikilink-card__gap-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-primary-fg-color) 16%, var(--md-default-bg-color, #fff));
}

.wikilink-card__gap-icon svg {
  width: 0.78rem;
  height: 0.78rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wikilink-card__gap-toggle:hover,
.wikilink-card__gap-toggle:focus-visible,
.wikilink-card__continuation-toggle:hover,
.wikilink-card__continuation-toggle:focus-visible {
  color: var(--md-primary-fg-color);
  border-color: color-mix(in srgb, var(--md-primary-fg-color) 58%, transparent);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--md-primary-fg-color) 16%, var(--md-default-bg-color, #fff)),
      color-mix(in srgb, var(--md-accent-fg-color, var(--md-primary-fg-color)) 12%, var(--md-default-bg-color, #fff)));
  box-shadow: 0 0.22rem 0.75rem rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.wikilink-card__gap-body,
.wikilink-card__continuation-body {
  margin-top: 0.35rem;
  padding: 0.1rem 0 0.15rem 0.55rem;
  border-left: 2px solid color-mix(in srgb, var(--md-primary-fg-color) 18%, transparent);
  color: var(--md-default-fg-color--light);
}

.wikilink-card__context mark,
.wl-sec-bullet mark,
.wl-sec-prose mark,
.wl-sec-h mark,
.wl-chunk mark {
  background-color: rgba(245, 196, 114, 0.55);  /* warm amber — same as block-highlight */
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

[data-md-color-scheme="slate"] .wikilink-card__context mark,
[data-md-color-scheme="slate"] .wl-sec-bullet mark,
[data-md-color-scheme="slate"] .wl-sec-prose mark,
[data-md-color-scheme="slate"] .wl-sec-h mark,
[data-md-color-scheme="slate"] .wl-chunk mark {
  background-color: rgba(245, 196, 114, 0.35);
}

.wikilink-card__section {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--md-default-fg-color, rgba(0, 0, 0, 0.75));
  margin: 0.25rem 0 0.35rem;
  letter-spacing: 0.01em;
}

.wikilink-card__breadcrumb {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0.14rem;
  column-gap: 0.32rem;
  max-width: 100%;
}

.wikilink-card__breadcrumb-part {
  color: var(--md-default-fg-color--light, rgba(0, 0, 0, 0.62));
  min-width: 0;
}

.wikilink-card__breadcrumb-part--current {
  color: var(--md-default-fg-color, rgba(0, 0, 0, 0.84));
  font-weight: 800;
}

.wikilink-card__breadcrumb-sep {
  width: 0.68rem;
  height: 0.68rem;
  flex: 0 0 auto;
  background-color: var(--md-default-fg-color--lighter, rgba(0, 0, 0, 0.36));
  -webkit-mask-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.2" viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg>');
  mask-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.2" viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg>');
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transform: translateY(0.01rem);
}

.wikilink-card__breadcrumb-sep-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[data-md-color-scheme="slate"] .wikilink-card__breadcrumb-part {
  color: var(--md-default-fg-color--light, rgba(255, 255, 255, 0.62));
}

[data-md-color-scheme="slate"] .wikilink-card__breadcrumb-part--current {
  color: var(--md-default-fg-color, rgba(255, 255, 255, 0.9));
}

[data-md-color-scheme="slate"] .wikilink-card__breadcrumb-sep {
  background-color: var(--md-default-fg-color--lighter, rgba(255, 255, 255, 0.4));
}



/* ── Extended context — lines revealed 3 at a time with + button ─────────────── */

.wikilink-card__extended {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--md-default-fg-color--light);
  word-break: break-word;
}

/* Each ext line starts hidden; JS adds --visible to reveal it */
.wikilink-card__ext-line {
  display: none;
  line-height: 1.6;
}

.wikilink-card__ext-line--visible {
  display: block;
}

/* ── Children of the occurrence keyword ─────────────────────────────────────── */

.wikilink-card__children {
  margin: 0.35rem 0 0 1rem;
  padding: 0;
  list-style: disc;
  font-size: 0.78rem;
  color: var(--md-default-fg-color--light);
  line-height: 1.5;
}

.wikilink-card__children li {
  margin-bottom: 0.15rem;
}

/* ── Graph CSS variables ────────────────────────────────────────────────────── */

:root {
  --graph-page-color:      #a8c8e8;  /* soft sky blue */
  --graph-page-text:       #1a3a5c;
  --graph-kw-color:        #a8d8b0;  /* sage green — leaf keyword nodes */
  --graph-kw-text:         #1a3d22;
  --graph-kw-parent-color: #d4a8e8;  /* soft violet — keyword nodes that have children */
  --graph-cat-parent-color: #f0d060;  /* yellow — category/group nodes with sub-groups */
  --graph-cat-color:        #f0d060;  /* yellow — leaf category/group nodes (Modules, Lab Resources) */
  --graph-connected-color: #f5c472;  /* warm amber for hovered neighbours */
  --graph-hover-color:     #ffffff;  /* white for the hovered node itself */
  --graph-edge-color:      rgba(0, 0, 0, 0.15);
  --graph-label-color:     #000000;
}

[data-md-color-scheme="slate"] {
  --graph-page-color:      #3a6080;
  --graph-page-text:       #d0e8f8;
  --graph-kw-color:        #3a6040;
  --graph-kw-text:         #c8e8cc;
  --graph-kw-parent-color: #6a3a8a;  /* deeper violet in dark mode */
  --graph-cat-parent-color: #8a7010;
  --graph-cat-color:        #8a7010;
  --graph-connected-color: #c8902a;
  --graph-hover-color:     #2a2a2a;
  --graph-edge-color:      rgba(255, 255, 255, 0.15);
  --graph-label-color:     #ffffff;
  --md-code-bg-color:      rgba(255, 255, 255, 0.06);
  --md-code-fg-color:      #c8d0d8;
}

/* ── Shared graph label ──────────────────────────────────────────────────────── */

.graph-label {
  font-family: var(--md-text-font, sans-serif);
  font-size:   10px;
  user-select: none;
  /* SVG fill via CSS — reacts to dark/light toggle without re-rendering */
  fill: var(--graph-label-color, #000);
}

/* ── Site graph search bar ───────────────────────────────────────────────────── */

.graph-search {
  margin-bottom: 0.6rem;
}

.graph-search__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.graph-search__input {
  width: 100%;
  max-width: 300px;
  padding: 0.38rem 0.85rem;
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.2));
  border-radius: 20px;
  font-size: 0.85rem;
  font-family: var(--md-text-font, sans-serif);
  background: var(--md-default-bg-color, #fff);
  color: var(--md-default-fg-color, #000);
  outline: none;
  transition: border-color 0.15s;
}

.graph-search__input:focus {
  border-color: var(--md-accent-fg-color, #4a90d9);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

.graph-search__chip {
  display: inline-flex;
  align-items: center;
  max-width: min(100%, 420px);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-primary-fg-color) 12%, var(--md-default-bg-color));
  color: var(--md-default-fg-color);
  font-size: 0.74rem;
  line-height: 1.2;
  border: 1px solid color-mix(in srgb, var(--md-primary-fg-color) 24%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.graph-search__hint {
  margin-top: 0.32rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--md-default-fg-color--light);
}

/* ── Section navigator — inline content styles ──────────────────────────────── */

.wikilink-card__section-view {
  --wl-list-indent-step: 0.68rem;
  --wl-list-marker-width: 1.35rem;
  --wl-list-marker-gap: 0.2rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--md-default-fg-color--light);
  word-break: break-word;
}

.wikilink-card__md-link {
  color: var(--md-primary-fg-color);
  text-decoration: none;
}

.wikilink-card__md-link:hover,
.wikilink-card__md-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.wl-inline-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15em;
  margin: 0 0.08em;
  color: var(--md-default-fg-color);
  vertical-align: text-bottom;
  font-size: 0.95em;
  line-height: 1;
}

.wikilink-card__section-view mark {
  background-color: rgba(245, 196, 114, 0.55);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

[data-md-color-scheme="slate"] .wikilink-card__section-view mark {
  background-color: rgba(245, 196, 114, 0.35);
}

.keys {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  vertical-align: middle;
}

.keys kbd {
  border-radius: 0.2rem;
  box-shadow: 0 0 0 0.05rem var(--md-typeset-kbd-border-color), 0 0.15rem 0 var(--md-typeset-kbd-border-color);
  background: var(--md-typeset-kbd-color);
  color: var(--md-default-fg-color);
  display: inline-block;
  font-size: 0.75em;
  line-height: 1.2;
  padding: 0 0.45rem;
  vertical-align: text-top;
}

.wl-key-sep {
  color: var(--md-default-fg-color--light);
  font-size: 0.8em;
}

.wl-sec-h { font-weight: 700; color: var(--md-default-fg-color); margin: 0.3rem 0 0.1rem; }
.wl-sec-h1, .wl-sec-h2 { font-size: 0.9rem; }
.wl-sec-h3, .wl-sec-h4 { font-size: 0.82rem; }
.wl-sec-h5, .wl-sec-h6 { font-size: 0.78rem; }

.wl-sec-list-item {
  margin: 0.1rem 0;
  padding-left: calc(var(--wl-depth, 0) * var(--wl-list-indent-step));
  display: grid;
  grid-template-columns: var(--wl-list-marker-width) minmax(0, 1fr);
  column-gap: var(--wl-list-marker-gap);
  align-items: start;
}

.wl-sec-list-item__marker {
  text-align: right;
  white-space: nowrap;
  color: var(--md-default-fg-color);
}

.wl-sec-list-item__content {
  min-width: 0;
}
.wl-sec-prose  { margin: 0.15rem 0; }
.wl-sec-gap    { height: 0.4rem; }

.wl-sec-table-wrap {
  margin: 0.35rem 0 0.45rem;
  overflow-x: auto;
}

.wl-sec-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  font-size: inherit;
  line-height: 1.1;
  color: inherit;
}

.wl-sec-table__cell {
  padding: 2px 6px;
  line-height: 1.1;
  vertical-align: top;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  overflow-wrap: anywhere;
}

.wl-sec-table__cell--th {
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid var(--md-default-fg-color--light, rgba(0,0,0,0.28));
}

.wl-sec-table tbody tr:last-child .wl-sec-table__cell {
  border-bottom: none;
}
.wl-sec-empty  { font-style: italic; opacity: 0.6; }

.wl-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.3rem 0;
  display: block;
}

.wl-sec-prose code,
.wl-sec-bullet code,
.wikilink-card__context code {
  background: var(--md-code-bg-color, rgba(0,0,0,0.05));
  border-radius: 3px;
  padding: 0 3px;
  font-size: 0.9em;
}

.wl-sec-code-block {
  margin: 0.45rem 0 0.6rem;
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--md-code-bg-color, rgba(0,0,0,0.05)) 92%, var(--md-default-bg-color));
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.wl-sec-code__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.38rem 0.55rem 0.34rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  background: color-mix(in srgb, var(--md-default-bg-color) 88%, var(--md-code-bg-color, rgba(0,0,0,0.05)));
}

.wl-sec-code__lang {
  font-size: 0.66rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-default-fg-color--light, rgba(0,0,0,0.54));
}

.wl-sec-code__copy {
  appearance: none;
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.14));
  border-radius: 999px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wl-sec-code__copy:hover,
.wl-sec-code__copy:focus-visible {
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
  outline: none;
}

.wl-sec-code__copy--done {
  border-color: color-mix(in srgb, var(--md-primary-fg-color) 35%, transparent);
  background: color-mix(in srgb, var(--md-primary-fg-color) 10%, var(--md-default-bg-color));
  color: var(--md-primary-fg-color);
}

.wl-sec-code__body {
  overflow-x: auto;
  padding: 0.55rem 0.7rem 0.6rem;
}

.wl-sec-code {
  display: block;
  min-width: max-content;
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--md-code-fg-color, inherit);
}

.wl-sec-code__line {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.65rem;
  align-items: start;
  min-height: 1.3em;
}

.wl-sec-code__line + .wl-sec-code__line {
  margin-top: 0.04rem;
}

.wl-sec-code__line-number {
  display: inline-flex;
  justify-content: flex-end;
  align-items: baseline;
  color: var(--md-default-fg-color--light, rgba(0,0,0,0.54));
  font-size: 0.72rem;
  line-height: 1.55;
  user-select: none;
  border-right: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  padding-right: 0.45rem;
}

.wl-sec-code__line-text {
  display: block;
  white-space: pre;
}

.wl-sec-code__annotation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  min-width: 1.4rem;
  height: 1.2rem;
  margin-top: 0.08rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--md-primary-fg-color) 12%, var(--md-default-bg-color));
  color: var(--md-primary-fg-color);
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
}

.wl-sec-list-item--annotation .wl-sec-list-item__marker {
  color: var(--md-primary-fg-color);
  font-weight: 800;
}

/* Mermaid diagrams rendered inside the pane */
.wl-sec-mermaid {
  margin: 0.5rem 0;
  overflow-x: auto;
}
.wl-sec-mermaid .mermaid {
  display: flex;
  justify-content: center;
}
.wl-sec-mermaid svg {
  max-width: 100%;
  height: auto;
}

/* HTML <table> blocks rendered inside the pane */
.wl-sec-html-table {
  margin: 0.35rem 0 0.45rem;
  overflow-x: auto;
  font-size: 0.82rem;
}
.wl-sec-html-table table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--md-default-fg-color--light);
  border-bottom: 1px solid var(--md-default-fg-color--light);
}
.wl-sec-html-table th,
.wl-sec-html-table td {
  padding: 2px 6px;
  vertical-align: top;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  overflow-wrap: anywhere;
}
.wl-sec-html-table th {
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid var(--md-default-fg-color--light, rgba(0,0,0,0.28));
}
.wl-sec-html-table tbody tr:last-child td { border-bottom: none; }

.wl-sec-admonition,
.wl-sec-tab-panel {
  margin: 0.6rem 0;
}

.wl-sec-admonition {
  --wl-admonition-accent: #448aff;
  --wl-admonition-icon: var(--md-admonition-icon--note);
  --wl-admonition-bg: color-mix(in srgb, var(--wl-admonition-accent) 10%, transparent);
  --wl-admonition-bg-strong: color-mix(in srgb, var(--wl-admonition-accent) 14%, transparent);
  --wl-admonition-border: color-mix(in srgb, var(--wl-admonition-accent) 20%, transparent);
  border: 1px solid var(--wl-admonition-border);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--wl-admonition-bg) 0%, color-mix(in srgb, var(--wl-admonition-accent) 6%, transparent) 100%);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--wl-admonition-accent) 10%, transparent);
  overflow: hidden;
}

.wl-sec-admonition.abstract {
  --wl-admonition-accent: #00b0ff;
  --wl-admonition-icon: var(--md-admonition-icon--abstract);
}

.wl-sec-admonition.info {
  --wl-admonition-accent: #00b8d4;
  --wl-admonition-icon: var(--md-admonition-icon--info);
}

.wl-sec-admonition.tip {
  --wl-admonition-accent: #00bfa5;
  --wl-admonition-icon: var(--md-admonition-icon--tip);
}

.wl-sec-admonition.success {
  --wl-admonition-accent: #00c853;
  --wl-admonition-icon: var(--md-admonition-icon--success);
}

.wl-sec-admonition.question {
  --wl-admonition-accent: #64dd17;
  --wl-admonition-icon: var(--md-admonition-icon--question);
}

.wl-sec-admonition.warning {
  --wl-admonition-accent: #ff9100;
  --wl-admonition-icon: var(--md-admonition-icon--warning);
}

.wl-sec-admonition.quote {
  --wl-admonition-accent: #9e9e9e;
  --wl-admonition-icon: var(--md-admonition-icon--quote);
}

.wl-sec-admonition.failure {
  --wl-admonition-accent: #ff5252;
  --wl-admonition-icon: var(--md-admonition-icon--failure);
}

.wl-sec-admonition.danger {
  --wl-admonition-accent: #ff1744;
  --wl-admonition-icon: var(--md-admonition-icon--danger);
}

.wl-sec-admonition__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 0.95rem;
  cursor: pointer;
  background: linear-gradient(180deg, var(--wl-admonition-bg-strong) 0%, var(--wl-admonition-bg) 100%);
  transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.wl-sec-admonition__summary::-webkit-details-marker {
  display: none;
}

.wl-sec-admonition__summary:hover,
.wl-sec-admonition__summary:focus-visible {
  background: color-mix(in srgb, var(--wl-admonition-accent) 18%, var(--md-default-bg-color, #fff));
}

.wl-sec-admonition[open] .wl-sec-admonition__summary {
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--wl-admonition-accent) 18%, transparent);
}

.wl-sec-admonition__summary--static {
  margin: 0;
  cursor: default;
}

.wl-sec-admonition__summary-main {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
  position: relative;
  padding-left: 1.6rem;
}

.wl-sec-admonition__summary-main::before {
  background-color: var(--wl-admonition-accent);
  content: "";
  width: 1rem;
  height: 1rem;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  -webkit-mask-image: var(--wl-admonition-icon);
  mask-image: var(--wl-admonition-icon);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.wl-sec-admonition__title {
  min-width: 0;
  font-weight: 700;
  color: var(--md-default-fg-color);
}

.wl-sec-admonition__title .hashtag,
.wl-sec-admonition__title .wikilink--inline,
.wl-sec-admonition__title .wikilink {
  vertical-align: baseline;
}

.wl-sec-admonition__chevron {
  width: 1.8rem;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--wl-admonition-accent) 9%, var(--md-default-bg-color, #fff));
  color: var(--wl-admonition-accent);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.wl-sec-admonition__chevron svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
}

.wl-sec-admonition[open] .wl-sec-admonition__chevron {
  transform: rotate(90deg);
  background: color-mix(in srgb, var(--wl-admonition-accent) 16%, var(--md-default-bg-color, #fff));
}

.wl-sec-admonition__body,
.wl-sec-tab-panel__body {
  margin-top: 0.5rem;
}

.wl-sec-admonition__body {
  margin-top: 0;
  padding: 0.75rem 0.95rem 0.9rem;
  background: color-mix(in srgb, var(--wl-admonition-accent) 4%, var(--md-default-bg-color, #fff));
}

details.wl-sec-admonition:not([open]) > .wl-sec-admonition__body {
  display: none;
}

.wl-sec-admonition__body > :first-child {
  margin-top: 0;
}

.wl-sec-admonition__body > :last-child {
  margin-bottom: 0;
}

.wl-sec-tab-panel {
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  border-radius: 8px;
  background: color-mix(in srgb, var(--md-code-bg-color, rgba(0,0,0,0.04)) 35%, var(--md-default-bg-color, #fff));
  padding: 0.7rem 0.8rem;
}

.wl-sec-tab-panel__title {
  font-weight: 700;
  color: var(--md-default-fg-color);
  margin-bottom: 0.4rem;
}

/* "Page graph" bold label shown above the sidebar graph widget */
.page-graph-label {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.5rem 0 0.15rem;
  color: var(--md-default-fg-color);
}

/* ── Page-graph container (lives in the TOC sidebar) ─────────────────────────── */

.page-graph-container {
  position:      relative;   /* anchor for the zoom button */
  width:         100%;
  height:        320px;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  overflow:      hidden;
  background:    transparent;
}

.page-graph-container--clickable {
  cursor: pointer;
}

.page-graph-container--clickable:focus-visible {
  outline: 2px solid var(--md-primary-fg-color);
  outline-offset: 2px;
}

.page-graph-site-link {
  display: block;
  margin: -0.15rem 0 0.85rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  border-radius: 8px;
  background: color-mix(in srgb, var(--md-primary-fg-color) 4%, var(--md-default-bg-color));
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.page-graph-site-link:hover,
.page-graph-site-link:focus-visible {
  border-color: var(--md-primary-fg-color);
  background: color-mix(in srgb, var(--md-primary-fg-color) 10%, var(--md-default-bg-color));
  outline: none;
  transform: translateY(-1px);
}

.page-graph-site-link__title {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--md-primary-fg-color);
  line-height: 1.3;
}

.page-graph-site-link__hint {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.72rem;
  color: var(--md-default-fg-color--light);
  line-height: 1.35;
}

.graph-controls-host {
  position: relative;
  overflow: hidden;
}

.graph-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  width: min(210px, calc(100% - 12px));
}

.graph-controls__buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  width: 100%;
}

.graph-hop-control {
  width: 100%;
  padding: 0.55rem 0.65rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  background: color-mix(in srgb, var(--md-default-bg-color) 88%, transparent);
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.15));
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
}

.graph-hop-control__header,
.graph-hop-control__scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.graph-hop-control__title,
.graph-hop-control__value,
.graph-hop-control__scale {
  font-size: 0.72rem;
  line-height: 1.2;
}

.graph-hop-control__title {
  font-weight: 700;
  color: var(--md-default-fg-color);
}

.graph-hop-control__value,
.graph-hop-control__scale {
  color: var(--md-default-fg-color--light);
}

.graph-hop-control__slider {
  width: 100%;
  margin: 0;
  accent-color: var(--md-primary-fg-color);
}

.graph-hop-control__slider:disabled {
  opacity: 0.65;
}

/* Graph control buttons — top-right of the graph */
.graph-control-btn {
  width:      30px;
  height:     30px;
  padding:    0;
  display:    flex;
  align-items:     center;
  justify-content: center;
  background: var(--md-default-bg-color);
  border:     1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.15));
  border-radius: 4px;
  color:      var(--md-default-fg-color--light);
  cursor:     pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.graph-control-btn {
  position: relative;
}

.graph-control-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.page-graph-zoom {
  position:   absolute;
  top:        6px;
  right:      6px;
  z-index:    10;
  width:      30px;
  height:     30px;
  padding:    0;
  display:    flex;
  align-items:     center;
  justify-content: center;
  background: var(--md-default-bg-color);
  border:     1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.15));
  border-radius: 4px;
  color:      var(--md-default-fg-color--light);
  cursor:     pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.graph-control-btn:hover,
.graph-control-btn:focus-visible,
.page-graph-zoom:hover {
  color:        var(--md-primary-fg-color);
  border-color: var(--md-primary-fg-color);
  background:   color-mix(in srgb, var(--md-primary-fg-color) 8%, var(--md-default-bg-color));
  outline: none;
}

/* ── Graph modal overlay ─────────────────────────────────────────────────────── */

.graph-modal {
  position:   fixed;
  inset:      0;
  z-index:    10020;
  background: rgba(0, 0, 0, 0.55);
  display:    flex;
  align-items:     center;
  justify-content: center;
  animation:  graph-modal-fade-in 0.18s ease;
}

@keyframes graph-modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.graph-modal__panel {
  position:      relative;
  width:         min(88vw, 1480px);
  height:        min(84vh, 980px);
  max-width:     calc(100vw - 1rem);
  max-height:    calc(100vh - 1rem);
  background:    var(--md-default-bg-color);
  border-radius: 10px;
  box-shadow:    0 8px 40px rgba(0, 0, 0, 0.28);
  overflow:      hidden;
  display:       flex;
  flex-direction: column;
}

.graph-modal__header {
  min-height: 52px;
  padding: 0.85rem 3.5rem 0.75rem 1.15rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.12));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.graph-modal__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--md-default-fg-color);
}

.graph-modal__action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--md-primary-fg-color);
  border-radius: 4px;
  color: var(--md-primary-fg-color);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.graph-modal__action:hover,
.graph-modal__action:focus-visible {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color, #fff);
  outline: none;
}

.graph-modal__graph {
  flex: 1;
  overflow: hidden;
}

.graph-modal__close {
  position:   absolute;
  top:        10px;
  right:      12px;
  z-index:    10;
  width:      30px;
  height:     30px;
  padding:    0;
  font-size:  1.3rem;
  line-height: 1;
  background: var(--md-default-bg-color);
  border:     1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.15));
  border-radius: 6px;
  color:      var(--md-default-fg-color--light);
  cursor:     pointer;
  display:    flex;
  align-items:     center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.graph-modal__close:hover,
.graph-modal__close:focus-visible {
  color:        var(--md-default-fg-color);
  border-color: var(--md-default-fg-color);
  outline:      none;
}

/* ── Image lightbox ─────────────────────────────────────────────────────────── */

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10100;               /* above pane (9999) and graph modal (9000) */
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: img-lightbox-fade-in 0.18s ease;
}

@keyframes img-lightbox-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.img-lightbox__img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.55);
  cursor: default;
  user-select: none;
}

.img-lightbox__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest, rgba(255,255,255,0.15));
  border-radius: 6px;
  color: var(--md-default-fg-color--light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.img-lightbox__close:hover,
.img-lightbox__close:focus-visible {
  color: var(--md-default-fg-color);
  border-color: var(--md-default-fg-color);
  outline: none;
}

.img-lightbox__caption {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80vw;
  background: rgba(0, 0, 0, 0.6);
  color: #e8e8e8;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  text-align: center;
  pointer-events: none;
}

/* Zoom cursor affordance on all content images */
.md-typeset img:not(.no-lightbox),
.wl-img { cursor: zoom-in; }

/* ── Responsive: full-width on small screens ────────────────────────────────── */

@media (max-width: 560px) {
  .wikilink-pane {
    width: 100vw;
    border-left: none;
  }
}
