:root,
[data-theme="light"] {
  --bg: #fff;
  --text: #222;
  --banner-bg: #0b57d0;
  --banner-fg: #fff;
  --banner-border: #0842a0;
  --menu-bg: #f7f7f7;
  --menu-border: #ddd;
  --menu-sec: #333;
  --link: #0b57d0;
  --link-hover-bg: #e8f0fe;
  --link-active-bg: #d3e3fd;
  --note: #666;
  --code-bg: #f4f4f4;
  --table-border: #ccc;
  --th-bg: #f0f0f0;
  --blockquote-border: #999;
  --blockquote-fg: #444;
  --meta: #555;
  --h1-border: #ddd;
  --iframe-bg: #fff;
  --callout-note-bg: #f5f8ff;
  --callout-note-border: #0b57d0;
  --callout-warn-bg: #fff8eb;
  --callout-warn-border: #c47d00;
}

[data-theme="dark"] {
  --bg: #12141a;
  --text: #e8eaed;
  --banner-bg: #1557b0;
  --banner-fg: #fff;
  --banner-border: #0d47a1;
  --menu-bg: #1e222a;
  --menu-border: #3c4043;
  --menu-sec: #bdc1c6;
  --link: #8ab4f8;
  --link-hover-bg: #293040;
  --link-active-bg: #3c4048;
  --note: #9aa0a6;
  --code-bg: #2d3139;
  --table-border: #5f6368;
  --th-bg: #2d3139;
  --blockquote-border: #5f6368;
  --blockquote-fg: #bdc1c6;
  --meta: #9aa0a6;
  --h1-border: #3c4043;
  --iframe-bg: #12141a;
  --callout-note-bg: #1a2332;
  --callout-note-border: #8ab4f8;
  --callout-warn-bg: #2a2118;
  --callout-warn-border: #f0b429;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141a;
    --text: #e8eaed;
    --banner-bg: #1557b0;
    --banner-fg: #fff;
    --banner-border: #0d47a1;
    --menu-bg: #1e222a;
    --menu-border: #3c4043;
    --menu-sec: #bdc1c6;
    --link: #8ab4f8;
    --link-hover-bg: #293040;
    --link-active-bg: #3c4048;
    --note: #9aa0a6;
    --code-bg: #2d3139;
    --table-border: #5f6368;
    --th-bg: #2d3139;
    --blockquote-border: #5f6368;
    --blockquote-fg: #bdc1c6;
    --meta: #9aa0a6;
    --h1-border: #3c4043;
    --iframe-bg: #12141a;
    --callout-note-bg: #1a2332;
    --callout-note-border: #8ab4f8;
    --callout-warn-bg: #2a2118;
    --callout-warn-border: #f0b429;
  }
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}
#Main {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "banner banner"
    "menu content";
  height: 100vh;
  width: 100vw;
  max-height: 100vh;
  max-width: 100vw;
  overflow: hidden;
  box-sizing: border-box;
}
#Banner {
  grid-area: banner;
  overflow: hidden;
  background: var(--banner-bg);
  color: var(--banner-fg);
  padding: 14px 20px;
  border-bottom: 1px solid var(--banner-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
}
#Banner h1 { margin: 0; font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
#Banner .subtitle {
  flex-basis: 100%;
  order: 3;
  margin: 4px 0 0;
  font-size: 0.85rem;
  opacity: 0.9;
}
.theme-toggle {
  margin-left: auto;
  order: 2;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.15);
  color: inherit;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}
.theme-toggle:hover,
.theme-toggle:focus {
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}
#Menu {
  grid-area: menu;
  overflow: auto;
  background: var(--menu-bg);
  border-right: 1px solid var(--menu-border);
  padding: 12px 10px 24px;
  box-sizing: border-box;
}
#Content {
  grid-area: content;
  overflow: auto;
  background: var(--bg);
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}
#Content iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--iframe-bg);
}

/* Menu: bold section headers; indent topics under each section */
#Menu .menu-title {
  font-size: 1rem;
  margin: 0 0 10px;
  padding: 0 6px;
  font-weight: 700;
}
#Menu .sec {
  margin-bottom: 12px;
}
#Menu .sec-t {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--menu-sec);
  padding: 4px 6px;
}
#Menu ul {
  list-style: none;
  margin: 0;
  padding: 2px 0 4px 18px;
}
#Menu li a {
  display: block;
  padding: 5px 8px 5px 10px;
  border-radius: 4px;
  color: var(--link);
  text-decoration: none;
  font-size: 0.86rem;
}
#Menu li a:hover,
#Menu li a:focus {
  background: var(--link-hover-bg);
}
#Menu li a.active {
  background: var(--link-active-bg);
  font-weight: 600;
}
#Menu .note {
  font-size: 0.75rem;
  color: var(--note);
  padding: 8px 6px 0;
  line-height: 1.35;
}
#Menu .menu-title a {
  color: var(--link);
  text-decoration: none;
}

body.topic {
  overflow: auto; height: auto; min-height: 100%;
  padding: 16px 24px 40px; box-sizing: border-box;
  line-height: 1.45; max-width: 960px;
}
body.topic h1 { font-size: 1.6rem; margin: 0 0 0.6rem; border-bottom: 1px solid var(--h1-border); padding-bottom: 0.35rem; }
body.topic h2 { font-size: 1.25rem; margin: 1.4rem 0 0.5rem; }
body.topic h3 { font-size: 1.05rem; margin: 1.1rem 0 0.4rem; }
body.topic p, body.topic li { font-size: 0.95rem; }
body.topic code {
  font-family: Consolas, Menlo, monospace; background: var(--code-bg);
  padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.9em;
}
body.topic pre { background: var(--code-bg); padding: 12px; overflow: auto; border-radius: 6px; }
body.topic pre code { background: none; padding: 0; }
body.topic table { border-collapse: collapse; width: 100%; margin: 0.8rem 0; font-size: 0.9rem; }
body.topic th, body.topic td { border: 1px solid var(--table-border); padding: 6px 8px; text-align: left; vertical-align: top; }
body.topic th { background: var(--th-bg); }
body.topic blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--blockquote-border); color: var(--blockquote-fg); }
body.topic a { color: var(--link); }
body.topic .meta { color: var(--meta); font-size: 0.9rem; }

/* Collapsible menu sections (expanded by default via open attribute) */
#Menu details.sec > summary.sec-t {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
#Menu details.sec > summary.sec-t::-webkit-details-marker { display: none; }
#Menu details.sec > summary.sec-t::marker { content: ""; }
#Menu details.sec > summary.sec-t::before {
  content: "- ";
  font-weight: 700;
  color: var(--link);
}
#Menu details.sec:not([open]) > summary.sec-t::before {
  content: "+ ";
}
