:root {
  --bg: #faf8f5; --surface: #ffffff; --text: #1f1d1a; --muted: #6b665e; --line: #e4dfd7;
  --accent: #2f6f5e; --accent-ink: #ffffff; --context: #fdf1e3; --context-line: #e9a35b;
  --danger: #a33a2c; --danger-bg: #fbeceb; --flash: #eef5f2; --add: #e6f4ea; --del: #fbeceb;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614; --surface: #211f1c; --text: #ece8e1; --muted: #a39d93; --line: #36322d;
    --accent: #6fbfa5; --accent-ink: #10201b; --context: #2e261c; --context-line: #b9803f;
    --danger: #ef8a7c; --danger-bg: #3a2220; --flash: #1f2b27; --add: #1d3324; --del: #3a2220;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; min-height: 100vh; }
a { color: var(--accent); }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
.side { width: 220px; flex-shrink: 0; padding: 20px 16px; border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; }
.side .brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--text); }
.side .ws { color: var(--muted); font-size: .85rem; }
.side ul { list-style: none; padding: 0; margin: 12px 0; }
.side li a { display: block; padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.side li a[aria-current] { background: var(--flash); color: var(--accent); font-weight: 600; }
.side .me { margin-top: auto; font-size: .85rem; color: var(--muted); }
main { flex: 1; min-width: 0; max-width: 1080px; padding: 28px 32px 64px; }
main.bare { max-width: 480px; margin: 8vh auto; }
.lead { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { color: var(--muted); padding: 24px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.crumb { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.inline { display: inline; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; }
label:has(> input[type=checkbox]), label:has(> input[type=radio]) { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea, button, .button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
button, .button { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); }
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger, .button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.side .new button { width: 100%; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.flash { background: var(--flash); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; }
.flash.error { background: var(--danger-bg); color: var(--danger); }
.chip { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--flash); color: var(--accent); vertical-align: middle; }
.chip.s-objection, .chip.s-returned, .chip.s-withdrawn { background: var(--danger-bg); color: var(--danger); }
.chip.s-archived, .chip.s-expired { background: var(--line); color: var(--muted); }
.list { list-style: none; padding: 0; margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.list li { padding: 10px 14px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.tabs { display: flex; gap: 4px; margin: 0 0 12px; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; }
.tabs a[aria-current] { background: var(--flash); font-weight: 600; }
.agreement h1 { font-size: 2rem; margin-bottom: .2rem; }
.agreement .subtitle { font-size: 1.15rem; color: var(--muted); margin-top: 0; }
.context { background: var(--context); border-left: 4px solid var(--context-line); border-radius: 8px; padding: 10px 14px; margin: 12px 0; display: block; }
.context p { margin: .3rem 0 0; }
.agreement .body blockquote, blockquote { border-left: 3px solid var(--line); margin: 8px 0; padding: 2px 12px; color: var(--muted); }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 20px; font-size: .9rem; }
.meta dt { color: var(--muted); font-size: .8rem; }
.meta dd { margin: 0; }
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor .title { font-size: 1.8rem; font-weight: 700; border: 0 !important; background: none !important; padding: 0 !important; }
.editor .subtitle { font-size: 1.1rem; border: 0 !important; background: none !important; padding: 0 !important; color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset.footer { flex-direction: row; flex-wrap: wrap; }
fieldset.footer label { flex: 1 1 200px; }
legend { font-weight: 600; padding: 0 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; padding-left: 1.2rem; }
.methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 12px; }
.method { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
table { border-collapse: collapse; width: 100%; margin: 8px 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .now { background: var(--flash); }
.pheader { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.pmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stepper { display: flex; list-style: none; padding: 0; margin: 0; gap: 4px; }
.stepper li { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: .9rem; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.stepper li small { font-size: .7rem; color: var(--muted); }
.stepper li.done { background: var(--flash); color: var(--accent); }
.stepper li.now { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stepper li.now small { color: inherit; opacity: .8; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.panel { position: sticky; top: 16px; }
.note { background: var(--flash); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.contribs { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.contrib { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.contrib p { margin: .3rem 0; }
.contrib .anchor { font-size: .9rem; }
.contrib.k-objection { border-color: var(--danger); }
.response { background: var(--flash); border-radius: 8px; padding: 6px 10px; margin-top: 6px; font-size: .92rem; }
.reactions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.reactions button { font-size: 1.3rem; padding: 2px 8px; }
.reactions button[aria-pressed=true] { border-color: var(--accent); background: var(--flash); }
.check { flex-direction: row; flex-wrap: wrap; gap: 16px; }
.hint { padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.hint.active { background: var(--context); color: var(--text); }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 20px; }
.diff { white-space: pre-wrap; font-size: .85rem; background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; }
.diff .add { background: var(--add); display: block; }
.diff .del { background: var(--del); display: block; text-decoration: line-through; }
.diff .same { display: block; color: var(--muted); }
details summary { cursor: pointer; }
@media (max-width: 820px) {
  body { flex-direction: column; }
  .side { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .side ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
  .side .me { margin-top: 4px; }
  main { padding: 16px 16px 48px; }
  .split { grid-template-columns: 1fr; }
  .panel { position: static; }
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.side { min-height: 100vh; height: auto; }
.diff span { min-height: 1.4em; }
