/* ============================================================
   Criminal Court · Public Rulings 2026
   ============================================================ */

:root {
  --paper: #f4f1e9;
  --card: #fffdf9;
  --ink: #17251f;
  --ink-soft: #5d6a63;
  --line: #e5dfd2;
  --line-strong: #d9d2c2;
  --emerald: #12503f;
  --emerald-dark: #0b3a2d;
  --emerald-soft: #eaf4ef;
  --gold: #a97b2f;
  --gold-bright: #d8b574;
  --gold-soft: #f4e9d4;
  --cream: #faf6ec;
  --danger-soft: #f7eae7;
  --danger: #a84234;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23, 37, 31, .04), 0 18px 40px -28px rgba(23, 37, 31, .45);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 88% -220px, rgba(216, 181, 116, .16), transparent 65%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1 0 auto; }

.noscript {
  margin: 24px 0 0;
  padding: 12px 15px;
  border: 1px solid #e5d6b7;
  border-radius: 10px;
  background: #fbf4e4;
  color: #765d32;
  font-size: 13px;
  line-height: 1.5;
}

.noscript a { color: #765d32; font-weight: 650; }

a { color: inherit; }

button, input { font: inherit; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -100px; z-index: 200;
  background: var(--card); color: var(--emerald); padding: 10px 14px;
  border-radius: 8px; border: 1px solid var(--line); text-decoration: none;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.wrap {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  color: #fff;
  background:
    radial-gradient(900px 260px at 82% -60%, rgba(216, 181, 116, .30), transparent 62%),
    linear-gradient(118deg, #0a3529 0%, #10503f 58%, #0b3b2e 100%);
  border-bottom: 1px solid rgba(216, 181, 116, .28);
  box-shadow: 0 12px 34px -22px rgba(0, 0, 0, .75);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 17px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--gold-bright);
  border: 1px solid rgba(216, 181, 116, .45);
  background: rgba(255, 255, 255, .045);
  box-shadow: inset 0 0 0 3px rgba(216, 181, 116, .07);
}

.brand-text { min-width: 0; }

.eyebrow {
  margin: 0 0 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .19em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-text .eyebrow { color: rgba(244, 236, 219, .66); }

h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.05;
}

h1 .year {
  color: var(--gold-bright);
  font-style: italic;
  font-weight: 400;
}

/* Search */

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 482px;
  margin-left: auto;
  min-width: 0;
}

.search {
  position: relative;
  flex: 1 1 auto;
  min-width: 200px;
}

.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  background: rgba(255, 255, 255, .10);
  color: #fff;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .18s;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(216, 181, 116, .55);
}

.theme-toggle:active { transform: scale(.95); }

.theme-toggle svg { display: none; }

[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, .58);
  pointer-events: none;
  transition: color .18s;
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 66px 0 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font-size: 13.5px;
  letter-spacing: .005em;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s;
  appearance: none;
}

.search input::placeholder { color: rgba(255, 255, 255, .55); }

.search input::-webkit-search-cancel-button { display: none; }

.search input:focus {
  outline: none;
  background: #fffdf9;
  color: var(--ink);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(216, 181, 116, .16);
}

.search input:focus::placeholder { color: #9aa19b; }

.search:focus-within .search-icon { color: var(--gold); }

.search-hint {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: rgba(255, 255, 255, .42);
  font-size: 11px;
}

.search-hint kbd {
  font: inherit;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 5px;
  padding: 1px 6px;
  line-height: 1.5;
}

.search:focus-within .search-hint { display: none; }

.clear-search {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.clear-search:hover { background: rgba(255, 255, 255, .3); }

.search:focus-within .clear-search { background: #ece7db; color: var(--ink); }

/* ---------- Intro ---------- */

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
  padding: 28px 2px 20px;
}

.intro-line {
  margin: 0;
  max-width: 560px;
  font-family: var(--font-serif);
  font-size: 17.5px;
  line-height: 1.5;
  color: #33423a;
}

.stats {
  display: flex;
  gap: 8px;
}

.stat {
  min-width: 82px;
  padding: 8px 13px 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, .72);
}

.stat strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- Update banner ---------- */

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 11px 14px;
  border: 1px solid #dac9a8;
  border-radius: 14px;
  background:
    radial-gradient(500px 120px at 88% 0%, rgba(216, 181, 116, .22), transparent 70%),
    linear-gradient(110deg, #fbf6e9, #f6f0df);
  box-shadow: 0 8px 24px -22px rgba(23, 37, 31, .5);
}

.update-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.update-count {
  display: grid;
  place-items: center;
  min-width: 43px;
  height: 43px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--emerald);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 14px -9px rgba(11, 58, 45, .8);
}

.update-copy { min-width: 0; }

.update-copy strong {
  display: block;
  color: #3f4e45;
  font-size: 12.5px;
  font-weight: 700;
}

.update-copy p {
  margin: 2px 0 0;
  color: #7b745f;
  font-size: 10.5px;
}

.update-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 8px 12px;
  border: 1px solid #c9b385;
  border-radius: 999px;
  background: #fffdf8;
  color: #7b5a20;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.update-btn:hover { background: #f6ecd7; border-color: #b99c61; }

.update-banner.is-clean {
  border-color: var(--line);
  background: #f7f5ef;
  box-shadow: none;
}

.update-banner.is-clean .update-count {
  background: #e7e2d6;
  color: #6d756e;
  box-shadow: none;
}

.update-banner.is-clean .update-copy strong { color: var(--ink-soft); }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(330px, 392px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding-bottom: 58px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Calendar ---------- */

.calendar-card {
  position: sticky;
  top: 94px;
  padding: 20px 18px 15px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 13px;
}

.cal-title-wrap { text-align: center; min-width: 0; }

.cal-title-wrap h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.15;
}

.cal-title-wrap p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
}

.nav-btn {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.nav-btn:hover:not(:disabled) {
  color: var(--emerald);
  border-color: #bcd2c8;
  background: var(--emerald-soft);
}

.nav-btn:disabled { opacity: .32; cursor: not-allowed; }

.weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.year-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 12px;
  padding: 3px;
  border: 1px solid #e9e3d6;
  border-radius: 10px;
  background: #f2efe7;
}

.year-tab {
  flex: 1;
  min-width: 0;
  padding: 5px 2px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #6f776f;
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.year-tab:hover { color: var(--emerald); }

.year-tab.active {
  background: var(--emerald);
  color: #fff;
  box-shadow: 0 4px 10px -6px rgba(11, 58, 45, .8);
}

.weekdays { margin-bottom: 5px; }

.weekdays span {
  padding: 3px 0;
  text-align: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #95998f;
}

.cal-day {
  position: relative;
  min-height: 46px;
  padding: 3px 1px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.cal-day:hover { background: #f3f0e7; }

.cal-day.has-rulings {
  background: var(--cream);
  border-color: #efe5cf;
}

.cal-day.has-rulings:hover {
  background: #f6eddb;
  border-color: #e1cfa8;
}

.cal-day.no-rulings { color: #adb0a8; }

.cal-day .cal-num {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.cal-day .cal-count {
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--gold); }

.cal-day.has-match:not(.selected) {
  border-color: var(--gold);
  background: #fff8e9;
}

.cal-day.has-match:not(.selected)::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
}

.cal-day.selected {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #fff;
  box-shadow: 0 9px 18px -11px rgba(11, 58, 45, .85);
}

.cal-day.selected:hover { background: var(--emerald-dark); }

.cal-day.selected .cal-count { color: #ecd9ae; }

.cal-pad { visibility: hidden; }

.cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.latest-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--emerald);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.latest-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 10px;
  color: var(--ink-soft);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--gold-soft);
  border: 1px solid #dfc79c;
}

/* ---------- Rulings panel ---------- */

.rulings-card {
  min-height: 430px;
  padding: 22px 22px 16px;
  scroll-margin-top: 96px;
}

.rulings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.rulings-heading { min-width: 0; }

.rulings-heading .eyebrow { color: var(--gold); }

.rulings-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.2;
}

.rulings-head .sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.ghost-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 11px;
  border: 1px solid #cbded4;
  border-radius: 999px;
  background: #f5faf7;
  color: var(--emerald);
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.ghost-btn:hover { background: var(--emerald-soft); border-color: #b3cec1; }

.rulings-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 7px;
}

.ruling {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: background .14s, border-color .14s;
}

.ruling:hover {
  background: #faf8f1;
  border-color: #eee7da;
}

.pdf-icon {
  width: 34px;
  height: 34px;
  flex: none;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
}

.ruling-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.ruling-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
}

.id-chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--emerald-soft);
  color: var(--emerald);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ruling-name.no-link {
  color: var(--ink-soft);
  cursor: default;
}

.ruling-name.no-link:hover { text-decoration: none; }

.no-link-label {
  padding: 0 4px;
  color: #a0a59c;
  font-size: 9px;
  font-weight: 650;
  white-space: nowrap;
}

.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 220px;
  color: var(--ink-soft);
  font-size: 11.5px;
}

.case-chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 5px;
  background: var(--gold-soft);
  color: #84601f;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.ruling-name {
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.45;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.ruling-name:hover {
  color: var(--emerald);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ruling-actions {
  flex: none;
  display: flex;
  align-items: center;
  margin-top: 2px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #7f8881;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.icon-btn:hover { background: #f0ede5; color: var(--ink); }

/* ---------- Search results ---------- */

.result-group { margin-top: 15px; }

.result-group:first-child { margin-top: 5px; }

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
  padding: 5px 6px 6px 2px;
  border-bottom: 1px dashed #e7e0d1;
}

.group-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--emerald);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.group-date:hover { text-decoration: underline; text-underline-offset: 2px; }

.group-date svg { opacity: .65; }

.group-count {
  flex: none;
  font-size: 10px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.limit-note {
  margin: 18px 0 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f2e6;
  color: #7a6a4c;
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- Empty state ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 58px 20px 44px;
  text-align: center;
  color: #a5a89e;
}

.empty h3 {
  margin: 6px 0 0;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}

.empty p {
  max-width: 340px;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ---------- View tabs ---------- */

.view-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e9e4d9;
}

.view-tab {
  padding: 8px 20px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}

.view-tab:hover:not(.active) { color: var(--emerald); }

.view-tab.active {
  background: var(--emerald);
  color: #fff;
  box-shadow: 0 5px 12px -8px rgba(11, 58, 45, .8);
}

/* ---------- Statistics ---------- */

.stats-view { padding-bottom: 58px; }

.stats-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 7px 2px 18px;
}

.stats-head .eyebrow { color: var(--gold); }

.stats-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.stats-sub {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.stats-generated {
  margin: 0;
  color: #8a9087;
  font-size: 10px;
  white-space: nowrap;
}

.stats-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 12px;
}

.stats-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid #d8d1c2;
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: stats-spin .9s linear infinite;
}

@keyframes stats-spin { to { transform: rotate(360deg); } }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}

.kpi {
  padding: 13px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  box-shadow: 0 8px 24px -24px rgba(23, 37, 31, .45);
}

.kpi strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.kpi span {
  display: block;
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.kpi small {
  display: block;
  margin-top: 5px;
  color: #92978e;
  font-size: 9.5px;
  line-height: 1.3;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stats-panel {
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  min-width: 0;
}

.stats-panel h3 {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.stats-featured {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  border-color: #1b5b49;
  background:
    radial-gradient(420px 160px at 90% 0%, rgba(216, 181, 116, .28), transparent 70%),
    linear-gradient(125deg, #0b3a2d, #12503f 65%, #0c4033);
}

.stats-featured .eyebrow { color: var(--gold-bright); }

.stats-featured h3 {
  margin: 4px 0 3px;
  color: #fff;
  font-size: 29px;
  line-height: 1.15;
}

.stats-panel-sub {
  margin: 0;
  color: rgba(255, 255, 255, .7);
  font-size: 11px;
}

.featured-bar {
  height: 7px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, .16);
}

.featured-bar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--gold-bright);
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rank-no {
  color: #a5a99f;
  font-size: 10px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank-main { min-width: 0; }

.rank-name {
  display: block;
  overflow: hidden;
  color: #39473f;
  font-size: 11.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar {
  display: block;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: #eee9dd;
}

.rank-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--emerald);
  opacity: .75;
}

.rank-count {
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.year-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 62px;
  align-items: center;
  gap: 9px;
}

.year-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #5d6a63;
  font-variant-numeric: tabular-nums;
}

.year-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #eee9dd;
}

.year-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #1a6652, #2e8a6f);
}

.year-value {
  color: var(--ink-soft);
  font-size: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-panel-note {
  margin: 11px 0 0;
  color: #989d94;
  font-size: 9.5px;
  line-height: 1.4;
}

.id-lookup-panel { margin-top: 14px; }

.id-lookup-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.id-lookup-head h3 { margin-bottom: 3px; }

.id-lookup-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10.5px;
}

.id-lookup-head code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--gold-soft);
  color: #7b5a20;
  font-size: 10px;
}

.id-lookup-head input {
  width: min(280px, 100%);
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  outline: none;
}

.id-lookup-head input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(169, 123, 47, .12);
}

.id-results {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 13px;
}

.id-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #eee8db;
  border-radius: 9px;
  background: #faf8f2;
  font-size: 11.5px;
}

.id-result .id-code {
  flex: none;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--emerald-soft);
  color: var(--emerald);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: .03em;
}

.id-result .id-file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.id-result .id-date {
  flex: none;
  color: var(--ink-soft);
  font-size: 10px;
  white-space: nowrap;
}

.id-result a {
  flex: none;
  color: var(--emerald);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.id-result a:hover { text-decoration: underline; }

.id-empty {
  padding: 12px 4px;
  color: var(--ink-soft);
  font-size: 11px;
}

.stats-note {
  margin: 14px 2px 0;
  color: #8a9087;
  font-size: 10px;
  line-height: 1.5;
}

/* ---------- PDF viewer ---------- */

body.viewer-open { overflow: hidden; }

.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 25, 20, .64);
  backdrop-filter: blur(3px);
}

.viewer-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  height: min(88vh, 900px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 16px;
  background: #f8f6f0;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55);
}

.viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.viewer-heading { min-width: 0; }

.viewer-heading .eyebrow {
  margin-bottom: 2px;
  color: var(--gold);
}

.viewer-head h2 {
  max-height: 2.6em;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.viewer-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.viewer-close:hover {
  color: var(--danger);
  border-color: #e5c6c0;
  background: var(--danger-soft);
}

.viewer-body {
  flex: 1;
  min-height: 0;
  background: #e7e3da;
}

.viewer-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.viewer-meta {
  max-width: 50%;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.viewer-link {
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--emerald-soft);
  color: var(--emerald);
  font-size: 10.5px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.viewer-link:hover { background: #dcece4; }

/* ---------- Footer ---------- */
.site-footer {
  flex: none;
  border-top: 1px solid var(--line);
  background: #eeeae1;
  padding: 18px 0;
  color: #6c756e;
  font-size: 11px;
  line-height: 1.5;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-inner p { margin: 0; }

.site-footer a {
  color: var(--emerald);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .calendar-card { position: static; }
  .rulings-card { scroll-margin-top: 96px; }
  .cal-day { min-height: 52px; }
}

@media (max-width: 860px) {
  .wrap { width: calc(100% - 32px); }
  .header-inner { flex-wrap: wrap; gap: 12px; padding: 14px 0; }
  .header-tools { flex: 1 1 100%; margin-left: 0; }
  .search { flex: 1 1 auto; min-width: 0; }
  .rulings-card { scroll-margin-top: 150px; }
  .intro { padding-top: 20px; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .wrap { width: calc(100% - 26px); }

  h1 { font-size: 23px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-text .eyebrow { font-size: 8.5px; letter-spacing: .15em; }
  .search input { height: 42px; font-size: 16px; padding-right: 44px; }
  .search-hint { display: none; }
  .theme-toggle { width: 42px; height: 42px; }

  .intro {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px 0 15px;
  }

  .intro-line { font-size: 15.5px; }
  .stats { width: 100%; }
  .stat { flex: 1; min-width: 0; padding: 8px 10px 7px; }
  .stat strong { font-size: 17px; }

  .update-banner { margin-bottom: 14px; padding: 10px 11px; gap: 10px; }
  .update-count { min-width: 39px; height: 39px; font-size: 18px; }
  .update-copy strong { font-size: 11.5px; }
  .update-copy p { font-size: 9.5px; }
  .update-btn { padding: 7px 10px; font-size: 10px; }

  .view-tabs { display: flex; width: 100%; margin-bottom: 14px; }
  .view-tab { flex: 1; padding: 8px 10px; }

  .stats-head { padding: 3px 0 14px; }
  .stats-head h2 { font-size: 24px; }
  .stats-sub { font-size: 11px; }
  .stats-generated { white-space: normal; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 11px 12px 10px; }
  .kpi strong { font-size: 21px; }
  .stats-panel { padding: 14px 13px; }
  .stats-featured h3 { font-size: 24px; }
  .id-lookup-head { align-items: stretch; }
  .id-lookup-head input { width: 100%; }
  .id-result { flex-wrap: wrap; }
  .id-result .id-file { flex-basis: calc(100% - 90px); }
  .id-result .id-date { margin-left: auto; }

  .calendar-card { padding: 15px 12px 12px; }
  .cal-title-wrap h2 { font-size: 20px; }
  .cal-title-wrap p { font-size: 10.5px; }
  .year-tabs { margin-bottom: 10px; gap: 3px; }
  .year-tab { font-size: 10px; padding: 5px 1px; }
  .weekdays, .cal-grid { gap: 3px; }
  .cal-day { min-height: 43px; border-radius: 9px; }
  .cal-day .cal-num { font-size: 13px; }
  .cal-day .cal-count { font-size: 9px; }
  .cal-foot { margin-top: 11px; padding-top: 10px; }

  .rulings-card { padding: 17px 12px 12px; min-height: 320px; }
  .rulings-head { gap: 10px; padding-bottom: 12px; }
  .rulings-head h2 { font-size: 20px; }
  .rulings-head .sub { font-size: 11.5px; }
  .ghost-btn { padding: 7px 9px; font-size: 10px; }

  .ruling { gap: 9px; padding: 9px 4px; }
  .pdf-icon { width: 30px; height: 30px; border-radius: 8px; }
  .ruling-name { font-size: 12.5px; }
  .case-chip { font-size: 8.5px; }
  .icon-btn { width: 28px; height: 28px; }

  .empty { padding: 44px 14px 34px; }

  .viewer-modal { padding: 0; }
  .viewer-dialog {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .viewer-head { padding: 10px 12px; }
  .viewer-head h2 { font-size: 15px; }
  .viewer-foot { padding: 8px 10px; }
  .viewer-meta { display: none; }
  .viewer-actions { width: 100%; justify-content: flex-end; }
  .viewer-link { padding: 6px 8px; font-size: 10px; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
}

@media (max-width: 380px) {
  .cal-day { min-height: 40px; }
  .cal-day .cal-num { font-size: 12.5px; }
  .pdf-icon { display: none; }
  .ruling { gap: 6px; }
}

/* ---------- Dark theme ---------- */

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0c1310;
  --card: #131b16;
  --ink: #e8eee9;
  --ink-soft: #9caaa1;
  --line: #27332c;
  --line-strong: #36463b;
  --emerald: #1f7058;
  --emerald-dark: #174f3f;
  --emerald-soft: #172b23;
  --gold: #d2a65e;
  --gold-bright: #e4c58a;
  --gold-soft: #2c2417;
  --cream: #1a241e;
  --danger-soft: #2c1d1a;
  --danger: #d98a7e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 40px -28px rgba(0, 0, 0, .85);
}

[data-theme="dark"] body {
  background:
    radial-gradient(1100px 500px at 88% -220px, rgba(216, 181, 116, .08), transparent 65%),
    var(--paper);
}

[data-theme="dark"] .site-header {
  background:
    radial-gradient(900px 260px at 82% -60%, rgba(216, 181, 116, .22), transparent 62%),
    linear-gradient(118deg, #071f19 0%, #0d4033 58%, #081f19 100%);
}

[data-theme="dark"] .search input:focus {
  background: #18221c;
  color: var(--ink);
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(210, 166, 94, .14);
}

[data-theme="dark"] .search input:focus::placeholder { color: #7f8c84; }
[data-theme="dark"] .search:focus-within .clear-search { background: #27332c; color: var(--ink); }
[data-theme="dark"] .intro-line { color: #cbd6cf; }
[data-theme="dark"] .stat { background: rgba(19, 27, 22, .78); }
[data-theme="dark"] .stat strong { color: var(--ink); }

[data-theme="dark"] .update-banner {
  border-color: #4a3d24;
  background:
    radial-gradient(500px 120px at 88% 0%, rgba(210, 166, 94, .16), transparent 70%),
    linear-gradient(110deg, #1a2018, #171c15);
  box-shadow: none;
}

[data-theme="dark"] .update-copy strong { color: #e3d3ae; }
[data-theme="dark"] .update-copy p { color: #a89c82; }
[data-theme="dark"] .update-btn { background: #211f16; border-color: #5c4a2a; color: #e4c58a; }
[data-theme="dark"] .update-btn:hover { background: #2b2719; border-color: #806636; }
[data-theme="dark"] .update-banner.is-clean { background: #151d18; border-color: var(--line); }
[data-theme="dark"] .update-banner.is-clean .update-count { background: #263129; color: #aab5ad; }
[data-theme="dark"] .update-banner.is-clean .update-copy strong { color: var(--ink-soft); }

[data-theme="dark"] .view-tabs { background: #18211b; border-color: var(--line); }
[data-theme="dark"] .view-tab { color: var(--ink-soft); }
[data-theme="dark"] .view-tab.active { background: var(--emerald); color: #fff; }

[data-theme="dark"] .nav-btn { background: #17211b; border-color: var(--line); color: var(--ink); }
[data-theme="dark"] .nav-btn:hover:not(:disabled) {
  color: #a7e0c9;
  border-color: #3b5a49;
  background: #1d2b23;
}

[data-theme="dark"] .year-tabs { background: #161f1a; border-color: var(--line); }
[data-theme="dark"] .year-tab { color: #8e9b93; }
[data-theme="dark"] .year-tab:hover { color: #d7e4dc; }
[data-theme="dark"] .year-tab.active { background: var(--emerald); color: #fff; }
[data-theme="dark"] .weekdays span { color: #7f8b84; }
[data-theme="dark"] .cal-day:hover { background: #1d271f; }
[data-theme="dark"] .cal-day.has-rulings { background: #1a231d; border-color: #2c382e; }
[data-theme="dark"] .cal-day.has-rulings:hover { background: #202d24; border-color: #43513f; }
[data-theme="dark"] .cal-day.no-rulings { color: #657168; }
[data-theme="dark"] .cal-day.selected { background: var(--emerald); border-color: var(--emerald); color: #fff; }
[data-theme="dark"] .cal-day.selected .cal-count { color: #f0d9a8; }
[data-theme="dark"] .cal-day.has-match:not(.selected) { background: #201f16; border-color: var(--gold); }
[data-theme="dark"] .legend-dot { background: #2c2417; border-color: #5a4828; }
[data-theme="dark"] .latest-btn { color: #9ed6c0; }

[data-theme="dark"] .ghost-btn { background: #16241d; border-color: #2c4a3b; color: #9ed6c0; }
[data-theme="dark"] .ghost-btn:hover { background: #1c2f25; border-color: #3c6351; }
[data-theme="dark"] .pdf-icon { background: #2b1d1a; color: #e69a8e; }
[data-theme="dark"] .case-chip { color: #e4c486; background: #2c2417; }
[data-theme="dark"] .id-chip { color: #9ed6c0; background: #172b23; }
[data-theme="dark"] .ruling:hover { background: #18211b; border-color: #2a382f; }
[data-theme="dark"] .ruling-name { color: var(--ink); }
[data-theme="dark"] .ruling-name:hover { color: #9ed6c0; }
[data-theme="dark"] .ruling-name.no-link { color: var(--ink-soft); }
[data-theme="dark"] .icon-btn { color: #8b978f; }
[data-theme="dark"] .icon-btn:hover { background: #1e2a22; color: var(--ink); }
[data-theme="dark"] .no-link-label { color: #6e7a72; }
[data-theme="dark"] .group-head { border-bottom-color: #2b382f; }
[data-theme="dark"] .group-date { color: #9ed6c0; }
[data-theme="dark"] .group-count { color: var(--ink-soft); }
[data-theme="dark"] .limit-note { background: #241f14; color: #c9b183; }
[data-theme="dark"] .empty { color: #6d7a71; }
[data-theme="dark"] .empty h3 { color: var(--ink); }
[data-theme="dark"] .empty p { color: var(--ink-soft); }
[data-theme="dark"] .search-loading { color: var(--ink-soft); }
[data-theme="dark"] .stats-spinner { border-color: #33443a; border-top-color: #8fd2ba; }

[data-theme="dark"] .stats-loading { background: var(--card); color: var(--ink-soft); }
[data-theme="dark"] .stats-generated { color: #7f8b84; }
[data-theme="dark"] .kpi small { color: #7f8b84; }
[data-theme="dark"] .stats-featured {
  background:
    radial-gradient(420px 160px at 90% 0%, rgba(216, 181, 116, .24), transparent 70%),
    linear-gradient(125deg, #09271e, #0f4b39 65%, #0a3529);
  border-color: #2b5c49;
}
[data-theme="dark"] .rank-name { color: #cbd6cf; }
[data-theme="dark"] .rank-no { color: #718077; }
[data-theme="dark"] .rank-bar { background: #243029; }
[data-theme="dark"] .rank-bar i { background: #6fc2a5; opacity: .85; }
[data-theme="dark"] .rank-count { color: var(--gold); }
[data-theme="dark"] .year-label { color: #9caaa1; }
[data-theme="dark"] .year-bar { background: #243029; }
[data-theme="dark"] .year-value { color: #9caaa1; }
[data-theme="dark"] .stats-panel-note { color: #7f8b84; }
[data-theme="dark"] .id-lookup-head input {
  background: #0f1712;
  color: var(--ink);
  border-color: var(--line-strong);
}
[data-theme="dark"] .id-lookup-head input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(210, 166, 94, .12);
}
[data-theme="dark"] .id-lookup-head code { background: #2c2417; color: #e4c486; }
[data-theme="dark"] .id-result { background: #17211b; border-color: #2a382f; }
[data-theme="dark"] .id-result .id-code { background: #172b23; color: #9ed6c0; }
[data-theme="dark"] .id-result .id-file { color: var(--ink); }
[data-theme="dark"] .id-result .id-date { color: var(--ink-soft); }
[data-theme="dark"] .id-result a { color: #9ed6c0; }
[data-theme="dark"] .id-empty { color: var(--ink-soft); }
[data-theme="dark"] .stats-note { color: #7f8b84; }

[data-theme="dark"] .viewer-dialog { background: #111914; }
[data-theme="dark"] .viewer-head,
[data-theme="dark"] .viewer-foot { background: var(--card); }
[data-theme="dark"] .viewer-body { background: #0b110e; }
[data-theme="dark"] .viewer-close {
  background: #17211b;
  color: var(--ink);
  border-color: var(--line);
}
[data-theme="dark"] .viewer-close:hover { background: #2c1d1a; color: #f0a79b; }
[data-theme="dark"] .viewer-link { background: #172b23; color: #9ed6c0; }
[data-theme="dark"] .viewer-link:hover { background: #1e3a2e; }
[data-theme="dark"] .viewer-meta { color: var(--ink-soft); }

[data-theme="dark"] .site-footer {
  background: #101611;
  border-top-color: var(--line);
  color: #8e9b93;
}
[data-theme="dark"] .site-footer a { color: #9ed6c0; }
[data-theme="dark"] .skip-link { background: var(--card); color: #9ed6c0; border-color: var(--line); }
[data-theme="dark"] .noscript { background: #241f14; border-color: #4a3d24; color: #c9b183; }
[data-theme="dark"] .noscript a { color: #e4c486; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
