:root {
  --bg: #16151b; --panel: #211f28; --text: #e4e1ec; --accent: #a99be0; --soft: #8a8796;
  --paper2: rgba(169,155,224,.08); --ink: #e4e1ec; --inksoft: #8a8796; --inkacc: #b9adf0; --rule: rgba(169,155,224,.18);
  --sans: "Archivo", system-ui, sans-serif; --serif: "Instrument Serif", Georgia, serif;
  --book: "Latin Modern Roman", "CMU Serif", "Computer Modern", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--sans); }
body { overflow-x: hidden; }

/* ---------- the world ---------- */
#hero { position: relative; height: 100vh; height: 100svh; overflow: hidden; }
#hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22%; z-index: 2; pointer-events: none;
  background: linear-gradient(rgba(22,21,27,0), var(--bg)); }
#sky, #stage { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage { z-index: 1; }
#world { width: 100%; height: 100%; display: block; }
#divi { cursor: pointer; }
.glabel { font: 400 13px var(--sans); fill: var(--soft); letter-spacing: .04em; }
.purl { font: 400 8.5px var(--sans); fill: var(--soft); }
.ptitle { font: 400 8.6px var(--sans); fill: #e4e1ec; }
.pline { font: 400 6.6px var(--sans); fill: #8a8796; }

.top { position: absolute; z-index: 3; top: 0; left: 0; right: 0; padding: max(16px, env(safe-area-inset-top)) 20px 0; pointer-events: none; }
h1 { font: 400 34px/1 var(--serif); margin: 0 0 6px; letter-spacing: .01em; }
#status { margin: 0; color: var(--text); opacity: .8; font-size: 14px; }
#status.in { animation: rise .5s ease; }
#mode { margin: 2px 0 0; color: var(--soft); font-size: 12px; }
#mode.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; animation: dots 1.6s infinite; }
#caption { margin: 8px 0 0; max-width: min(46ch, 70vw); color: var(--text); opacity: .72; font: italic 400 15px/1.35 var(--book);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#caption.in { animation: rise .6s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: .8; transform: none; } }

#down { position: absolute; z-index: 3; right: 20px; bottom: calc(40px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 4px;
  color: var(--soft); text-decoration: none; font-size: 12px; letter-spacing: .04em; }
#down:hover { color: var(--text); }
#down svg { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(5px); } }

/* ---------- chat ---------- */
#ask { position: fixed; z-index: 6; left: 50%; bottom: calc(34px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); display: flex; gap: 8px; padding: 6px; border-radius: 999px;
  background: rgba(33,31,40,.82); border: 1px solid rgba(169,155,224,.3); backdrop-filter: blur(10px); }
#ask input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: 400 15px var(--sans); padding: 8px 14px; }
#ask input::placeholder { color: var(--soft); }
#ask button { border: 0; border-radius: 999px; padding: 8px 18px; background: var(--accent); color: #1a1824; font: 500 14px var(--sans); cursor: pointer; }
#ask.busy button { opacity: .5; }

#bubble { position: fixed; z-index: 7; width: min(380px, calc(100% - 24px)); padding: 14px 18px 16px; border-radius: 18px;
  background: rgba(33,31,40,.94); border: 1px solid rgba(169,155,224,.4); backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(8px) scale(.98); pointer-events: none; transition: opacity .3s ease, transform .3s ease;
  max-height: 46vh; overflow-y: auto; }
#bubble.on { opacity: 1; transform: none; pointer-events: auto; }
#btext { margin: 0; white-space: pre-wrap; padding-right: 14px; }
#btext.wait::after { content: "· · ·"; letter-spacing: .2em; color: var(--accent); animation: dots 1.2s infinite; }
@keyframes dots { 50% { opacity: .2; } }
#bsrc { margin: 8px 0 0; font: 400 12px var(--sans); color: var(--soft); }
#bsrc:empty { display: none; }
#bsrc a { color: var(--accent); text-underline-offset: 3px; }
#bclose { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--soft); font-size: 18px; cursor: pointer; }

/* ---------- the paper ---------- */
#paper { position: relative; z-index: 2; padding: 40px 16px 150px; background: var(--bg); }
#paper::before { content: ""; position: absolute; left: 50%; top: 0; width: min(900px, 90%); height: 420px; transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(ellipse at top, rgba(169,155,224,.07), rgba(169,155,224,0) 70%); }
.sheet { position: relative; max-width: 1060px; margin: 0 auto; color: var(--ink);
  padding: 24px clamp(4px, 4vw, 56px) 40px; font: 400 16px/1.65 var(--book); }
.phead { text-align: center; max-width: 720px; margin: 0 auto 40px; }
.pmeta { margin: 0 0 26px; font: 400 12px var(--sans); color: var(--inksoft); letter-spacing: .05em; }
.ptitle { font: 400 clamp(34px, 5vw, 52px)/1.1 var(--serif); margin: 0 0 18px; letter-spacing: -.005em; }
.pauthor { margin: 0; font-size: 18px; }
.paffil { margin: 2px 0 0; font-size: 14px; font-style: italic; color: var(--inksoft); }
.abstract { margin: 34px auto 0; max-width: 600px; text-align: justify; hyphens: auto; font-size: 15px; }
.abstract h3 { text-align: center; font: 400 15px var(--book); font-style: italic; color: var(--inkacc); margin: 0 0 6px; letter-spacing: .02em; }
.abstract p { margin: 0 0 8px; }
.pnote { color: var(--inksoft); font-style: italic; }

.pcols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 44px; border-top: 1px solid var(--rule); padding-top: 34px; }
.psec { font: 400 26px/1.2 var(--serif); color: var(--ink); margin: 0 0 14px; }
.plog { border-right: 1px solid var(--rule); padding-right: 30px; }
.empty { color: var(--inksoft); font-style: italic; }

#hist { list-style: none; margin: 0; padding: 0; font-size: 14px; }
#hist li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
#hist li:first-child { padding-top: 0; }
#hist time { display: block; font: 400 12px var(--sans); color: var(--inksoft); }
#hist .msg { display: block; margin: 2px 0 4px; }
#hist .stat { font: 400 12px var(--sans); }
#hist .add { color: #8fd1ad; } #hist .del { color: #e39ab0; }
#hist button { font: 400 12px var(--sans); color: var(--inkacc); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#hist pre { margin: 8px 0 0; padding: 10px; background: var(--paper2); border-radius: 3px; overflow-x: auto; font: 400 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
#hist pre .a { color: #8fd1ad; } #hist pre .d { color: #e39ab0; } #hist pre .h { color: var(--inksoft); }

.psec2 { margin-top: 38px; }
#runs { list-style: none; margin: 0; padding: 0; font-size: 14px; }
#runs li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
#runs time { display: block; font: 400 12px var(--sans); color: var(--inksoft); }
#runs .task { display: block; margin: 2px 0; }
#runs .out { display: block; color: var(--inksoft); font-style: italic; }
#runs .src { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; font: 400 12px var(--sans); }
#runs .src a { color: var(--inkacc); text-underline-offset: 3px; }
#runs blockquote { margin: 8px 0 0; padding-left: 10px; border-left: 2px solid rgba(169,155,224,.35); font-size: 13.5px; }
#runs blockquote small { display: block; color: var(--inksoft); font: 400 11.5px var(--sans); margin-top: 2px; }
#hb { text-align: justify; hyphens: auto; }
#hb h1, #hb h2, #hb h3, #hb h4 { font-family: var(--book); text-align: left; line-height: 1.3; scroll-margin-top: 20px; }
#hb h1 { font-size: 25px; font-weight: 400; margin: 0 0 12px; }
#hb h2 { font-size: 21px; font-weight: 400; margin: 28px 0 8px; }
#hb h3 { font-size: 17.5px; font-weight: 400; font-style: italic; margin: 22px 0 6px; }
#hb h4 { font-size: 16px; font-weight: 400; font-style: italic; margin: 18px 0 4px; }
#hb p { margin: 0 0 12px; }
#hb ul, #hb ol { margin: 0 0 12px; padding-left: 22px; }
#hb blockquote { margin: 0 0 12px; padding: 2px 0 2px 16px; border-left: 2px solid rgba(169,155,224,.45); color: var(--inksoft); font-style: italic; }
#hb code { font: 400 13.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--paper2); padding: 1px 4px; border-radius: 3px; }
#hb pre { background: var(--paper2); padding: 12px; border-radius: 3px; overflow-x: auto; text-align: left; }
#hb pre code { background: none; padding: 0; }
#hb a { color: var(--inkacc); text-underline-offset: 3px; }
#hb .tbl { overflow-x: auto; margin: 0 0 16px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
#hb table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 1.4; text-align: left; }
#hb th { font-weight: 400; font-style: italic; color: var(--inkacc); border-bottom: 1px solid var(--rule); padding: 7px 8px; white-space: nowrap; }
#hb td { padding: 6px 8px; border-bottom: 1px solid rgba(169,155,224,.08); vertical-align: top; }
#hb td code { font-size: 11.5px; white-space: nowrap; }
/* the register */
#hb .reg { margin: 6px 0 24px; text-align: left; }
#hb .rbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 10px 0; background: var(--bg); }
#hb .rq { flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid var(--rule); color: var(--ink);
  font: 400 15px var(--sans); padding: 8px 2px; outline: 0; transition: border-color .2s; }
#hb .rq:focus { border-color: var(--accent); }
#hb .rq::placeholder { color: var(--inksoft); }
#hb .rcount { font: 400 12px var(--sans); color: var(--inksoft); white-space: nowrap; }
#hb .rhead, #hb .rrow { display: grid; grid-template-columns: 3.2ch minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: baseline; }
#hb .rhead { padding: 6px 10px; font: 400 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--inksoft); }
#hb .rlist { list-style: none; margin: 0; padding: 0; }
#hb .ri { border-top: 1px solid rgba(169,155,224,.09); }
#hb .ri:last-child { border-bottom: 1px solid rgba(169,155,224,.09); }
#hb .rrow { width: 100%; padding: 11px 10px; background: none; border: 0; color: inherit; text-align: left; cursor: pointer; font: inherit; border-radius: 6px; transition: background .2s; }
#hb .rrow:hover, #hb .ri.on .rrow { background: rgba(169,155,224,.06); }
#hb .rnum { font: 400 12px var(--sans); color: var(--inksoft); font-variant-numeric: tabular-nums; }
#hb .rname { font-size: 16.5px; }
#hb .rname small { display: block; margin-top: 1px; font: italic 400 13px/1.35 var(--book); color: var(--inksoft); }
#hb .rorig { font-size: 14px; color: var(--ink); opacity: .85; }
#hb .rhow { font: 400 12.5px var(--sans); color: var(--inkacc); letter-spacing: .02em; }
#hb .rmore { display: none; padding: 2px 10px 16px calc(3.2ch + 24px); font-size: 14.5px; }
#hb .ri.on .rmore { display: block; animation: rise .35s ease; }
#hb .rmore p { margin: 0 0 8px; }
#hb .rmore dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font: 400 12.5px var(--sans); }
#hb .rmore dt { color: var(--inksoft); }
#hb .rmore dd { margin: 0; }
#hb .rmore code { font-size: 11.5px; }
#hb .rall { display: block; margin: 14px auto 0; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 8px 20px;
  color: var(--inkacc); font: 400 13px var(--sans); cursor: pointer; transition: border-color .2s; }
#hb .rall:hover { border-color: var(--accent); }
#hb .reg.open .rall { display: none; }
#hb .rnone { color: var(--inksoft); font-style: italic; padding: 12px 10px; }
#hb details.rules { margin: 6px 0 26px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
#hb details.rules summary { cursor: pointer; padding: 12px 2px; list-style: none; font-size: 16px; }
#hb details.rules summary::-webkit-details-marker { display: none; }
#hb details.rules summary::before { content: "+"; display: inline-block; width: 1.4em; color: var(--accent); font-family: var(--sans); }
#hb details.rules[open] summary::before { content: "−"; }
#hb details.rules summary span { margin-left: 8px; font: 400 12px var(--sans); color: var(--inksoft); }
#hb details.rules > :not(summary) { margin-left: 1.4em; }
#hb hr { border: 0; border-top: 1px solid var(--rule); margin: 22px 0; }

.pfoot { max-width: 1060px; margin: 0 auto; color: var(--soft); }

@media (max-width: 760px) {
  h1 { font-size: 28px; }
  #mode { max-width: 60vw; }
  #down { right: 50%; transform: translateX(50%); bottom: calc(96px + env(safe-area-inset-bottom)); }
  .sheet { padding-top: 16px; font-size: 15.5px; }
  .pcols { grid-template-columns: 1fr; gap: 34px; }
  #hb .rhead { display: none; }
  #hb .rrow { grid-template-columns: 3.2ch minmax(0, 1fr); row-gap: 2px; }
  #hb .rorig, #hb .rhow { grid-column: 2; }
  #hb .rorig { font-size: 13px; }
  #hb .rmore { padding-left: 10px; }
  .pbook { order: 1; } .plog { order: 2; border-right: 0; padding-right: 0; border-top: 1px solid var(--rule); padding-top: 26px; }
}
