:root {
  --ars-ink: #2b1d2a;
  --ars-ochre: #cb5b2e;
  --ars-gold: #d8a33c;
  --ars-green: #5b8e3e;
  --ars-blue: #2c89a0;
  --ars-sand: #f6f1e8;
  --ars-paper: #fffdfa;
  --ars-border: #e2d8ca;
  --ars-muted: #6d625b;
  --footer-h: 38px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding-bottom: var(--footer-h);
  color: var(--ars-ink);
  background: linear-gradient(180deg, var(--ars-sand), #f8f7f3 42%, #f4f2ec);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: #126f82; text-underline-offset: 2px; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--ars-blue);
  outline-offset: 3px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  background: var(--ars-paper);
  border-bottom: 5px solid var(--ars-ochre);
  box-shadow: 0 1px 12px rgba(43, 29, 42, .07);
}

.brand-block { min-width: 0; }
.eyebrow { margin: 0 0 .25rem; color: var(--ars-ochre); font-size: .77rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.45rem, 2.7vw, 2.35rem); line-height: 1.05; letter-spacing: -.03em; }
.subtitle { margin: .45rem 0 0; color: var(--ars-muted); font-size: .98rem; }
.ars-logo { display: block; width: auto; max-width: min(340px, 38vw); max-height: 96px; object-fit: contain; }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 0;
  min-height: calc(100vh - var(--footer-h));
}

.layout.reader-open { grid-template-columns: 300px minmax(0, 1fr) minmax(420px, 40vw); }

aside {
  position: sticky;
  top: 0;
  align-self: start;
  height: calc(100vh - var(--footer-h));
  overflow: auto;
  padding: 1rem;
  background: rgba(255, 255, 255, .72);
  border-right: 1px solid var(--ars-border);
}

.filters-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.filters-head h2 { margin: 0; font-size: 1.08rem; }

.filter-panel {
  margin-top: .85rem;
  background: var(--ars-paper);
  border: 1px solid var(--ars-border);
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(43, 29, 42, .045);
}

.filter-panel summary {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  padding: .85rem;
  cursor: pointer;
  font-weight: 800;
  list-style-position: inside;
}

.filter-summary { margin-left: auto; color: var(--ars-muted); font-size: .8rem; font-weight: 650; text-align: right; }
.filter-content { padding: 0 .85rem .9rem; border-top: 1px solid #eee2d4; }
.field-label { display: block; margin: .8rem 0 .35rem; font-size: .86rem; font-weight: 750; }

input[type="search"],
select {
  width: 100%;
  padding: .68rem .75rem;
  color: var(--ars-ink);
  background: #fff;
  border: 1px solid #cfc2b4;
  border-radius: 9px;
  font: inherit;
}

.range-slider { position: relative; height: 2.5rem; margin: 1rem .25rem .25rem; }
.range-track { position: absolute; top: 1rem; right: 0; left: 0; height: 6px; border-radius: 99px; background: linear-gradient(to right, #d8cec1 0 var(--range-from, 0%), var(--ars-green) var(--range-from, 0%) var(--range-to, 100%), #d8cec1 var(--range-to, 100%) 100%); }
.range-slider input[type="range"] {
  position: absolute;
  top: .35rem;
  left: 0;
  width: 100%;
  height: 1.8rem;
  margin: 0;
  appearance: none;
  pointer-events: none;
  background: transparent;
}
.range-slider input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: transparent; }
.range-slider input[type="range"]::-moz-range-track { height: 6px; background: transparent; }
.range-slider input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -7px; appearance: none; pointer-events: auto; cursor: grab; border: 2px solid #376721; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(43, 29, 42, .25); }
.range-slider input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; pointer-events: auto; cursor: grab; border: 2px solid #376721; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(43, 29, 42, .25); }
.range-slider input[type="range"]:focus-visible { outline: none; }
.range-slider input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--ars-blue); outline-offset: 3px; }
.range-slider input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--ars-blue); outline-offset: 3px; }

.range-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.range-fields label { font-size: .82rem; font-weight: 750; }
.range-fields select { margin-top: .3rem; }

.author-options { max-height: min(42vh, 360px); margin-top: .55rem; overflow: auto; }
.author-options label { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: .5rem; padding: .32rem .1rem; line-height: 1.3; }
.author-options input { margin-top: .17rem; }
.author-options .facet-count { color: var(--ars-muted); font-size: .82rem; }
.author-options .empty-options { color: var(--ars-muted); font-style: italic; }

button {
  padding: .52rem .8rem;
  color: var(--ars-ink);
  background: #fff7ef;
  border: 1px solid var(--ars-ochre);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}
button:hover:not(:disabled) { background: #fcebdc; }
button:disabled { cursor: not-allowed; opacity: .45; }
.text-button { margin-top: .7rem; padding: .2rem 0; color: #126f82; background: transparent; border: 0; border-radius: 0; text-decoration: underline; text-underline-offset: 2px; }
.text-button:hover:not(:disabled) { background: transparent; color: #0a5362; }

main { min-width: 0; padding: clamp(.85rem, 2vw, 1.35rem); }

.search-panel {
  position: sticky;
  top: .75rem;
  z-index: 10;
  margin-bottom: 1rem;
  padding: .9rem;
  background: rgba(255, 253, 250, .96);
  border: 1px solid var(--ars-border);
  border-top: 4px solid var(--ars-green);
  border-radius: 14px;
  box-shadow: 0 3px 16px rgba(43, 29, 42, .09);
  backdrop-filter: blur(8px);
}
.search-row { display: flex; align-items: end; gap: .7rem; }
.search-field { flex: 1 1 auto; min-width: 0; }
.search-field label { display: block; margin-bottom: .35rem; font-weight: 850; }
.search-field input { border-radius: 999px; }
.search-status-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-top: .55rem; }
.scope { margin: 0; color: var(--ars-muted); font-size: .86rem; }
#counts { flex: none; font-size: .88rem; }
#status { min-height: 1.35rem; margin: 0 0 .7rem; color: var(--ars-muted); font-size: .88rem; }

.issue-toolbar,
.view-heading,
.empty-state,
.result-list,
.issue-card {
  width: min(980px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.issue-toolbar {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto auto;
  align-items: center;
  gap: .55rem;
  margin-bottom: .85rem;
  padding: .72rem;
  background: var(--ars-paper);
  border: 1px solid var(--ars-border);
  border-radius: 12px;
}
.issue-toolbar select { min-width: 0; }

.view-heading { margin-bottom: .8rem; }
.view-heading .section-label { margin: 0 0 .2rem; color: var(--ars-ochre); font-size: .76rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.view-heading h2 { margin: 0; font-size: clamp(1.45rem, 2.6vw, 2rem); }
.view-heading p { margin: .35rem 0 0; color: var(--ars-muted); }

.issue-card {
  overflow: hidden;
  background: var(--ars-paper);
  border: 1px solid var(--ars-border);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(43, 29, 42, .06);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: .68rem .75rem; text-align: left; vertical-align: top; border-top: 1px solid #eee2d4; }
thead th { border-top: 0; color: var(--ars-muted); background: #fffaf3; font-size: .78rem; letter-spacing: .045em; text-transform: uppercase; }
th:last-child, td:last-child { width: 34%; }
.article-link { color: #376f25; font-weight: 720; }
tr.article.active { background: #eef8f4; }

.result-list { display: grid; gap: .65rem; padding: 0; list-style: none; }
.result-card { padding: .85rem 1rem; background: var(--ars-paper); border: 1px solid var(--ars-border); border-radius: 12px; box-shadow: 0 1px 8px rgba(43, 29, 42, .04); }
.result-card.active { background: #eef8f4; border-color: #bed0b2; }
.result-title { display: inline-block; color: #376f25; font-size: 1.02rem; font-weight: 780; }
.result-meta { display: flex; flex-wrap: wrap; gap: .28rem .75rem; margin-top: .38rem; color: var(--ars-muted); font-size: .86rem; }
.result-meta span:not(:last-child)::after { content: "·"; margin-left: .75rem; color: #b9aa9a; }
.issue-badge { display: inline-block; margin-right: .45rem; padding: .12rem .4rem; color: #6b3a24; background: #fff0e5; border-radius: 999px; font-size: .75rem; font-weight: 800; vertical-align: .08rem; }

.empty-state { padding: 2rem; text-align: center; background: var(--ars-paper); border: 1px dashed #cdbdad; border-radius: 14px; }
.empty-state h2 { margin-top: 0; }
.empty-state p { color: var(--ars-muted); }

.reader { display: none; position: sticky; top: 0; align-self: start; flex-direction: column; height: calc(100vh - var(--footer-h)); overflow: hidden; background: var(--ars-paper); border-left: 1px solid var(--ars-border); box-shadow: -6px 0 18px rgba(43, 29, 42, .09); }
.reader-open .reader { display: flex; }
.reader-head { display: flex; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; background: #fffaf3; border-bottom: 1px solid var(--ars-border); }
.reader-title { font-weight: 850; }
.reader-meta { margin-top: .25rem; color: var(--ars-muted); font-size: .86rem; }
.reader-actions { display: flex; align-items: start; gap: .55rem; white-space: nowrap; }
.reader-action { padding: .52rem .8rem; color: var(--ars-ink); background: #fff7ef; border: 1px solid var(--ars-ochre); border-radius: 999px; cursor: pointer; font: inherit; font-weight: 750; line-height: normal; text-decoration: none; }
.reader-action:hover { background: #fcebdc; }
.reader-body { padding: 1rem; overflow: auto; white-space: pre-wrap; font: .9rem/1.48 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.reader-body.article { white-space: normal; font: inherit; }
.article-record { border-collapse: collapse; }
.article-record th,
.article-record td { width: auto; padding-right: 1rem; padding-left: 1rem; border: 0; }
.article-field:nth-of-type(odd) tr { background: #f7f2e9; }
.article-field:nth-of-type(even) tr { background: #edf4ef; }
.article-field-name th {
  padding-top: .75rem;
  padding-bottom: .16rem;
  color: var(--ars-muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.article-field-value td {
  padding-top: .14rem;
  padding-bottom: .9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .93rem;
  line-height: 1.55;
}
.article-field-title .article-field-value td { font-size: 115%; font-weight: 800; line-height: 1.35; }
.article-field-article-text .article-field-value td { line-height: 1.65; }
.article-text-content { white-space: pre-wrap; }
.media-trigger {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  max-width: 100%;
  margin: .65rem 0;
  padding: .6rem .8rem;
  color: #315f22;
  background: #f4faef;
  border-color: #9ab78b;
  border-radius: 12px;
  text-align: left;
  white-space: normal;
}
.media-trigger:hover { background: #e9f5e1; }
.media-trigger-icon { flex: 0 0 auto; color: var(--ars-green); font-size: 1.2rem; line-height: 1; }
.article-field-citation .article-field-value td { padding-bottom: 1rem; }
.citation-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: start;
}
.citation-value cite {
  padding-left: 1.1rem;
  border-left: 3px solid var(--ars-gold);
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
  line-height: 1.55;
}
.citation-copy {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  padding: .42rem .62rem;
  color: var(--ars-ink);
  background: var(--ars-paper);
  border: 1px solid #cdbd9f;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: .78rem;
  font-weight: 750;
  white-space: nowrap;
}
.citation-copy:hover { background: #fff7e8; border-color: var(--ars-gold); }
.citation-copy-icon { font-size: 1rem; line-height: 1; }
.reader-empty { color: var(--ars-muted); }
.reader-source-fallback { margin: 0; white-space: pre-wrap; font: .9rem/1.48 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.reader-body.pdf { padding: 0; overflow: hidden; white-space: normal; font: inherit; }
.reader-body iframe { width: 100%; height: 100%; min-height: calc(100vh - var(--footer-h) - 78px); border: 0; }

.media-dialog {
  width: min(96vw, 1120px);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
}
.media-dialog::backdrop { background: rgba(31, 23, 30, .78); backdrop-filter: blur(2px); }
.media-dialog-panel {
  display: flex;
  flex-direction: column;
  width: fit-content;
  min-width: min(420px, 92vw);
  max-width: 100%;
  max-height: 92vh;
  margin: auto;
  overflow: hidden;
  background: var(--ars-paper);
  border: 1px solid var(--ars-border);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .38);
}
.media-dialog-head,
.media-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem .9rem;
  background: #fffaf3;
}
.media-dialog-head { border-bottom: 1px solid var(--ars-border); }
.media-dialog-head h2 { margin: 0; font-size: 1rem; line-height: 1.3; }
.media-dialog-actions { justify-content: flex-end; border-top: 1px solid var(--ars-border); }
.media-dialog-body { display: grid; place-items: center; min-height: 120px; overflow: auto; background: #201d20; }
.media-content { display: block; max-width: 88vw; max-height: calc(92vh - 132px); }
.media-content-image,
.media-content-video { width: auto; height: auto; object-fit: contain; }
.media-content-audio { width: min(620px, 82vw); margin: 2.5rem; }
.media-content-document { width: min(88vw, 960px); height: min(74vh, 760px); border: 0; background: #fff; }
.media-error { max-width: 52rem; margin: 0; padding: 2rem; color: #fff; line-height: 1.55; }

.site-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--footer-h);
  padding: .35rem .9rem;
  color: #fffaf3;
  background: var(--ars-ink);
  font-size: .8rem;
  box-shadow: 0 -1px 8px rgba(43, 29, 42, .2);
}
.site-footer a { color: #fffaf3; }
.mobile-only { display: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 1120px) {
  .layout.reader-open { grid-template-columns: 300px minmax(0, 1fr); }
  .reader { position: fixed; z-index: 40; right: 0; bottom: var(--footer-h); width: min(92vw, 640px); height: calc(100vh - var(--footer-h)); }
}

@media (max-width: 850px) {
  .site-header { align-items: flex-start; padding: .85rem 1rem; }
  .ars-logo { max-width: 34vw; max-height: 72px; }
  .layout, .layout.reader-open { display: block; }
  aside { display: none; position: fixed; z-index: 35; top: 0; bottom: var(--footer-h); left: 0; width: min(88vw, 340px); height: auto; box-shadow: 8px 0 24px rgba(43, 29, 42, .22); }
  .filters-visible aside { display: block; }
  .mobile-only { display: inline-block; }
  .search-panel { top: .35rem; }
  .issue-toolbar { grid-template-columns: 1fr 1fr; }
  .issue-toolbar select { grid-column: 1 / -1; grid-row: 1; }
  .issue-toolbar .open-pdf { grid-column: 1 / -1; }
  .reader { top: 0; width: 100vw; }
}

@media (max-width: 560px) {
  :root { --footer-h: 52px; }
  .site-header { display: block; }
  .ars-logo { margin-top: .7rem; max-width: min(230px, 74vw); }
  main { padding: .65rem; }
  .search-row { align-items: stretch; flex-wrap: wrap; }
  .search-field { flex-basis: 100%; }
  .search-status-row { display: block; }
  #counts { display: block; margin-top: .35rem; }
  .issue-toolbar { grid-template-columns: 1fr 1fr; }
  .issue-toolbar button { min-height: 42px; }
  .issue-card { border-radius: 10px; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr.article { padding: .75rem; border-top: 1px solid #eee2d4; }
  tr.article:first-child { border-top: 0; }
  td { width: auto !important; padding: 0; border: 0; }
  td + td { margin-top: .28rem; color: var(--ars-muted); font-size: .86rem; }
  .reader-head { display: block; }
  .reader-actions { margin-top: .65rem; }
  .citation-value { grid-template-columns: 1fr; }
  .citation-copy { justify-self: start; }
  .media-dialog { width: 100vw; max-height: 100vh; }
  .media-dialog-panel { min-width: 0; max-height: 100vh; border-radius: 0; }
  .media-content { max-width: 100vw; max-height: calc(100vh - 132px); }
  .media-content-document { width: 100vw; height: calc(100vh - 132px); }
  .site-footer { justify-content: center; flex-wrap: wrap; gap: .15rem .8rem; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
