/* MujicaUI docs: court-gothic tokens from PRD 3.2. No web fonts, gradients, glow or glass. */
:root {
  color-scheme: light;
  --bg: #F2EBDD;
  --surface: #FBF7EF;
  --hover: #E8DFD0;
  --text: #211C1D;
  --muted: #6A5B55;
  --border: #D2C3AF;
  --control: #877662;
  --accent: #7D2034;
  --accent-hover: #651729;
  --on-accent: #FFF8EE;
  --accent-text: #7D2034;
  --selection: #EAD7D9;
  --ornament: #AD9164;
  --code-bg: #EFE6D6;
  --serif: Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191618;
    --surface: #242024;
    --hover: #342C32;
    --text: #F2EBDD;
    --muted: #BCAEAA;
    --border: #51424A;
    --control: #968278;
    --accent: #9C3C53;
    --accent-hover: #AA425C;
    --accent-text: #E4A0AE;
    --selection: #492A36;
    --ornament: #BDA172;
    --code-bg: #211D20;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191618;
  --surface: #242024;
  --hover: #342C32;
  --text: #F2EBDD;
  --muted: #BCAEAA;
  --border: #51424A;
  --control: #968278;
  --accent: #9C3C53;
  --accent-hover: #AA425C;
  --accent-text: #E4A0AE;
  --selection: #492A36;
  --ornament: #BDA172;
  --code-bg: #211D20;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  overflow-wrap: anywhere;
}
::selection { background: var(--selection); }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; text-wrap: balance; }
h1 { font-size: 1.9rem; margin: 0 0 .6rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
img { max-width: 100%; height: auto; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

/* Ornament: thin gold rule with a centered diamond. */
.rule { position: relative; height: 1px; background: var(--ornament); margin: 1.2rem auto; max-width: 320px; }
.rule span { position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; background: var(--bg); border: 1px solid var(--ornament); transform: translate(-50%, -50%) rotate(45deg); }

.top {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--ornament); background: var(--bg);
}
.brand { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; }
.lozenge { width: 9px; height: 9px; border: 1px solid var(--ornament); transform: rotate(45deg); display: inline-block; }
.toplinks { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; }
.toplinks a { color: var(--text); text-decoration: none; font-size: .92rem; padding: 4px 0; }
.toplinks a:hover { color: var(--accent-text); text-decoration: underline; }
button { font: inherit; }
.theme, .copy, .navtoggle {
  background: var(--surface); color: var(--text); border: 1px solid var(--control);
  border-radius: 2px; padding: 4px 12px; min-height: 32px; cursor: pointer;
}
.theme:hover, .copy:hover, .navtoggle:hover { background: var(--hover); }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); max-width: 1280px; margin: 0 auto; }
.navtoggle { display: none; }
.side {
  position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto;
  padding: 16px 12px 32px; border-right: 1px solid var(--border); font-size: .9rem;
}
.side details { margin-bottom: 4px; }
.side summary { font-family: var(--serif); font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 2px; }
.side summary:hover { background: var(--hover); }
.side ul { list-style: none; margin: 2px 0 8px; padding: 0 0 0 10px; border-left: 1px solid var(--border); }
.side li a { display: block; padding: 3px 8px; color: var(--text); text-decoration: none; border-radius: 2px; }
.side li a:hover { background: var(--hover); }
.side li a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.side li a[aria-current="page"] .zh { color: var(--on-accent); }
.zh { color: var(--muted); font-size: .85em; }
.count { color: var(--muted); font-family: var(--sans); font-weight: 400; font-size: .8em; }

main { min-width: 0; padding: 24px 32px 48px; }
main.solo { max-width: 920px; margin: 0 auto; }
.crumb { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }

.doc { max-width: 860px; }
.doc h1 { padding-bottom: .5rem; border-bottom: 1px solid var(--ornament); }
.doc h2 { padding-bottom: .25rem; border-bottom: 1px solid var(--border); }
.doc code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 2px; padding: 0 4px; overflow-wrap: anywhere; }
.doc ul, .doc ol { padding-left: 1.4rem; }
.doc li { margin: .2rem 0; }
.doc blockquote { margin: 1rem 0; padding: .2rem 1rem; border-left: 2px solid var(--ornament); color: var(--muted); }
.doc hr { border: 0; border-top: 1px solid var(--ornament); margin: 2rem 0; }
.code { position: relative; margin: 1rem 0; }
.code pre { margin: 0; padding: 14px 16px; padding-right: 72px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; overflow-x: auto; font: 13px/1.55 var(--mono); }
.code pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; }
.copy { position: absolute; top: 6px; right: 6px; min-height: 28px; padding: 2px 10px; font-size: .8rem; }
.table { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { background: var(--surface); font-family: var(--serif); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td code { overflow-wrap: normal; white-space: nowrap; }

/* Snapshots: both shown; the one matching the page theme comes first. */
.snaps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 24px; max-width: 860px; }
.snap { margin: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); padding: 8px; }
.snap img { display: block; margin: 0 auto; }
.snap figcaption { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 6px; }
.nosnap { padding: 32px 8px; text-align: center; color: var(--muted); }
.snap-dark { order: 2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .snap-dark { order: 0; }
  :root:not([data-theme="light"]) .snap-light { order: 1; }
}
:root[data-theme="dark"] .snap-dark { order: 0; }
:root[data-theme="dark"] .snap-light { order: 1; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--ornament); max-width: 860px; }
.pager .next { margin-left: auto; text-align: right; }

/* Index */
.hero { text-align: center; padding: 32px 0 8px; }
.hero h1 { font-size: 2.6rem; margin: 0; letter-spacing: .02em; }
.eyebrow { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 6px; }
.lede { max-width: 620px; margin: 0 auto 1rem; }
.honest { max-width: 680px; margin: 1rem auto; padding: 12px 16px; border: 1px solid var(--ornament); border-radius: 4px; background: var(--surface); text-align: left; font-size: .92rem; }
.ctas { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 1.2rem; }
.btn { display: inline-block; padding: 8px 18px; min-height: 36px; border-radius: 2px; background: var(--accent); color: var(--on-accent); text-decoration: none; border: 1px solid var(--accent); }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--accent-text); border-color: var(--control); }
.btn.ghost:hover { background: var(--hover); }
.search { margin: 32px 0 8px; }
.search label { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; margin-bottom: 6px; }
.search input { width: 100%; font: inherit; padding: 8px 12px; min-height: 40px; border: 1px solid var(--control); border-radius: 2px; background: var(--surface); color: var(--text); }
.qcount { color: var(--muted); font-size: .85rem; margin: 6px 0; min-height: 1.2em; }
.results { list-style: none; padding: 0; margin: 0; }
.results li a { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 6px 10px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.results li a:hover { background: var(--hover); }
.results .c { color: var(--muted); font-size: .8rem; margin-left: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.cat { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; text-decoration: none; color: var(--text); }
.cat:hover { border-color: var(--ornament); background: var(--hover); }
.cname { font-family: var(--serif); font-weight: 600; }
.catlist h2 { scroll-margin-top: 12px; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.cards a { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: 2px; text-decoration: none; color: var(--text); background: var(--surface); }
.cards a:hover { background: var(--hover); }
.num { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.n { font-weight: 600; }

.foot { padding: 8px 16px 32px; text-align: center; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); margin-top: 24px; }
.foot p { max-width: 720px; margin: .5rem auto; }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .navtoggle { display: block; margin: 12px 16px 0; }
  .side { display: none; position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .side.open { display: block; }
  main { padding: 16px 16px 40px; }
}
@media (max-width: 520px) {
  .snaps { grid-template-columns: minmax(0, 1fr); }
  .hero h1 { font-size: 2rem; }
  h1 { font-size: 1.55rem; }
  .theme { margin-left: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
