/* System Design Primer: extras for MkDocs Material
   Theme-aware site overlays + small tweaks. Works in light + dark palettes. */

/* ---------- Header share button ---------------------------------------- */
/* Inherits Material's .md-header__button visual so it lines up with the
   palette toggle and search icons. */
.sdp-share-btn {
  margin: 0.2rem;
  cursor: pointer;
}
.sdp-share-btn svg {
  display: block;
  width: 1.2rem;
  height: 1.2rem;
}

/* Toast used by the share-fallback copy path */
.sdp-toast {
  position: fixed;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--md-default-fg-color);
  color: var(--md-default-bg-color);
  padding: 0.55rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
  z-index: 1100;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.sdp-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media print {
  .sdp-share-btn,
  .sdp-toast { display: none !important; }
}

/* Mermaid container tweaks: let diagrams breathe and centre */
.md-typeset .mermaid { text-align: center; }
.md-typeset .mermaid svg { max-width: 100%; height: auto; }

/* Dark mode: mermaid classDef fills are light pastels with intentionally
 * dark text (color:#0f172a). Material's dark palette overrides text to light,
 * which becomes unreadable on the pastel fills. Force text dark. */
body[data-md-color-scheme="slate"] .md-typeset .mermaid .nodeLabel,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .nodeLabel *,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .cluster-label,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .cluster-label *,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .clusterLabel,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .clusterLabel *,
body[data-md-color-scheme="slate"] .md-typeset .mermaid foreignObject span,
body[data-md-color-scheme="slate"] .md-typeset .mermaid foreignObject p,
body[data-md-color-scheme="slate"] .md-typeset .mermaid svg text {
  color: #0f172a !important;
  fill: #0f172a !important;
}

/* Edge labels (text on arrows) float without their own fill. Give them a
 * light backplate so the dark text stays readable on the dark page. */
body[data-md-color-scheme="slate"] .md-typeset .mermaid .edgeLabel,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .edgeLabel * {
  color: #0f172a !important;
  background-color: rgba(241, 245, 249, 0.94) !important;
}
body[data-md-color-scheme="slate"] .md-typeset .mermaid .edgeLabel rect,
body[data-md-color-scheme="slate"] .md-typeset .mermaid .edgeLabel .labelBkg {
  fill: rgba(241, 245, 249, 0.94) !important;
  background-color: rgba(241, 245, 249, 0.94) !important;
}

/* ---------- Click-to-fullscreen affordance ----------------------------- */

/* Hint that a diagram or image is clickable to enter fullscreen */
.sdp-zoom-target {
  cursor: zoom-in;
  transition: filter 120ms;
}
.sdp-zoom-target:hover {
  filter: brightness(1.02) drop-shadow(0 1px 4px rgba(0,0,0,0.12));
}

@media print {
  .sdp-zoom-target { cursor: default; }
}

/* ---------- Per-diagram toolbar (Open / Fullscreen / Copy) ------------- */

/* Wrap each mermaid block in a positioned container; the toolbar floats
   top-right of the diagram like a code-block Copy button. */
.sdp-mermaid-wrap {
  position: relative !important;
  margin: 1rem 0 !important;
  display: block !important;
  /* z-index: 0 creates a new stacking context so the floating toolbar
     (z-index:5 inside) is scoped within the wrap and cannot leak above
     the Material header (z-index:200 in the root stacking context). */
  z-index: 0;
}
.sdp-mermaid-host {
  margin: 0 !important;
}
.sdp-mtb {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  display: inline-flex !important;
  flex-direction: row !important;
  gap: 4px !important;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(15, 23, 42, 0.18) !important;
  border-radius: 8px !important;
  padding: 4px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22) !important;
  z-index: 5 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  font-family: var(--md-text-font-family, system-ui, sans-serif) !important;
  white-space: normal !important;
}

.sdp-mtb__btn {
  /* Icon-only square pill; no text, tooltip from title= attribute */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #0f172a;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms, transform 120ms;
}
.sdp-mtb__btn:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.12);
}
.sdp-mtb__btn:active { transform: translateY(1px); }
.sdp-mtb__btn--flash {
  background: var(--md-primary-fg-color, #4338ca);
  color: #ffffff;
  border-color: var(--md-primary-fg-color, #4338ca);
}

/* Native fullscreen: render diagram at intrinsic size, container scrolls
   so users can pan a large diagram. Theme-aware background respects the
   light/dark preference. */
.sdp-mermaid-wrap:fullscreen,
.sdp-mermaid-wrap:-webkit-full-screen,
.sdp-mermaid-host:fullscreen,
.sdp-mermaid-host:-webkit-full-screen {
  background: var(--md-default-bg-color, #ffffff);
  color-scheme: light dark;
  padding: 2rem;
  overflow: auto;
  text-align: center;
}
.sdp-mermaid-host:fullscreen svg,
.sdp-mermaid-host:-webkit-full-screen svg,
.sdp-mermaid-wrap:fullscreen svg,
.sdp-mermaid-wrap:-webkit-full-screen svg {
  /* Override mermaid's inline width="100%" + max-width caps so the SVG
     renders at its viewBox-derived intrinsic size; the container scrolls. */
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  display: inline-block;
}

/* Image fullscreen (figure wraps the <img>; click handler enters fullscreen
   on the figure). Intrinsic-size + scrollable container, same approach. */
.md-typeset figure:fullscreen,
.md-typeset figure:-webkit-full-screen {
  background: var(--md-default-bg-color, #ffffff);
  color-scheme: light dark;
  padding: 2rem;
  overflow: auto;
  text-align: center;
}
.md-typeset figure:fullscreen img,
.md-typeset figure:-webkit-full-screen img {
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  display: inline-block;
}

@media (max-width: 540px) {
  .sdp-mtb { top: 4px; right: 4px; padding: 3px; }
  .sdp-mtb__btn { width: 1.55rem; height: 1.55rem; font-size: 0.85rem; }
}

@media print {
  .sdp-mtb { display: none !important; }
}

/* ---------- Top tier tabs: scroll affordance --------------------------- */
.sdp-tabs {
  position: relative;
}
.sdp-tabs .md-tabs__list {
  -ms-overflow-style: none;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.sdp-tabs .md-tabs__list::-webkit-scrollbar { display: none; }

/* edge fades only when there's overflow + we're not at the corresponding edge */
.sdp-tabs::before,
.sdp-tabs::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.5rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 5;
}
.sdp-tabs::before {
  left: 0;
  background: linear-gradient(to right, var(--md-primary-fg-color), rgba(0,0,0,0));
}
.sdp-tabs::after {
  right: 0;
  background: linear-gradient(to left, var(--md-primary-fg-color), rgba(0,0,0,0));
}
.sdp-tabs--overflow:not(.sdp-tabs--at-start)::before { opacity: 1; }
.sdp-tabs--overflow:not(.sdp-tabs--at-end)::after    { opacity: 1; }

/* "scroll →" hint button on the right */
.sdp-tabs__hint {
  position: absolute;
  top: 50%;
  right: 0.6rem;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.92);
  color: var(--md-primary-fg-color);
  border: 0;
  border-radius: 1rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: none;
  z-index: 6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: sdpNavHintPulse 1.6s ease-in-out 2 1s both;
}
.sdp-tabs--overflow:not(.sdp-tabs--at-end):not(.sdp-tabs--seen) .sdp-tabs__hint {
  display: block;
}
@keyframes sdpNavHintPulse {
  0%, 100% { transform: translateY(-50%) translateX(0); opacity: 0.95; }
  50%      { transform: translateY(-50%) translateX(4px); opacity: 1; }
}

@media print {
  .sdp-tabs__hint, .sdp-tabs::before, .sdp-tabs::after { display: none !important; }
}

/* ---------- Concept SVG illustrations ---------------------------------- */
.concept-figure {
  margin: 1rem auto 1.5rem;
  text-align: center;
}
.concept-figure .concept-illustration {
  max-width: 100%;
  height: auto;
  display: inline-block;
}
/* On the dark palette, frame the SVG in a soft tinted card so the
   pastel fills don't float on a near-black background. */
[data-md-color-scheme="slate"] .concept-figure {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem;
  padding: 0.75rem 0.5rem;
}
/* On light, a subtle border keeps the illustration grouped. */
[data-md-color-scheme="default"] .concept-figure {
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 0.5rem;
  padding: 0.75rem 0.5rem;
}

@media print {
  .concept-figure { break-inside: avoid; }
}

/* =========================================================================
   Floating prev / next page arrows
   =========================================================================
   Two pill buttons pinned to the bottom-left and bottom-right corners of
   the viewport, clear of Material's primary sidebar (which only extends
   to the page footer, not the bottom of the viewport on scroll).
   At rest: collapsed to an arrow icon (≈ 2.5 rem wide), semi-transparent.
   On hover: slides open to reveal the destination page title.
   Keyboard: ← = prev page, → = next page (handled in related.js).
   ========================================================================= */

.sdp-pg-arrow {
  position: fixed;
  bottom: 1rem;
  z-index: 60;                /* below Material header (200) + sidebars */
  display: flex;
  align-items: center;
  text-decoration: none !important;
  overflow: hidden;
  /* Collapsed width: just the icon */
  max-width: 2.5rem;
  /* Opacity: subtle at rest */
  opacity: 0.5;
  transition: max-width 220ms ease, opacity 160ms, box-shadow 140ms;
  /* Visual style */
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color) !important;
  padding: 0.9rem 0.6rem;
  gap: 0;
  white-space: nowrap;
  font-family: var(--md-text-font-family, system-ui, sans-serif);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 0.6rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

/* Prev: bottom-left, opens rightward */
.sdp-pg-arrow--prev {
  left: 1rem;
  flex-direction: row;
}
/* Next: bottom-right, opens leftward */
.sdp-pg-arrow--next {
  right: 1rem;
  flex-direction: row-reverse;
}

/* Expanded state */
.sdp-pg-arrow:hover,
.sdp-pg-arrow:focus-visible,
.sdp-pg-arrow--flash {
  max-width: 280px;
  opacity: 1;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
}
/* Add inner padding when open so text isn't flush with icon */
.sdp-pg-arrow--prev:hover,
.sdp-pg-arrow--prev:focus-visible,
.sdp-pg-arrow--prev.sdp-pg-arrow--flash { padding-right: 0.85rem; }
.sdp-pg-arrow--next:hover,
.sdp-pg-arrow--next:focus-visible,
.sdp-pg-arrow--next.sdp-pg-arrow--flash { padding-left: 0.85rem; }

/* Icon: always visible */
.sdp-pg-arrow__icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1;
  display: block;
}

/* Label: hidden when collapsed, revealed on hover */
.sdp-pg-arrow__label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
  opacity: 0;
  transition: max-width 200ms ease, opacity 130ms 80ms, margin 200ms ease;
}
.sdp-pg-arrow--prev .sdp-pg-arrow__label { margin-left: 0; }
.sdp-pg-arrow--next .sdp-pg-arrow__label { margin-right: 0; }

.sdp-pg-arrow:hover .sdp-pg-arrow__label,
.sdp-pg-arrow:focus-visible .sdp-pg-arrow__label,
.sdp-pg-arrow--flash .sdp-pg-arrow__label {
  max-width: 200px;
  opacity: 1;
  margin-left: 0.45em;
  margin-right: 0.45em;
}

/* Small keyboard-hint badge: shows inside the button on hover */
.sdp-pg-arrow__key {
  flex-shrink: 0;
  display: block;
  font-size: 0.58rem;
  font-family: var(--md-code-font-family, ui-monospace, monospace);
  background: rgba(255, 255, 255, 0.18);
  border-radius: 0.25rem;
  padding: 0.1rem 0.3rem;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 200ms ease 60ms, opacity 130ms 100ms, margin 200ms ease;
  white-space: nowrap;
}
.sdp-pg-arrow:hover .sdp-pg-arrow__key,
.sdp-pg-arrow:focus-visible .sdp-pg-arrow__key {
  max-width: 4rem;
  opacity: 0.85;
  margin-left: 0.2em;
}
.sdp-pg-arrow--next .sdp-pg-arrow__key {
  margin-left: 0;
  margin-right: 0;
}
.sdp-pg-arrow--next:hover .sdp-pg-arrow__key,
.sdp-pg-arrow--next:focus-visible .sdp-pg-arrow__key {
  margin-right: 0.2em;
}

/* Flash pulse on keyboard nav */
@keyframes sdpArrowFlash {
  0%   { opacity: 1;   box-shadow: 0 4px 20px rgba(0,0,0,0.35); }
  100% { opacity: 0.5; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
}
.sdp-pg-arrow--flash {
  animation: sdpArrowFlash 0.45s ease 0.25s forwards;
}

/* On mobile (no sidebar) make both arrows slightly more prominent */
@media (max-width: 76.1875em) {
  .sdp-pg-arrow { opacity: 0.65; }
}

/* Compact on small phones */
@media (max-width: 540px) {
  .sdp-pg-arrow {
    padding: 0.7rem 0.5rem;
    max-width: 2.2rem;
  }
  .sdp-pg-arrow__icon { font-size: 0.95rem; }
}

@media print {
  .sdp-pg-arrow { display: none !important; }
}

/* =========================================================================
   Mermaid dark-theme text fix
   =========================================================================
   Material's "slate" colour scheme sets a global light text colour that
   bleeds into SVG <text> and foreignObject elements, making our dark
   (#0f172a) classDef node labels almost invisible against the pastel fills.
   Force node-label text back to near-black; keep edge labels readable on
   the dark canvas by using a lighter slate-grey.
   ========================================================================= */

/* --- Node labels --------------------------------------------------------- */
/* Flowchart / sequence actor boxes / class diagram compartments            */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .nodeLabel,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .nodeLabel *,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg g.node text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .node text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .label text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .label foreignObject div,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .label foreignObject span,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .label foreignObject p {
  fill: #0f172a !important;
  color: #0f172a !important;
}

/* Mermaid v10 / v11 renders HTML labels via foreignObject inside .node     */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg foreignObject div,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg foreignObject span,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg foreignObject p {
  color: #0f172a !important;
}

/* --- Subgraph / cluster labels ------------------------------------------ */
/* These float on a tinted rectangle; keep them dark.                       */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .cluster-label text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .cluster-label foreignObject div,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .cluster-label foreignObject span,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .cluster rect {
  fill: #1e293b !important;    /* dark-slate card, readable on dark canvas */
  stroke: #475569 !important;
}
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .cluster-label text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .cluster-label foreignObject div {
  fill: #e2e8f0 !important;
  color: #e2e8f0 !important;
}

/* --- Edge / transition labels ------------------------------------------- */
/* These float over the dark canvas background, so use a light slate-grey.  */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .edgeLabel rect,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .edgeLabel .label rect {
  fill: transparent !important;
  opacity: 0 !important;
}
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .edgeLabel text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .edgeLabel div,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .edgeLabel span,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .edgeLabel foreignObject div {
  fill: #94a3b8 !important;
  color: #94a3b8 !important;
}

/* Arrow paths themselves: brighten slightly on dark canvas */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .flowchart-link,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg path.path,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .messageLine0,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .messageLine1 {
  stroke: #94a3b8 !important;
}
[data-md-color-scheme="slate"] .md-typeset .mermaid svg marker path {
  fill: #94a3b8 !important;
  stroke: #94a3b8 !important;
}

/* --- Sequence diagrams -------------------------------------------------- */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .actor text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .actor-line,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .activation0,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .loopText text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .noteText,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .note text {
  fill: #0f172a !important;
  color: #0f172a !important;
}
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .messageText {
  fill: #cbd5e1 !important;
  color: #cbd5e1 !important;
}

/* --- Class diagrams ----------------------------------------------------- */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .classLabel text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .classLabel .label {
  fill: #0f172a !important;
  color: #0f172a !important;
}

/* --- State / entity relation diagrams ----------------------------------- */
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .stateLabel text,
[data-md-color-scheme="slate"] .md-typeset .mermaid svg .er.relationshipLabel text {
  fill: #0f172a !important;
}

/* --- External image attributions --------------------------------------- */
.sdp-ext-image {
  margin: 1.5rem auto;
  text-align: center;
}
.sdp-ext-image img {
  max-width: 100%;
  height: auto;
  border-radius: 0.4rem;
  border: 1px solid var(--md-default-fg-color--lightest);
}
.sdp-ext-image figcaption {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--md-default-fg-color--light);
  font-style: italic;
}
.sdp-ext-image figcaption a {
  color: var(--md-default-fg-color--light);
  text-decoration: underline;
}
[data-md-color-scheme="slate"] .sdp-ext-image img {
  background: rgba(255,255,255,0.04);
}

/* =========================================================================
   Keyboard accessibility
   =========================================================================
   1. Skip-to-content link  (visible only on keyboard focus)
   2. Focus-visible outlines on every custom interactive element
   3. Help dialog opened with `?`
   4. Chord-armed indicator while the `g` chord is pending
   ========================================================================= */

/* ---------- 1. Skip link ------------------------------------------------- */
.sdp-skip-link {
  position: fixed;
  top: -100px;
  left: 0.75rem;
  z-index: 1000;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  padding: 0.55rem 0.95rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: top 140ms ease;
}
.sdp-skip-link:focus,
.sdp-skip-link:focus-visible {
  top: 0.75rem;
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 2px;
}
/* Don't show the dotted browser outline on the article when it receives focus
   from the skip link; keep the visual quiet while still being keyboard-usable. */
article.md-content__inner:focus,
article.md-content__inner:focus-visible {
  outline: none;
}

/* ---------- 2. Focus-visible outlines on custom controls ---------------- */
:where(
  .sdp-tabs__hint,
  .sdp-mtb__btn,
  .sdp-pg-arrow,
  .sdp-keyhelp__close
):focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-accent-fg-color) 22%, transparent);
}

/* Mermaid host gets a clear focus ring so the user knows Enter will fullscreen it. */
.md-typeset .mermaid:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 4px;
  border-radius: 0.4rem;
}

/* ---------- 3. Help dialog ---------------------------------------------- */
.sdp-keyhelp {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.sdp-keyhelp.sdp-keyhelp--open { display: flex; }
.sdp-keyhelp__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.sdp-keyhelp__panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.6rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.sdp-keyhelp__panel:focus { outline: none; }
.sdp-keyhelp__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  background: var(--md-default-fg-color--lightest);
}
.sdp-keyhelp__header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.sdp-keyhelp__close {
  background: transparent;
  border: 0;
  color: var(--md-default-fg-color--light);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 0.4rem;
  border-radius: 0.3rem;
}
.sdp-keyhelp__close:hover {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
}
.sdp-keyhelp__body {
  padding: 0.85rem 1rem 0.5rem;
  overflow-y: auto;
}
.sdp-keyhelp__group { margin-bottom: 0.85rem; }
.sdp-keyhelp__group h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-default-fg-color--light);
  font-weight: 600;
}
.sdp-keyhelp__group table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.sdp-keyhelp__group tr + tr td {
  border-top: 1px solid var(--md-default-fg-color--lightest);
}
.sdp-keyhelp__group td {
  padding: 0.4rem 0.5rem;
  vertical-align: middle;
}
.sdp-keyhelp__keys {
  width: 38%;
  white-space: nowrap;
  color: var(--md-default-fg-color--light);
}
.sdp-keyhelp kbd,
.sdp-keyhelp__keys kbd {
  display: inline-block;
  min-width: 1.4em;
  text-align: center;
  font-family: var(--md-code-font-family, ui-monospace, monospace);
  font-size: 0.78em;
  padding: 0.05em 0.45em;
  margin: 0 0.15em;
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 0.25rem;
  box-shadow: inset 0 -1px 0 var(--md-default-fg-color--lighter);
}
.sdp-keyhelp__footer {
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  background: var(--md-default-fg-color--lightest);
  font-size: 0.72rem;
  color: var(--md-default-fg-color--light);
  text-align: center;
}
body.sdp-keyhelp--lock { overflow: hidden; }

/* ---------- 4. Chord-armed indicator ------------------------------------ */
/* Tiny "g…" hint in the corner while we are waiting for the second key. */
body.sdp-chord-armed::after {
  content: "g …";
  position: fixed;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  font-family: var(--md-code-font-family, ui-monospace, monospace);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  border-radius: 0.3rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

/* Honour prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  .sdp-skip-link { transition: none; }
}

/* Hide skip link / chord indicator on print. */
@media print {
  .sdp-skip-link,
  .sdp-keyhelp { display: none !important; }
  body.sdp-chord-armed::after { display: none !important; }
}
