/* RPG Maker (PS1): an English guide. One stylesheet for every page (Tools/guide_build.py; adapted from the RT2 guide's);
   adapted from the RPG Tsukuru 4 guide's. */

:root {
  --ink: #1f2330;
  --muted: #5b6275;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --rule: #e2dfd6;
  --accent: #b03a1e;      /* the logo's red-orange */
  --accent-soft: #f6e4e1;
  --gold: #c9971c;
  --navy: #2b2f5e;        /* the window blue */
  --rt3: #1d6b4f;
  --rt3-soft: #e3f2ea;
  --bug: #9b2c2c;
  --bug-soft: #fbe9e7;
  --fix: #8a5a00;
  --fix-soft: #fbf0d9;
  --note-soft: #eceff7;
  --heading: #2b2f5e;     /* the window blue as text: headings, labels */
  --code-bg: #f0eee8;
  --kbd-bg: #fff;
  --kbd-border: #c7c3b8;
  --lead: #333a4d;
  --stripe: #f4f2ec;
  --btn-bg: #fff;
  --field-border: #c9c5b8;
  --frame: #0d1330;       /* the border round screenshots */
  --shadow: rgba(20, 25, 50, .18);
  --tip-soft: #fbf5e3;
  --tip-title: #7a5a06;
  --hidden: #6b3fa0;
  --hidden-soft: #f1ebf8;
  --ref-bg: #efe6cf;
  --ref-ink: #6b5310;
  --todo-bg: #fdeeee;
  --todo-ink: #9b2c2c;
  --todo-border: #e3a5a5;
  --grid-line: #cfcbbf;
  --grid-major: #8f8b80;
  --form-line: #9b978a;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, "Segoe UI", -apple-system, Roboto, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light dark;
}

/* ---- dark mode: follows the reader's system setting, as the eschaton.games hub does ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6e4de;
    --muted: #a3a8b8;
    --paper: #16182a;
    --panel: #1f2236;
    --rule: #33374f;
    --accent: #ef8a6c;
    --accent-soft: #3a2522;
    --gold: #d9ab3a;
    --rt3: #6fcf9f;
    --rt3-soft: #172e27;
    --bug: #f08a80;
    --bug-soft: #3a1f22;
    --fix: #e2b04f;
    --fix-soft: #33291a;
    --note-soft: #262a42;
    --heading: #b9c3ef;
    --code-bg: #2a2d44;
    --kbd-bg: #262a42;
    --kbd-border: #4a4f6b;
    --lead: #d0d3de;
    --stripe: #1c1f33;
    --btn-bg: #262a42;
    --field-border: #4a4f6b;
    --frame: #3c4266;
    --shadow: rgba(0, 0, 0, .45);
    --tip-soft: #302a18;
    --tip-title: #e9c46a;
    --hidden: #c39bf0;
    --hidden-soft: #2a2140;
    --ref-bg: #3a3220;
    --ref-ink: #e9cf86;
    --todo-bg: #3a1f22;
    --todo-ink: #f6a5a5;
    --todo-border: #7a3a3a;
    --grid-line: #3a3e57;
    --grid-major: #6a6f8a;
    --form-line: #6a6f8a;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 4rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--serif);
}

/* ---- masthead and layout ---- */
.masthead {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  padding: .55rem 1.25rem;
}
.brand {
  color: #fff; text-decoration: none;
  font: 700 1.05rem/1 var(--sans); letter-spacing: .02em;
}
.brand span { color: #c9d2f0; font-weight: 400; margin-left: .4rem; }

.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  max-width: 78rem;
  margin: 0 auto;
}
nav.side {
  position: sticky; top: 3rem; align-self: start;
  max-height: calc(100vh - 3rem); overflow-y: auto;
  padding: 1.5rem 1rem 2rem 1.25rem;
  font: .88rem/1.45 var(--sans);
  border-right: 1px solid var(--rule);
}
.side-title {
  margin: 0 0 .4rem; color: var(--muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600;
}
nav.side ol, nav.side ul { list-style: none; margin: 0 0 1.5rem; padding: 0; }
nav.side ul ul { margin: .1rem 0 .3rem .8rem; }
nav.side a { color: var(--ink); text-decoration: none; display: block; padding: .15rem .4rem; border-radius: 4px; }
nav.side a:hover { background: var(--note-soft); }
nav.side a.here { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side ol.chapters { margin-bottom: 1.1rem; }
nav.side ol.chapters + .side-title { margin-top: 0; }

main { padding: 1.75rem 2.5rem 3rem; min-width: 0; }
main > * { max-width: 46rem; }
main > figure.shot, main > .table-wrap, main > aside.box { max-width: 48rem; }

/* ---- type ---- */
h1, h2, h3, h4 { font-family: var(--sans); line-height: 1.25; color: var(--heading); }
h1 { font-size: 2.1rem; margin: .2rem 0 .6rem; border-bottom: 3px solid var(--accent); padding-bottom: .4rem; }
h2 { font-size: 1.45rem; margin: 2.4rem 0 .6rem; padding-top: .6rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.12rem; margin: 1.8rem 0 .4rem; }
h4 { font-size: 1rem; margin: 1.4rem 0 .3rem; }
.headerlink { color: var(--rule); text-decoration: none; margin-left: .35rem; font-weight: 400; }
h2:hover .headerlink, h3:hover .headerlink { color: var(--muted); }
a { color: var(--accent); }
code, kbd { font-family: var(--mono); font-size: .86em; }
code { background: var(--code-bg); padding: .05em .3em; border-radius: 3px; }
kbd {
  display: inline-block; min-width: 1.5em; text-align: center;
  padding: 0 .35em; border: 1px solid var(--kbd-border); border-bottom-width: 2px;
  border-radius: 4px; background: var(--kbd-bg); font-size: .8em; line-height: 1.5;
}
.ui { font-family: var(--sans); font-size: .92em; font-weight: 600; color: var(--heading); white-space: nowrap; }
.jp { font-family: "Yu Gothic", "Meiryo", "Hiragino Sans", sans-serif; font-size: .92em; }
.covers { font: .85rem var(--sans); color: var(--muted); margin: 0 0 1.2rem; }
.lead { font-size: 1.15rem; color: var(--lead); }

/* ---- screenshots ---- */
figure.shot { margin: 1.4rem 0 1.6rem; }
figure.shot img {
  display: block; width: 640px; max-width: 100%; height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
  border: 1px solid var(--frame); border-radius: 3px; box-shadow: 0 2px 10px var(--shadow);
  background: #000;
}
figure.shot figcaption { font: .86rem/1.45 var(--sans); color: var(--muted); margin-top: .5rem; max-width: 640px; }
figure.shot.compare .pair { display: flex; gap: 1rem; flex-wrap: wrap; }
figure.shot.compare .pair > div { flex: 1 1 300px; max-width: 480px; }
figure.shot.compare img { width: 100%; }
figure.shot.compare span {
  display: block; font: 600 .76rem var(--sans); text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-top: .35rem;
}
figure.shot.small img { width: 320px; }
.shots-row { display: flex; flex-wrap: wrap; gap: 1rem; max-width: 48rem; }
.shots-row figure.shot { flex: 0 1 calc(50% - .5rem); margin: .6rem 0; }
@media (max-width: 40rem) { .shots-row figure.shot { flex-basis: 100%; } }
.shots-row figure.shot img { width: 100%; }
/* ---- catalogue sheets: at their own size, scaled down only to fit ---- */
figure.sheet { margin: 1.2rem 0 1.6rem; }
figure.sheet img {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--frame); border-radius: 3px; background: #28282c;
}
figure.sheet.big img, figure.sheet.anim img, figure.sheet.pixel img, .gallery figure.tile img { image-rendering: pixelated; image-rendering: crisp-edges; }
figure.sheet figcaption { font: .86rem/1.45 var(--sans); color: var(--muted); margin-top: .5rem; max-width: 640px; }
/* galleries of animated pictures ({{gallery}}): the movies */
.gallery { display: flex; flex-wrap: wrap; gap: .9rem 1rem; align-items: flex-end; margin: 1rem 0 .4rem; }
.gallery figure.tile { margin: 0; max-width: 100%; }
.gallery figure.tile img { display: block; max-width: 100%; height: auto; background: #000; border: 1px solid var(--frame); border-radius: 3px; }
.gallery figure.tile figcaption { font: .8rem/1.35 var(--sans); color: var(--ink); margin-top: .3rem; max-width: 320px; }
.gallery .len { color: var(--muted); white-space: nowrap; }
.gallery-cap { font: .86rem/1.45 var(--sans); color: var(--muted); margin: .2rem 0 1.6rem; max-width: 640px; }
/* the graphics viewers (Guide/viewer.js) */
figure.viewer canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
figure.viewer .vgrid { border: 1px solid var(--frame); border-radius: 3px; background: #28282c; }
figure.viewer .vgrid.pickable { cursor: pointer; }
.vbar, .vhead { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center; margin: 0 0 .55rem; font: .8rem var(--sans); }
.vgroup { display: flex; align-items: center; gap: .25rem; }
.vlabel { font: 600 .72rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: .2rem; }
.vbtn {
  font: 600 .78rem var(--sans); padding: .16rem .55rem; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--btn-bg); color: var(--ink); cursor: pointer;
}
.vbtn:hover { border-color: var(--muted); }
.vbtn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.vnum { width: 4.2em; font: .85rem var(--sans); padding: .1rem .3rem; }
.vdetail { margin: 0 0 .8rem; padding: .6rem .7rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); max-width: 34rem; }
.vpanels { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.vpanel { display: flex; flex-direction: column; gap: .3rem; }
.vpanel canvas { border: 1px solid var(--frame); border-radius: 3px; }
.vcap { font: 600 .72rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.vpose { font: .8rem var(--sans); max-width: 128px; }
button.swap {
  font: 600 .75rem var(--sans); margin-left: .4rem; vertical-align: 1px;
  padding: .12rem .55rem; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--btn-bg); color: var(--muted); cursor: pointer;
}
button.swap:hover { border-color: var(--muted); color: var(--ink); }
button.swap.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
figure.missing .placeholder {
  width: 512px; max-width: 100%; aspect-ratio: 256 / 224;
  display: grid; place-items: center; text-align: center; padding: 1rem;
  border: 2px dashed var(--rule); border-radius: 4px; color: var(--muted); font: .9rem var(--sans);
}

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 1rem 0 1.4rem; }
table { border-collapse: collapse; font: .9rem/1.45 var(--sans); width: 100%; }
th, td { text-align: left; vertical-align: top; padding: .38rem .6rem; border-bottom: 1px solid var(--rule); }
thead th { background: var(--navy); color: #fff; font-weight: 600; border-bottom: none; }
tbody tr:nth-child(even) { background: var(--stripe); }

/* ---- boxes ---- */
aside.box {
  margin: 1.4rem 0; padding: .8rem 1.1rem .5rem; border-radius: 6px;
  border-left: 5px solid var(--muted); background: var(--note-soft);
  font-size: .96rem;
}
aside.box .box-title {
  margin: 0 0 .3rem; font: 700 .78rem var(--sans); text-transform: uppercase; letter-spacing: .07em;
}
aside.box.rt3 { border-color: var(--rt3); background: var(--rt3-soft); }
aside.box.rt3 .box-title { color: var(--rt3); }
aside.box.bug { border-color: var(--bug); background: var(--bug-soft); }
aside.box.bug .box-title { color: var(--bug); }
aside.box.tip { border-color: var(--gold); background: var(--tip-soft); }
aside.box.tip .box-title { color: var(--tip-title); }
aside.box.fix { border-color: var(--fix); background: var(--fix-soft); }
aside.box.fix .box-title { color: var(--fix); }
aside.box.note .box-title { color: var(--heading); }
aside.box.hidden { border-color: var(--hidden); background: var(--hidden-soft); }
aside.box.hidden .box-title { color: var(--hidden); }
aside.box > :last-child { margin-bottom: .4rem; }

/* ---- markers ---- */
.ref {
  display: inline-block; font: 600 .72rem/1.6 var(--sans); white-space: nowrap;
  padding: 0 .5rem; border-radius: 999px; background: var(--ref-bg); color: var(--ref-ink); vertical-align: 1px;
}
.todo {
  display: inline-block; font: italic .85rem/1.5 var(--sans);
  padding: .1rem .55rem; border-radius: 4px; background: var(--todo-bg); color: var(--todo-ink); border: 1px dashed var(--todo-border);
}
p.todo { display: block; }

/* ---- cards (index) ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: .9rem; max-width: 48rem; margin: 1rem 0 1.5rem; }
.cards a {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: .8rem .95rem;
  font: .88rem/1.45 var(--sans);
}
.cards a:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.cards b { display: block; color: var(--heading); font-size: 1rem; margin-bottom: .2rem; }

/* ---- pager ---- */
footer.pager {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font: .92rem var(--sans);
}
footer.pager a { text-decoration: none; font-weight: 600; }

/* ---- narrow screens ---- */
@media (max-width: 900px) {
  .layout { display: block; }
  nav.side { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--rule); }
  main { padding: 1.25rem 1rem 2rem; }
}

/* ---- worksheets: lists, forms and the map grid, each sheet a printed page ---- */
section.worksheet {
  margin: 2.2rem 0; padding: 1.2rem 1.4rem 1.4rem; max-width: 48rem;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 4px;
}
section.worksheet h2 { margin-top: 0; }
section.worksheet .use { font: .86rem/1.45 var(--sans); color: var(--muted); margin: -.3rem 0 .8rem; }
section.worksheet h3 { font-size: 1rem; margin: 1.1rem 0 .4rem; }
table.blank, section.worksheet table.data { font-size: .8rem; }
table.blank thead th, section.worksheet table.data thead th { background: var(--panel); color: var(--ink); border-bottom: 1.5px solid var(--ink); padding: .25rem .35rem; }
table.blank td, section.worksheet table.data td { height: 1.55rem; padding: 0 .35rem; border: 1px solid var(--field-border); vertical-align: middle; color: var(--muted); }
table.blank tbody tr:nth-child(even), section.worksheet table.data tbody tr:nth-child(even) { background: none; }
table.blank td:first-child { width: 2.6rem; }
table.form { font-size: .82rem; margin: .3rem 0 .6rem; }
table.form th { width: 1%; white-space: nowrap; font-weight: 600; padding: .5rem .5rem 0 0; border: none; vertical-align: bottom; }
table.form td { border: none; border-bottom: 1px solid var(--form-line); height: 1.7rem; padding: 0; }
table.form td.none { border-bottom: none; }
table.form tr:nth-child(even) { background: none; }
svg.grid { display: block; width: 100%; height: auto; margin: .4rem 0; }
svg.grid line { stroke: var(--grid-line); stroke-width: .5; }
svg.grid line.major { stroke: var(--grid-major); stroke-width: .8; }
svg.grid text { font: 7px var(--sans); fill: var(--muted); text-anchor: middle; }
svg.grid text.row { text-anchor: end; }
button.print {
  font: 600 .9rem var(--sans); padding: .45rem 1rem; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
}

@media print {
  .masthead, nav.side, footer.pager, button.swap, .headerlink, .vbar, .vdetail { display: none; }
  .layout { display: block; }
  main { padding: 0; }
  /* the worksheets page prints the sheets alone, one to a page */
  body.page-worksheets main > *:not(section.worksheet) { display: none; }
  section.worksheet { break-before: page; border: none; margin: 0; padding: 0; max-width: none; }
  section.worksheet:first-of-type { break-before: auto; }
  section.worksheet .use { display: none; }
  table.blank thead { display: table-header-group; }
  @page { size: A4 portrait; margin: 12mm; }
}

h1 .headerlink { display: none; }

/* ---- spoilers: <details class="spoiler" markdown="1"><summary>...</summary> ... </details> ---- */
details.spoiler { max-width: 48rem; background: var(--note-soft); border-radius: 6px; padding: .6rem 1rem; margin: 1rem 0; }
details.spoiler summary { font: 600 .95rem var(--sans); color: var(--heading); cursor: pointer; }
details.spoiler[open] summary { margin-bottom: .6rem; }

/* ---- text diagrams: <pre class="diagram"> ---- */
pre.diagram { max-width: 48rem; background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: .8rem 1rem; font: .85rem/1.45 var(--mono); color: var(--heading); overflow-x: auto; }

/* Sound clips ({{audio}}, {{play}}) */
figure.audio { margin: 1rem 0 1.2rem; }
figure.audio audio { width: 100%; max-width: 420px; display: block; }
figure.audio figcaption { font: .86rem/1.45 var(--sans); color: var(--muted); margin-top: .35rem; max-width: 640px; }
.audio-row { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
.audio-row figure.audio { flex: 1 1 260px; max-width: 420px; }
table.data audio.clip { width: 12rem; height: 2rem; vertical-align: middle; }

/* ---- annotated screenshots ({{ann}}): numbered boxes over the shot, a legend under it ---- */
figure.shot.ann .annwrap { position: relative; width: 512px; max-width: 100%; }
figure.shot.ann .annwrap img { width: 100%; }
figure.shot.ann .mark {
  position: absolute; border: 2px solid #ffd23f; border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .35);
}
figure.shot.ann .mark b {
  position: absolute; left: -9px; top: -9px; min-width: 18px; height: 18px; padding: 0 3px;
  border-radius: 9px; background: #ffd23f; color: #1f2330; font: 700 11px/18px var(--sans); text-align: center;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}
figure.shot.ann .annwrap:hover .mark { opacity: .25; }
figure.shot.ann .annwrap .mark:hover { opacity: 1; }
ol.legend { list-style: none; margin: .6rem 0 0; padding: 0; max-width: 640px; columns: 2 15rem; column-gap: 1.2rem;
  font: .84rem/1.4 var(--sans); }
ol.legend li { break-inside: avoid; margin: 0 0 .35rem; }
ol.legend .n { display: inline-block; min-width: 1.3rem; height: 1.3rem; line-height: 1.3rem; text-align: center;
  border-radius: .65rem; background: #ffd23f; color: var(--ink); font-size: .75rem; margin-right: .25rem; }
ol.legend .lab { font-weight: 600; color: var(--heading); }
ol.legend .jp { color: var(--muted); margin-left: .2rem; }
ol.legend .what { display: block; color: var(--muted); margin-left: 1.6rem; }

/* ---- figures kept in git ({{fig}}) and inline SVG diagrams (<figure class="diagram">) ---- */
figure.fig img { background: #fff; }
figure.diagram { margin: 1.4rem 0 1.6rem; max-width: 48rem; }
figure.diagram svg { display: block; width: 100%; height: auto; background: var(--panel);
  border: 1px solid var(--rule); border-radius: 6px; font-family: var(--sans); }
figure.diagram figcaption { font: .86rem/1.45 var(--sans); color: var(--muted); margin-top: .5rem; }

/* ---- key numbers (index) ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .7rem; max-width: 48rem; margin: 1rem 0 1.6rem; }
.stats div { background: var(--panel); border: 1px solid var(--rule); border-top: 4px solid var(--gold); border-radius: 6px; padding: .6rem .75rem; font: .8rem/1.35 var(--sans); color: var(--muted); }
.stats b { display: block; font: 700 1.6rem/1.1 var(--sans); color: var(--heading); }

/* ---- the map browser ({{maps}}, guide.js) ---- */
main > .mapbrowser, main > details.mb-table { max-width: 74rem; }
.mapbrowser { margin: 1.2rem 0 1rem; font-family: var(--sans); }
.mb-tools { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin-bottom: .6rem; }
.mb-find { flex: 1 1 18rem; max-width: 28rem; font: .95rem var(--sans); padding: .45rem .7rem; border: 1px solid var(--field-border); border-radius: 6px; background: var(--btn-bg); color: var(--ink); }
.mb-find:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.mb-cyc { font-size: .88rem; color: var(--muted); display: flex; gap: .35rem; align-items: center; cursor: pointer; }
.mb-count { font-size: .85rem; color: var(--muted); margin-left: auto; }
.mb-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.mb-chip { font: .8rem var(--sans); padding: .22rem .6rem; border: 1px solid var(--field-border); border-radius: 999px; background: var(--btn-bg); color: var(--ink); cursor: pointer; }
.mb-chip:hover { border-color: var(--heading); }
.mb-chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.mb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: .8rem; }
.mcard { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--panel);
  border: 1px solid var(--rule); border-radius: 8px; padding: .5rem; transition: border-color .12s, box-shadow .12s; }
.mcard:hover, .mcard:focus-visible { border-color: var(--heading); box-shadow: 0 2px 10px rgba(31, 35, 48, .14); outline: none; }
.mcard[hidden] { display: none; }
.mc-thumb { display: flex; align-items: center; justify-content: center; height: 176px; background: #101322; border-radius: 5px; overflow: hidden; }
.mc-thumb img { display: block; max-width: 100%; max-height: 176px; width: auto; height: auto; }
.mc-name { font-weight: 600; font-size: .92rem; margin: .45rem .15rem 0; color: var(--heading); }
.mc-meta { font-size: .78rem; color: var(--muted); margin: .05rem .15rem 0; }
.mc-cyc { display: inline-block; font-size: .68rem; padding: 0 .35rem; border-radius: 3px; background: var(--fix-soft); color: var(--fix); margin-left: .2rem; }
details.mb-table { margin: .6rem 0 1.6rem; font-family: var(--sans); }
details.mb-table summary { cursor: pointer; color: var(--accent); font-size: .92rem; }

/* ---- the viewer (guide.js) ---- */
img.gv-zoomable { cursor: zoom-in; }
img.gv-zoomable:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
html.gv-open { overflow: hidden; }
.gv { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto 1fr auto;
  background: #0c0e18; color: #e8e9ef; font-family: var(--sans); }
.gv[hidden] { display: none; }
.gv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; padding: .55rem .9rem;
  background: #1b1f36; border-bottom: 2px solid var(--gold); }
.gv-title { font-size: 1rem; margin-right: auto; min-width: 0; }
.gv-title b { color: #fff; }
.gv-title span { color: #a9adc2; font-size: .85rem; margin-left: .35rem; }
.gv-title .gv-count { margin-left: 0; }
.gv-tabs, .gv-zoom, .gv-nav { display: flex; gap: .25rem; }
.gv-tabs[hidden] { display: none; }
.gv-nav.single button:not(.gv-close) { display: none; }
.gv-tab, .gv-btn { font: .85rem var(--sans); color: #e8e9ef; background: #2a2f4d; border: 1px solid #3c4266;
  border-radius: 5px; padding: .25rem .6rem; cursor: pointer; }
.gv-tab:hover, .gv-btn:hover { border-color: var(--gold); }
.gv-tab.on, .gv-btn.on { background: var(--gold); border-color: var(--gold); color: #1b1f36; font-weight: 600; }
.gv-tab:focus-visible, .gv-btn:focus-visible, .gv-file:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.gv-close { font-size: 1rem; padding: .15rem .55rem; }
.gv-pos { font: .85rem var(--mono); color: #f1d27a; min-width: 6.5rem; }
.gv-file { font-size: .82rem; color: #a9adc2; }
.gv-stage { position: relative; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.gv-stage.drag { cursor: grabbing; }
.gv-img { position: absolute; left: 0; top: 0; max-width: none; image-rendering: pixelated; image-rendering: crisp-edges;
  transform-origin: 0 0; box-shadow: 0 0 0 1px #3c4266; background: #000; }
.gv-img.smooth { image-rendering: auto; }
.gv-info { padding: .55rem .9rem .7rem; background: #1b1f36; border-top: 1px solid #2a2f4d; font-size: .88rem; line-height: 1.45; max-height: 30vh; overflow: auto; }
.gv-info[hidden] { display: none; }
.gv-info p { margin: 0 0 .3rem; max-width: 60rem; }
.gv-info a { color: #f1d27a; }
.gv-info dl { display: flex; flex-wrap: wrap; gap: .2rem 1.4rem; margin: .2rem 0 .3rem; }
.gv-info dl div { display: flex; gap: .4rem; }
.gv-info dt { color: #a9adc2; }
.gv-info dd { margin: 0; }
.gv-legend { color: #c5c8d8; }
.gv-legend .k { font-weight: 600; }
.gv-legend .red { color: #ff6b6b; }
.gv-legend .green { color: #5ad27a; }
.gv-legend .blue { color: #6d9bff; }
.gv-legend .magenta { color: #f070f0; }
.gv-legend .yellow { color: #f1d27a; }
@media (max-width: 40rem) { .gv-title { flex-basis: 100%; } .gv-pos { display: none; } }
@media print { .mb-tools, .mb-chips, .gv { display: none !important; } }

/* ---- dark mode, elements (last, so they win over the rules above; the palette is at the top) ---- */
@media (prefers-color-scheme: dark) {
  /* the inline diagrams are drawn in the light palette: turn their lightness over, keep their hues.
     The border is set to the grey that comes out of the filter as the dark rule colour. */
  figure.diagram svg { filter: invert(1) hue-rotate(180deg); background: transparent; border-color: #c4c1b3; }
  /* the figures kept in git keep a light card, as printed inserts */
  figure.fig img { background: #fbfaf7; }
}
