:root {
  --paper: #f6f1e6;
  --paper-2: #fffdf8;
  --ink: #1c1914;
  --muted: #5d574c;
  --line: #d9d0bf;
  --green: #1f4f43;
  --green-2: #2f6d5c;
  --gold: #b0893e;
  --active: #1b6b45;
  --inactive: #9a3d32;
  --pending: #8a5a12;
  --shadow: 0 18px 40px rgba(40, 32, 18, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "PT Sans", sans-serif;
  background:
    radial-gradient(1200px 400px at 10% -10%, #efe4c8 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
}

#app { max-width: 1080px; margin: 0 auto; padding: 28px 22px 64px; }
#app.reading { max-width: 1380px; }
.top {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: -28px -22px 20px;
  padding: 14px 22px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(40, 32, 18, 0.08);
  flex-wrap: wrap;
}
.find-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 280px;
  max-width: 720px;
  margin-left: auto;
}
.find-bar input, .find-bar select {
  border: 1px solid var(--line);
  background: var(--paper-2);
  font: inherit;
  padding: 10px 12px;
}
.find-bar input { flex: 1; min-width: 160px; }
.find-bar button[type="submit"] {
  background: var(--green);
  color: #f7f3ea;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
}
#app:not(.reading) .find-nav { display: none; }
.find-nav { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.find-nav button {
  border: 1px solid var(--line);
  background: var(--paper-2);
  cursor: pointer;
  font: inherit;
  padding: 4px 8px;
}
mark.find-hit { background: #ffe566; color: inherit; padding: 0 1px; }
mark.find-hit.current { outline: 2px solid #b0893e; }
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.brand strong { display: block; font-size: 18px; }
.brand em { font-style: normal; color: var(--muted); font-size: 13px; }
.source { margin: 0; color: var(--muted); font-size: 13px; }

.search-panel h1 {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 36px;
  font-weight: 500;
  margin: 8px 0 10px;
  letter-spacing: -0.02em;
}
.lead { margin: 0 0 28px; color: var(--muted); max-width: 46rem; font-size: 17px; line-height: 1.45; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}
.home-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.home-card b { display: block; margin-bottom: 8px; font-size: 15px; }
.home-card p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 14px; }
.home-h2 {
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 700;
}
.start-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.start-item {
  text-align: left;
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 14px 16px;
  font: inherit;
  cursor: pointer;
  color: inherit;
}
.start-item:hover { border-color: var(--green); color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chips button {
  border: 1px solid var(--line);
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
}
.chips button:hover { border-color: var(--green); color: var(--green); }

.meta-line, .err, .empty { color: var(--muted); }
.err { color: var(--inactive); }

.card {
  display: block;
  text-decoration: none;
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 16px 18px;
  margin: 12px 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.card:hover { border-color: var(--green); }
.card .status { margin-bottom: 8px; }
.card h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 650;
}
.card.practice-card h2 { font-size: 16px; }
.practice-frame {
  width: 100%;
  min-height: calc(100vh - 180px);
  border: 1px solid var(--line);
  background: #fff;
}
.practice-meta { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.45; }

.badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid currentColor;
  font-weight: 700;
}
.badge.active { color: var(--active); }
.badge.inactive { color: var(--inactive); }
.badge.pending, .badge.unknown { color: var(--pending); }
.badge.practice { color: var(--green); }

.reader-head {
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 22px;
  box-shadow: var(--shadow);
}
.reader-head h1 {
  font-family: Georgia, serif;
  font-size: 30px;
  margin: 8px 0 6px;
  font-weight: 500;
}
.kicker { color: var(--muted); margin: 8px 0 0; }
.dates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.dates div {
  border-top: 2px solid var(--gold);
  padding-top: 8px;
}
.dates b { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }

.notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  line-height: 1.4;
}
.notice.info { border-color: var(--green); color: var(--green); }
.notice.warn { border-color: var(--pending); color: var(--pending); }
.notice.danger { border-color: var(--inactive); color: var(--inactive); }

.related { margin-top: 18px; }
.related h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
}
.rel-item {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  padding: 10px 12px;
  margin: 8px 0 0;
}
.rel-item:hover { border-color: var(--green); }
.rel-item strong { display: block; margin: 6px 0 2px; }
.rel-item .sub { color: var(--muted); font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions a, .actions button, .back {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--green);
  color: var(--green);
  background: transparent;
  text-decoration: none;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}
.back { margin-bottom: 16px; }

.doc-body {
  margin-top: 22px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 36px 42px 56px;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 18.5px;
  line-height: 1.55;
}
.doc-body p { margin: 0 0 0.7em; }
.doc-body p.C, .doc-body p.T { text-align: center; font-weight: 700; }
.doc-body p.H { font-weight: 700; margin-top: 1.4em; }
.doc-body p.I { color: var(--muted); }
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 12px 0 24px;
  font-family: "Segoe UI", "PT Sans", sans-serif;
}
.doc-body td, .doc-body th {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
}
.doc-body td p, .doc-body th p { margin: 0 0 0.35em; font-weight: 400; text-align: left; }

.busy { opacity: 0.65; pointer-events: none; }
[hidden] { display: none !important; }
footer { margin-top: 48px; color: var(--muted); font-size: 13px; max-width: 46rem; }

.doc-shell { margin-top: 8px; }
.actual-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: #ece8df;
  border: 1px solid var(--line);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 0;
}
.linkish {
  border: 0;
  background: none;
  color: #1a5f9e;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: none;
  font-weight: 500;
}
.linkish:hover { text-decoration: underline; }
.plaque-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  background: #d8d2c6;
  padding: 8px 8px 0;
  flex-wrap: wrap;
}
.plaque-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.plaque-tabs button {
  border: 1px solid transparent;
  border-bottom: 0;
  background: #c9c2b4;
  color: var(--ink);
  padding: 8px 16px;
  cursor: pointer;
  font: inherit;
  border-radius: 8px 8px 0 0;
}
.plaque-tabs button.on {
  background: var(--paper-2);
  border-color: var(--line);
  font-weight: 650;
}
.doc-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 8px 8px 0;
}
.doc-tools a, .doc-tools button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  padding: 4px 6px;
}
.doc-tools a:hover, .doc-tools button:hover { color: var(--ink); }
.doc-title-line {
  margin: 0;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-top: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.doc-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.doc-side {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 92px);
  overflow: auto;
}
.side-plaque {
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 12px;
}
.side-plaque h2, .panel-card h2 {
  margin: 0 0 10px;
  font-size: 14px;
}
.toc-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 280px); overflow: auto; }
.toc-item {
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  padding: 4px 0;
}
.toc-item:hover { color: var(--green); }
.toc-item.lvl-1 { padding-left: 12px; color: var(--muted); }
.toc-item.repealed { color: var(--inactive); }
.panel-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 22px;
}
.edition-plaque {
  border: 1px solid var(--line);
  padding: 10px;
  margin-top: 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.edition-plaque.current {
  background: #eef2f4;
  border-color: #b7c2ca;
}
.edition-plaque.old { background: #f8ecec; border-color: #e3c8c8; }
.edition-plaque strong { display: block; font-size: 13px; }
.edition-plaque a { color: #1a5f9e; font-size: 13px; }
.about-card ul { padding-left: 18px; }
.about-am li { margin: 0 0 10px; }
.doc-note {
  font-family: "Segoe UI", "PT Sans", sans-serif;
  font-size: 15px;
  background: #f7e7a6;
  border: 1px solid #e2d4aa;
  padding: 8px 12px;
  margin: 14px 0 8px;
}
.doc-note.repealed { color: var(--inactive); }
.doc-body p.repealed-point { color: var(--muted); text-decoration: line-through; }
mark.diff-old {
  background: #f7c8c8;
  color: inherit;
  padding: 0 2px;
}
mark.diff-new {
  background: #cfe4f7;
  color: inherit;
  padding: 0 2px;
}
mark.on-change { outline: 2px solid #1a5f9e; }
.compare-heads, .compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.edition-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  border: 1px solid var(--line);
  border-top: 0;
}
.edition-head.old { background: #f3d6d6; }
.edition-head.current { background: #e4e8ec; border-left: 0; }
.compare-pane {
  margin-top: 0;
  max-height: calc(100vh - 220px);
  overflow: auto;
  border-top: 0;
}
.compare-pane + .compare-pane { border-left: 0; }
.change-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 0; }
.change-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.change-row.on-change { outline: 2px solid #1a5f9e; }
.change-col { padding: 12px 16px; font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.5; }
.change-col.old { background: #fbf3f3; }
.change-col.new { background: #f3f7fb; border-left: 1px solid var(--line); }
.change-col p { margin: 0 0 0.6em; }
.change-hit { outline: 1px dashed transparent; }

@media (max-width: 900px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; max-height: none; }
  .compare-heads, .compare-grid, .change-row { grid-template-columns: 1fr; }
  .compare-pane { max-height: none; }
  .change-col.new { border-left: 0; border-top: 1px solid var(--line); }
  .home-grid { grid-template-columns: 1fr; }
}

@media print {
  .top, .search-panel, .back, .actions, footer, #results, .related, .plaque-row, .doc-side, .actual-bar, .doc-tools { display: none !important; }
  .doc-body, .reader-head { border: 0; box-shadow: none; }
  body { background: #fff; }
}

@media (max-width: 720px) {
  .search-panel h1 { font-size: 28px; }
  .home-grid, .start-list { grid-template-columns: 1fr; }
  .doc-body { padding: 22px 16px 36px; font-size: 17px; }
  .top { flex-direction: column; align-items: flex-start; }
  .find-bar { max-width: none; width: 100%; }
}
