/* One stylesheet, four looks. The root carries data-style (classic|modern)
   and data-mode (light|dark). No data-mode = follow the system. A style or
   mode only ever changes CSS, never markup. */

/* ---- colors: classic light (the default, also the no-JS look) ---------- */
:root {
  --bg: #ffffff; --fg: #000000; --muted: #444444; --rule: #000000;
  --link: #0000ee; --link-hover: #551a8b; --accent: #0000ee;
  --code-bg: #f4f4f4;
  --g-near: #1c1c1f; --g-far: #a3a19a; --g-dim: #d6d4ce; --g-label: #6b6a65;
  --g-edge: #cfcdc6; --g-edge-near: #8a8880; --g-edge-dim: #e6e4de;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #111111; --fg: #dddddd; --muted: #aaaaaa; --rule: #dddddd;
    --link: #8cb4ff; --link-hover: #c9a0ff; --accent: #8cb4ff;
    --code-bg: #1c1c1c;
    --g-near: #dedcd6; --g-far: #6f6e69; --g-dim: #3a3a3f; --g-label: #8f8d86;
    --g-edge: #3a3a3f; --g-edge-near: #8a8880; --g-edge-dim: #26262a;
  }
}
:root[data-mode="dark"] {
  --bg: #111111; --fg: #dddddd; --muted: #aaaaaa; --rule: #dddddd;
  --link: #8cb4ff; --link-hover: #c9a0ff; --accent: #8cb4ff;
  --code-bg: #1c1c1c;
  --g-near: #dedcd6; --g-far: #6f6e69; --g-dim: #3a3a3f; --g-label: #8f8d86;
  --g-edge: #3a3a3f; --g-edge-near: #8a8880; --g-edge-dim: #26262a;
}

/* ---- colors: modern ----------------------------------------------------- */
:root[data-style="modern"] {
  --bg: #f7f6f2; --fg: #1c1c1f; --muted: #5f5e59; --rule: #dcdad3;
  --link: #8a5a00; --link-hover: #5c3c00; --accent: #8a5a00;
  --code-bg: #efede7;
  --g-near: #1c1c1f; --g-far: #a3a19a; --g-dim: #d6d4ce; --g-label: #6b6a65;
  --g-edge: #cfcdc6; --g-edge-near: #8a8880; --g-edge-dim: #e6e4de;
}
@media (prefers-color-scheme: dark) {
  :root[data-style="modern"]:not([data-mode="light"]) {
    --bg: #151517; --fg: #dedcd6; --muted: #9c9a93; --rule: #2a2a2e;
    --link: #e3a857; --link-hover: #f2c98a; --accent: #e3a857;
    --code-bg: #1c1c1f;
    --g-near: #dedcd6; --g-far: #6f6e69; --g-dim: #3a3a3f; --g-label: #8f8d86;
    --g-edge: #3a3a3f; --g-edge-near: #8a8880; --g-edge-dim: #26262a;
  }
}
:root[data-style="modern"][data-mode="dark"] {
  --bg: #151517; --fg: #dedcd6; --muted: #9c9a93; --rule: #2a2a2e;
  --link: #e3a857; --link-hover: #f2c98a; --accent: #e3a857;
  --code-bg: #1c1c1f;
  --g-near: #dedcd6; --g-far: #6f6e69; --g-dim: #3a3a3f; --g-label: #8f8d86;
  --g-edge: #3a3a3f; --g-edge-near: #8a8880; --g-edge-dim: #26262a;
}

/* ---- classic: browser defaults, lightly arranged ------------------------ */
html { background: var(--bg); color: var(--fg); }
body { margin: 0; font-family: "Times New Roman", Times, serif; font-size: 17px; line-height: 1.4; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
.page { box-sizing: border-box; padding: 16px 20px 48px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 40px; }
.tree { flex: 0 1 250px; min-width: 0; }
.tree .site { margin: 0 0 2px; }
.tree .toggles { margin: 0 0 10px; font-size: 15px; }
.tree ul { margin: 0; padding-left: 20px; }
.tree details > summary { list-style: none; cursor: default; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details:not([open]) > ul { display: none; }
.tree a[aria-current="page"] { font-weight: bold; color: inherit; text-decoration: none; }
.note { flex: 1 1 520px; min-width: 0; max-width: 700px; }
.note h1 { margin: 0 0 4px; font-size: 30px; line-height: 1.2; }
.note .meta { margin: 0 0 12px; font-style: italic; }
.note .meta span + span::before { content: " · "; }
.note hr.top { border: 0; border-top: 1px solid var(--rule); margin: 0 0 16px; }
.note h2 { margin: 18px 0 6px; font-size: 21px; }
.note h3 { margin: 14px 0 4px; font-size: 18px; }
.note p { margin: 0 0 12px; }
.note ul, .note ol { margin: 0 0 12px; padding-left: 28px; }
.note dl { margin: 0 0 12px; }
.note dt { font-weight: bold; }
.note dd { margin: 0 0 6px 28px; }
.note table { border-collapse: collapse; margin: 0 0 18px; }
.note th, .note td { border: 1px solid var(--rule); padding: 3px 8px; text-align: left; vertical-align: top; }
.note pre, .note code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.92em; }
.note pre { background: var(--code-bg); padding: 10px 12px; overflow-x: auto; margin: 0 0 12px; }
.note blockquote { margin: 0 0 12px 20px; }
.note .checkbox { font-family: ui-monospace, monospace; }
.side { flex: 0 1 320px; min-width: 0; max-width: 380px; }
.side .graph { display: block; width: 100%; height: 230px; margin: 0 0 16px; }
.side .graph:empty { display: none; }
.side h2 { margin: 0 0 4px; font-size: 17px; }
.side ul { margin: 0 0 16px; padding-left: 22px; }
.side .snippet { display: block; font-size: 15px; color: var(--muted); }
.side .empty { color: var(--muted); font-style: italic; margin: 0 0 16px; }
.note .tag { font-style: italic; }
@media (max-width: 760px) { .page { gap: 24px; } .note { max-width: none; } }

/* ---- modern: Plex, spacing, hairlines ------------------------------------ */
:root[data-style="modern"] body {
  font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 16px; line-height: 1.65;
}
:root[data-style="modern"] .page { padding: 0; gap: 0; align-items: stretch; min-height: 100vh; }
:root[data-style="modern"] .tree {
  flex: 0 1 260px; padding: 28px 20px; border-right: 1px solid var(--rule);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.5;
}
:root[data-style="modern"] .tree .site { margin: 0 0 10px; font-size: 14px; }
:root[data-style="modern"] .tree .site a { color: var(--fg); text-decoration: none; font-weight: 500; }
:root[data-style="modern"] .tree .toggles { margin: 0 0 24px; font-size: 12.5px; color: var(--muted); }
:root[data-style="modern"] .tree .toggles a { color: var(--muted); }
:root[data-style="modern"] .tree .toggles b { color: var(--fg); font-weight: 400; }
:root[data-style="modern"] .tree ul { list-style: none; padding-left: 14px; }
:root[data-style="modern"] .tree > ul { padding-left: 0; }
:root[data-style="modern"] .tree li { padding: 0; }
:root[data-style="modern"] .tree a, :root[data-style="modern"] .tree summary { display: block; padding: 6px 0; color: var(--muted); text-decoration: none; }
:root[data-style="modern"] .tree details > summary { cursor: pointer; }
:root[data-style="modern"] .tree details[open] > summary { color: var(--fg); }
:root[data-style="modern"] .tree a[aria-current="page"] { color: var(--accent); font-weight: 400; }
:root[data-style="modern"] .note { flex: 999 1 560px; max-width: none; padding: 56px 48px 72px; }
:root[data-style="modern"] .note > * { max-width: 680px; margin-left: auto; margin-right: auto; }
:root[data-style="modern"] .note .crumb, :root[data-style="modern"] .note .meta {
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--muted); font-style: normal;
}
:root[data-style="modern"] .note .crumb { margin: 0 auto 20px; }
:root[data-style="modern"] .note h1 { font-size: 34px; font-weight: 600; letter-spacing: -0.01em; margin: 0 auto 20px; }
:root[data-style="modern"] .note .meta { margin: 0 auto 36px; }
:root[data-style="modern"] .note .meta span + span::before { content: ""; margin-right: 20px; }
:root[data-style="modern"] .note hr.top { display: none; }
:root[data-style="modern"] .note h2 { font-size: 20px; font-weight: 600; line-height: 1.3; margin: 36px auto 12px; }
:root[data-style="modern"] .note h3 { font-size: 16px; font-weight: 600; margin: 24px auto 8px; }
:root[data-style="modern"] .note p { margin: 0 auto 16px; }
:root[data-style="modern"] .note ul, :root[data-style="modern"] .note ol { padding-left: 22px; margin: 0 auto 16px; }
:root[data-style="modern"] .note li { margin: 0 0 8px; }
:root[data-style="modern"] .note table { width: 100%; font-size: 14.5px; line-height: 1.5; }
:root[data-style="modern"] .note th { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; font-weight: 500; color: var(--muted); }
:root[data-style="modern"] .note th, :root[data-style="modern"] .note td { border: 0; border-bottom: 1px solid var(--rule); padding: 10px 12px 10px 0; }
:root[data-style="modern"] .note pre { border: 1px solid var(--rule); border-radius: 4px; padding: 16px 18px; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13.5px; line-height: 1.6; }
:root[data-style="modern"] .note code { font-family: "IBM Plex Mono", ui-monospace, monospace; }
:root[data-style="modern"] .note .tag { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--muted); font-style: normal; }
:root[data-style="modern"] .side { flex: 0 1 320px; max-width: none; border-left: 1px solid var(--rule); display: flex; flex-direction: column; }
:root[data-style="modern"] .side .graph { height: 240px; margin: 0; border-bottom: 1px solid var(--rule); }
:root[data-style="modern"] .side .links { padding: 24px 24px 40px; font-size: 14px; line-height: 1.55; }
:root[data-style="modern"] .side h2 { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; font-weight: 500; color: var(--muted); margin: 0 0 14px; }
:root[data-style="modern"] .side ul { list-style: none; padding: 0; margin: 0 0 28px; }
:root[data-style="modern"] .side li { margin: 0 0 12px; }
:root[data-style="modern"] .side a { text-decoration: none; font-weight: 500; }
:root[data-style="modern"] .side .snippet { font-size: 14px; }
@media (max-width: 760px) {
  :root[data-style="modern"] .tree { border-right: 0; border-bottom: 1px solid var(--rule); }
  :root[data-style="modern"] .note { padding: 32px 20px 48px; }
  :root[data-style="modern"] .side { border-left: 0; border-top: 1px solid var(--rule); }
}
