/* ==========================================================
   Character Record — archive edition
   Palette: Navy #0F294A · Slate #1E293B · Paper #F8FAFC · Gold #B45309
   ========================================================== */
:root {
  --navy: #0F294A;
  --navy-deep: #0A1D36;
  --slate: #1E293B;
  --paper: #F8FAFC;
  --sheet: #FFFEFB;
  --gold: #B45309;
  --gold-soft: #D9A066;
  --rule: #D8DEE6;
  --muted: #5B6778;
  --ok: #166534;
  --bad: #9F1D1D;
  --serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --radius: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--slate);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* faint paper grain */
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.06 0 0 0 0 0.16 0 0 0 0 0.29 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body.locked { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { position: relative; z-index: 1; width: min(1080px, 100% - 40px); margin-inline: auto; }
.mono { font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: .85rem 1.35rem; font-weight: 600; font-size: .92rem; letter-spacing: .01em;
  text-decoration: none; overflow: hidden; isolation: isolate;
  transition: color .35s var(--ease), border-color .35s var(--ease), transform .2s var(--ease), box-shadow .35s var(--ease);
}
.btn::after { /* sweep fill */
  content: ""; position: absolute; inset: 0; z-index: -1;
  transform: scaleX(0); transform-origin: left;
  transition: transform .45s var(--ease);
}
.btn:hover::after { transform: scaleX(1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }
.btn-ink { background: var(--navy); color: #fff; }
.btn-ink::after { background: var(--gold); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold::after { background: var(--navy-deep); }
.btn-line { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-line::after { background: var(--navy); }
.btn-line:hover { color: #fff; }
.btn-ghost { background: rgba(255,255,255,.06); color: #fff; border-color: rgba(255,255,255,.28); }
.btn-ghost::after { background: rgba(255,255,255,.14); }
.btn-danger { background: transparent; color: var(--bad); border-color: #E7B4B4; }
.btn-danger::after { background: var(--bad); }
.btn-danger:hover { color: #fff; }
.btn-sm { padding: .5rem .8rem; font-size: .78rem; }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--gold); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ---------- Top strip ---------- */
.strip { background: var(--navy-deep); color: rgba(255,255,255,.7); border-bottom: 1px solid rgba(217,160,102,.25); position: relative; z-index: 2; }
.strip .wrap { display: flex; justify-content: space-between; gap: 1rem; padding-block: .6rem; }
.strip .mono { font-size: .64rem; }
.strip .hide-sm { display: none; }
@media (min-width: 720px) { .strip .hide-sm { display: inline; } }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(217,160,102,.16), transparent 60%),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
}
.hero::before { /* archival ruled grid */
  content: ""; position: absolute; inset: 0; opacity: .07;
  background-image: linear-gradient(rgba(255,255,255,.9) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.9) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}
.hero .wrap { padding-block: 3rem 0; display: grid; gap: 2.5rem; }
@media (min-width: 900px) { .hero .wrap { grid-template-columns: 1fr 260px; align-items: center; padding-top: 5rem; } }
.badge {
  display: inline-block; border: 1px solid rgba(217,160,102,.55); color: var(--gold-soft);
  padding: .5rem .8rem; font-family: var(--mono); font-size: .62rem; letter-spacing: .2em; line-height: 1.6;
}
.hero h1 {
  font-family: var(--serif); font-weight: 500; font-size: clamp(2.6rem, 7.5vw, 4.9rem);
  line-height: 1.02; letter-spacing: -.01em; margin: 1.4rem 0 1.1rem;
}
.hero h1 em { font-style: italic; color: var(--gold-soft); font-weight: 500; }
.hero .lede { font-size: 1.08rem; color: rgba(255,255,255,.78); max-width: 34rem; margin: 0; }
.hero .actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

.seal { width: 220px; height: 220px; margin-inline: auto; position: relative; display: none; }
@media (min-width: 900px) { .seal { display: block; } }
.seal svg { width: 100%; height: 100%; }
.seal .ring { transform-origin: 50% 50%; animation: spin 80s linear infinite; }
.seal .core { font-family: var(--serif); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Ledger of totals */
.ledger {
  position: relative; z-index: 1; margin-top: 2.25rem;
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(255,255,255,.18);
}
.ledger > div { padding: 1.4rem .2rem 1.6rem; border-right: 1px solid rgba(255,255,255,.12); }
.ledger > div + div { padding-left: 1rem; }
.ledger > div:last-child { border-right: 0; }
.ledger .num { font-family: var(--serif); font-size: clamp(2.3rem, 8vw, 3.6rem); font-weight: 500; line-height: 1; color: #fff; font-variant-numeric: lining-nums tabular-nums; }
.ledger .num.gold { color: var(--gold-soft); }
.ledger .mono { display: block; margin-top: .6rem; font-size: .6rem; color: rgba(255,255,255,.62); line-height: 1.5; }
.privacy-note { position: relative; z-index: 1; display: flex; gap: .6rem; align-items: center; padding: 1rem 0 1.4rem; color: rgba(255,255,255,.62); font-size: .82rem; border-top: 1px solid rgba(255,255,255,.12); }
.privacy-note svg { width: 15px; height: 15px; flex: none; color: var(--gold-soft); }

/* ---------- Folios (sections) ---------- */
main { position: relative; z-index: 1; }
.folio { padding-block: 4.5rem; border-bottom: 1px solid var(--rule); }
.folio:last-of-type { border-bottom: 0; }
.folio-grid { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .folio-grid { grid-template-columns: 200px 1fr; gap: 3rem; } }
.folio-mark { display: flex; flex-direction: row; align-items: baseline; gap: 1rem; }
@media (min-width: 900px) { .folio-mark { flex-direction: column; gap: .4rem; position: sticky; top: 2rem; align-self: start; } }
.folio-mark .sym { font-family: var(--serif); font-size: 2.6rem; line-height: 1; color: var(--gold); font-style: italic; }
.folio-mark .mono { color: var(--muted); }
.folio h2 { font-family: var(--serif); font-weight: 600; color: var(--navy); font-size: clamp(1.9rem, 4.4vw, 2.6rem); line-height: 1.1; margin: 0 0 1.1rem; letter-spacing: -.005em; }
.folio p.body { font-size: 1.06rem; line-height: 1.8; color: #2B3648; margin: 0; max-width: 64ch; }
.dropcap::first-letter { font-family: var(--serif); float: left; font-size: 3.9rem; line-height: .82; padding: .32rem .55rem 0 0; color: var(--navy); font-weight: 600; }

/* Exhibits */
.exhibits { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
@media (min-width: 760px) { .exhibits { grid-template-columns: repeat(3, 1fr); } }
.exhibit { background: var(--sheet); padding: 1.6rem 1.5rem 1.8rem; position: relative; transition: background .4s var(--ease); }
.exhibit:hover { background: #fff; }
.exhibit::before { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--gold); transition: width .6s var(--ease); }
.exhibit:hover::before { width: 100%; }
.exhibit .mono { color: var(--gold); }
.exhibit h3 { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; color: var(--navy); line-height: 1.2; margin: .7rem 0 .6rem; }
.exhibit p { margin: 0; font-size: .93rem; color: var(--muted); line-height: 1.7; }

/* Document card */
.document {
  background: var(--sheet); border: 1px solid var(--rule); position: relative;
  padding: 2rem 1.6rem; box-shadow: 0 1px 0 #fff inset, 0 18px 40px -28px rgba(15,41,74,.35);
}
@media (min-width: 640px) { .document { padding: 2.6rem 2.6rem; } }
.document::before, .document::after { /* stacked-paper edges */
  content: ""; position: absolute; left: 10px; right: 10px; height: 100%; z-index: -1;
  background: var(--sheet); border: 1px solid var(--rule);
}
.document::before { bottom: -6px; transform: rotate(-.35deg); }
.document::after { bottom: -11px; left: 20px; right: 20px; transform: rotate(.4deg); opacity: .7; }
.doc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; padding-bottom: 1.1rem; margin-bottom: 1.4rem; border-bottom: 1px dashed var(--rule); color: var(--muted); }
.document h3 { font-family: var(--serif); font-size: 1.8rem; color: var(--navy); font-weight: 600; margin: 0 0 1rem; line-height: 1.15; }
.document p { margin: 0; line-height: 1.8; color: #2B3648; font-size: 1.02rem; }
.document .btn { margin-top: 1.8rem; }

/* ---------- Form ---------- */
.form { display: grid; gap: 2rem; }
.field-label { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--navy); margin-bottom: .5rem; }
.req { color: var(--gold); }
.opt { color: #8A94A3; letter-spacing: .08em; }
.types { display: grid; gap: 1rem; }
@media (min-width: 680px) { .types { grid-template-columns: 1fr 1fr; } }
.type { display: block; cursor: pointer; }
.type .card {
  height: 100%; padding: 1.25rem 1.3rem 1.3rem 3.1rem; border: 1px solid var(--rule); background: var(--sheet);
  position: relative; transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
.type .card::before { content: ""; position: absolute; left: 1.15rem; top: 1.4rem; width: 16px; height: 16px; border: 1px solid #9AA5B4; border-radius: 50%; transition: all .3s var(--ease); }
.type .card strong { display: block; font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--navy); line-height: 1.2; }
.type .card span { display: block; font-size: .9rem; color: var(--muted); margin-top: .35rem; line-height: 1.55; }
.type:hover .card { border-color: #A9B3C1; }
.type input:checked + .card { border-color: var(--gold); background: #FFFBF3; box-shadow: 0 0 0 1px var(--gold); }
.type input:checked + .card::before { border-color: var(--gold); box-shadow: inset 0 0 0 4px #FFFBF3; background: var(--gold); }
.type input:focus-visible + .card { outline: 2px solid var(--navy); outline-offset: 3px; }

.fields { display: grid; gap: 1.75rem 2rem; }
@media (min-width: 680px) { .fields { grid-template-columns: 1fr 1fr; } }
.input, .textarea {
  width: 100%; border: 0; border-bottom: 1px solid #9AA5B4; background: transparent; border-radius: 0;
  padding: .55rem 0 .6rem; font: inherit; font-size: 1.05rem; color: var(--slate);
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.textarea { border: 1px solid #C4CCD7; padding: .8rem .9rem; resize: vertical; min-height: 7rem; background: var(--sheet); }
.input:focus, .textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 1px 0 0 var(--navy); }
.textarea:focus { box-shadow: 0 0 0 1px var(--navy); }
.help { font-size: .8rem; color: #788396; margin: .45rem 0 0; }
.counter { text-align: right; font-family: var(--mono); font-size: .66rem; color: #8A94A3; margin-top: .4rem; transition: color .3s; }
.counter.warn { color: var(--gold); }

.sigbox { position: relative; border: 1px solid #C4CCD7; background: #fff; overflow: hidden; }
.sigbox canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; }
.sigbox .baseline { position: absolute; left: 1.5rem; right: 1.5rem; bottom: 2.6rem; border-bottom: 1px solid #C4CCD7; pointer-events: none; }
.sigbox .x { position: absolute; left: 1.5rem; bottom: 2.75rem; font-family: var(--serif); font-size: 1.3rem; color: #9AA5B4; pointer-events: none; }
.sigbox .hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9AA5B4; font-size: .9rem; pointer-events: none; transition: opacity .3s; }
.sigbox.signed .hint { opacity: 0; }
.sighead { display: flex; justify-content: space-between; align-items: baseline; }

.consent { display: flex; gap: .9rem; align-items: flex-start; padding: 1.2rem 1.2rem; background: #F1F4F8; border-left: 2px solid var(--navy); cursor: pointer; }
.consent input { width: 20px; height: 20px; margin-top: .2rem; accent-color: var(--navy); flex: none; }
.consent span { font-size: .9rem; line-height: 1.65; color: #364152; }
.alert { padding: .9rem 1rem; border-left: 2px solid var(--bad); background: #FBEFEF; color: var(--bad); font-size: .9rem; }
.hidden { display: none !important; }

/* ---------- Footer ---------- */
.foot { background: var(--navy-deep); color: rgba(255,255,255,.62); position: relative; z-index: 1; }
.foot .wrap { padding-block: 2.8rem 2.2rem; display: grid; gap: 1.8rem; }
@media (min-width: 800px) { .foot .wrap { grid-template-columns: 1fr auto; align-items: end; } }
.foot p { margin: 0; font-size: .82rem; line-height: 1.7; max-width: 60ch; }
.foot .sig-line { font-family: var(--serif); font-style: italic; color: #fff; font-size: 1.25rem; margin-bottom: .6rem; }
.access-link { display: inline-flex; align-items: center; gap: .5rem; background: none; border: 1px solid rgba(255,255,255,.18); color: rgba(255,255,255,.75); padding: .55rem .85rem; border-radius: var(--radius); font-family: var(--mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; transition: border-color .3s, color .3s; }
.access-link:hover { border-color: var(--gold-soft); color: #fff; }
.access-link svg { width: 13px; height: 13px; }

/* ---------- Reveal animations ---------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }
.hero .reveal { transition-duration: 1.1s; }
.rule-draw { height: 1px; background: var(--gold); transform: scaleX(0); transform-origin: left; transition: transform 1.2s var(--ease) .2s; margin-bottom: 2rem; width: 72px; }
.in .rule-draw, .rule-draw.in { transform: scaleX(1); }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1.25rem; visibility: hidden; pointer-events: none; }
.modal.open { visibility: visible; pointer-events: auto; }
.modal .scrim { position: absolute; inset: 0; background: rgba(10,29,54,.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .45s var(--ease); }
.modal.open .scrim { opacity: 1; }
.modal .panel { position: relative; background: var(--sheet); width: 100%; max-width: 420px; max-height: calc(100vh - 2.5rem); overflow: auto; box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); opacity: 0; transform: translateY(18px) scale(.985); transition: opacity .45s var(--ease), transform .55s var(--ease); }
.modal.open .panel { opacity: 1; transform: none; }
.panel-pad { padding: 2rem 1.8rem; text-align: center; }
.panel h2 { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; color: var(--navy); margin: .3rem 0 .4rem; line-height: 1.1; }
.panel p { color: var(--muted); font-size: .93rem; margin: 0; }
.qr { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--rule); margin-top: 1.4rem; }
.qr img, .qr canvas { display: block; }
.url-chip { margin-top: .9rem; font-family: var(--mono); font-size: .7rem; color: var(--muted); word-break: break-all; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: 1.4rem; }
.tick { width: 54px; height: 54px; margin: 0 auto; }
.tick circle { stroke: var(--gold); stroke-dasharray: 160; stroke-dashoffset: 160; }
.tick path { stroke: var(--navy); stroke-dasharray: 40; stroke-dashoffset: 40; }
.modal.open .tick circle { animation: draw .8s var(--ease) .15s forwards; }
.modal.open .tick path { animation: draw .5s var(--ease) .8s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Reader */
.reader .panel { max-width: 860px; height: calc(100vh - 2.5rem); display: flex; flex-direction: column; }
@media (max-width: 640px) { .reader { padding: 0; } .reader .panel { height: 100%; max-height: 100%; } }
.reader-scroll { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.reader-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.4rem; background: rgba(255,254,251,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.reader-head h2 { font-size: 1.35rem; margin: 0; }
.reader-head .mono { color: var(--gold); font-size: .6rem; display: block; }
.prose-account { max-width: 68ch; margin: 0 auto; padding: 1.5rem 1.4rem 3rem; }
.prose-account h3 { font-family: var(--serif); font-size: 1.65rem; font-weight: 600; color: var(--navy); margin: 2.6rem 0 .9rem; line-height: 1.2; }
.prose-account h3::before { content: ""; display: block; width: 36px; height: 1px; background: var(--gold); margin-bottom: 1rem; }
.prose-account h3:first-of-type { margin-top: 1.2rem; }
.prose-account p { color: #253246; font-size: 1.06rem; line-height: 1.75; margin: 0 0 1.15rem; }
.prose-account strong { color: var(--navy); font-weight: 600; }
.reader-end { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--rule); text-align: center; }
.reader-end .mono { color: var(--muted); display: block; margin-bottom: 1rem; }

/* ---------- Console sign-in ---------- */
.signin .panel { max-width: 400px; text-align: left; }
.signin .panel-pad { text-align: left; }
.step { display: flex; gap: .9rem; padding: 1.1rem 0; border-top: 1px solid var(--rule); }
.step:first-of-type { border-top: 0; }
.step .n { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--navy); color: var(--navy); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: .7rem; transition: all .3s; }
.step.done .n { background: var(--navy); color: #fff; }
.step .body { flex: 1; min-width: 0; }
.step .body strong { display: block; font-size: .9rem; color: var(--navy); margin-bottom: .55rem; }
.gsi-slot { min-height: 44px; }
.signed-as { font-size: .85rem; color: var(--ok); }
.check { display: flex; gap: .5rem; align-items: center; font-size: .85rem; color: var(--muted); margin-top: .8rem; }
.check input { accent-color: var(--navy); }

/* ---------- Console ---------- */
.console { position: fixed; inset: 0; z-index: 50; background: var(--paper); overflow-y: auto; opacity: 0; visibility: hidden; transition: opacity .45s var(--ease), visibility 0s .45s; }
.console.open { opacity: 1; visibility: visible; transition: opacity .45s var(--ease); }
.console-bar { position: sticky; top: 0; z-index: 3; background: var(--navy-deep); color: #fff; border-bottom: 1px solid rgba(217,160,102,.3); }
.console-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .85rem; }
.console-bar h2 { font-family: var(--serif); font-weight: 500; font-size: 1.45rem; margin: 0; line-height: 1.1; }
.console-bar .mono { color: var(--gold-soft); font-size: .58rem; }
.console-bar .who { font-size: .72rem; color: rgba(255,255,255,.6); display: none; }
@media (min-width: 720px) { .console-bar .who { display: inline; } }
.console-bar .tools { display: flex; gap: .4rem; align-items: center; }
.console-bar .tools .btn { white-space: nowrap; }
@media (max-width: 520px) { .console-bar h2 { font-size: 1.15rem; } .console-bar .tools .btn { padding: .45rem .6rem; font-size: .72rem; } #cRefresh { display: none; } }
.console main { padding-block: 1.8rem 4rem; display: grid; gap: 1.5rem; }
.console main > *, .two > * { min-width: 0; }
.qr img { width: 100%; height: auto; }
.panelcard { background: var(--sheet); border: 1px solid var(--rule); padding: 1.4rem; }
.panelcard h3 { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; color: var(--navy); margin: 0 0 .3rem; }
.panelcard > p { color: var(--muted); font-size: .88rem; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats > div { background: var(--sheet); padding: 1.1rem 1.2rem; }
.stats .num { font-family: var(--serif); font-size: 2.4rem; color: var(--navy); line-height: 1; }
.stats .mono { color: var(--muted); font-size: .58rem; display: block; margin-top: .45rem; }
.two { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .two { grid-template-columns: 340px 1fr; } }
.urlbox { margin-top: 1rem; padding: .7rem .8rem; border: 1px solid var(--rule); background: #fff; font-family: var(--mono); font-size: .72rem; word-break: break-all; }
#qrBox { margin: 1.1rem auto 0; padding: 14px; background: #fff; border: 1px solid var(--rule); max-width: 240px; }
#qrBox img { width: 100% !important; height: auto !important; image-rendering: pixelated; }
.exports { display: grid; gap: .7rem; margin-top: 1.1rem; }
@media (min-width: 560px) { .exports { grid-template-columns: 1fr 1fr; } }
.ledger-tools { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.ledger-tools .filters { display: flex; gap: .5rem; flex: 1; min-width: 240px; max-width: 460px; }
.ledger-tools input, .ledger-tools select { border: 1px solid #C4CCD7; background: #fff; padding: .55rem .7rem; font: inherit; font-size: .88rem; border-radius: var(--radius); }
.ledger-tools input { flex: 1; min-width: 0; }
.entry { display: grid; gap: 1rem; padding: 1.3rem 0; border-top: 1px solid var(--rule); animation: fadeUp .5s var(--ease) both; }
@media (min-width: 760px) { .entry { grid-template-columns: 1fr 210px; } }
.entry h4 { font-family: var(--serif); font-size: 1.35rem; color: var(--navy); margin: 0; font-weight: 600; }
.entry .org { font-size: .9rem; color: #364152; margin: .1rem 0 .6rem; }
.entry dl { display: grid; gap: .25rem 1.4rem; margin: 0; font-size: .84rem; }
@media (min-width: 560px) { .entry dl { grid-template-columns: 1fr 1fr; } }
.entry dt { display: inline; color: #8A94A3; }
.entry dd { display: inline; margin: 0; word-break: break-word; }
.entry blockquote { margin: .8rem 0 0; padding-left: .9rem; border-left: 1px solid var(--gold); font-family: var(--serif); font-style: italic; font-size: 1.1rem; color: #2B3648; }
.entry .id { font-family: var(--mono); font-size: .62rem; color: #A0A9B6; margin-top: .6rem; word-break: break-all; }
.entry .side { display: flex; flex-direction: column; gap: .7rem; }
.entry .sig { height: 76px; border: 1px solid var(--rule); background: #fff; }
.entry .sig img { width: 100%; height: 100%; object-fit: contain; }
.entry .acts { display: flex; gap: .5rem; flex-wrap: wrap; }
.tags { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .45rem; }
.tag { font-family: var(--mono); font-size: .56rem; letter-spacing: .14em; text-transform: uppercase; padding: .25rem .45rem; border: 1px solid var(--rule); color: var(--muted); }
.tag.gold { color: var(--gold); border-color: #E8C9A5; }
.tag.ok { color: var(--ok); border-color: #B7D8C0; }
.tag.bad { color: var(--bad); border-color: #E7B4B4; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.toast { position: fixed; left: 50%; bottom: 1.5rem; z-index: 80; transform: translate(-50%, 20px); opacity: 0; background: var(--navy-deep); color: #fff; padding: .7rem 1.1rem; font-size: .85rem; border-left: 2px solid var(--gold); transition: all .4s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .rule-draw { transform: none; }
  .tick circle, .tick path { stroke-dashoffset: 0; }
}

/* ==========================================================
   Console v3 — mobile-first layout, menu, tab bar, security
   ========================================================== */
.console-bar .wrap { padding-block: .7rem; }
.cb-title { min-width: 0; }
.cb-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk { display: none !important; }
.mob { display: inline-flex; }
@media (min-width: 820px) { .desk { display: inline-flex !important; } .mob { display: none !important; } }
.icon-btn { width: 42px; height: 42px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: #fff; align-items: center; justify-content: center; transition: background .3s; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: rgba(255,255,255,.16); }
.icon-btn svg { width: 20px; height: 20px; }

.cmenu { position: absolute; right: 12px; top: calc(100% + 8px); width: min(280px, calc(100vw - 24px)); background: var(--sheet); color: var(--slate); border: 1px solid var(--rule); box-shadow: 0 24px 48px -20px rgba(10,29,54,.45); padding: .4rem; opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right; pointer-events: none; transition: opacity .25s var(--ease), transform .3s var(--ease); z-index: 5; }
.cmenu.open { opacity: 1; transform: none; pointer-events: auto; }
.cmenu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .85rem .9rem; font-size: .95rem; color: var(--navy); border-radius: var(--radius); }
.cmenu button:hover { background: #F1F4F8; }
.cmenu button.danger { color: var(--bad); border-top: 1px solid var(--rule); border-radius: 0; margin-top: .3rem; }
.cmenu-who { padding: .6rem .9rem .7rem; font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--rule); margin-bottom: .3rem; word-break: break-all; }

.cmain { padding-bottom: 6.5rem !important; }
@media (min-width: 820px) { .cmain { padding-bottom: 4rem !important; } }
.csec { scroll-margin-top: 84px; }
.csec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.csec-head h3 { font-family: var(--serif); font-size: 1.45rem; color: var(--navy); margin: 0; font-weight: 600; }
.panelcard h4, .sec-block h4 { font-family: var(--serif); font-size: 1.25rem; color: var(--navy); margin: 0 0 .8rem; font-weight: 600; }
.notice { margin-top: 1rem; padding: .9rem 1rem; background: #FFF8EC; border-left: 2px solid var(--gold); font-size: .88rem; color: #5A3A10; line-height: 1.6; }
.notice .link { margin-left: .3rem; }

/* Tab bar (phones) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255,254,251,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { background: none; border: 0; padding: .55rem 0 .5rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; color: #7B8696; font-size: .64rem; font-weight: 500; position: relative; transition: color .25s; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--gold); transform: scaleX(0); transition: transform .35s var(--ease); }
.tabbar button.on { color: var(--navy); }
.tabbar button.on::before { transform: scaleX(1); }
@media (min-width: 820px) { .tabbar { display: none; } }

/* Mobile refinements */
@media (max-width: 819px) {
  .console main { gap: 1rem; padding-top: 1.1rem; }
  .panelcard { padding: 1.15rem; }
  .stats .num { font-size: 2rem; }
  .stats > div { padding: .9rem 1rem; }
  .ledger-tools { flex-direction: column; align-items: stretch; }
  .ledger-tools .filters { flex-direction: column; max-width: none; min-width: 0; }
  .ledger-tools input, .ledger-tools select { width: 100%; padding: .75rem .8rem; font-size: 1rem; }
  .entry { padding: 1.1rem 0; }
  .entry .sig { height: 84px; }
  .entry .acts { display: grid; grid-template-columns: 1fr auto; }
  .entry .acts .btn { padding: .7rem .8rem; font-size: .8rem; }
  .entry dl { font-size: .86rem; }
  .btn-row .btn, .exports .btn { padding: .85rem 1rem; }
}
.sec-grid { display: grid; gap: 1.5rem; margin-top: 1.2rem; }
@media (min-width: 820px) { .sec-grid { grid-template-columns: 1fr 1fr; } }
.sec-block { border: 1px solid var(--rule); padding: 1.2rem; background: #fff; }
.sec-block .alert { margin-top: 1rem; }
.alert.ok { border-left-color: var(--ok); background: #EEF7F0; color: var(--ok); }
.codebox { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--gold); background: #FFFBF3; text-align: center; }
.codebox .mono { display: block; color: var(--gold); font-size: .6rem; margin-bottom: .5rem; }
.codebox code { display: block; font-family: var(--mono); font-size: 1.02rem; letter-spacing: .06em; color: var(--navy); word-break: break-all; margin-bottom: .5rem; user-select: all; }
.mono-input { font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.dev { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--rule); }
.dev:first-child { border-top: 0; }
.dev strong { display: block; color: var(--navy); font-size: .92rem; }
.dev span { font-size: .78rem; color: var(--muted); }
.signin .panel { max-height: calc(100vh - 2.5rem); }
.stats .num, .ledger .num { font-variant-numeric: lining-nums tabular-nums; font-feature-settings: "lnum" 1, "tnum" 1; }
.stats .num { font-family: var(--serif); }
.codebox code { white-space: nowrap; word-break: normal; overflow-x: auto; font-size: clamp(.82rem, 3.9vw, 1.02rem); letter-spacing: .03em; }

/* ==========================================================
   v4 — character edition, chips, timeline, console polish
   ========================================================== */
.ledger.ledger-single { grid-template-columns: 1fr; }
.ledger.ledger-single > div { border-right: 0; }
.ledger.ledger-single .num { font-size: clamp(3rem, 12vw, 4.6rem); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.6rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 1px; background: linear-gradient(var(--gold), var(--rule)); }
.timeline li { position: relative; padding: 0 0 2rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: calc(-1.6rem + 1px); top: .35rem; width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 1px solid var(--gold); transition: background .6s var(--ease) .2s; }
.timeline li.in::before { background: var(--gold); }
.timeline .when { color: var(--gold); font-size: .62rem; }
.timeline h3 { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; color: var(--navy); margin: .3rem 0 .35rem; line-height: 1.2; }
.timeline p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.7; max-width: 60ch; }

/* Select + chips + phone */
.select { width: 100%; border: 0; border-bottom: 1px solid #9AA5B4; background: transparent; padding: .55rem 1.6rem .6rem 0; font: inherit; font-size: 1.05rem; color: var(--slate); border-radius: 0; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%230F294A' stroke-width='1.5'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .2rem center; }
.select:focus { outline: none; border-color: var(--navy); box-shadow: 0 1px 0 0 var(--navy); }
.chipset { border: 0; padding: 0; margin: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .55rem; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: .6rem .95rem; border: 1px solid #C4CCD7; background: var(--sheet); font-size: .92rem; color: #2B3648; border-radius: 999px; transition: all .25s var(--ease); user-select: none; }
.chip:hover span { border-color: #9AA5B4; }
.chip input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip input[type="checkbox"]:checked + span::before { content: "✓ "; color: var(--gold-soft); }
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.phone-input { display: flex; align-items: stretch; }
.phone-input .cc { display: flex; align-items: center; padding: 0 .6rem 0 0; font-size: 1.05rem; color: var(--navy); border-bottom: 1px solid #9AA5B4; font-variant-numeric: lining-nums; }
.phone-input .input { flex: 1; min-width: 0; }

/* Console inputs: boxed for clarity */
.console .input, .signin .input { border: 1px solid #C4CCD7; border-radius: var(--radius); background: #fff; padding: .7rem .85rem; font-size: 1rem; }
.console .input:focus, .signin .input:focus { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.console .field-label { margin-bottom: .4rem; }
.signin .step .body label strong { margin-bottom: .45rem; }

/* Security panel: flatter on phones */
@media (max-width: 819px) {
  #c-security .sec-grid { gap: 0; margin-top: .6rem; }
  #c-security .sec-block { border: 0; border-top: 1px solid var(--rule); padding: 1.3rem 0 .4rem; background: transparent; margin-top: 0 !important; }
  #c-security .sec-block h4 { font-size: 1.2rem; }
  #c-security .csec-head { flex-direction: column; align-items: flex-start; gap: .6rem; }
  #c-security .csec-head .btn { width: 100%; }
  .dev { flex-direction: column; align-items: stretch; gap: .6rem; }
  .dev .btn { align-self: flex-start; }
}

/* Console share-link switch + country breakdown + entry meta */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); margin-top: 1rem; }
.seg button { background: #fff; border: 0; border-right: 1px solid var(--rule); padding: .6rem .3rem; font-size: .78rem; color: var(--muted); line-height: 1.3; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }
.seg-note { font-size: .8rem; color: var(--muted); margin: .6rem 0 0; }
.countries { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.countries .tag { font-size: .62rem; }
.entry .meta-line { font-size: .8rem; color: var(--muted); margin: .1rem 0 .5rem; }
.entry .traits { margin-top: .5rem; font-size: .82rem; color: #364152; }
