/* WorldSMP Wiki: white and calm by default, dark mode on request (button top right, remembered). Gold = WorldSMP. */
:root {
  --bg: #ffffff; --bg2: #f6f6f3; --panel: #ffffff; --ink: #1d1d1b; --ink2: #55554f; --line: #e3e2dc; --line2: #cfcdc4;
  --gold: #a87a10; --gold-bg: #fbf4e2; --link: #1f5fbf; --new: #c0392b; --code: #f1f0ec; --shadow: 0 1px 2px rgba(0,0,0,.05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15161a; --bg2: #1c1d22; --panel: #1e2026; --ink: #e8e6e1; --ink2: #a4a29b; --line: #2e3038; --line2: #3c3f48;
  --gold: #e0b34a; --gold-bg: #2a2416; --link: #7fb0ff; --new: #ff8a7a; --code: #262830; --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a.new { color: var(--new); }
a.ext::after { content: " ↗"; font-size: .8em; }
img { max-width: 100%; height: auto; }
.muted { color: var(--ink2); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 19px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--gold); }
.search { flex: 1; max-width: 460px; }
.search input { width: 100%; padding: 8px 14px; border: 1px solid var(--line2); border-radius: 999px; background: var(--bg2); color: var(--ink); font: inherit; font-size: 15px; }
.search input:focus { outline: 2px solid var(--gold); outline-offset: 1px; background: var(--panel); }
.tools { display: flex; align-items: center; gap: 14px; margin-left: auto; font-size: 15px; white-space: nowrap; }
.tools .play { padding: 7px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 600; }
.tools .play:hover { text-decoration: none; opacity: .9; }
.theme { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line2); border-radius: 50%; background: var(--bg2); color: var(--ink); font-size: 17px; cursor: pointer; }
.theme .sun { display: none; }
:root[data-theme="dark"] .theme .sun { display: inline; }
:root[data-theme="dark"] .theme .moon { display: none; }

/* layout */
.wrap { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 36px; max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }
.side { position: sticky; top: 84px; align-self: start; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.side a { padding: 5px 10px; border-radius: 6px; color: var(--ink2); }
.side a:hover { background: var(--bg2); color: var(--ink); text-decoration: none; }
.side hr { margin: 10px 0; }
main { min-width: 0; }
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 1240px; margin: 0 auto; padding: 18px 20px 30px; border-top: 1px solid var(--line); color: var(--ink2); font-size: 14px; }

/* a page */
.page { max-width: 820px; }
.page::after { content: ""; display: block; clear: both; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
h1 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 24px; line-height: 1.3; margin: 1.6em 0 .5em; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
h3 { font-size: 19px; margin: 1.4em 0 .4em; }
h4 { font-size: 17px; margin: 1.2em 0 .3em; }
.page p, .page ul, .page ol { margin: 0 0 1em; }
.page li { margin: .2em 0; }
code { padding: 1px 6px; border-radius: 4px; background: var(--code); font: .9em ui-monospace, "Cascadia Mono", Menlo, monospace; }
blockquote { margin: 0 0 1em; padding: 10px 16px; border-left: 4px solid var(--gold); background: var(--gold-bg); border-radius: 0 8px 8px 0; }
.tbl { overflow-x: auto; margin: 0 0 1.2em; }
.tbl table, .infobox table { border-collapse: collapse; }
.tbl th, .tbl td { padding: 7px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: var(--bg2); }
figure { margin: 0; }
.pic { margin: 0 0 1.2em; }
.pic img { display: block; border-radius: 8px; border: 1px solid var(--line); }
figcaption { padding-top: 6px; color: var(--ink2); font-size: 14px; }
.infobox { float: right; width: 290px; margin: 0 0 16px 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); font-size: 15px; overflow: hidden; }
.ib-title { padding: 10px 14px; background: var(--gold-bg); border-bottom: 1px solid var(--line); font-weight: 700; text-align: center; }
.infobox figure { padding: 10px 10px 0; text-align: center; }
.infobox figure img { border-radius: 6px; }
.infobox table { width: 100%; }
.infobox th, .infobox td { padding: 6px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.infobox th { width: 42%; color: var(--ink2); font-weight: 600; }
.toc { display: inline-block; min-width: 240px; margin: 0 0 1.2em; padding: 12px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); font-size: 15px; }
.toc ol { margin: 6px 0 0; padding-left: 20px; }
.toc .l3 { margin-left: 14px; list-style: circle; }
.toc .l4 { margin-left: 28px; list-style: square; }
.updated { margin-top: 2.4em; font-size: 14px; clear: both; }

/* main page sections, lists of pages */
.sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 24px; }
.sections section { padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.sections h2 { margin: 0 0 6px; font-size: 17px; border: 0; color: var(--gold); }
.sections ul { margin: 0; padding-left: 18px; font-size: 15px; }
.cards { list-style: none; padding: 0; display: grid; gap: 10px; }
.cards a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); }
.cards a:hover { border-color: var(--gold); text-decoration: none; }
.cards b { display: block; color: var(--link); }
.cards span { color: var(--ink2); font-size: 15px; }
.revs { padding-left: 18px; }
.revs li { margin: 6px 0; }
.tag { padding: 1px 8px; border-radius: 999px; background: var(--gold-bg); color: var(--gold); font-size: 13px; font-weight: 600; }
.note { margin: 0 0 18px; padding: 10px 16px; border: 1px solid var(--gold); border-radius: 10px; background: var(--gold-bg); }

/* buttons */
.btn { display: inline-block; padding: 7px 16px; border: 1px solid var(--ink); border-radius: 8px; background: var(--ink); color: var(--bg); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; opacity: .88; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line2); }
.btn.small { padding: 3px 10px; font-size: 14px; margin-left: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.acts { display: flex; gap: 8px; margin-bottom: 12px; }

/* the editor */
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.editor label .muted { font-weight: 400; }
.editor input, .editor select, .editor textarea { padding: 8px 12px; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; font-size: 16px; font-weight: 400; }
.editor input:focus, .editor select:focus, .editor textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; }
.ed-head { display: flex; gap: 12px; flex-wrap: wrap; }
.ed-head .grow { flex: 1; min-width: 240px; }
.toolbar { position: sticky; top: 57px; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); }
.toolbar button { padding: 5px 11px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.toolbar button:hover { border-color: var(--gold); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line2); margin: 0 4px; }
.toolbar .help { margin-left: auto; font-size: 14px; }
.ed-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: 62vh; }
.ed-panes textarea { min-height: 62vh; resize: vertical; font: 15px/1.6 ui-monospace, "Cascadia Mono", Menlo, monospace; }
.preview { max-width: none; padding: 4px 18px 18px; border: 1px dashed var(--line2); border-radius: 8px; overflow: auto; max-height: 80vh; }
.preview h1 { font-size: 28px; margin-top: 10px; }
.preview .infobox { width: 44%; min-width: 200px; }
.ed-foot { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; background: var(--bg); border-top: 1px solid var(--line); }
.ed-foot input { flex: 1; min-width: 220px; }
.msg { color: var(--ink2); font-size: 14px; }

/* phones */
@media (max-width: 860px) {
  .wrap { grid-template-columns: 1fr; gap: 0; padding-top: 18px; }
  .side { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; font-size: 14px; }
  .side hr { display: none; }
  .side a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .tools .play { display: none; }
  .infobox { float: none; width: auto; margin: 0 0 16px; }
  .ed-panes { grid-template-columns: 1fr; }
  .preview { max-height: none; }
  h1 { font-size: 28px; }
}
