:root {
  color-scheme: light;
  /* Layout: a legal petition sheet under a bot status strip; on wide screens the tally and signing form sit in a side column beside the text, the ledger runs full width below. */
  --bg: #E9EDF1;
  --surface: #F8FAFB;
  --fg: #15202B;
  --muted: #56626F;
  --rule: #C8D0D8;
  --track: #D6DDE4;
  --accent: #0B6E63;
  --accent-fg: #FFFFFF;
  --warn: #9A5206;
  --warn-bg: #F6E7D2;
  --bad: #B3261E;
  --f-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'Newsreader', Georgia, 'Times New Roman', serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D131A;
    --surface: #141C25;
    --fg: #E4EAF0;
    --muted: #9AA7B4;
    --rule: #2A3643;
    --track: #233040;
    --accent: #47C6B3;
    --accent-fg: #06201C;
    --warn: #F0A650;
    --warn-bg: #2C2113;
    --bad: #FF8A80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D131A;
  --surface: #141C25;
  --fg: #E4EAF0;
  --muted: #9AA7B4;
  --rule: #2A3643;
  --track: #233040;
  --accent: #47C6B3;
  --accent-fg: #06201C;
  --warn: #F0A650;
  --warn-bg: #2C2113;
  --bad: #FF8A80;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-body);
  font-size: 18px;
  line-height: 1.55;
  padding-block: 20px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* status strip */
.status {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  font: 500 12.5px/1.4 var(--f-mono); color: var(--muted);
  padding-bottom: 14px; border-bottom: 1px solid var(--rule);
}
.who { color: var(--fg); font-weight: 600; display: inline-flex; gap: 8px; align-items: center; }
.tag { background: var(--fg); color: var(--bg); font-size: 10px; letter-spacing: .08em; padding: 2px 5px; border-radius: 3px; }
.chip { display: inline-flex; gap: 6px; align-items: center; }
.chip.warn { color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* header */
.head { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.headtext { min-width: 0; }
.avatar { width: 80px; height: 80px; border-radius: 50%; background: #fff; border: 1px solid var(--rule); display: block; flex: none; }
@media (min-width: 640px) { .head { flex-direction: row; align-items: center; gap: 24px; } }
.eyebrow { font: 600 12px/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
h1 {
  font-family: var(--f-display); font-weight: 800;
  font-size: clamp(2.1rem, 8vw, 3.6rem); line-height: 1.02; letter-spacing: -.02em;
  margin: 0 0 14px; text-wrap: balance;
}
.lede { font-size: 1.15rem; max-width: 34em; margin: 0; }

/* layout */
.layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "tally" "text" "sign" "ledger"; }
.tally { grid-area: tally; }
.text { grid-area: text; }
.sign { grid-area: sign; }
.ledger-wrap { grid-area: ledger; }
@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 22rem;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "text tally" "text sign" "ledger ledger";
    column-gap: 36px;
  }
  .text { align-self: start; grid-row: 1 / span 2; }
  .sign { align-self: start; }
}

.sheet { background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: 22px; }
h2 {
  font: 600 12px/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 14px;
}

/* petition text */
.text { display: flex; flex-direction: column; gap: 22px; }
.clauses, .articles { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.kw { font-family: var(--f-display); font-weight: 700; font-size: .78em; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-right: .35em; }
.articles { counter-reset: art; }
.articles li { counter-increment: art; display: grid; grid-template-columns: 3.6rem minmax(0, 1fr); gap: 12px; }
.articles li::before { content: "Art. " counter(art); font: 600 12px/2 var(--f-mono); text-transform: uppercase; color: var(--muted); }
.articles strong { font-family: var(--f-display); font-weight: 700; }
.closing { margin: 0; font-style: italic; color: var(--muted); }
.text p { margin: 0; }


.log { list-style: none; margin: 0; padding: 14px; background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; font: 400 13px/1.55 var(--f-mono); display: flex; flex-direction: column; gap: 8px; }
.log li { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: 12px; }
.log time { color: var(--muted); }
.log span { min-width: 0; overflow-wrap: anywhere; }
.qa { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.qa dt { font-family: var(--f-display); font-weight: 700; }
.qa dd { margin: 2px 0 0; font-style: italic; color: var(--muted); }
.fine { font: 400 12.5px/1.5 var(--f-mono); color: var(--muted); }

/* tally */
.tally { display: flex; flex-direction: column; gap: 10px; }
.count { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.n { font: 700 clamp(3.2rem, 13vw, 4.6rem)/1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.of { font: 500 13px/1.3 var(--f-mono); color: var(--muted); }
.bar { height: 10px; background: var(--track); border-radius: 2px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.tmsg { font: 500 13px/1.4 var(--f-mono); color: var(--muted); margin: 0; }

/* form */
.sign form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl { font: 600 12px/1.3 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.lbl .cc { font-weight: 400; letter-spacing: 0; }
input[type="text"], textarea {
  font: 400 17px/1.4 var(--f-body); color: var(--fg); background: var(--bg);
  border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 5.2em; }
input:disabled, textarea:disabled { opacity: .55; }
.agree { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.4; }
.agree input { accent-color: var(--accent); width: 18px; height: 18px; margin: 1px 0 0; flex: none; }
.btn {
  font: 700 16px/1 var(--f-display); min-height: 46px; padding: 0 18px; border-radius: 4px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--rule); }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 14px; }
.gate { font: 500 13px/1.45 var(--f-mono); color: var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 4px; margin: 0; }
.msg { font: 500 13px/1.45 var(--f-mono); margin: 0; min-height: 1.45em; color: var(--muted); }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--accent); }
.mine { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--rule); font: 500 13px/1.4 var(--f-mono); color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ledger */
.lhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.lhead h2 { margin: 0; }
.lhead span { font: 500 13px/1.3 var(--f-mono); color: var(--muted); }
.ledger { list-style: none; margin: 0; padding: 0; min-width: 0; }
.ledger li { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--rule); }
.num { font: 600 13px/1.9 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.body { min-width: 0; }
.top { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.nm { font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.you { font: 600 10px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-fg); background: var(--accent); padding: 3px 5px; border-radius: 3px; }
.top time { font: 400 12px/1.4 var(--f-mono); color: var(--muted); }
.why { margin: 4px 0 0; font-style: italic; overflow-wrap: anywhere; }
.empty { border: 1px dashed var(--rule); border-radius: 4px; padding: 20px; color: var(--muted); margin: 8px 0 0; }

footer { font: 400 12.5px/1.5 var(--f-mono); color: var(--muted); border-top: 1px solid var(--rule); padding-top: 14px; }

@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }

[hidden] { display: none !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#ts { display: flex; }
