:root {
  --accent: #a36a00;
  --accent-soft: #fff7e0;
  --accent-bg: #fef0c3;
  --rule: #f1d68a;
  --muted: #666;
  --bg: #fafaf7;
  --border: #e5e5e0;
  --card-border: #eee;
}
* { box-sizing: border-box; }
body {
  font: 15px/1.55 system-ui, -apple-system, Segoe UI, sans-serif;
  margin: 0;
  color: #1a1a1a;
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }

header {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: white;
  display: flex;
  gap: .75rem;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
header h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}
header h1 a { color: inherit; }
header select,
header input {
  padding: .45rem .65rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font: inherit;
  background: white;
}
header input {
  flex: 1;
  min-width: 200px;
}
header .manifest {
  font-size: .7rem;
  color: var(--muted);
  margin-left: auto;
}

main {
  display: grid;
  grid-template-columns: 340px 1fr 300px;
  gap: .75rem;
  padding: .75rem 1.25rem;
  height: calc(100vh - 58px);
}

aside {
  overflow-y: auto;
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: .5rem;
}
aside h3 {
  font-size: .7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .05em;
  margin: .5rem .5rem .25rem;
  font-weight: 600;
}

.row {
  padding: .35rem .5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: .85rem;
  line-height: 1.35;
}
.row:hover { background: var(--accent-soft); }
.row.active { background: var(--accent-bg); }
.row .num {
  font-weight: 600;
  color: var(--accent);
  margin-right: .3rem;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
}
.row .heading { color: #444; }
.row.toc-other {
  color: #888;
  font-size: .78rem;
  cursor: default;
}
.row.toc-other:hover { background: transparent; }

.viewer {
  overflow-y: auto;
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.25rem 1.75rem;
}
.viewer .cite {
  font-family: ui-monospace, monospace;
  color: var(--accent);
  font-size: .85rem;
}
.viewer .crumbs {
  font-size: .78rem;
  color: var(--muted);
  margin: .25rem 0 1rem;
}
.viewer h2 {
  font-size: 1.25rem;
  margin: .25rem 0 .5rem;
}
.viewer .amended {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.viewer h4.subsection-head {
  font-size: .95rem;
  color: #7a5200;
  margin: 1.2rem 0 .25rem;
}
.viewer p.statutory-body { margin: .4rem 0; }
.viewer pre.rawtext {
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
}

.viewer .subsection {
  border-left: 2px solid var(--rule);
  padding: .5rem 1rem;
  margin: 1rem 0;
  background: #fffbed;
}
.viewer .subsection .anchor-id {
  font-family: ui-monospace, monospace;
  font-size: .7rem;
  color: var(--muted);
  float: right;
}
.viewer .subsection h4 {
  margin: 0 0 .4rem 0;
  font-size: .95rem;
  color: #7a5200;
}
.viewer .subsection .sub-body {
  font-size: .9rem;
  color: #333;
  white-space: pre-wrap;
}

.regs { padding: .75rem 1rem; }
.reg {
  padding: .4rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: .82rem;
  border: 1px solid transparent;
  margin-bottom: .2rem;
}
.reg:hover {
  background: var(--accent-soft);
  border-color: var(--rule);
}
.reg .num {
  color: var(--accent);
  font-weight: 600;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
}
.reg .heading {
  color: #444;
  font-size: .8rem;
  margin-top: .1rem;
  line-height: 1.3;
}

.empty {
  color: var(--muted);
  font-size: .85rem;
  padding: .5rem;
  font-style: italic;
}
a.source {
  color: var(--accent);
  font-size: .78rem;
}
a.source:hover { text-decoration: underline; }

dialog {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0;
  width: min(90vw, 900px);
  max-height: 85vh;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog .body {
  padding: 1.25rem 1.75rem;
  overflow-y: auto;
  max-height: 75vh;
}
dialog button.close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}

/* Homepage */
.homepage {
  max-width: 980px;
  margin: 0 auto;
  padding: .5rem 1rem 3rem;
}
.homepage .hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.homepage .hero h1 {
  font-size: 2rem;
  margin: 0 0 .5rem;
  font-weight: 600;
}
.homepage .tagline {
  font-size: 1rem;
  color: #444;
  max-width: 620px;
  margin: .5rem auto .75rem;
  line-height: 1.5;
}
.homepage .stats {
  font-size: .85rem;
  color: var(--muted);
  margin: 0;
}
.home-group {
  margin: 2rem 0;
}
.home-group h3 {
  font-size: .75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .08em;
  margin: 0 0 .75rem;
  font-weight: 600;
}
.juris-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .75rem;
}
.juris-card {
  display: block;
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .1s;
}
.juris-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.juris-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}
.juris-emoji {
  font-size: 1.5rem;
}
.juris-count {
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .15rem .5rem;
  border-radius: 4px;
}
.juris-label {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .25rem;
  line-height: 1.3;
}
.juris-blurb {
  font-size: .82rem;
  color: #555;
  line-height: 1.4;
}
.home-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1024px) {
  main {
    grid-template-columns: 280px 1fr;
    height: auto;
  }
  .regs { display: none; }
}
@media (max-width: 640px) {
  main {
    grid-template-columns: 1fr;
  }
  aside#list { max-height: 40vh; }
}
