/* Phase IX-C — architecture corpus usability refinements */
@media (min-width: 1051px) {
  .toc-inner {
    max-height: calc(100vh - 128px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 8px;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
  }

  .toc-inner::-webkit-scrollbar {
    width: 7px;
  }

  .toc-inner::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 999px;
  }

  .toc-inner::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
  }
}

/* Recovered architecture diagrams are source-preserved text geometry. Fenced
   blocks must retain every space and line break and use a glyph-complete
   monospace stack so box-drawing characters and arrows remain aligned. */
.prose pre.source-diagram {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  tab-size: 4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.38;
  font-variant-ligatures: none;
  letter-spacing: 0;
  text-rendering: geometricPrecision;
  overscroll-behavior-x: contain;
}

.prose pre.source-diagram code {
  display: block;
  min-width: max-content;
  font: inherit;
  white-space: inherit;
  color: inherit;
  background: transparent;
}

/* Recovered architecture sources also use a compact LaTeX-style display
   notation. The renderer converts the supported operators to readable Unicode
   while this presentation preserves multiline formula structure and prevents
   long expressions from wrapping into ambiguous prose. */
.prose .source-formula {
  margin: 24px 0;
  padding: 14px 18px;
  overflow-x: auto;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  overscroll-behavior-x: contain;
}

.prose .source-formula code {
  display: inline-block;
  min-width: max-content;
  max-width: none;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre;
  text-align: left;
  letter-spacing: 0;
  font-variant-ligatures: none;
}

.prose .source-formula sub {
  font-size: .72em;
  line-height: 0;
}

/* Pipe tables in recovered architecture Markdown are semantic source content,
   not ASCII diagrams. Preserve their row/column structure as real HTML tables
   and allow narrow viewports to scroll without crushing the question/result
   columns into unreadable fragments. */
.prose .source-table-wrap {
  margin: 24px 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.prose table.source-table {
  width: 100%;
  min-width: 760px;
  margin: 0;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}

.prose table.source-table th,
.prose table.source-table td {
  padding: 11px 14px;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.prose table.source-table th:last-child,
.prose table.source-table td:last-child {
  border-right: 0;
}

.prose table.source-table tbody tr:last-child td {
  border-bottom: 0;
}

.prose table.source-table th {
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.prose table.source-table td {
  color: var(--muted);
}

.prose table.source-table td strong {
  color: var(--text);
}

.footer-brand {
  max-width: 520px;
}

.footer-wordmark {
  display: block;
  width: 112px;
  min-width: 112px;
  height: auto;
  aspect-ratio: 1233 / 164;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
  opacity: .98;
}

html[data-theme="light"] .footer-wordmark {
  filter: none;
}

.footer-tagline {
  margin: 12px 0 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--muted);
}

.footer-break {
  display: block;
  content: "";
  margin-top: 12px;
}

.footer-copyright {
  margin: 0;
  max-width: 520px;
  font-size: 10px;
  line-height: 1.55;
  letter-spacing: .025em;
  color: var(--muted);
}

@media (max-width: 760px) {
  .footer-wordmark {
    width: 92px;
    min-width: 92px;
  }

  .footer-copyright {
    font-size: 10px;
  }

  .prose pre.source-diagram {
    font-size: 12px;
  }

  .prose .source-formula {
    padding: 12px 14px;
  }

  .prose .source-formula code {
    font-size: 13px;
  }

  .prose table.source-table {
    min-width: 680px;
    font-size: 12px;
  }

  .prose table.source-table th,
  .prose table.source-table td {
    padding: 10px 12px;
  }
}
