:root {
  --ink: #1d2433;
  --muted: #5d6677;
  --line: #d9dde4;
  --paper: #f6f4ef;
  --card: #ffffff;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --ok: #2f6b3a;
  --warn: #8a5300;
  --bad: #9b2226;
  --mark: #fff1b8;
  --radius: 8px;
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.55 Georgia, "Iowan Old Style", "Times New Roman", serif; }
button, input, select, textarea { font: 0.95rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

.banner { background: #3b2f12; color: #fff6dc; padding: 10px 20px; text-align: center; font: 0.92rem/1.4 system-ui, sans-serif; }
.top { border-bottom: 1px solid var(--line); background: var(--card); padding: 28px 0 22px; margin-bottom: 24px; }
.top h1 { margin: 0 0 6px; font-size: 1.9rem; letter-spacing: -0.01em; }
.sub { margin: 0; color: var(--muted); max-width: 62ch; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h2, .h2label { font-size: 1.2rem; margin: 0 0 8px; display: block; font-weight: 700; }
h2.inline { display: inline; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
.hint { color: var(--muted); margin: 4px 0 14px; font-size: 0.95rem; }
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span2 { grid-column: span 2; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
label { display: flex; flex-direction: column; gap: 4px; font: 0.88rem/1.3 system-ui, sans-serif; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.row input { flex: 1 1 240px; width: auto; }
.row select { width: auto; }
button { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 6px; padding: 9px 18px; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
button.ghost { background: transparent; color: var(--accent); }
button.small { padding: 5px 10px; font-size: 0.84rem; }
button.danger { color: var(--bad); border-color: var(--bad); }
.status { color: var(--muted); font: 0.9rem system-ui, sans-serif; }

.pill { display: inline-block; font: 0.78rem/1 system-ui, sans-serif; padding: 5px 9px; border-radius: 99px; background: #eceef2; color: var(--muted); white-space: nowrap; }
.pill.ok { background: #e3f0e5; color: var(--ok); }
.pill.warn { background: #f8ecd9; color: var(--warn); }
.tag { font: 0.75rem/1 system-ui, sans-serif; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.tag.unv { background: #f8ecd9; color: var(--warn); }
.tag.bad { background: #f6dfe0; color: var(--bad); }

.filters { margin-top: 12px; }
.filters summary { cursor: pointer; color: var(--accent); font: 0.9rem system-ui, sans-serif; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; color: var(--ink); }

.disclaimer { font: 600 0.85rem system-ui, sans-serif; color: var(--warn); border-left: 3px solid var(--warn); padding-left: 10px; margin-bottom: 14px; }
.note { font: 0.88rem system-ui, sans-serif; color: var(--muted); background: #f3f4f6; padding: 6px 10px; border-radius: 6px; margin: 0 0 8px; }
.answer p, .answer li { margin: 0 0 10px; }
.answer h4 { margin: 16px 0 6px; }
.cite { font: 600 0.72rem/1 system-ui, sans-serif; background: #e4ecf4; color: var(--accent); padding: 2px 5px; border-radius: 4px; text-decoration: none; vertical-align: 1px; }
.cite:hover { background: var(--accent); color: #fff; }

.sources { padding-left: 0; list-style: none; }
.sources li { border-top: 1px solid var(--line); padding: 12px 0; transition: background 0.3s; }
.sources li.flash { background: #fff8dc; }
.sid { font: 600 0.75rem/1 system-ui, sans-serif; background: #e4ecf4; color: var(--accent); padding: 3px 6px; border-radius: 4px; }
.sid.case { background: #ece6f3; color: #4b2f74; }
.meta { display: block; color: var(--muted); font: 0.82rem/1.4 system-ui, sans-serif; }
.meta.warn { color: var(--warn); }
.snip { font-size: 0.92rem; color: #333; margin-top: 6px; }
.actions { margin-top: 6px; display: flex; gap: 12px; align-items: center; font: 0.86rem system-ui, sans-serif; }
mark { background: var(--mark); padding: 0 1px; }

.library { padding-left: 18px; }
.library li { margin: 8px 0; }
details > summary { cursor: pointer; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); max-width: 760px; width: 92vw; padding: 0; }
dialog::backdrop { background: rgba(20, 24, 33, 0.45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; gap: 12px; }
dialog textarea { border: 0; border-radius: 0; font: 0.9rem/1.5 ui-monospace, Menlo, monospace; padding: 16px; }
dialog .row { padding: 0 16px 16px; }
.pagetext { white-space: pre-wrap; font: 0.9rem/1.55 ui-monospace, Menlo, monospace; padding: 16px; margin: 0; max-height: 70vh; overflow: auto; }
.pagetext.short { max-height: 240px; background: #fafafa; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font: 0.9rem/1.4 system-ui, sans-serif; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
td select { width: auto; padding: 4px 6px; }
td.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.review { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.flagged { margin: 12px 0; }
.flagged.done { opacity: 0.6; }

.foot { color: var(--muted); font-size: 0.85rem; padding-bottom: 40px; }
.row input[type=checkbox] { flex: none; width: auto; }
label.h2label { color: var(--ink); font-family: inherit; }
