#topic-page[hidden] { display: none; }

#topic-page {
  --hub-ink: oklch(26.15% 0.06478 299.01);
  --hub-muted: oklch(46.59% 0.03795 300.83);
  --hub-accent: oklch(40.62% 0.12797 303.01);
  --hub-tint: oklch(95.83% 0.01875 309.80);
  --hub-border: oklch(88.13% 0.03752 306.38);
  --hub-highlight: oklch(85.27% 0.08659 301.09);
  --hub-banner-end: oklch(35.65% 0.07492 258.98);
  --preview-spring: cubic-bezier(.34, 1.56, .64, 1);
  display: grid;
  gap: clamp(14px, 2vw, 22px);
  padding-block-end: 12px;
  color: var(--hub-ink);
}

#topic-page[data-topic="list"] {
  --hub-accent: oklch(45.04% 0.07828 165.71);
  --hub-tint: oklch(96.9% 0.01482 158.25);
  --hub-border: oklch(90.17% 0.03004 157.85);
  --hub-highlight: oklch(87.85% 0.08087 175.12);
  --hub-banner-end: oklch(37.79% 0.05437 189.72);
}

#topic-page[data-topic="stack"] {
  --hub-accent: oklch(47.77% 0.10704 0.38);
  --hub-tint: oklch(96.64% 0.01650 26.65);
  --hub-border: oklch(89.76% 0.03171 357.89);
  --hub-highlight: oklch(87.32% 0.07645 354.70);
  --hub-banner-end: oklch(37.47% 0.06415 322.32);
}

#topic-page[data-topic="queue"] {
  --hub-accent: oklch(46.29% 0.06677 209.23);
  --hub-tint: oklch(97.12% 0.01171 203.47);
  --hub-border: oklch(90.38% 0.02779 205.10);
  --hub-highlight: oklch(88.71% 0.07140 197.04);
  --hub-banner-end: oklch(39.08% 0.05694 221.81);
}

#topic-page .topic-back {
  justify-self: start;
  display: inline-grid;
  align-items: center;
  min-height: 34px;
  margin-block-end: calc(-1 * clamp(12px, 1.4vw, 18px));
  color: var(--hub-accent);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

#topic-page .topic-back:hover { text-decoration: underline; }

.topic-hub-intro {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 42%);
  gap: 8px clamp(8px, 2vw, 18px);
  padding: 11px clamp(12px, 1.5vw, 16px);
  border: 1px solid oklch(36.34% 0.08847 297.82);
  border-radius: 16px;
  background: linear-gradient(108deg, oklch(23.69% 0.05659 295.60) 8%, oklch(32.52% 0.11079 294.02) 52%, var(--hub-banner-end));
  color: oklch(100% 0 0);
}

.topic-hub-intro::before {
  position: absolute;
  z-index: -1;
  inset: 0 0 0 37%;
  border-radius: inherit;
  background: radial-gradient(circle, var(--hub-highlight) 1px, transparent 1px) 0 0 / 16px 16px;
  mask-image: linear-gradient(to right, transparent, oklch(0% 0 0));
  opacity: .25;
  pointer-events: none;
  content: '';
}

.topic-hub-intro h1 {
  margin: 0;
  font-size: clamp(27px, 3vw, 42px);
  font-weight: 780;
  line-height: 1.05;
  letter-spacing: -.04em;
}

.topic-hub-intro p {
  max-width: 52ch;
  margin: 4px 0 0;
  color: oklch(93.84% 0.02387 304.48);
  font-size: clamp(14px, 1.35vw, 16px);
  line-height: 1.45;
}

.topic-intro-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-block-start: 6px;
}

#topic-page .topic-intro-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.2;
  text-decoration: none;
}

#topic-page .topic-intro-links a[data-watch-example] {
  background: oklch(100% 0 0);
  color: var(--hub-accent);
  box-shadow: 0 4px 12px oklch(20.76% 0.05773 294.69 / 0.2078);
}

#topic-page .topic-intro-links a[data-watch-example]:hover { background: var(--hub-tint); }

.topic-hub-copy { min-width: 0; }
#topic-hub-preview {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-width: 0;
}

body.dashboard #topic-hub-preview .topic-stage {
  height: clamp(112px, 10vw, 120px);
  padding: 10px 11px;
  overflow: hidden;
}

body.dashboard #topic-hub-preview .topic-stage figcaption { padding-inline-end: 86px; }
body.dashboard #topic-hub-preview .topic-art { padding-top: 0; }

#topic-hub-motion {
  position: absolute;
  z-index: 2;
  inset-block-start: 5px;
  inset-inline-end: 5px;
  min-height: 35px;
  padding: 3px 7px;
  border: 1px solid oklch(87.7% 0.06802 296.19 / 0.2314);
  border-radius: 7px;
  background: oklch(26.74% 0.04448 281.11 / 0.902);
  color: oklch(100% 0 0);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
}

#topic-hub-motion:hover { background: oklch(33.31% 0.04556 283.65); }

.topic-section h2 {
  margin: 0 0 9px;
  font-size: clamp(19px, 2.25vw, 27px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -.022em;
  scroll-margin-block-start: 14px;
}

.topic-section.topic-problems {
  padding-block-start: 13px;
  border-top: 1px solid oklch(92.88% 0.01262 255.51);
}

.topic-problems h2 { color: var(--hub-accent); }

.topic-lesson-grid,
.topic-problems .problem-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(8px, 1.2vw, 14px);
}

.topic-lesson-grid { align-items: start; }

.topic-lesson-card,
.topic-problems .problem-card {
  min-width: 0;
  border: 1px solid oklch(92.88% 0.01262 255.51);
  border-radius: 12px;
  background: oklch(100% 0 0);
  color: inherit;
  text-decoration: none;
}

:is(a, article).topic-lesson-card,
.topic-lesson-card > summary {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 88px;
  padding: 11px 13px;
}

.topic-lesson-card > summary {
  position: relative;
  padding-inline-end: 35px;
  border-radius: 11px;
  list-style: none;
  cursor: pointer;
}

.topic-lesson-card > summary::-webkit-details-marker { display: none; }

.topic-lesson-card > summary::after {
  position: absolute;
  inset-block-start: 16px;
  inset-inline-end: 14px;
  width: 7px;
  height: 7px;
  border: solid var(--hub-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  content: '';
}

.topic-lesson-card[open] > summary { min-height: 0; }
.topic-lesson-card[open] > summary::after { transform: rotate(225deg); }

.topic-lesson-card.basic-operations {
  border-color: var(--hub-border);
  background: var(--hub-tint);
}

.topic-lesson-card :is(h3, .topic-lesson-title),
.topic-problems .problem-card h3 {
  margin: 0;
  font-size: clamp(16px, 1.45vw, 19px);
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -.015em;
  overflow-wrap: anywhere;
}

.topic-lesson-card :is(p, .topic-lesson-description),
.topic-problems .problem-card p {
  margin: 4px 0 0;
  color: var(--hub-muted);
  font-size: 13px;
  line-height: 1.4;
}

.topic-lesson-action {
  margin-top: auto;
  padding-top: 5px;
  color: var(--hub-accent);
  font-size: 12px;
  font-weight: 700;
}

a.topic-lesson-card:hover .topic-lesson-action,
.topic-lesson-card ul a:hover { text-decoration: underline; }

.topic-lesson-card > summary:hover { background: var(--hub-tint); }

.topic-lesson-card ul {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-lesson-card > ul { padding: 0 8px 8px; }

.topic-operation-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 6px;
  padding: 0 8px 8px;
}

.topic-operation-links h4 {
  margin: 0 0 4px 3px;
  color: var(--hub-accent);
  font-size: 12px;
}

.topic-lesson-card ul a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 5px 7px;
  border: 1px solid var(--hub-border);
  border-radius: 6px;
  background: oklch(100% 0 0);
  color: var(--hub-accent);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.topic-problems .problem-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 110px;
  padding: 10px 12px;
  color: oklch(20.77% 0.03982 265.75);
}

.topic-problems .problem-card p { color: oklch(50.96% 0.03621 257.28); }

.topic-problems a.problem-card:hover { border-color: var(--hub-accent); }
.problem-card-action { margin-top: auto; padding-top: 8px; color: var(--hub-accent); font-size: 12px; font-weight: 700; }
.topic-problems a.problem-card:hover .problem-card-action { text-decoration: underline; }

.topic-problems .problem-card :is(.tag-easy, .tag-medium, .tag-hard) {
  margin-bottom: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.5;
}

.topic-problems .tag-easy { background: oklch(96.24% 0.04338 156.74); color: oklch(44.79% 0.10832 151.33); }
.topic-problems .tag-medium { background: oklch(94.51% 0.12430 101.54); color: oklch(47.62% 0.10337 61.91); }
.topic-problems .tag-hard { background: oklch(93.56% 0.03090 17.72); color: oklch(44.37% 0.16132 26.90); }

#topic-page small {
  margin-top: auto;
  padding-top: 6px;
  color: oklch(50.96% 0.03621 257.28);
  font-size: 11px;
  font-weight: 650;
}

.topic-next-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 9px;
  padding-block-start: 9px;
  border-top: 1px solid oklch(92.88% 0.01262 255.51);
}

.topic-next-links > :is(span,strong) { color: var(--hub-muted); font-size: 13px; font-weight: 650; }
.topic-next-links > div { display: contents; }

#topic-page .topic-next-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 3px 9px;
  border: 1px solid var(--hub-border);
  border-radius: 8px;
  background: oklch(100% 0 0);
  color: var(--hub-accent);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

#topic-page .topic-next-links a:hover { background: var(--hub-tint); }

#topic-page :is(a, button, summary):focus-visible {
  outline: 2px solid var(--hub-accent);
  outline-offset: 3px;
}

#topic-page .topic-hub-intro :is(a, button):focus-visible,
#topic-page .topic-hub-intro h1:focus-visible { outline-color: var(--hub-highlight); }

@media (min-width: 380px) {
  .topic-problems .problem-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 620px) {
  .topic-lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 680px) {
  .topic-hub-intro {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 34%);
  }
}

@media (max-width: 679px) {
  body.dashboard #topic-hub-preview .topic-stage { padding-inline: 7px; }
  body.dashboard #topic-hub-preview .topic-stage figcaption { padding-inline-end: 22px; }
  #topic-hub-motion {
    min-height: 24px;
    min-width: 24px;
    padding: 0;
    font-size: 0;
  }
  #topic-hub-motion::before { content: 'Ⅱ' / ''; font-size: 13px; }
  .topic-animations-paused #topic-hub-motion::before { content: '▶' / ''; font-size: 10px; }
}

@media (min-width: 1000px) {
  .topic-lesson-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topic-problems .problem-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.dashboard.topic-hub[data-hosted-badge] #main { padding-bottom: 72px; }
}

@media (max-width: 619px) {
  :is(a, article).topic-lesson-card,
  .topic-lesson-card > summary { min-height: 0; }
  .topic-lesson-card ul a { min-height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .topic-lesson-grid > *,
  .topic-problems .problem-grid > * {
    animation: topic-card-enter .26s ease-out backwards;
    animation-delay: calc(var(--entry-order, 0) * 32ms);
  }

  .topic-lesson-grid > :nth-child(2n), .topic-problems .problem-grid > :nth-child(2n) { --entry-order: 1; }
  .topic-lesson-grid > :nth-child(3n), .topic-problems .problem-grid > :nth-child(3n) { --entry-order: 2; }

  .topic-lesson-card[open] > :not(summary) { animation: topic-card-enter .2s ease-out; }
  .topic-lesson-card > summary::after { transition: transform .2s ease; }
}

@keyframes topic-card-enter {
  from { opacity: .82; translate: 0 5px; }
  to { opacity: 1; translate: 0 0; }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  :is(a, details).topic-lesson-card,
  .topic-problems a.problem-card,
  #topic-page .topic-next-links a {
    transition: transform .24s var(--preview-spring), box-shadow .2s ease, border-color .2s ease;
  }

  :is(a, details:not([open])).topic-lesson-card:hover,
  .topic-problems a.problem-card:hover,
  #topic-page .topic-next-links a:hover {
    transform: translateY(-2px);
    border-color: var(--hub-border);
    box-shadow: 0 5px 14px oklch(25.6% 0.07288 294.53 / 0.0706);
  }
}

@media (prefers-reduced-motion: reduce) {
  #topic-hub-motion { display: none; }
}

.topic-problems .problem-badges {
  display:flex; flex-wrap:wrap; align-items:center; gap:4px 6px; margin-bottom:6px;
}
.topic-problems .problem-badges :is(.tag-easy,.tag-medium,.tag-hard) {
  margin:0;
}
.topic-problems .problem-pattern {
  border:1px solid oklch(86.99% 0.06222 274.04); border-radius:999px; background:oklch(96.19% 0.01793 272.31); color:oklch(39.84% 0.17734 277.37);
  padding:1px 6px; font-size:11px; font-weight:650; line-height:1.4;
}

#topic-page[data-topic] {
  --hub-card-surface: #fff;
  --hub-card-ink: #17253d;
  --hub-card-muted: #465670;
  --hub-card-edge: #e2e7ee;
  --hub-card-shadow: 0 1px 2px rgb(24 36 60 / .04), 0 5px 16px -8px rgb(24 36 60 / .18);
  --art-ink: #243652;
  --art-guide: #9aabc2;
}

:root[data-theme="dark"] #topic-page[data-topic] {
  --hub-card-surface: var(--aura-rail);
  --hub-card-ink: var(--aura-text);
  --hub-card-muted: var(--aura-muted);
  --hub-card-edge: var(--aura-hairline);
  --hub-card-shadow: 0 1px 2px rgb(0 0 0 / .16), 0 6px 16px -9px rgb(0 0 0 / .38);
  --art-ink: #b7c9df;
  --art-guide: #7c8da5;
}

#topic-page[data-topic] :is(.topic-lesson-card, .problem-card) {
  border-color: var(--hub-card-edge);
  background: var(--hub-card-surface);
  box-shadow: var(--hub-card-shadow);
  color: var(--hub-card-ink);
}

:root[data-theme="dark"] #topic-page[data-topic] .topic-lesson-card.basic-operations {
  background: var(--hub-card-surface);
}

.topic-card-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

.topic-card-copy > :is(.topic-lesson-title, .topic-lesson-description, .topic-lesson-action) {
  display: block;
}

#topic-page[data-topic] :is(a.topic-lesson-card, .topic-lesson-card > summary, .topic-problem-body) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(76px, 7.6vw, 102px);
  align-items: center;
  gap: clamp(6px, 1vw, 13px);
}

#topic-page[data-topic] :is(a.topic-lesson-card, .topic-lesson-card:not([open]) > summary) {
  min-height: 90px;
}

#topic-page[data-topic] .topic-lesson-grid:not(:has(details[open])) {
  align-items: stretch;
}

#topic-page[data-topic] .topic-lesson-card:not([open]) > summary {
  height: 100%;
}

#topic-page[data-topic] .topic-lesson-card > summary:hover {
  background: transparent;
}

#topic-page[data-topic] .topic-card-copy :is(p, .topic-lesson-description) {
  color: var(--hub-card-muted);
}

#topic-page[data-topic] .problem-card {
  min-height: 136px;
  padding: 12px 13px;
}

.topic-problem-body { width: 100%; }

#topic-page[data-topic] .problem-badges :is(.tag-easy, .tag-medium, .tag-hard, .problem-pattern) {
  border: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 21%, transparent);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  line-height: 1.45;
}

#topic-page[data-topic] .problem-badges .tag-easy {
  background: rgb(37 186 117 / .12);
  color: #116443;
}

#topic-page[data-topic] .problem-badges .tag-medium {
  background: rgb(234 175 38 / .19);
  color: #77450b;
}

#topic-page[data-topic] .problem-badges .tag-hard {
  background: rgb(228 81 104 / .13);
  color: #9c2340;
}

#topic-page[data-topic] .problem-badges .problem-pattern {
  background: rgb(102 110 235 / .11);
  color: #38378b;
}

:root[data-theme="dark"] #topic-page[data-topic] .problem-badges .tag-easy { color: var(--aura-mint); }
:root[data-theme="dark"] #topic-page[data-topic] .problem-badges .tag-medium { color: var(--aura-amber); }
:root[data-theme="dark"] #topic-page[data-topic] .problem-badges .tag-hard { color: var(--aura-rose); }
:root[data-theme="dark"] #topic-page[data-topic] .problem-badges .problem-pattern { color: var(--aura-violet); }

.topic-card-art {
  display: block;
  width: 100%;
  height: auto;
  align-self: center;
  pointer-events: none;
}

.topic-card-art .art-tile {
  fill: var(--art-fill, #edf2fb);
  stroke: #314465;
  stroke-width: 1;
  stroke-linejoin: round;
}

.topic-card-art .art-blue { --art-fill: #8cbbfc; }
.topic-card-art .art-violet { --art-fill: #c0aafd; }
.topic-card-art .art-mint { --art-fill: #79dfba; }
.topic-card-art .art-amber { --art-fill: #ffcc78; }
.topic-card-art .art-red { --art-fill: #f591a0; }
.topic-card-art .art-pale { --art-fill: #f2f5fd; }
.topic-card-art .art-skin { --art-fill: #f4bd9e; }
.topic-card-art .art-side { filter: brightness(.83); }
.topic-card-art :is(.art-port, .art-solid) { fill: #253851; }

.topic-card-art text {
  fill: #182a47;
  font: 700 8.5px ui-monospace, monospace;
  dominant-baseline: central;
  text-anchor: middle;
}

.topic-card-art .art-label { fill: var(--art-ink); font-size: 7.4px; }

.topic-card-art :is(.art-guide, .art-line) {
  fill: none;
  stroke: var(--art-ink);
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topic-card-art .art-divider { stroke: #314465; stroke-width: 1; }
.topic-card-art .art-guide { stroke: var(--art-guide); stroke-width: 1; }
.topic-card-art .art-line-violet { stroke: #9261da; }
.topic-card-art .art-line-mint { stroke: #23876f; }
.topic-card-art .art-line-blue { stroke: #3979c7; }
.topic-card-art .art-line-red { stroke: #c84a63; }

@media (max-width: 539px) {
  #topic-page[data-topic] .problem-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  #topic-page .problem-card:is(:hover, :focus-visible) .art-flow {
    animation: topic-art-trace .72s ease-out;
  }

  .art-swap-left { --art-travel: 66px; --art-lift: -13px; }
  .art-swap-right { --art-travel: -66px; --art-lift: 13px; }
  #topic-page .problem-card:is(:hover, :focus-visible) :is(.art-swap-left, .art-swap-right) {
    animation: topic-art-swap .7s cubic-bezier(.35,.82,.32,1) both;
  }
}

@keyframes topic-art-trace {
  from { stroke-dasharray: 100; stroke-dashoffset: 100; }
  to { stroke-dasharray: 100; stroke-dashoffset: 0; }
}

@keyframes topic-art-swap {
  20% { translate: 0 var(--art-lift); }
  75% { translate: var(--art-travel) var(--art-lift); }
  100% { translate: var(--art-travel) 0; }
}

#topic-page .topic-related-problem {
  margin: 12px 0 0;
  color: var(--hub-card-muted);
  font-size: 13px;
}
#topic-page .topic-related-problem a {
  color: var(--hub-accent);
  font-weight: 700;
}

.topic-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 12px;
  margin-block-end: 9px;
}
.topic-section .topic-section-heading h2 { margin: 0; }
#topic-page [data-complexity-topic] {
  min-height: 34px;
  padding: 5px 9px;
  border-color: var(--hub-card-edge);
  background: var(--hub-card-surface);
  color: var(--hub-accent);
  font-size: 12px;
}
.topic-applications {
  padding-block-start: 13px;
  border-top: 1px solid var(--hub-card-edge);
}
.topic-application-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(8px, 1.2vw, 14px);
}
.topic-application-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-content: start;
  gap: 6px 10px;
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid var(--hub-card-edge);
  border-radius: 12px;
  color: var(--hub-card-ink);
  background: var(--hub-card-surface);
  box-shadow: var(--hub-card-shadow);
}
.topic-application-card h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.topic-application-card p { margin: 4px 0 0; color: var(--hub-card-muted); font-size: 13px; line-height: 1.45; }
@media (min-width: 760px) {
  .topic-application-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#complexity-reference { width: min(900px, 94vw); max-width: 94vw; }
.complexity-cases { display: flex; gap: 6px; flex-wrap: wrap; }
#complexity-reference #complexity-case-note { margin: 8px 0 12px; }
#complexity-reference .complexity-cases [aria-pressed="true"] {
  background: var(--theme-focus);
  border-color: var(--theme-focus);
  color: #fff;
}
:root[data-theme="dark"] #complexity-reference .complexity-cases [aria-pressed="true"] { color: #17122b; }
.complexity-reference-scroll {
  overflow: auto;
  max-height: min(55dvh, 540px);
  border: 1px solid var(--aura-hairline, #dcd5ea);
  border-radius: 9px;
}
.complexity-reference-scroll table { width: 100%; min-width: 515px; border-collapse: collapse; }
.complexity-reference-scroll caption { padding: 8px 10px; text-align: left; }
.complexity-reference-scroll :is(th, td) {
  padding: 8px 10px;
  border-top: 1px solid var(--aura-hairline, #dcd5ea);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.45;
}
.complexity-reference-scroll thead th { position: sticky; z-index: 1; top: 0; background: var(--aura-raised, #f5f0fa); }
.complexity-reference-scroll tbody th { min-width: 130px; }
.complexity-reference-scroll tbody a { color: var(--theme-focus); }
.complexity-reference-scroll td:nth-child(2) { white-space: nowrap; }

#complexity-guide[hidden] { display: none; }
#complexity-guide {
  --guide-paper: #fff;
  --guide-muted: #435370;
  --guide-line: #dfe5ed;
  --guide-quiet: #f4f7fb;
  --guide-accent: #4d3683;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
:root[data-theme="dark"] #complexity-guide {
  --guide-paper: var(--aura-rail);
  --guide-muted: var(--aura-muted);
  --guide-line: var(--aura-hairline);
  --guide-quiet: var(--aura-raised);
  --guide-accent: var(--aura-violet);
}
#complexity-guide :is(h1,h2,h3,p,dl) { margin: 0; }
#complexity-guide p { max-width: 86ch; color: var(--guide-muted); line-height: 1.55; }
#complexity-guide h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.15; letter-spacing: -.035em; }
#complexity-guide h2 { font-size: clamp(20px, 2.35vw, 28px); line-height: 1.25; }
#complexity-guide h3 { font-size: 16px; }
.complexity-back { justify-self: start; color: var(--guide-accent); font-size: 14px; font-weight: 650; }
.complexity-guide-intro { display: grid; gap: 6px; }
.complexity-paper {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: clamp(12px, 2.4vw, 26px);
  border: 1px solid var(--guide-line);
  border-radius: 14px;
  background: var(--guide-paper);
}
.complexity-paper :is(code, var) { color: var(--guide-accent); }
.complexity-paper code { font-weight: 650; }
.complexity-notation,
.complexity-case-definitions,
.complexity-growth,
.complexity-matrix-notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 8px;
}
.complexity-paper dl > div {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--guide-line);
  border-radius: 9px;
  background: var(--guide-quiet);
}
.complexity-paper dt { font-size: 14px; font-weight: 700; }
.complexity-notation dt code { margin-inline-end: 5px; }
.complexity-paper dd { margin: 4px 0 0; color: var(--guide-muted); font-size: 13px; line-height: 1.45; }
#complexity-guide .complexity-explanation { font-size: 13px; }
.complexity-matrix-scroll {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--guide-line);
  border-radius: 9px;
}
.complexity-matrix {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}
.complexity-matrix caption { padding: 9px 10px; text-align: left; color: var(--guide-muted); }
.complexity-matrix :is(th, td) { border-top: 1px solid var(--guide-line); text-align: left; vertical-align: top; padding: 8px 10px; }
.complexity-matrix :is(thead, .complexity-matrix-group) { background: var(--guide-quiet); }
.complexity-matrix .complexity-matrix-group th { font-size: 12px; color: var(--guide-accent); }
.complexity-matrix tbody th[scope="row"] { width: 36%; min-width: 180px; }
.complexity-matrix tbody th small { display: block; color: var(--guide-muted); font-size: 12px; font-weight: 420; }
.complexity-matrix td code {
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--guide-quiet);
  white-space: nowrap;
}
.complexity-demo-link { justify-self: start; }
.complexity-demo-link .button { max-width: 100%; white-space: normal; }
.complexity-scroll-hint { display: none; }
@media (max-width: 830px) {
  #complexity-guide .complexity-scroll-hint { display: block; font-size: 12px; }
}
