/* Soltown docs: the town's look (framed panels, pixel headings), a sticky contents
   column, and the town's own UI pieces (world.css) shown as examples. */
:root {
  --d-bg: #efe4cb;
  --d-paper: #fbf5e6;
  --d-ink: #2b2118;
  --d-soft: #5f4b38;
  --d-faint: #8c765f;
  --d-line: rgba(43, 33, 24, 0.2);
  --d-edge: #2b2118;
  --d-accent: #2f6d8c;
  --d-accent-soft: rgba(47, 109, 140, 0.14);
  --d-warn: #b23b2a;
  --d-shadow: 3px 3px 0 rgba(43, 33, 24, 0.85);
}
@media (prefers-color-scheme: dark) {
  :root {
    --d-bg: #161e2f;
    --d-paper: #1f2a40;
    --d-ink: #f3e8d2;
    --d-soft: #c3cadb;
    --d-faint: #8e98ae;
    --d-line: rgba(195, 202, 219, 0.2);
    --d-edge: #070b14;
    --d-accent: #7cc0dd;
    --d-accent-soft: rgba(124, 192, 221, 0.16);
    --d-shadow: 3px 3px 0 #04070d;
    /* The town's night colours for the example pieces. */
    --w-card: #1f2a40;
    --w-card-solid: #283550;
    --w-ink: #f3e8d2;
    --w-ink-soft: #c3cadb;
    --w-ink-faint: #8e98ae;
    --w-line: rgba(195, 202, 219, 0.2);
    --w-edge: #070b14;
    --w-accent: #7cc0dd;
    --w-accent-soft: rgba(124, 192, 221, 0.16);
    --w-good: #7fc070;
    --w-bad: #ef7a64;
    --w-shadow: 3px 3px 0 #04070d;
    --w-bevel: inset -2px -2px 0 rgba(0, 0, 0, 0.35), inset 2px 2px 0 rgba(255, 255, 255, 0.1);
    --w-sunk: inset 2px 2px 0 rgba(0, 0, 0, 0.35), inset -2px -2px 0 rgba(255, 255, 255, 0.06);
    --w-portrait-bg: #3a4a68;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; background: var(--d-bg); color: var(--d-ink); font: 400 16px/1.6 var(--w-text); -webkit-font-smoothing: antialiased; }
a { color: var(--d-accent); font-weight: 800; }
code { font: 700 0.86em ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--d-accent-soft); padding: 1px 6px; border-radius: 3px; word-break: break-all; }

/* --- top bar ----------------------------------------------------------------- */
.d-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px max(20px, env(safe-area-inset-left));
  background: var(--d-bg);
  border-bottom: 2px solid var(--d-edge);
}
.d-brand { display: flex; align-items: center; gap: 10px; color: var(--d-ink); text-decoration: none; }
.d-brand b { display: block; font: 600 20px/1 var(--w-ui); }
.d-brand small { display: block; color: var(--d-faint); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.d-mark { display: block; flex: none; width: 36px; height: 36px; image-rendering: pixelated; }
.d-back { margin-left: auto; padding: 8px 16px; border-radius: 3px; background: var(--d-accent); color: var(--d-paper); text-decoration: none; font-size: 13px; }
.d-narrow { display: none; }
.d-menu { display: none; margin-left: auto; padding: 8px 14px; border-radius: 3px; border: 1px solid var(--d-line); background: var(--d-paper); color: var(--d-ink); font: 800 13px var(--w-text); }

/* --- layout ------------------------------------------------------------------- */
.d-layout { display: grid; grid-template-columns: 230px minmax(0, 760px); gap: 48px; justify-content: center; padding: 28px 24px 80px; }
.d-nav { position: sticky; top: 84px; align-self: start; display: grid; gap: 2px; max-height: calc(100vh - 110px); overflow-y: auto; }
.d-nav a { padding: 7px 12px; border-radius: 3px; color: var(--d-soft); text-decoration: none; font-size: 14px; font-weight: 700; }
.d-nav a:hover { background: var(--d-accent-soft); color: var(--d-ink); }
.d-nav a.on { background: var(--d-accent-soft); color: var(--d-ink); box-shadow: inset 3px 0 0 var(--d-accent); }

.d-main section { padding: 8px 0 28px; border-bottom: 1px solid var(--d-line); margin-bottom: 28px; }
.d-main section:last-of-type { border-bottom: 0; }
h1, h2, h3, h4 { font-family: var(--w-ui); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(34px, 5vw, 50px); letter-spacing: -0.01em; }
h2 { font-size: 30px; margin-bottom: 14px; }
h3 { font-size: 20px; margin: 22px 0 8px; }
h4 { font-size: 17px; margin-bottom: 6px; }
p, ul, ol, dl { margin: 0 0 12px; }
ul, ol { padding-left: 22px; }
li { margin: 4px 0; }
.d-kicker { color: var(--d-accent); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 8px; }
.d-lede { font-size: 18.5px; color: var(--d-soft); margin: 14px 0 20px; }

/* --- pictures ------------------------------------------------------------------- */
.d-figure { margin: 18px 0; }
.d-figure img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 3px; background: var(--d-accent-soft); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
.d-figure.wide img { aspect-ratio: 16 / 8; }
.d-figure.square img { aspect-ratio: 1; max-width: 380px; object-fit: contain; }
.d-figure figcaption { margin-top: 8px; color: var(--d-faint); font-size: 13px; font-weight: 700; }

/* --- blocks --------------------------------------------------------------------- */
.d-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.d-stats div { padding: 14px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
.d-stats b { display: block; font: 600 24px/1.1 var(--w-ui); }
.d-stats span { color: var(--d-soft); font-size: 12.5px; font-weight: 700; }
.d-steps { counter-reset: step; list-style: none; padding: 0; display: grid; gap: 10px; }
.d-steps li { counter-increment: step; position: relative; padding: 12px 14px 12px 54px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); margin: 0; }
.d-steps li::before { content: counter(step); position: absolute; left: 14px; top: 12px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 2px; background: var(--d-accent); color: var(--d-paper); font-weight: 800; font-size: 14px; }
.d-note { color: var(--d-soft); font-size: 14.5px; }
.d-callout { margin: 0 0 14px; padding: 12px 16px; border-radius: 3px; background: var(--d-accent-soft); border-left: 4px solid var(--d-accent); font-weight: 700; }
.d-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.d-card { padding: 14px 16px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
.d-card ul { margin: 0; padding-left: 18px; font-size: 15px; }
.d-defs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.d-defs dt { font-weight: 800; }
.d-defs dd { margin: 0; color: var(--d-soft); }
.d-table-wrap { overflow-x: auto; margin: 10px 0 14px; border-radius: 3px; border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); background: var(--d-paper); }
.d-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.d-table th { text-align: left; padding: 10px 14px; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--d-faint); border-bottom: 1px solid var(--d-line); }
.d-table td { padding: 9px 14px; border-bottom: 1px solid var(--d-line); }
.d-table tr:last-child td { border-bottom: 0; }
.d-table td:first-child { font-weight: 800; text-transform: capitalize; }
.d-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 3px; background: var(--d-accent-soft); font-size: 11px; font-weight: 800; text-transform: none; }
.d-tiers { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.d-tiers .w-tier { font-size: 12.5px; padding: 4px 11px; }
.d-mono { font-size: 14px; color: var(--d-soft); }
details { margin: 0 0 8px; padding: 12px 16px; border-radius: 3px; background: var(--d-paper); border: 2px solid var(--d-edge); box-shadow: var(--d-shadow); }
details summary { cursor: pointer; font-weight: 800; }
details p { margin: 8px 0 0; color: var(--d-soft); }
.d-foot { color: var(--d-faint); font-size: 13.5px; padding-top: 10px; }

/* --- the town's UI, shown as examples ------------------------------------------------ */
.d-demo { margin: 14px 0; padding: 16px; border-radius: 3px; background: repeating-linear-gradient(135deg, var(--d-accent-soft) 0 12px, transparent 12px 24px); border: 1px dashed var(--d-line); display: grid; gap: 10px; }
.d-demo .w-me.d-static { position: static; transform: none; max-width: 100%; flex-wrap: wrap; justify-self: start; }
.d-demo .w-me-btn { cursor: default; }
.d-demo .w-cta { margin: 0; }
.d-demo .w-btn { cursor: default; }

/* --- phones ---------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .d-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 16px 16px 60px; }
  .d-menu { display: block; }
  .d-top { gap: 8px; padding: 10px 14px; }
  .d-back { margin-left: 0; padding: 8px 14px; }
  .d-wide { display: none; }
  .d-narrow { display: inline; }
  .d-nav { position: fixed; z-index: 19; top: 62px; left: 12px; right: 12px; max-height: 70vh; padding: 8px; border-radius: 3px; background: var(--d-paper); border: 1px solid var(--d-line); box-shadow: var(--d-shadow); display: none; }
  .d-nav.open { display: grid; }
  .d-stats { grid-template-columns: 1fr 1fr; }
  .d-two { grid-template-columns: 1fr; }
  .d-defs { grid-template-columns: 1fr; gap: 2px; }
  .d-defs dd { margin-bottom: 8px; }
  h2 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* --- the town's look: pixel headings, flat stamps, raised buttons ---------------- */
h1, h2, h3, h4, .d-brand b, .d-mark, .d-stats b, .d-kicker, .d-back, .d-menu, .d-table th, .d-steps li::before, .d-badge { font-family: var(--w-ui); font-weight: 600; letter-spacing: 0.01em; }
h1 { letter-spacing: 0; }
.d-back, .d-menu { border: 2px solid var(--d-edge); box-shadow: var(--w-bevel); }
.d-back { color: var(--d-paper); }

.d-callout { border: 2px solid var(--d-edge); border-left-width: 6px; border-left-color: var(--d-accent); }
.d-demo { border-radius: 3px; background: repeating-conic-gradient(var(--d-accent-soft) 0 25%, transparent 0 50%) 0 0 / 12px 12px; }
.d-demo .w-ico { color: currentColor; }
.d-nav a.on { box-shadow: inset 4px 0 0 var(--d-accent); }
a { font-weight: 600; }
.d-defs dt, details summary, .d-table td:first-child { font-weight: 600; }
