:root {
  --cover: #262823; --cover-2: #30332c; --gold: #c9a968; --gold-dim: #8c7647; --gold-ink: #b49a63;
  --paper: #f7f5ef; --surface: #fffdf8; --sunk: #efebe1; --ink: #1c1a17; --muted: #57524a; --line: #ddd6c6;
  --accent: #2f5544; --accent-ink: #ffffff; --accent-soft: #e2ebe3; --link: #2f5544; --ext: #8a5a1c;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --sans: "Source Sans 3", "Gill Sans", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --danger: #a12b2b; accent-color: var(--accent);
}
[hidden] { display: none !important }
@media (prefers-color-scheme: dark) { :root {
  --paper: #1d1e1a; --surface: #25271f; --sunk: #2e3029; --ink: #ece6d6; --muted: #b3aa94; --line: #3d3f35;
  --accent: #c9a968; --accent-ink: #1d1e1a; --accent-soft: #3a3526; --link: #d4b878; --ext: #9ec2ad; --danger: #e8826f; color-scheme: dark } }

.gx-head { position: relative; z-index: 1200; display: flex; align-items: center; gap: 28px; height: 50px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); background: var(--cover); color: var(--gold); border-bottom: 1px solid var(--gold-dim); font: 15px/1.3 var(--sans) }
.gx-head a { color: inherit; text-decoration: none }
.gx-brand { display: flex; align-items: center; gap: 10px; flex: none }
.gx-brand img { width: 30px; height: 30px; display: block; margin: -3px 0 }
.gx-brand span { font: 500 20px/24px var(--serif); display: block }
.gx-nav { display: flex; align-items: center; gap: 2px }
.gx-nav a { display: block; padding: 0 12px; height: 32px; line-height: 32px; border-radius: 7px; color: var(--gold-ink); letter-spacing: .03em; white-space: nowrap }
.gx-avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; border: 1.5px solid var(--gold); display: grid; place-items: center; background: var(--cover-2); text-decoration: none }
.gx-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22% }
.gx-avatar i { font: 600 14px var(--sans); font-style: normal; color: var(--gold); letter-spacing: .02em }
summary.gx-avatar { list-style: none; cursor: pointer }
summary.gx-avatar::-webkit-details-marker { display: none }
.gx-avatar:hover { box-shadow: 0 0 0 3px var(--cover-2), 0 0 0 4px var(--gold) }
.gx-tools { display: flex; align-items: center; gap: 6px; margin-left: auto }
.gx-icon { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--gold); cursor: pointer; padding: 0 }
.gx-icon:hover { background: var(--cover-2) }
.gx-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round }
.gx-burger { display: none }
.gx-icon .gx-x, .gx-head.searching [data-find] svg, .gx-head.menuopen .gx-burger svg { display: none }
.gx-head.searching [data-find] .gx-x, .gx-head.menuopen .gx-burger .gx-x { display: block }
.gx-head .gx-search { display: none; position: relative; flex: 1; max-width: 560px }
.gx-head.searching .gx-search:not([hidden]) { display: block }
.gx-head.searching .gx-nav { display: none }
.gx-head .gx-results { left: 0; right: auto; width: min(420px, 92vw) }
.gx-head .gx-search[hidden] ~ .gx-tools [data-find] { display: none }
.gx-search input { font: 15px var(--sans); width: 100%; padding: 8px 10px 8px 32px; border: 1px solid var(--gold-dim); border-radius: 8px; background: var(--cover-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23b49a63' stroke-width='2'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5 13 13'/%3E%3C/svg%3E") 11px 50% no-repeat; color: #f1ead8 }
.gx-nav a:hover { color: var(--gold); background: var(--cover-2) }
.gx-nav a[aria-current="page"] { color: var(--cover); background: var(--gold); font-weight: 600 }
.gx-search input::placeholder { color: #8f8566 }
.gx-search input:focus { outline: none; border-color: var(--gold) }
.gx-results { position: absolute; z-index: 60; top: calc(100% + 6px); right: 0; width: min(360px, 92vw); margin: 0; padding: 4px; list-style: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.25); max-height: 60vh; overflow: auto }
.gx-results a { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; color: var(--ink) }
.gx-results a:hover, .gx-results a.active { background: var(--sunk) }
.gx-results img, .gx-results i { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: 50% 22%; flex: none; background: var(--sunk); display: grid; place-items: center; font: 500 11px var(--serif); font-style: normal; color: var(--muted) }
.gx-results b { display: block; font-weight: 600 }
.gx-results small { color: var(--muted); font-size: 13px }
.gx-results .gx-none { padding: 8px 10px; color: var(--muted); font-size: 14px }
.gx-foot .linkish { color: var(--gold) }
.gx-btn { font: 15px var(--sans); border: 1px solid var(--gold-dim); background: transparent; color: var(--gold); padding: 5px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis }
.gx-btn:hover { border-color: var(--gold); background: var(--cover-2) }
.gx-head .account { position: relative }
.gx-head .acct summary { list-style: none; font: 15px var(--sans); margin: 0 }
.gx-head details { background: none; padding: 0; margin: 0; text-align: left; font: inherit }
.gx-head .acct summary::-webkit-details-marker { display: none }
.gx-head .acct .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; max-width: calc(100vw - 16px); display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.25) }
.gx-head .acct .menu p { margin: 0 6px 6px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere }
.gx-head .acct .menu a, .gx-head .acct .menu button { font: 15px var(--sans); text-align: left; border: 0; background: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--ink) }
.gx-head .acct .menu a:hover, .gx-head .acct .menu button:hover { background: var(--sunk) }

.gx-foot { background: var(--cover); color: var(--gold-ink); border-top: 1px solid var(--gold-dim); padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); font: 14px/1.6 var(--sans); text-align: center }
.gx-foot p { margin: 4px auto; max-width: 620px }
.gx-foot nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; margin: 12px 0 8px }
.gx-foot a { color: var(--gold); text-decoration: none }
.gx-foot a:hover { text-decoration: underline }
.gx-foot .gx-small { font-size: 12.5px; color: #a89d7d }

.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); font: 15px/1.45 var(--sans) }
.dialog::backdrop { background: rgba(20, 21, 17, .55) }
.signform { position: relative; padding: 24px 26px 26px; display: flex; flex-direction: column; gap: 12px }
.signform .crest { width: 36px; margin: 0 auto -2px }
.signform h2 { font: 500 24px var(--serif); margin: 0; text-align: center; letter-spacing: .02em }
.signform p { margin: 0 }
.signform label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600 }
.signform label .muted { font-weight: 400 }
.signform input { font: 16px var(--sans); padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-weight: 400 }
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3000; display: grid; gap: 8px; width: min(92vw, 30rem) }
.toast { margin: 0; padding: 10px 14px; border: 1px solid var(--gold-dim); border-radius: 8px; background: var(--accent-soft); color: var(--ink); font: 15px/1.4 var(--sans); box-shadow: 0 4px 16px rgba(0, 0, 0, .15); cursor: pointer }
.toast.err { border-color: var(--danger); background: var(--surface) }
input.code { font-size: 1.4rem; letter-spacing: .2em; max-width: 9em }
.signform .close { position: absolute; right: 10px; top: 6px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted) }
.signform .dev { background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; font-size: 14px }
.signform .dev a { color: var(--link); font-weight: 600 }
.signform textarea { font: 15px/1.45 var(--sans); padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-weight: 400; resize: vertical }
.signform .first { margin: 4px 0 -4px }
.signform .picked { background: var(--accent-soft); padding: 8px 12px; border-radius: 8px; font-size: 14.5px }
.signform .newme { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px }
.signform .newme legend { font-size: 14px; font-weight: 600; padding: 0 4px }
.signform .relrow { display: flex; align-items: center; gap: 8px; font-size: 15px }
.signform select { font: 15px var(--sans); padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink) }
.signform .born { width: 7em }
.signform .orline { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px }
.signform .orline::before, .signform .orline::after { content: ""; flex: 1; border-top: 1px solid var(--line) }
.signform [data-link] { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 10px; font: 600 15px var(--sans); color: var(--ink); cursor: pointer }
.whohits:empty { display: none }
.whohits { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 260px; overflow: auto }
.whohits button { width: 100%; text-align: left; border: 1px solid transparent; background: none; padding: 7px 8px; border-radius: 6px; cursor: pointer; font: 15px var(--sans); color: var(--ink) }
.whohits button:hover, .whohits button.active { background: var(--sunk) }
.whohits button.picked { border-color: var(--accent); background: var(--accent-soft) }
.linkish { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; text-decoration: underline; font: inherit }
.primary { font: 600 15px var(--sans); border: 0; background: var(--accent); color: var(--accent-ink); padding: 9px 16px; border-radius: 8px; cursor: pointer }
.primary:hover { filter: brightness(1.08) }
.primary:disabled { opacity: .5; cursor: default }
.err { color: var(--danger); margin: 6px 0 0; font-size: 14px }
.muted { color: var(--muted) }
.cards .by { color: var(--muted); font-size: 13px }
.cards .by a.person { color: inherit; text-decoration: none }
.cards .by a.person:hover { color: var(--link) }
.wiki a[href^="http"], .bio-body a[href^="http"] { color: var(--ext); text-decoration-color: color-mix(in srgb, var(--ext) 45%, transparent) }


/* The book reader's own stylesheet styles every <nav>; keep the header and footer navs out of it. */
.gx-head .gx-nav, .gx-foot nav { max-width: none; margin-left: 0; margin-right: 0; padding-top: 0; padding-bottom: 0; border: 0; justify-content: flex-start; font: inherit }
.gx-foot nav { justify-content: center; margin: 12px 0 8px }
@media (max-width: 760px) {
  .gx-head { gap: 10px }
  .gx-burger { display: grid }
  .gx-head .gx-nav { display: none }
  .gx-head.menuopen .gx-nav { display: flex; flex-direction: column; align-items: stretch; gap: 0; position: absolute; top: 100%; left: 0; right: 0; padding: 6px 0 12px; background: var(--cover); border-bottom: 1px solid var(--gold-dim); box-shadow: 0 12px 24px rgba(0,0,0,.25) }
  .gx-head.menuopen .gx-nav a { height: auto; line-height: 1.3; padding: 12px max(20px, env(safe-area-inset-left)); border-radius: 0; font-size: 17px; border-left: 3px solid transparent }
  .gx-head.menuopen .gx-nav a[aria-current="page"] { background: none; color: var(--gold); border-left-color: var(--gold) }
  .gx-head.searching .gx-brand span, .gx-head.searching #account, .gx-head.searching .gx-burger { display: none }
.gx-icon .gx-x, .gx-head.searching [data-find] svg, .gx-head.menuopen .gx-burger svg { display: none }
.gx-head.searching [data-find] .gx-x, .gx-head.menuopen .gx-burger .gx-x { display: block }
  .gx-head .gx-results { position: fixed; left: 8px; right: 8px; top: 54px; width: auto }
  .gx-search input { font-size: 16px }
  .gx-btn { max-width: 120px; padding: 5px 10px }
}
@media (max-width: 560px) {
  .gx-brand span { font-size: 18px; white-space: nowrap }
  .gx-brand { flex: 0 1 auto; min-width: 0; gap: 8px }
}
.gx-viewas { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px max(16px, env(safe-area-inset-left)); background: #a2412f; color: #fff; font: 14px var(--sans) }
.gx-viewas button { border: 1px solid rgba(255,255,255,.7); background: none; color: #fff; border-radius: 6px; padding: 2px 10px; cursor: pointer; font: inherit }
.gx-viewas button:hover { background: rgba(255,255,255,.15) }
.viewasform .primary { align-self: flex-start }
.viewasform select { font: 14px var(--sans); padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink) }
.aiwrap { position: relative; display: inline-block; max-width: 100%; vertical-align: top; line-height: 0 }
.aiwrap.block { display: block; width: fit-content }
.aiwrap > img { display: block; max-width: 100% }
.aitoggle { position: absolute; right: 6px; bottom: 6px; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgba(20, 20, 18, .45); color: #fff; opacity: .55; cursor: pointer; transition: opacity .15s }
.aitoggle:hover, .aitoggle:focus-visible { opacity: 1 }
.aitoggle:focus { outline: none }
.aitoggle:focus-visible { outline: 2px solid #fff; outline-offset: 1px }
.aitoggle[aria-pressed="true"] { background: rgba(255, 255, 255, .7); color: #1c1a17 }
@media print { .aitoggle { display: none } }
.cue { margin: 12px 0 0; font: 14.5px var(--sans); color: var(--ink) }
.cuebtn { font: inherit; font-weight: 600; color: #4a3407; background: #f5dc9e; border: 1px solid #e3c06c; border-radius: 999px; padding: 6px 15px; cursor: pointer; box-shadow: 0 1px 3px rgba(150,110,20,.15) }
.cuebtn::after { content: "\00a0→" }
.cuebtn:hover { background: #f2d184; border-color: #d4ab4c }
.cuelink { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: #b8740f; text-decoration: underline; text-underline-offset: 2px; cursor: pointer }
.cuelink::after { content: " →" }
.cuelink:hover { color: #95600c }
p.cue:not(:has(.cuebtn)) { display: inline-block; background: #fbecc4; color: #4a3608; border: 1px solid #ecd08a; border-radius: 999px; padding: 5px 13px }
.gx-cue { padding: 8px 4px 4px; margin-top: 4px; border-top: 1px solid var(--line) }
.gx-cue .cue { margin: 0 }
.viewcue { position: absolute; left: 12px; bottom: 12px; z-index: 5; max-width: calc(100% - 90px) }
.viewcue .cue { margin: 0 }
.hero .cue { margin-top: 18px }
@media (max-width: 760px) { .viewcue { bottom: 56px } }
.lede + .cue { margin: 0 0 18px }
.mixhead .cue { margin: 10px 0 0 }
.viewcue.map { left: auto; right: 12px; top: 12px; bottom: auto; z-index: 1000 }
@media (max-width: 760px) { .viewcue.map { display: none } }
.gx-results .gx-locked > div { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; color: var(--ink) }
.gx-results .gx-locked span { min-width: 0; flex: 1 }
.gx-results .gx-locked .cuelink { font-size: 13.5px; white-space: nowrap }
.tip { position: fixed; left: 0; top: 0; z-index: 1000; max-width: 340px; padding: 7px 10px; background: var(--ink); color: var(--paper); font: 13px/1.4 var(--sans); white-space: pre-line; border-radius: 6px; box-shadow: 0 8px 22px rgba(0, 0, 0, .22); pointer-events: none }
.relpick { position: relative }
.relbtn { display: grid; place-items: center; color: var(--muted) }
.relbtn.on { color: var(--accent-ink); background: var(--accent) !important; border-color: var(--accent) !important }
.relmenu { position: absolute; right: calc(100% + 8px); bottom: 0; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); display: grid; gap: 2px }
.relmenu b { font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 2px 8px 4px }
.relmenu button { width: auto !important; height: auto !important; text-align: left; border: 0 !important; box-shadow: none !important; background: none; padding: 6px 8px 6px 24px; border-radius: 6px; font: 14px var(--sans); color: var(--ink); position: relative }
.relmenu button:hover { background: var(--sunk) }
.relmenu button[aria-checked="true"]::before { content: "✓"; position: absolute; left: 8px; color: var(--accent) }
@media (max-width: 760px) { .relmenu { right: 0; left: auto; bottom: calc(100% + 8px) } }
.relpick > .relbtn { width: 34px; height: 30px; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; cursor: pointer; padding: 0 }
.relpick.down .relmenu { right: 0; left: auto; top: calc(100% + 6px); bottom: auto; z-index: 30 }
.relpick.right .relmenu { left: calc(100% + 8px); right: auto; top: 0; bottom: auto; z-index: 1000 }
@media (max-width: 760px) { .relpick.down .relmenu { left: 0; right: auto } }

.photoviewer { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden }
.photoviewer::backdrop { background: rgba(12, 11, 9, .9) }
.photoviewer figure { box-sizing: border-box; height: 100%; margin: 0; padding: 56px 64px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px }
.photoviewer img { max-width: 100%; max-height: calc(100% - 48px); object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5) }
.photoviewer figcaption { max-width: 640px; color: #e9e3d6; font: 14px/1.45 var(--sans); text-align: center }
.photoviewer figcaption span { color: #a9a294; margin-left: 6px }
.photoviewer figcaption a { color: #e8c547; margin-left: 8px }
.photoviewer button { position: fixed; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 28px; line-height: 1; cursor: pointer }
.photoviewer button:hover { background: rgba(255, 255, 255, .24) }
.photoviewer .pvclose { top: 12px; right: 12px }
.photoviewer .pvstep { top: calc(50% - 22px) }
.photoviewer .prev { left: 10px }
.photoviewer .next { right: 10px }
@media (max-width: 600px) { .photoviewer figure { padding: 60px 8px 72px } .photoviewer .pvstep { top: auto; bottom: 14px } }
.gx-nav [hidden] { display: none !important }
@media (max-width: 760px) { input, select, textarea { font-size: 16px !important } }
