:root {
  color-scheme: light;
  --ink: #171a1d;
  --paper: #f3f3ef;
  --paper-2: #e8e9e4;
  --red: #d72b27;
  --red-dark: #a91f1c;
  --blue: #183e8f;
  --muted: #6e7174;
  --line: #c7c9c4;
  --white: #fff;
  --shadow: 0 18px 50px rgb(18 22 26 / 12%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    linear-gradient(90deg, rgb(23 26 29 / 3%) 1px, transparent 1px) 0 0 / 54px 54px,
    var(--paper);
  color: var(--ink);
}

button, textarea, select { font: inherit; }
button { color: inherit; }

.masthead {
  height: 82px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
  background: rgb(243 243 239 / 94%);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--red); color: var(--white);
  font: 800 2.25rem/1 Georgia, serif;
}
.brand h1 { margin: 0; font: 800 1.45rem/1 "Arial Narrow", Impact, sans-serif; letter-spacing: .16em; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; letter-spacing: .04em; }
.archive-status { font-size: .82rem; font-weight: 650; }
.archive-status span { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--blue); }

.workspace {
  height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: 250px minmax(420px, 1fr) 350px;
}

.archive-nav, .issue-panel { min-width: 0; overflow-y: auto; }
.archive-nav { padding: 28px 20px; border-right: 1px solid var(--ink); }
.issue-panel { border-left: 1px solid var(--ink); background: var(--paper-2); }
.panel-heading { margin: 0 4px 22px; }
.eyebrow { margin: 0 0 7px; color: var(--red-dark); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h2 { margin: 0; font: 700 1.35rem/1.18 Georgia, serif; }

.scope-all, .year-button, .issue-button {
  width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.scope-all {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 13px; border: 1px solid var(--line); font-size: .9rem;
}
.scope-all strong { color: var(--muted); font-size: .76rem; }
.scope-all:hover, .scope-all.is-active { border-color: var(--ink); background: var(--ink); color: var(--white); }
.scope-all.is-active strong { color: var(--white); }

.years { margin-top: 24px; border-top: 1px solid var(--line); }
.year-button {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 13px 4px;
  border-bottom: 1px solid var(--line); font: 700 1rem/1 Georgia, serif;
}
.year-button small { color: var(--muted); font: 600 .72rem/1.2 Inter, sans-serif; }
.year-button:hover, .year-button.is-active { color: var(--red); padding-left: 10px; }
.issue-heading { display: flex; justify-content: space-between; margin: 26px 4px 9px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.issues { display: grid; grid-template-columns: repeat(4, 1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.issue-button {
  aspect-ratio: 1; display: grid; place-items: center; padding: 0;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font: 700 .9rem/1 Georgia, serif;
}
.issue-button:hover { background: var(--white); }
.issue-button.is-active { background: var(--red); color: var(--white); }
.mobile-filters { display: none; }

.conversation { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; background: rgb(255 255 255 / 46%); }
.conversation-head { padding: 25px 30px 20px; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.conversation-tools { display: flex; gap: 10px; align-items: center; }
.mode-switch { display: flex; border: 1px solid var(--ink); }
.mode-switch button { padding: 7px 10px; border: 0; background: transparent; cursor: pointer; font-size: .74rem; font-weight: 800; }
.mode-switch button.is-active { background: var(--ink); color: var(--white); }
.scope-pill { align-self: center; padding: 7px 11px; border: 1px solid var(--blue); color: var(--blue); font-size: .76rem; font-weight: 750; }
.messages { overflow-y: auto; padding: 34px max(28px, 7vw) 28px; scroll-behavior: smooth; }
.message { max-width: 760px; margin: 0 auto 26px; }
.message-label { margin-bottom: 9px; color: var(--red-dark); font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.message p { margin: 0; white-space: pre-line; font: 1.03rem/1.62 Georgia, serif; }
.answer-meta { width: fit-content; margin: 0 0 10px; padding: 5px 8px; background: var(--paper-2); color: var(--muted); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.user-message { padding-left: 15%; }
.user-message .message-label { color: var(--blue); }
.user-message p { padding: 17px 19px; background: var(--blue); color: var(--white); font-family: Inter, sans-serif; line-height: 1.5; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.suggestions button {
  padding: 8px 11px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: .78rem;
}
.suggestions button:hover { border-color: var(--red); color: var(--red-dark); }

.source-grid { display: grid; gap: 12px; margin-top: 18px; }
.source-card { border: 1px solid var(--line); background: var(--white); padding: 15px 16px; box-shadow: 3px 3px 0 var(--paper-2); }
.source-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.source-rank { color: var(--red); font: 800 1rem/1 Georgia, serif; }
.source-card h3 { margin: 0 0 4px; font: 700 .96rem/1.25 Georgia, serif; }
.source-card .source-meta { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.source-card blockquote { margin: 13px 0 11px; font: .88rem/1.55 Georgia, serif; }
.source-card button { padding: 0; border: 0; border-bottom: 1px solid var(--ink); background: transparent; cursor: pointer; font-size: .76rem; font-weight: 750; }
.source-card button:hover { color: var(--red-dark); border-color: var(--red-dark); }
.loading-card { border-left: 4px solid var(--red); padding: 18px; background: var(--white); }

.composer { margin: 0 max(22px, 5vw) 24px; border: 1px solid var(--ink); background: var(--white); box-shadow: var(--shadow); }
.composer textarea { width: 100%; min-height: 74px; padding: 17px 18px 8px; border: 0; outline: 0; resize: vertical; color: var(--ink); background: transparent; font-size: 1rem; line-height: 1.45; }
.composer-foot { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 7px 9px 9px 18px; }
.composer-foot > span { color: var(--muted); font-size: .72rem; }
.strategy-control { display: flex; gap: 7px; align-items: center; margin-left: auto; color: var(--muted); font-size: .7rem; font-weight: 750; }
.strategy-control[hidden] { display: none; }
.strategy-control select { max-width: 190px; padding: 6px; border: 1px solid var(--line); background: var(--white); font-size: .72rem; }
.composer button[type="submit"] { padding: 10px 15px; border: 0; background: var(--red); color: var(--white); cursor: pointer; font-weight: 800; }
.composer button[type="submit"]:hover { background: var(--red-dark); }
.composer button[disabled] { opacity: .55; cursor: wait; }

.issue-cover { min-height: 235px; padding: 20px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; background: var(--red); color: var(--white); }
.issue-cover span { font-size: .72rem; font-weight: 800; letter-spacing: .13em; }
.issue-cover strong { grid-row: 1 / 3; grid-column: 2; font: 900 7.5rem/.8 Georgia, serif; letter-spacing: -.09em; }
.issue-cover small { max-width: 175px; align-self: end; font-size: .62rem; font-weight: 800; letter-spacing: .08em; line-height: 1.5; }
.issue-copy { padding: 22px 22px 17px; border-bottom: 1px solid var(--line); }
.issue-copy > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.article-list { padding: 0 22px 30px; }
.article-button { width: 100%; display: block; padding: 15px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.article-button:hover h3 { color: var(--red-dark); }
.article-button h3 { margin: 0 0 6px; font: 700 .95rem/1.28 Georgia, serif; }
.article-button p { margin: 0; color: var(--muted); font-size: .74rem; line-height: 1.35; text-transform: none; }
.empty-state { padding: 26px 0; }
.empty-state span { color: var(--red); font: 700 2.5rem/1 Georgia, serif; }
.empty-state p { margin: 12px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }

.reader { width: min(900px, calc(100% - 30px)); max-height: calc(100% - 30px); padding: 0; border: 1px solid var(--ink); background: var(--paper); box-shadow: 0 30px 90px rgb(0 0 0 / 35%); }
.reader::backdrop { background: rgb(15 17 20 / 70%); }
.reader-shell > header { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; gap: 20px; padding: 24px 28px; border-bottom: 1px solid var(--ink); background: var(--paper); }
.reader-shell header > div > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: .82rem; }
.reader-close { width: 42px; height: 42px; flex: 0 0 auto; border: 1px solid var(--ink); background: transparent; cursor: pointer; font-size: 1.7rem; line-height: 1; }
.reader-close:hover { background: var(--ink); color: var(--white); }
.reader-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 28px; border-bottom: 1px solid var(--line); }
.reader-toolbar button { border: 1px solid var(--line); padding: 7px 11px; background: transparent; color: var(--ink); cursor: pointer; font-size: .78rem; }
.reader-toolbar button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.reader-toolbar span { margin-left: auto; color: var(--muted); font-size: .74rem; }
.reader-body { padding: 12px 28px 38px; }
.reader-fragment { padding: 25px 0; border-bottom: 1px solid var(--line); }
.reader-fragment .citation { margin-bottom: 13px; color: var(--red-dark); font-size: .78rem; font-weight: 750; }
.reader-fragment .reader-paragraph { margin: 0 0 1em; font: 1rem/1.68 Georgia, serif; text-align: justify; hyphens: auto; overflow-wrap: break-word; }
.reader-fragment .reader-raw { margin: 0; white-space: pre-wrap; font: 1rem/1.68 Georgia, serif; }
.reader-fragment .reader-note { margin: 0 0 18px; padding: 10px 12px; border-left: 3px solid var(--red); color: var(--muted); font: .78rem/1.45 sans-serif; }
.reader-fragment footer { margin-top: 16px; color: var(--muted); font-size: .76rem; }
.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; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px minmax(400px, 1fr) 300px; }
  .issue-cover strong { font-size: 6rem; }
  .messages { padding-inline: 30px; }
}

@media (max-width: 860px) {
  .masthead { height: 72px; padding: 0 16px; }
  .brand-mark { width: 40px; height: 40px; font-size: 1.9rem; }
  .archive-status { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 72px); grid-template-columns: 1fr; }
  .archive-nav { border-right: 0; border-bottom: 1px solid var(--ink); padding: 18px 16px; }
  .panel-heading, .scope-all, .years, .issue-heading, .issues { display: none; }
  .mobile-filters { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px; align-items: center; }
  .mobile-filters label { font-size: .76rem; font-weight: 800; }
  .mobile-filters select { min-width: 0; padding: 9px; border: 1px solid var(--ink); background: var(--white); }
  .conversation { min-height: 710px; }
  .conversation-head { padding: 20px 18px 16px; }
  .messages { padding: 25px 18px; }
  .composer { margin: 0 16px 18px; }
  .composer-foot > span { display: none; }
  .composer-foot { justify-content: flex-end; }
  .issue-panel { border-left: 0; border-top: 1px solid var(--ink); }
  .issue-cover { min-height: 190px; }
}

@media (max-width: 520px) {
  .brand p { display: none; }
  .mobile-filters { grid-template-columns: auto 1fr; }
  .conversation-head { align-items: flex-start; }
  .conversation-tools { align-items: flex-end; flex-direction: column-reverse; }
  .mode-switch button { padding-inline: 7px; }
  .scope-pill { max-width: 130px; text-align: right; }
  .user-message { padding-left: 6%; }
  .source-top { display: block; }
  .source-rank { margin-bottom: 8px; }
  .reader-shell > header, .reader-toolbar, .reader-body { padding-left: 18px; padding-right: 18px; }
}
