.soma-sidebar-github {
  margin: 1rem 1rem 1.25rem 0;
}

.soma-sidebar-github__main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--color-background-border);
  border-radius: 0.65rem;
  text-decoration: none;
  color: var(--color-foreground-primary);
  background: var(--color-background-primary);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.soma-sidebar-github__main:hover {
  border-color: var(--color-brand-primary);
  background: var(--color-background-hover);
  text-decoration: none;
}

.soma-sidebar-github__icon {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  opacity: 0.7;
}

.soma-sidebar-github__text {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  flex: 1;
  min-width: 0;
}

.soma-sidebar-github__repo-name {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soma-sidebar-github__cta {
  font-size: 0.71rem;
  font-weight: 400;
  color: var(--color-foreground-muted);
  line-height: 1.25;
}

.soma-sidebar-github__arrow {
  width: 0.65rem;
  height: 0.65rem;
  flex: 0 0 auto;
  opacity: 0.3;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.soma-sidebar-github__main:hover .soma-sidebar-github__arrow {
  opacity: 0.8;
  color: var(--color-brand-primary);
  transform: translate(1px, -1px);
}

.soma-sidebar-github__release {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 2rem;
  border: 1px solid var(--color-brand-primary);
  color: var(--color-brand-content);
  background: rgba(61, 148, 255, 0.08);
  text-decoration: none;
  white-space: nowrap;
  flex: 0 0 auto;
}

.soma-sidebar-github__release:hover {
  background: rgba(61, 148, 255, 0.18);
  text-decoration: none;
}

@media (max-width: 63em) {
  .soma-sidebar-github {
    margin-top: 0.75rem;
  }
}

/* ─── Landing page cards ──────────────────────────── */

:root {
  --soma-card-bg: color-mix(in srgb, var(--color-background-primary) 88%, var(--color-brand-primary) 12%);
  --soma-card-border: var(--color-background-border);
  --soma-card-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
}

.soma-section {
  margin: 2rem 0 1rem;
}

.soma-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.soma-card {
  display: block;
  padding: 1.15rem 1.15rem 1.25rem;
  border: 1px solid var(--soma-card-border);
  border-radius: 1rem;
  background: var(--soma-card-bg);
  box-shadow: var(--soma-card-shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.soma-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-brand-primary);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  text-decoration: none;
}

.soma-card h3 {
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 1.05rem;
}

.soma-card p {
  margin: 0;
  color: var(--color-foreground-muted);
  line-height: 1.55;
}

@media (max-width: 63em) {
  .soma-card-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Diagram figures ──────────────────────────────── */

/*
 * The reused talk diagrams are drawn on white. Wrap them in a light card so they
 * stay legible in both light and dark themes (a transparent SVG on the dark
 * content background would float washed-out gray boxes). `figclass: soma-figure`
 * on a `.. figure::` directive lands this class on the <figure> element.
 */
figure.soma-figure {
  margin: 1.75rem auto;
  padding: 1.25rem 1.25rem 1rem;
  background: #ffffff;
  border: 1px solid var(--color-background-border);
  border-radius: 0.9rem;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
  text-align: center;
}

figure.soma-figure img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

/* Hero on the landing page: a touch more presence, capped so it never sprawls. */
figure.soma-figure.soma-hero {
  max-width: 620px;
  margin-top: 1.25rem;
}

figure.soma-figure > figcaption {
  margin-top: 0.85rem;
  padding: 0;
  color: var(--color-foreground-muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

figure.soma-figure > figcaption p {
  margin: 0;
}

/* ─── API class / function blocks ──────────────────── */

/*
 * Furo sets text-indent: -35px on dt.sig, so the "class" / "def" keyword
 * hangs left relative to the content box by (padding-left - 35px).
 * We set padding-left: 2.5rem (40px) → keyword lands 5 px inside dt, 8 px
 * inside the card border-box, so overflow:hidden no longer clips it and we
 * get properly clipped rounded corners on the header strip for free.
 */
dl.py.class,
dl.py.function {
  border: 1px solid var(--color-background-border);
  border-left: 3px solid var(--color-brand-primary);
  border-radius: 0.5rem;
  background: var(--color-background-secondary);
  margin: 1.75rem 0;
  padding: 0;
  overflow: hidden;
}

/* Signature header: tinted strip clipped by card's overflow:hidden */
dl.py.class > dt.sig,
dl.py.function > dt.sig {
  background: var(--color-background-hover);
  border-bottom: 1px solid var(--color-background-border);
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  margin: 0;
}

/* Docstring body */
dl.py.class > dd,
dl.py.function > dd {
  padding: 0.75rem 1.25rem;
  margin: 0;
}

/* Nested methods / attributes: left-rule, no card */
dl.py.class > dd > dl.py {
  border: none;
  border-left: 2px solid var(--color-background-border);
  background: transparent;
  margin: 0.75rem 0;
  padding: 0 0 0 0.875rem;
}

dl.py.class > dd > dl.py > dt.sig {
  background: transparent;
  border-bottom: none;
  padding: 0.2rem 0;
  margin: 0;
}

dl.py.class > dd > dl.py > dd {
  padding: 0.25rem 0;
  margin: 0;
}
