/* Human Design knowledge base — layout, prose, and diagram styles.
   Built on the brand tokens from style.css (--accent, --text, --surface, …). */

.docs-body {
  background: var(--bg);
  color: var(--text);
}

/* ---------- Docs header (KB title left, single CTA right) ---------- */
.docs-header .container {
  max-width: 1280px; /* align the logo with the docs content left edge */
}

.docs-header-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding-left: 0.85rem;
  border-left: 1px solid var(--border-strong);
  line-height: 1.1;
}

.docs-header-title:hover {
  color: var(--accent);
}

.docs-header-cta {
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
  /* Compact header button — override the large homepage .btn-primary sizing.
     The key fix: .btn-primary sets min-height:44px which (with inline-block)
     pushed empty space below the text. Center it in a flex box instead. */
  display: inline-flex;
  align-items: center;
  min-height: 0;
  padding: 0.55rem 1.05rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  line-height: 1.1;
}

@media (max-width: 640px) {
  .docs-header-title {
    display: none;
  }
  .docs-header-cta {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }
}

.docs-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.docs-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 200px;
  gap: 2.5rem;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.docs-sidebar {
  position: sticky;
  top: 1.25rem;
  align-self: start;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding: 1.5rem 0.5rem 2rem 0;
  font-size: 0.9rem;
}

.docs-search {
  position: relative;
  margin-bottom: 1.25rem;
}

.docs-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.docs-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.docs-search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--card-shadow-hover);
}

.docs-search-results a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

.docs-search-results a:last-child {
  border-bottom: none;
}

.docs-search-results a:hover,
.docs-search-results a.active {
  background: var(--accent-soft);
}

.docs-search-results .sr-title {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
}

.docs-search-results .sr-section {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.docs-search-empty {
  padding: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.docs-nav-home {
  display: block;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.docs-nav-home:hover {
  background: var(--accent-soft);
}

.docs-nav-home.aria-current,
.docs-nav-home[aria-current] {
  color: var(--accent);
}

.docs-nav-section {
  border: none;
  margin-bottom: 0.15rem;
}

.docs-nav-section > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.docs-nav-section > summary::-webkit-details-marker {
  display: none;
}

.docs-nav-section > summary::before {
  content: "▸";
  font-size: 0.7rem;
  transition: transform 0.15s;
}

.docs-nav-section[open] > summary::before {
  transform: rotate(90deg);
}

.docs-nav-section > summary:hover {
  color: var(--text);
}

.docs-nav-section ul {
  list-style: none;
  margin: 0.1rem 0 0.5rem;
  padding: 0 0 0 0.85rem;
  border-left: 1px solid var(--border);
  margin-left: 0.65rem;
}

.docs-nav-section li a {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-mid);
  font-size: 0.85rem;
  line-height: 1.35;
}

.docs-nav-section li a:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.docs-nav-section li a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Main column ---------- */
.docs-main {
  min-width: 0;
  padding: 1.75rem 0 4rem;
}

.docs-crumb {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.docs-crumb a {
  color: var(--text-soft);
  text-decoration: none;
}

.docs-crumb a:hover {
  color: var(--accent);
}

.docs-crumb .sep {
  color: var(--border-strong);
}

.docs-article > h1 {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  color: var(--text);
}

/* ---------- Admonition ---------- */
.docs-admonition {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin: 0 0 2rem;
}

.docs-admonition .adm-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 2px;
}

.docs-admonition p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-mid);
}

.docs-admonition a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.docs-admonition a:hover {
  text-decoration: underline;
}

/* ---------- Prose ---------- */
.docs-prose {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-mid);
}

.docs-prose > *:first-child {
  margin-top: 0;
}

.docs-prose h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 1.5rem;
}

.docs-prose h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 1.5rem;
}

.docs-prose h4 {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.5rem 0 0.5rem;
}

.docs-prose p {
  margin: 0 0 1.1rem;
}

.docs-prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.docs-prose a:hover {
  border-bottom-color: var(--accent);
}

.docs-prose strong {
  color: var(--text);
  font-weight: 600;
}

.docs-prose ul,
.docs-prose ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
}

.docs-prose li {
  margin-bottom: 0.4rem;
}

.docs-prose li::marker {
  color: var(--accent);
}

.docs-prose blockquote {
  margin: 1.5rem 0;
  padding: 0.6rem 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  border-radius: 0 8px 8px 0;
  color: var(--text-mid);
  font-style: italic;
}

.docs-prose code {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

.docs-prose pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 0 0 1.2rem;
}

.docs-prose pre code {
  background: none;
  border: none;
  padding: 0;
}

.docs-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.5rem;
  font-size: 0.92rem;
}

.docs-prose th,
.docs-prose td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  vertical-align: top;
}

.docs-prose th {
  background: var(--bg-alt);
  font-weight: 600;
  color: var(--text);
}

.docs-prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.docs-prose .headerlink {
  opacity: 0;
  margin-left: 0.4rem;
  font-weight: 400;
  border: none;
  color: var(--text-soft);
  text-decoration: none;
}

.docs-prose h2:hover .headerlink,
.docs-prose h3:hover .headerlink {
  opacity: 1;
}

/* Markdown 'admonition' extension blocks (!!! note) */
.docs-prose .admonition {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface);
  padding: 0.85rem 1.1rem;
  margin: 0 0 1.3rem;
}

.docs-prose .admonition-title {
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.docs-prose .admonition > *:last-child {
  margin-bottom: 0;
}

/* Key-fact callout grid authors can use: a <div class="hd-keyfacts"> of dt/dd */
.docs-prose .hd-keyfacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.75rem;
  padding: 0;
}

.docs-prose .hd-keyfact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 0.95rem;
}

.docs-prose .hd-keyfact .k {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-bottom: 0.2rem;
}

.docs-prose .hd-keyfact .v {
  display: block;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
}

/* ---------- Figures / diagrams ---------- */
.hd-figure {
  margin: 1.75rem auto;
  text-align: center;
}

.hd-figure svg {
  max-width: 100%;
  height: auto;
}

.hd-figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.5;
}

.hd-hexagram svg {
  width: 64px;
}

.hd-channel svg {
  width: 320px;
}

/* Real bodygraph (assets/bodygraph.svg painted by Bodygraph.js) */
.hd-bodygraph-canvas {
  position: relative;
  width: 260px;
  max-width: 100%;
  margin: 0 auto;
  min-height: 60px;
}

/* Brand mark, bottom-right (added by docs-bodygraph.js after paint). */
.hd-bg-mark {
  position: absolute;
  right: 4px;
  bottom: 4px;
  pointer-events: none;
}
.hd-bg-mark-icon {
  line-height: 0;
}
.hd-bg-mark-icon svg {
  display: block;
}
.hd-bg-mark-text {
  line-height: 1;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-mid);
}

.hd-bodygraph-canvas svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Labeled bodygraphs (center names) need more room than the plain ones. */
.hd-bodygraph-canvas[data-labels] {
  width: 380px;
}

.bg-name {
  fill: var(--text-mid);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 26px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}

/* Clear arrow (line + head) pointing at each center — matches the label grey. */
.bg-name-arrow {
  stroke: var(--text-mid);
  stroke-width: 1.5;
}

.bg-name-arrowhead {
  fill: var(--text-mid);
}

.hd-bg-label {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

/* Example bodygraph carousel */
.hd-carousel {
  max-width: 420px;
}

.hd-carousel-viewport {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hd-carousel-track {
  flex: 1;
  min-width: 0;
}

.hd-carousel-slide .hd-bodygraph-canvas {
  width: 240px;
}

.hd-carousel-meta {
  margin-top: 0.75rem;
  text-align: center;
}

.hd-carousel-type {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.hd-carousel-sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.45;
}

.hd-carousel-birth {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.4;
}

.hd-carousel-nav {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.hd-carousel-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hd-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.hd-carousel-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.15s;
}

.hd-carousel-dot.active {
  background: var(--accent);
}

/* Hexagram */
.hx-line {
  fill: var(--accent);
}

/* Channel diagram */
.ch-bar {
  stroke: var(--border-strong);
  stroke-width: 8;
  stroke-linecap: round;
}

.ch-node circle {
  fill: color-mix(in srgb, var(--accent) 18%, var(--surface));
  stroke: var(--accent);
  stroke-width: 2.5;
}

.ch-gate {
  fill: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.ch-center {
  fill: var(--text-soft);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
}

/* ---------- Relationship visuals: two-person colour coding ---------- */
/* Person A reuses the warm brand accent; person B a complementary teal; the
   electromagnetic spark a warm gold. All theme-aware. */
.docs-body {
  --hd-person-a: #c4622d;
  --hd-person-a-soft: rgba(196, 98, 45, 0.16);
  --hd-person-b: #2f8f83;
  --hd-person-b-soft: rgba(47, 143, 131, 0.16);
  --hd-spark: #e0a92e;
}
[data-theme="dark"] .docs-body,
.docs-body[data-theme="dark"] {
  --hd-person-a: #e07a3e;
  --hd-person-a-soft: rgba(224, 122, 62, 0.2);
  --hd-person-b: #4cb3a5;
  --hd-person-b-soft: rgba(76, 179, 165, 0.2);
  --hd-spark: #f0c050;
}

/* Electromagnetic diagram (two-colour channel + spark) */
.hd-electromagnetic svg {
  width: 340px;
}
.em-bar {
  stroke: var(--border-strong);
  stroke-width: 8;
  stroke-linecap: round;
}
.em-node.em-a circle {
  fill: var(--hd-person-a-soft);
  stroke: var(--hd-person-a);
  stroke-width: 2.5;
}
.em-node.em-b circle {
  fill: var(--hd-person-b-soft);
  stroke: var(--hd-person-b);
  stroke-width: 2.5;
}
.em-gate {
  fill: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}
.em-zap path,
.hd-connection-spark .em-zap {
  fill: var(--hd-spark);
  stroke: var(--bg);
  stroke-width: 1.2;
  stroke-linejoin: round;
}
.em-person {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
}
.em-person-a {
  fill: var(--hd-person-a);
}
.em-person-b {
  fill: var(--hd-person-b);
}

/* Connection chart: two bodygraphs side by side */
.hd-connection {
  max-width: 560px;
}
.hd-connection-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.hd-connection-person {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.hd-connection-person .hd-bodygraph-canvas {
  width: 210px;
}
.hd-connection-name {
  display: block;
  margin-bottom: 0.4rem;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
}
.hd-conn-a {
  color: var(--hd-person-a);
}
.hd-conn-b {
  color: var(--hd-person-b);
}
.hd-connection-spark {
  flex-shrink: 0;
  width: 26px;
  line-height: 0;
}
.hd-connection-spark svg {
  width: 100%;
  height: auto;
}
@media (max-width: 520px) {
  .hd-connection-pair {
    flex-direction: column;
  }
  .hd-connection-spark {
    transform: rotate(90deg);
    width: 22px;
  }
}

/* Penta column (Sacral → G → Throat, six channels) */
.hd-penta svg {
  width: 300px;
}
.pn-center {
  fill: color-mix(in srgb, var(--accent) 14%, var(--surface));
  stroke: var(--accent);
  stroke-width: 2;
}
.pn-center-label {
  fill: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}
.pn-chan {
  stroke: var(--border-strong);
  stroke-width: 3;
  stroke-dasharray: 5 5;
}
.pn-chan.on {
  stroke: var(--accent);
  stroke-width: 7;
  stroke-dasharray: none;
  stroke-linecap: round;
}
.pn-name {
  fill: var(--text-soft);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
}
.pn-name.on {
  fill: var(--text);
}
.pn-gates {
  fill: var(--text-soft);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
}

/* ---------- Schematic step diagrams (center & channel explainers) ---------- */
/* Palette mirrors the real bodygraph (Bodygraph.colors) so the little inline
   diagrams read as the same centers/channels, theme-aware via these tokens. */
.docs-body {
  --hd-center-fill: #faf8f5;
  --hd-center-stroke: #d4cdc4;
  --hd-center-defined-fill: #f5dcc5;
  --hd-center-defined-stroke: #a8663d;
  --hd-design: #c75050;
  --hd-personality: #2a2420;
}
[data-theme="dark"] .docs-body,
.docs-body[data-theme="dark"] {
  --hd-center-fill: #2a2724;
  --hd-center-stroke: #4a453e;
  --hd-center-defined-fill: #3d2415;
  --hd-center-defined-stroke: #9a6842;
  --hd-design: #e05555;
  --hd-personality: #ede9e3;
}

.hd-channel-steps,
.hd-center-compare {
  max-width: 580px;
}
.cb-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.6rem;
}
.hd-center-compare .cb-row {
  gap: 1.75rem;
}
.cb-step {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.cb-step-art {
  width: 100%;
}
.cb-step-art svg {
  width: 100%;
  max-width: 124px;
  height: auto;
}
.cb-step-art-center svg {
  max-width: 92px;
}
.cb-step-label {
  margin-top: 0.55rem;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.cb-step-sub {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-soft);
}

/* Center shape (square stand-in for any center) */
.cb-center {
  fill: var(--hd-center-fill);
  stroke: var(--hd-center-stroke);
  stroke-width: 2;
}
.cb-center.is-defined {
  fill: var(--hd-center-defined-fill);
  stroke: var(--hd-center-defined-stroke);
}
.cb-center-label {
  fill: var(--text-soft);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
}

/* Channel bar halves — one per gate */
.cb-gate {
  fill: color-mix(in srgb, var(--border-strong) 20%, var(--surface));
  stroke: var(--border);
  stroke-width: 1;
}
.cb-gate.on {
  fill: var(--accent);
  stroke: var(--accent);
}
.cb-gate.design {
  fill: var(--hd-design);
  stroke: var(--hd-design);
}
.cb-gate.personality {
  fill: var(--hd-personality);
  stroke: var(--hd-personality);
}

/* Gate-number pills sit on the bar (constant identifiers) */
.cb-node circle {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}
.cb-node-num {
  fill: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

@media (max-width: 520px) {
  .cb-step-sub {
    display: none;
  }
  .cb-row {
    gap: 0.4rem;
  }
}

/* I Ching trigram matrix */
.hd-iching-table {
  max-width: 100%;
}

.ic-scroll {
  overflow-x: auto;
}

.iching-matrix {
  border-collapse: collapse;
  margin: 0 auto;
  font-size: 0.9rem;
}

.iching-matrix th,
.iching-matrix td {
  border: 1px solid var(--border);
  text-align: center;
  width: 2.6rem;
  height: 2.6rem;
}

.iching-matrix .ic-th,
.iching-matrix .ic-rh,
.iching-matrix .ic-corner {
  background: var(--bg-alt);
  color: var(--text-soft);
  font-weight: 600;
  padding: 0.2rem;
}

.iching-matrix .ic-tri {
  display: block;
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1;
}

.iching-matrix .ic-tri-name {
  display: block;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.15rem;
}

.iching-matrix .ic-corner span {
  display: block;
  font-size: 0.58rem;
  line-height: 1.3;
}

.iching-matrix .ic-cell {
  padding: 0;
}

.iching-matrix .ic-cell a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 2.6rem;
  text-decoration: none;
  color: var(--text-mid);
  font-weight: 600;
  border: none;
  transition:
    background 0.12s,
    color 0.12s;
}

.iching-matrix .ic-cell a:hover {
  background: var(--accent);
  color: #fff;
}

/* Numbers ⇄ hexagrams toggle */
.ic-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.ic-controls-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

.ic-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.ic-toggle-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}

.ic-toggle-btn + .ic-toggle-btn {
  border-left: 1px solid var(--border);
}

.ic-toggle-btn:hover {
  color: var(--text);
}

.ic-toggle-btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* Cells show the gate number by default; the hexagram is revealed on toggle. */
.ic-hex {
  display: none;
}

.iching-matrix .ic-cell a .ic-hex-svg {
  width: 22px;
  height: auto;
}

.ic-hex-svg rect {
  fill: var(--text-mid);
  transition: fill 0.12s;
}

.hd-iching-table.show-hex .ic-num {
  display: none;
}

.hd-iching-table.show-hex .ic-hex {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.iching-matrix .ic-cell a:hover .ic-hex-svg rect {
  fill: #fff;
}

/* ---------- Related + CTA ---------- */
.docs-related {
  margin: 3rem 0 0;
}

.docs-related h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem;
}

.docs-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.docs-related-card {
  display: block;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition:
    border-color 0.15s,
    transform 0.15s;
}

.docs-related-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.docs-related-card .rc-title {
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 0.92rem;
}

.docs-related-card .rc-section {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

.docs-cta {
  margin: 3.5rem 0 0;
  padding: 2rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
}

.docs-cta h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.6rem;
}

.docs-cta p {
  color: var(--text-mid);
  max-width: 46ch;
  margin: 0 auto 1.25rem;
  line-height: 1.65;
}

.docs-cta .btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  text-decoration: none;
}

.docs-cta .btn-primary:hover {
  background: var(--accent-hover);
}

/* ---------- On-this-page TOC ---------- */
.docs-toc {
  position: sticky;
  top: 1.75rem;
  align-self: start;
  font-size: 0.82rem;
  padding-top: 1.75rem;
}

.docs-toc .toc-title {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-soft);
  margin: 0 0 0.6rem;
}

.docs-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.docs-toc li a {
  display: block;
  padding: 0.25rem 0 0.25rem 0.85rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  text-decoration: none;
  line-height: 1.4;
}

.docs-toc li.toc-l3 a {
  padding-left: 1.6rem;
  font-size: 0.78rem;
}

.docs-toc li a:hover,
.docs-toc li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ---------- Mobile sidebar toggle ---------- */
.docs-nav-toggle {
  display: none;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 1rem 0 0;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.docs-nav-toggle svg {
  width: 18px;
  height: 18px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .docs-grid {
    grid-template-columns: 230px minmax(0, 1fr);
  }
  .docs-toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .docs-grid {
    grid-template-columns: 1fr;
  }
  .docs-nav-toggle {
    display: flex;
  }
  .docs-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    display: none;
    padding-top: 0.5rem;
  }
  .docs-sidebar.open {
    display: block;
  }
  .docs-main {
    padding-top: 1rem;
  }
}
