/* In-app handbook (/readme) — illustrated docs skin */

.docs-layout {
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr);
  gap: 1.5rem 1.75rem;
  align-items: start;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.25rem 0 2rem;
}

.docs-catalog {
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  background:
    linear-gradient(165deg, rgba(217, 146, 11, 0.08), transparent 42%),
    var(--surface, #fff);
  border: 1px solid var(--line, var(--border, #d9d3c7));
  font-size: 0.88rem;
}

.docs-catalog-kicker {
  margin: 0 0 0.65rem;
  font-family: var(--font-display, "Bebas Neue", sans-serif);
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  color: var(--ink, #15181e);
}

.docs-catalog-group {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #5c6570);
}

.docs-catalog ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-catalog li { margin: 0.15rem 0; }

.docs-catalog a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2, #16181c);
  opacity: 0.82;
}

.docs-catalog a:hover {
  opacity: 1;
  background: var(--chip, rgba(21, 24, 30, 0.07));
}

.docs-catalog a.active {
  opacity: 1;
  font-weight: 600;
  background: var(--accent-soft, rgba(217, 146, 11, 0.16));
  color: var(--primary, #9e6000);
}

.docs-main { min-width: 0; }

.docs-hero {
  position: relative;
  margin: 0 0 1.35rem;
  padding: 1.35rem 1.4rem 1.2rem;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 120% at 100% 0%, rgba(217, 146, 11, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 80% at 0% 100%, rgba(90, 120, 150, 0.12), transparent 50%),
    linear-gradient(145deg, var(--page-1, #f6f4ef), var(--surface, #fff));
  border: 1px solid var(--line, #d9d3c7);
}

.docs-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary, #9e6000);
}

.docs-title {
  margin: 0;
  font-family: var(--font-display, "Bebas Neue", sans-serif);
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: 0.04em;
  line-height: 1.05;
  font-weight: 400;
  color: var(--ink, #15181e);
}

.docs-lead {
  margin: 0.65rem 0 0;
  max-width: 38rem;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--muted, #5c6570);
}

.docs-path {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  opacity: 0.65;
}

.docs-body-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, 11rem);
  gap: 1.5rem;
  align-items: start;
}

.docs-toc {
  position: sticky;
  top: 0.75rem;
  padding: 0.75rem 0 0.75rem 0.85rem;
  border-left: 2px solid var(--line, #d9d3c7);
  font-size: 0.8rem;
}

.docs-toc-title {
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #5c6570);
}

.docs-toc a {
  display: block;
  margin: 0.28rem 0;
  text-decoration: none;
  color: var(--ink-2, #16181c);
  opacity: 0.75;
  line-height: 1.3;
}

.docs-toc a:hover { opacity: 1; color: var(--primary, #9e6000); }
.docs-toc-h3 { padding-left: 0.65rem; font-size: 0.76rem; }

/* Article prose */
.doc-prose.docs-article,
.docs-article.doc-prose {
  line-height: 1.6;
  font-size: 0.98rem;
  color: var(--ink, #15181e);
}

.docs-article > h2:first-child { margin-top: 0; }

.docs-article h2 {
  margin: 1.75em 0 0.55em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--line, #d9d3c7);
  font-size: 1.35rem;
  line-height: 1.25;
}

.docs-article h3 {
  margin: 1.35em 0 0.45em;
  font-size: 1.1rem;
}

.docs-article p,
.docs-article ul,
.docs-article ol { margin: 0.7em 0; }

.docs-article li { margin: 0.28em 0; }

.docs-article code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.86em;
  padding: 0.12em 0.38em;
  border-radius: 4px;
  background: var(--chip, rgba(21, 24, 30, 0.07));
}

.docs-article pre {
  overflow-x: auto;
  padding: 0.95rem 1.05rem;
  border-radius: 10px;
  background: var(--ink, #15181e);
  color: #f0ebe3;
  font-size: 0.82rem;
  border: 1px solid transparent;
}

.docs-article pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.docs-article table.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.1em 0;
  font-size: 0.9rem;
  border-radius: 10px;
  overflow: hidden;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.docs-article table.doc-table th,
.docs-article table.doc-table td {
  border: 1px solid var(--line, #d9d3c7);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.docs-article table.doc-table th {
  background: var(--accent-soft, rgba(217, 146, 11, 0.16));
  font-weight: 600;
}

.docs-article hr {
  border: 0;
  border-top: 1px solid var(--line, #d9d3c7);
  margin: 1.75rem 0;
}

.docs-article a { color: var(--primary, #9e6000); }

/* Callouts */
.docs-callout {
  margin: 1.1rem 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border-left: 4px solid var(--accent, #d9920b);
  background: var(--accent-soft, rgba(217, 146, 11, 0.16));
}

.docs-callout.tip {
  border-left-color: var(--ok, #1f6b4a);
  background: var(--ok-bg, #e7f3ec);
}

.docs-callout.warn {
  border-left-color: var(--warn, #9a5f00);
  background: var(--warn-bg, #fff4d8);
}

.docs-callout.note {
  border-left-color: #5a7896;
  background: rgba(90, 120, 150, 0.12);
}

.docs-callout p { margin: 0.35em 0; }
.docs-callout p:first-child { margin-top: 0; }
.docs-callout p:last-child { margin-bottom: 0; }

/* Diagrams */
.docs-diagram {
  margin: 1.35rem 0;
  padding: 1rem 1rem 0.65rem;
  border-radius: 14px;
  background:
    linear-gradient(180deg, var(--surface-2, #faf8f4), var(--page-0, #ebe7df));
  border: 1px solid var(--line, #d9d3c7);
}

.docs-diagram-cap {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #5c6570);
}

.docs-diagram-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
}

.dg-box {
  fill: var(--surface, #fff);
  stroke: var(--line, #d9d3c7);
  stroke-width: 1.25;
}

.dg-stage { fill: var(--accent-soft, rgba(217, 146, 11, 0.2)); stroke: var(--accent, #d9920b); }
.dg-accent { fill: rgba(158, 96, 0, 0.12); stroke: var(--primary, #9e6000); }
.dg-yt { fill: rgba(196, 48, 43, 0.1); stroke: var(--plat-yt, #c4302b); }
.dg-ig { fill: rgba(193, 53, 132, 0.1); stroke: var(--plat-ig, #c13584); }
.dg-head { fill: rgba(90, 120, 150, 0.12); stroke: #5a7896; }

.dg-label {
  fill: var(--ink, #15181e);
  font-family: var(--font-body, Figtree, sans-serif);
  font-size: 12px;
  font-weight: 600;
}

.dg-sub {
  fill: var(--muted, #5c6570);
  font-family: var(--font-body, Figtree, sans-serif);
  font-size: 10px;
}

.dg-note {
  fill: var(--muted, #5c6570);
  font-family: var(--font-body, Figtree, sans-serif);
  font-size: 11px;
}

.dg-arrow {
  stroke: var(--muted, #5c6570);
  stroke-width: 1.5;
}

.dg-marker { fill: var(--muted, #5c6570); }

.dg-track { fill: var(--chip, rgba(21, 24, 30, 0.08)); }
.dg-peak { fill: var(--accent, #d9920b); opacity: 0.85; }

/* Live learning chart inside handbook */
.docs-article .report-chart-wrap {
  margin: 1rem 0;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #d9d3c7);
}

@media (max-width: 960px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-catalog {
    position: static;
    max-height: none;
  }
  .docs-catalog ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .docs-catalog li { margin: 0; }
  .docs-catalog-group { width: 100%; }
  .docs-body-wrap {
    grid-template-columns: 1fr;
  }
  .docs-toc {
    display: none;
  }
  .docs-hero {
    padding: 1.1rem 1rem 1rem;
  }
  .docs-title {
    font-size: 1.85rem;
  }
  .docs-article {
    font-size: 0.95rem;
  }
  .docs-article table.doc-table {
    font-size: 0.82rem;
  }
  .docs-article table.doc-table th,
  .docs-article table.doc-table td {
    padding: 0.4rem 0.5rem;
  }
  .docs-diagram {
    padding: 0.75rem 0.65rem 0.5rem;
  }
}

/* Dark theme */
[data-theme="dark"] .docs-hero {
  background:
    radial-gradient(ellipse 80% 120% at 100% 0%, rgba(217, 146, 11, 0.18), transparent 55%),
    linear-gradient(145deg, #1c212b, #15181e);
  border-color: #2c3340;
}

[data-theme="dark"] .docs-catalog,
[data-theme="dark"] .docs-diagram,
[data-theme="dark"] .docs-article .report-chart-wrap {
  background: #1c212b;
  border-color: #2c3340;
}

[data-theme="dark"] .dg-box { fill: #15181e; stroke: #3a4250; }
[data-theme="dark"] .dg-label { fill: #f0ebe3; }
[data-theme="dark"] .docs-article pre { background: #0e1116; }
