/* Elle documentation site — self-contained, no external assets.
   Light/dark follows the reader's system preference. */

:root {
  --bg: #faf9f6;
  --panel: #f1efe9;
  --ink: #23262d;
  --soft: #5c6270;
  --line: #ddd9cf;
  --accent: #9a6b00;
  --accent-ink: #6f4d00;
  --code-bg: #23262d;
  --code-ink: #e8e6df;
  --code-soft: #9aa0ab;
  --good: #1c7c4a;
  --warn: #b5502a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --ink: #e8e6df;
    --soft: #9aa0ab;
    --line: #2c303a;
    --accent: #ffcc00;
    --accent-ink: #ffd94d;
    --code-bg: #0e1013;
    --code-ink: #e8e6df;
    --code-soft: #7d8590;
    --good: #4cc38a;
    --warn: #e0764f;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- layout ---- */
.layout { display: flex; min-height: 100vh; }
nav.sidebar {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 1.4rem 1.1rem 2rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  margin: 0 0 0.15rem;
}
.sidebar .brand a { color: var(--ink); text-decoration: none; }
.sidebar .tagline { font-size: 0.78rem; color: var(--soft); margin: 0 0 1.2rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: block;
  padding: 0.34rem 0.55rem;
  margin: 0.1rem 0;
  border-radius: 6px;
  color: var(--soft);
  text-decoration: none;
  font-size: 0.9rem;
}
.sidebar li a:hover { color: var(--ink); background: var(--panel); }
.sidebar li a.active { color: var(--accent-ink); background: var(--panel); font-weight: 600; }
.sidebar .foot { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.75rem; color: var(--soft); }
.sidebar .foot a { color: var(--soft); }

main {
  flex: 1;
  min-width: 0;
  padding: 2.4rem 3rem 5rem;
  max-width: 860px;
}

/* ---- mobile ---- */
.menu-btn { display: none; }
@media (max-width: 820px) {
  .layout { display: block; }
  nav.sidebar {
    position: fixed;
    z-index: 40;
    background: var(--bg);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  nav.sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.35); }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: sticky;
    top: 0.6rem;
    margin: 0.6rem 0 0 0.9rem;
    z-index: 30;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
  }
  main { padding: 1.2rem 1.2rem 4rem; }
}

/* ---- typography ---- */
h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 0.4rem; letter-spacing: -0.01em; }
.lead { color: var(--soft); font-size: 1.05rem; margin: 0 0 2rem; }
h2 {
  font-size: 1.28rem;
  margin: 2.6rem 0 0.7rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  letter-spacing: -0.005em;
}
h3 { font-size: 1.02rem; margin: 1.6rem 0 0.5rem; }
p { margin: 0.7rem 0; }
a { color: var(--accent-ink); }
strong { font-weight: 650; }
ul, ol { padding-left: 1.3rem; }
li { margin: 0.3rem 0; }
.note {
  background: var(--panel);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  margin: 1.1rem 0;
  font-size: 0.93rem;
}
.note.warn { border-left-color: var(--warn); }

/* ---- inline code & blocks ---- */
code {
  font: 0.86em/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.08em 0.35em;
  white-space: nowrap;
}
.codeblock { margin: 1.1rem 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.codeblock .src {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  color: var(--soft);
  font: 0.75rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.codeblock pre {
  margin: 0;
  padding: 0.9rem 1rem;
  background: var(--code-bg);
  color: var(--code-ink);
  overflow-x: auto;
  font: 0.82rem/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.codeblock pre .c { color: var(--code-soft); font-style: italic; }
.codeblock pre .k { color: #79b8ff; }
.codeblock pre .s { color: #a5d6a7; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; margin: 1.1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--soft);
  border-bottom: 2px solid var(--line);
  padding: 0.45rem 0.7rem 0.45rem 0;
}
td { border-bottom: 1px solid var(--line); padding: 0.55rem 0.7rem 0.55rem 0; vertical-align: top; }
td:first-child { white-space: nowrap; }
td code { white-space: nowrap; }

/* ---- diagrams ---- */
.diagram {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.2rem 1.2rem 0.9rem;
  margin: 1.3rem 0;
  overflow-x: auto;
}
.diagram .cap { font-size: 0.8rem; color: var(--soft); margin-top: 0.8rem; }
.drow { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin: 0.5rem 0; }
.dnode {
  background: var(--bg);
  border: 1.5px solid var(--soft);
  border-radius: 9px;
  padding: 0.4rem 0.8rem;
  font-size: 0.83rem;
  line-height: 1.35;
  text-align: center;
}
.dnode small { display: block; color: var(--soft); font-size: 0.72rem; }
.dnode.hot { border-color: var(--accent); }
.dnode.good { border-color: var(--good); }
.dnode.warn { border-color: var(--warn); }
.darrow { color: var(--soft); font-size: 1rem; flex-shrink: 0; }
.dlabel { font-size: 0.72rem; color: var(--soft); }
.dcol { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }

/* ---- misc ---- */
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--soft);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin-right: 0.3rem;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.1rem 0; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.card h3 { margin-top: 0.1rem; }
.card p { font-size: 0.9rem; color: var(--soft); }
.card a { font-size: 0.9rem; }
footer.docfoot {
  margin-top: 4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--soft);
}

/* ---- generated SVG diagrams (sequence + ERD) ---- */
.figwrap {
  margin: 1.3rem 0;
  padding: 1rem 0.6rem 0.6rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}
.figwrap figcaption {
  font-size: 0.8rem;
  color: var(--soft);
  text-align: center;
  padding: 0.6rem 1rem 0.2rem;
}
.sdg { display: block; margin: 0 auto; max-width: none; }
.sdg text { font: 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace; fill: var(--ink); }
.sdg .sdg-lbl { fill: var(--soft); }
.sdg-ah { fill: var(--ink); }
.sdg-life { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; }
.sdg-actor rect { fill: var(--bg); stroke: var(--soft); stroke-width: 1.3; }
.sdg-actor text { font-weight: 700; }
.sdg-msg { stroke: var(--ink); stroke-width: 1.4; }
.sdg-ret { stroke: var(--soft); stroke-width: 1.2; stroke-dasharray: 5 4; }
.sdg-note rect { fill: var(--bg); stroke: var(--accent); stroke-width: 1; }
.sdg-note text { fill: var(--soft); font-style: italic; }

.erd-box { fill: var(--bg); stroke: var(--soft); stroke-width: 1.3; }
.erd-head { fill: var(--soft); opacity: 0.18; stroke: none; }
.erd-title { font-weight: 700; }
.erd-col { fill: var(--ink); }
.erd-pk { font-weight: 700; }
.erd-fk { fill: var(--accent-ink); }
.erd-type { fill: var(--soft); font-size: 10px; }
.erd-rel { stroke: var(--accent); stroke-width: 1.4; opacity: 0.8; }

/* ---- crossover chart ---- */
.ch-hosted { stroke: var(--accent); stroke-width: 2.2; }
.ch-gpu { stroke: var(--good); stroke-width: 2.2; }
.ch-fleet { stroke: var(--warn); stroke-width: 2.2; }
.ch-cap { stroke-dasharray: 4 4; stroke-width: 1.2; }
.ch-dot { fill: var(--ink); stroke: var(--bg); stroke-width: 2; }
.ch-mark { fill: var(--ink); font-weight: 700; }

/* ---- ERD crow's-foot notation ---- */
.erd-underline { stroke: var(--ink); stroke-width: 1; }
.erd-card { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.erd-card-o { fill: var(--bg); }
.erd-verb { font-style: italic; }

/* ── Citations ───────────────────────────────────────────────────────────────
   Numbered source list used by the introduction's "why an interaction model"
   argument. Superscript markers in prose point into it. */
.refs { list-style: none; margin: 1.1rem 0 0; padding: 0; font-size: 0.85rem; }
.refs li {
  color: var(--soft);
  padding: 0.35rem 0 0.35rem 2.1rem;
  text-indent: -2.1rem;
  line-height: 1.5;
}
.refs .n {
  display: inline-block;
  width: 1.6rem;
  color: var(--accent-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.refs a { word-break: break-word; }
sup.cite { font-size: 0.7em; line-height: 0; }
sup.cite a { text-decoration: none; font-weight: 700; }
