:root {
  --navy: #1a3a6c;
  --navy-deep: #142c54;
  --navy-mid: #244a82;
  --ink: #333333;
  --muted: #666666;
  --line: #d0d5dd;
  --zebra: #f0f4f8;
  --paper: #ffffff;
  --ok: #1e5b3a;
  --danger: #8b2e2e;
  --radius: 6px;
  --max: 1120px;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: var(--navy);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--navy-mid); }

img { max-width: 100%; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 8px 12px;
  z-index: 20;
}
.skip-link:focus { left: 12px; top: 12px; }

/* Header */
.site-header { background: #fff; }

.brand-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--navy);
}

.crest { width: 64px; height: auto; flex-shrink: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-transform: uppercase;
  color: var(--navy);
}

.brand-kicker {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
}

.header-tools {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.today { margin: 0; font-size: 0.82rem; color: var(--muted); }

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  background: var(--zebra);
  padding: 3px;
  border-radius: 999px;
  font-size: 13px;
}

.lang-toggle a,
.lang-toggle span {
  color: var(--navy);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
}

.lang-toggle a:hover { background: #e4ebf4; }

.lang-toggle a[aria-current="true"] {
  background: var(--navy);
  color: #fff;
  font-weight: 650;
}

.nav-bar { background: var(--navy); }

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.nav-inner a {
  color: #fff;
  text-decoration: none;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.92rem;
}

.nav-inner a:hover,
.nav-inner a.active {
  background: var(--navy-mid);
  color: #fff;
}

.nav-inner .staff-links { margin-left: auto; display: flex; }

.staff-badge {
  align-self: center;
  margin-right: 8px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c5d4ea;
  font-weight: 700;
}

/* Hero */
.hero {
  background:
    linear-gradient(rgba(20, 44, 84, 0.72), rgba(20, 44, 84, 0.72)),
    url("img/hero.jpg") center / cover no-repeat;
  color: #fff;
  padding: 56px 20px 48px;
}

.hero-inner {
  max-width: var(--max);
  margin: 0 auto;
  text-align: center;
}

.hero-inner h2 {
  margin: 0 0 10px;
  font-size: 1.7rem;
  font-weight: 700;
}

.hero-inner p {
  margin: 0 auto 22px;
  max-width: 62ch;
  color: #e8eef6;
  font-size: 0.95rem;
}

.hero-search {
  display: flex;
  align-items: stretch;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  max-width: 920px;
  margin: 0 auto;
  text-align: left;
}

.hero-search select,
.hero-search input {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  font: inherit;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  max-width: none;
}

.hero .hero-search select { flex: 0 0 auto; width: auto; min-width: 140px; max-width: none; }
.hero .hero-search input[type="search"] { flex: 1; width: auto; min-width: 160px; max-width: none; }

.hero-search .btn {
  border: 0;
  border-radius: 0;
  padding: 12px 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-search label.ai-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 16px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  border-left: 1px solid var(--line);
}

.hero-search label.ai-opt input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  flex: 0 0 auto;
  accent-color: var(--navy);
}

.hero .flash { max-width: 920px; margin: 12px auto 0; text-align: left; }

/* Layout */
main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.subnav { margin-bottom: 18px; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1,
.page-head h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--navy);
}

main h2 { color: var(--navy); }

.lede {
  margin: 0 0 20px;
  color: var(--muted);
  max-width: 68ch;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.panel-pad { padding: 18px 20px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar-label { font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 11px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}

.chip:hover { border-color: var(--navy); color: var(--navy); }

.chip[aria-current="page"],
.chip[aria-current="true"],
.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table.gazette {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.gazette th,
table.gazette td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.gazette th {
  background: var(--navy);
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

table.gazette tbody tr:nth-child(even) { background: var(--zebra); }
table.gazette tbody tr:hover { background: #e4ebf4; }

.vol { font-weight: 700; color: var(--navy); white-space: nowrap; }
.date { white-space: nowrap; }

.title-link { font-weight: 650; color: var(--navy); }

.meta-sub {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

/* Checksum */
.checksum {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.checksum-item { display: flex; flex-direction: column; gap: 4px; }

.checksum-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.checksum code {
  font-size: 0.72rem;
  word-break: break-all;
  background: var(--zebra);
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--navy);
}

table.gazette tbody tr:nth-child(even) .checksum code { background: #fff; }

.checksum-actions { display: flex; gap: 8px; flex-wrap: wrap; }

td.snippet {
  min-width: 18rem;
  max-width: 28rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ink);
}

td.snippet p { margin: 0; }

td.snippet mark {
  background: #ffe08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* Buttons */
.btn,
button {
  appearance: none;
  display: inline-block;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 650;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover, button:hover { background: var(--navy-deep); color: #fff; }

.btn:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: var(--zebra); color: var(--navy); }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #6e2222; }

.btn-sm { font-size: 0.78rem; padding: 4px 8px; font-weight: 600; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

/* Forms */
.actions,
.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}

label {
  display: block;
  margin: 0.8rem 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
}

input:not([type="file"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  max-width: 28rem;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 1rem 0;
  max-width: 28rem;
}

legend { font-weight: 700; color: var(--navy); padding: 0 4px; }

.flash {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 0 16px;
}

.flash.error, ul.flash {
  background: #fbeceb;
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

ul.flash { padding-left: 2rem; }

.flash.success {
  background: #e7f6ee;
  color: var(--ok);
  border-left: 4px solid var(--ok);
}

.callout {
  border: 1px solid var(--navy);
  background: var(--zebra);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-top: 24px;
}

.callout h2 { margin-top: 0; font-size: 1.05rem; }

.note-line { color: var(--danger); }

/* Upload form */
.upload-form .dropzone {
  margin-top: 28px;
  position: relative;
  border: 2px dashed var(--navy-mid);
  background: #fff;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
}

.upload-form .dropzone.dragover {
  background: #d5e0ee;
  border-color: var(--navy);
}

.upload-form .dropzone:focus-within {
  outline: 3px solid #7aa2d6;
  outline-offset: 2px;
}

.upload-form .dropzone input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  outline: none;
}

.upload-form .dropzone strong {
  display: block;
  color: var(--navy);
  font-size: 1.05rem;
}

.upload-form .dropzone .meta-sub { margin-top: 4px; }

.upload-form .file-meta {
  display: none;
  margin-top: 14px;
}

.upload-form .file-meta.visible { display: block; }

.upload-form .file-meta p { margin: 0; color: var(--ink); }

.upload-form .upload-details,
.update-form .form-details,
.delete-form .form-details {
  /* margin-top: 18px; */
  border-left: 4px solid var(--navy);
  background: var(--zebra);
  padding: 14px 16px 36px;
}

.delete-form .form-details { border-left-color: var(--danger); }

.upload-form .upload-details h2,
.update-form .form-details h2,
.delete-form .form-details h2 {
  margin: 0;
  font-size: 1rem;
}

.update-form .form-hint,
.delete-form .form-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.upload-form .form-grid,
.update-form .form-grid,
.delete-form .form-grid,
.delete-form .record-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.upload-form .field,
.update-form .field,
.delete-form .field,
.delete-form .record-summary > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.upload-form .field.full,
.update-form .field.full,
.delete-form .field.full,
.delete-form .record-summary .full { grid-column: 1 / -1; }

.upload-form .field label,
.update-form .field label,
.delete-form .field label,
.delete-form .record-summary dt {
  margin: 0;
}

.delete-form .record-summary {
  margin-bottom: 0;
}

.delete-form .record-summary dt {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
}

.delete-form .record-summary dd {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eef2f7;
  color: var(--ink);
  min-height: 2.45rem;
  overflow-wrap: anywhere;
}

.delete-form .delete-warning {
  margin: 18px 0 0;
  padding: 10px 14px;
  background: #fbeceb;
  color: var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  font-weight: 650;
}

.upload-form .field input,
.update-form .field input,
.delete-form .field input {
  width: 100%;
  max-width: none;
}

.update-form .field input[readonly] {
  background: #eef2f7;
  color: var(--ink);
  cursor: default;
}

.upload-form .actions,
.update-form .actions,
.delete-form .actions { margin-top: 18px; }

.update-form .form-grid > .actions,
.delete-form .form-grid > .actions { grid-column: 1 / -1; }

.upload-form .actions .btn,
.update-form .actions .btn,
.delete-form .actions .btn { padding: 10px 18px; }

/* Admin AI chat */
.ai-chat-form textarea { max-width: 48rem; resize: vertical; }

.ai-chat-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.ai-answer h2,
.ai-sources h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.ai-answer-text {
  max-width: 75ch;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai-sources ul {
  margin: 0;
  padding-left: 1.25rem;
}

.ai-sources li + li { margin-top: 6px; }

.ai-sources span {
  color: var(--muted);
  font-size: 0.92rem;
}

/* Public AI search summary */
.ai-summary { margin-bottom: 20px; }

.ai-summary .ai-sources { margin-top: 14px; }

.ai-summary .ai-sources h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.ai-summary-status {
  margin: 0;
  color: var(--muted);
}

.ai-summary-status.error { color: var(--danger); }

.ai-summary-disclaimer {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Pager */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}

/* Prose */
.prose h2, .prose h3 { color: var(--navy); margin: 1.4em 0 0.4em; }
.prose p { max-width: 70ch; }

/* Footer */
footer {
  background: #fff;
  color: var(--ink);
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.footer-crest-wrap { text-align: center; padding: 22px 20px 8px; }

.crest-footer { width: 52px; height: auto; }

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px 20px 22px;
  display: grid;
  grid-template-columns: 0.8fr 1fr 1fr 1fr 1.2fr;
  gap: 20px;
}

footer h3 {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--navy);
}

footer p,
footer li,
footer address {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: normal;
}

footer ul { margin: 0; padding: 0; list-style: none; }

footer a { color: var(--navy); text-decoration: none; }
footer a:hover { text-decoration: underline; }

.qr {
  width: 92px;
  height: 92px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.footer-bar {
  border-top: 1px solid var(--line);
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px 20px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
}

.footer-bar p { margin: 0; font-size: 0.78rem; }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  display: none;
  z-index: 30;
}

.toast.visible { display: block; }

:focus-visible {
  outline: 3px solid #7aa2d6;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .hero-search { flex-wrap: wrap; }
  .hero .hero-search select,
  .hero .hero-search input[type="search"] {
    flex: 1 1 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    width: 100%;
  }
  .hero-search .btn { width: 100%; }
  .hero-search label.ai-opt {
    flex: 1 1 100%;
    justify-content: flex-end;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 10px 16px;
  }
}

@media (max-width: 640px) {
  .upload-form .form-grid,
  .update-form .form-grid,
  .delete-form .form-grid,
  .delete-form .record-summary { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav-inner .staff-links { margin-left: 0; width: 100%; }
  .brand-text h1 { font-size: 1.05rem; }
  .brand-inner { flex-wrap: wrap; }
  .header-tools { margin-left: 0; align-items: flex-start; width: 100%; }
}
