:root {
  --navy: #032b67;
  --navy-deep: #021f4b;
  --teal: #0b6f6a;
  --teal-dark: #07544f;
  --mint: #d9f2ed;
  --warmwhite: #faf8f3;
  --paper: #fffefb;
  --dark: #182535;
  --muted: #5a6773;
  --line: #d6ddd9;
  --gold: #e4b466;
  --error: #9f3429;
  --shadow: 0 14px 34px rgba(3, 43, 103, 0.08);
  --sans: "DM Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, Cambria, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { background: var(--warmwhite); }

body {
  min-width: 320px;
  margin: 0;
  color: var(--dark);
  background: var(--warmwhite);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

button, input, select, summary { font: inherit; }
button, select, summary { cursor: pointer; }
a { color: var(--navy); }
a:hover { color: var(--teal-dark); }

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

svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

[hidden] { display: none !important; }

.site-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 27px 16px 20px;
  color: #fff;
  background: var(--navy-deep);
}

.brand {
  display: block;
  width: 100%;
  margin: 0 4px 36px;
  color: #fff;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 166px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.brand-subtitle {
  display: block;
  margin-top: 11px;
  color: #bcd3ee;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.library-nav { display: grid; gap: 6px; }

.nav-link {
  display: flex;
  min-height: 48px;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #d6e5f6;
  background: transparent;
  text-align: left;
  font-weight: 600;
}

.nav-link:hover { color: #fff; background: rgba(217, 242, 237, 0.12); }
.nav-link.is-active { color: var(--navy-deep); background: var(--mint); }
.nav-link.is-active svg { color: var(--teal); }

.sidebar-foot {
  display: flex;
  gap: 9px;
  margin-top: auto;
  padding: 18px 5px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: #bcd3ee;
  font-size: 0.77rem;
  line-height: 1.45;
}
.sidebar-foot svg { width: 18px; height: 18px; margin-top: 2px; color: var(--gold); }
.sidebar-foot p { margin: 0; }

.library-main {
  width: min(100%, 1540px);
  padding: clamp(28px, 4vw, 58px) clamp(20px, 4vw, 64px) 70px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1210px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { color: var(--dark); }
h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.15rem, 5vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.048em;
  line-height: 1.04;
}

.header-copy {
  max-width: 690px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}
.button-primary { color: #fff; background: var(--teal); box-shadow: 0 7px 14px rgba(11, 111, 106, 0.17); }
.button-primary:hover { color: #fff; background: var(--teal-dark); }
.button-secondary { color: var(--navy); border-color: #9cb9d6; background: var(--paper); }
.button-secondary:hover { border-color: var(--teal); color: var(--teal-dark); }
.button-quiet { color: var(--navy); border-color: transparent; background: transparent; }
.button-quiet:hover { background: #edf3f7; }
.button-small { min-height: 42px; padding: 8px 12px; font-size: 0.88rem; }
.button[disabled] { cursor: wait; opacity: 0.66; }

.source-notice {
  display: flex;
  width: 100%;
  max-width: 1210px;
  min-height: 48px;
  align-items: center;
  margin: 28px 0 16px;
  padding: 10px 14px;
  border-left: 4px solid var(--gold);
  color: #3b4b57;
  background: #f4eee0;
  font-size: 0.9rem;
}
.source-notice.is-error { border-color: var(--error); background: #f9eeeb; color: #6e2b24; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  max-width: 1210px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.stat-card { min-width: 0; padding: 17px 20px 15px; background: var(--paper); }
.stat-label, .stat-note { display: block; }
.stat-label { color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.stat-card strong { display: block; margin: 2px 0; color: var(--navy); font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.stat-note { color: #71808a; font-size: 0.76rem; }

#app { max-width: 1210px; margin-top: 28px; }

.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 0 0 19px; }
.view-heading h2 { margin: 0; font-family: var(--serif); font-size: clamp(1.65rem, 3vw, 2.35rem); letter-spacing: -0.035em; line-height: 1.15; }
.view-heading p { margin: 5px 0 0; color: var(--muted); }
.view-heading .batch-summary { max-width: 760px; margin-top: 9px; color: var(--teal-dark); font-size: 0.9rem; font-weight: 700; }

.filter-panel, .calendar-shell, .source-panel, .article-card, .post-card, .empty-state {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 3px 12px rgba(24, 37, 53, 0.025);
}

.filter-panel { padding: 18px; }
.filter-topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.filter-topline h3 { margin: 0; font-size: 0.99rem; }
.filter-count { color: var(--muted); font-size: 0.9rem; }
.platform-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.platform-tab, .segmented-button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid #b8c7d4;
  border-radius: 7px;
  color: #42515d;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}
.platform-tab[aria-selected="true"], .segmented-button[aria-pressed="true"] { border-color: var(--navy); color: #fff; background: var(--navy); }
.platform-tab:hover, .segmented-button:hover { border-color: var(--teal); color: var(--teal-dark); }
.platform-tab[aria-selected="true"]:hover, .segmented-button[aria-pressed="true"]:hover { color: #fff; background: var(--navy-deep); }

.filter-fields { display: grid; grid-template-columns: minmax(210px, 2.1fr) minmax(160px, 1fr) minmax(160px, 1fr) auto; gap: 12px; margin-top: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field label { color: #52616c; font-size: 0.78rem; font-weight: 700; }
.field input, .field select {
  min-height: 46px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #aebdc9;
  border-radius: 7px;
  color: var(--dark);
  background: #fff;
}
.field input::placeholder { color: #78848d; }
.clear-filter { align-self: end; white-space: nowrap; }

.advanced-filters { margin-top: 12px; border-top: 1px solid var(--line); }
.advanced-filters summary { display: inline-flex; min-height: 44px; align-items: center; color: var(--navy); font-size: 0.9rem; font-weight: 700; }
.advanced-filters[open] summary { color: var(--teal-dark); }
.advanced-fields { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); gap: 12px; padding-bottom: 3px; }

.browser-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 14px; }
.browser-controls p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.control-cluster { display: flex; flex-wrap: wrap; gap: 7px; }
.control-cluster .field { display: block; }
.control-cluster .field label { display: inline-flex; align-items: center; min-height: 44px; margin-right: 7px; }
.control-cluster select { min-height: 44px; padding: 7px 30px 7px 10px; border: 1px solid #b8c7d4; border-radius: 7px; background: #fff; color: var(--dark); font-size: 0.9rem; }

.post-collection { display: grid; gap: 14px; }
.post-collection.timeline { position: relative; padding-left: 25px; }
.post-collection.timeline::before { position: absolute; top: 15px; bottom: 15px; left: 6px; width: 2px; background: #a9d5ce; content: ""; }
.post-collection.timeline > .post-card { position: relative; }
.post-collection.timeline > .post-card::before { position: absolute; top: 28px; left: -26px; width: 11px; height: 11px; border: 3px solid var(--warmwhite); border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 1px #87c3ba; content: ""; }
.post-collection.gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.post-collection.gallery .post-card { height: 100%; }
.post-group { display: grid; gap: 11px; padding: 8px 0 19px; border-bottom: 1px solid var(--line); }
.post-group:last-child { border-bottom: 0; }
.post-group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0; color: var(--navy); font-family: var(--serif); font-size: 1.3rem; line-height: 1.25; }
.post-group-heading small { color: var(--muted); font-family: var(--sans); font-size: 0.78rem; font-weight: 700; white-space: nowrap; }

.post-card { position: relative; padding: 19px; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 11px; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 8px; border: 1px solid #92c4ba; border-radius: 99px; color: var(--teal-dark); background: #eef9f6; font-size: 0.76rem; font-weight: 700; }
.badge-platform { border-color: #a8bdda; color: var(--navy); background: #eff5fc; }
.badge-detail { color: var(--muted); font-size: 0.8rem; }
.post-card h3 { margin: 0 0 7px; font-family: var(--serif); font-size: clamp(1.22rem, 2.3vw, 1.52rem); letter-spacing: -0.025em; line-height: 1.22; }
.post-time { margin: 0 0 12px; color: #41535f; font-size: 0.86rem; font-weight: 700; }
.post-excerpt { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #33434e; }
.post-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.inline-link { display: inline-flex; min-height: 40px; align-items: center; gap: 6px; color: var(--navy); font-size: 0.9rem; font-weight: 700; }
.inline-link svg { width: 17px; height: 17px; }

.post-media { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr); gap: 16px; margin-top: 16px; padding-top: 15px; border-top: 1px solid #e3e8e5; }
.media-frame { display: flex; min-height: 126px; align-items: center; justify-content: center; overflow: hidden; border: 1px solid #d7dfdc; border-radius: 8px; background: #f5f6f3; }
.media-frame img { display: block; width: 100%; max-height: 310px; object-fit: contain; object-position: center; }
.media-summary { align-self: center; color: var(--muted); font-size: 0.88rem; }
.media-summary p { margin: 0; }
.media-unavailable { display: grid; gap: 7px; padding: 13px; color: #6a4933; background: #fbf4e7; font-size: 0.88rem; }
.media-unavailable a { font-weight: 700; }

.empty-state { padding: 31px 23px; text-align: center; }
.empty-state h3 { margin: 0; font-family: var(--serif); font-size: 1.45rem; }
.empty-state p { max-width: 560px; margin: 8px auto 0; color: var(--muted); }

.articles-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.article-card { display: flex; min-width: 0; flex-direction: column; overflow: hidden; }
.article-media { display: flex; min-height: 157px; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); background: #f5f6f3; }
.article-media img { display: block; width: 100%; max-height: 260px; object-fit: contain; }
.article-media .media-unavailable { width: 100%; min-height: 157px; align-content: center; }
.article-copy { display: flex; flex: 1; flex-direction: column; padding: 18px; }
.article-category { margin: 0 0 9px; color: var(--teal-dark); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.article-card h3 { margin: 0; font-family: var(--serif); font-size: 1.35rem; letter-spacing: -0.025em; line-height: 1.2; }
.article-description { margin: 12px 0; color: #465660; }
.article-date { margin: 0 0 15px; color: var(--muted); font-size: 0.83rem; }
.article-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }

.calendar-shell { padding: clamp(16px, 3vw, 25px); }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.calendar-heading h3 { margin: 0; color: var(--navy); font-family: var(--serif); font-size: clamp(1.45rem, 3vw, 2rem); }
.icon-button { display: inline-flex; min-width: 48px; min-height: 48px; align-items: center; justify-content: center; border: 1px solid #aebdc9; border-radius: 7px; color: var(--navy); background: #fff; }
.icon-button:hover { color: var(--teal-dark); border-color: var(--teal); }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays span { padding: 0 4px 7px; color: var(--muted); font-size: 0.74rem; font-weight: 700; text-align: center; }
.calendar-day { min-height: 98px; padding: 6px; border: 1px solid #e2e7e5; background: #fff; text-align: left; }
.calendar-day.is-outside { color: #9aa4ab; background: #fafbf9; }
.calendar-day.has-records { border-color: #9fcfc5; background: #f2faf7; }
.calendar-day[aria-pressed="true"] { border: 2px solid var(--navy); background: var(--mint); }
.day-number { display: block; color: currentColor; font-size: 0.85rem; font-weight: 700; }
.day-count { display: block; margin-top: 11px; color: var(--teal-dark); font-size: 0.75rem; font-weight: 700; line-height: 1.2; }
.calendar-caption { margin: 14px 0 0; color: var(--muted); font-size: 0.88rem; }
.calendar-agenda { display: none; }
.calendar-results { margin-top: 23px; }
.calendar-results h3 { margin: 0 0 13px; font-family: var(--serif); font-size: 1.35rem; }

.source-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr); gap: 16px; }
.source-panel { padding: 20px; }
.source-panel h3 { margin: 0 0 13px; font-family: var(--serif); font-size: 1.4rem; }
.source-panel p { margin: 0 0 12px; color: #40505a; }
.source-list, .holds-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.source-list li, .holds-list li { padding: 11px 0; border-top: 1px solid #e2e7e5; }
.source-list li:first-child, .holds-list li:first-child { border-top: 0; }
.source-list strong, .holds-list strong { display: block; color: var(--navy); font-size: 0.93rem; }
.source-list span, .holds-list span { display: block; color: var(--muted); font-size: 0.87rem; }
.source-state { padding: 12px; border-left: 4px solid var(--gold); background: #f6f0e3; }
.source-state.is-error { border-color: var(--error); background: #f9efed; }
.source-state code { display: block; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; color: #6d2d26; font-family: var(--sans); font-size: 0.84rem; }
.timestamp-list { display: grid; gap: 6px; margin: 13px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.88rem; }
.timestamp-list strong { color: var(--dark); }
.source-scope { margin-top: 15px !important; padding-top: 14px; border-top: 1px solid #e2e7e5; font-size: 0.88rem; }

.ssr-content { max-width: 1210px; margin-top: 28px; }
.ssr-content > * + * { margin-top: 14px; }
.ssr-content .post-card, .ssr-content article, .ssr-content .ssr-post { padding: 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 12px rgba(24, 37, 53, 0.025); }
.ssr-content .caption, .ssr-content [data-source-text] { white-space: pre-wrap; overflow-wrap: anywhere; }

.post-dialog { width: min(760px, calc(100vw - 26px)); max-height: min(85vh, 880px); padding: 0; border: 0; border-radius: 13px; color: var(--dark); background: var(--paper); box-shadow: 0 25px 70px rgba(2, 31, 75, 0.32); }
.post-dialog::backdrop { background: rgba(2, 31, 75, 0.61); }
.dialog-inner { padding: clamp(20px, 4vw, 30px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.dialog-header h2 { margin: 0; font-family: var(--serif); font-size: clamp(1.45rem, 4vw, 2.15rem); letter-spacing: -0.03em; line-height: 1.15; }
.dialog-caption { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #30414c; }
.dialog-id { margin: 14px 0 0; color: var(--muted); font-size: 0.83rem; }
.dialog-media { display: grid; gap: 13px; margin-top: 20px; }
.dialog-media .media-frame { min-height: 160px; max-height: 500px; }
.dialog-media .media-frame img { max-height: 480px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 21px; }
.copy-feedback { align-self: center; color: var(--teal-dark); font-size: 0.87rem; font-weight: 700; }

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

@media (max-width: 1040px) {
  .articles-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-fields > .field:first-child { grid-column: 1 / -1; }
  .clear-filter { grid-column: 1 / -1; justify-self: start; }
  .source-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .site-shell { display: block; }
  .sidebar { position: relative; display: block; height: auto; padding: 13px 14px 11px; }
  .brand { display: flex; width: auto; align-items: center; gap: 12px; margin: 0 0 11px; }
  .brand img { width: 128px; }
  .brand-subtitle { margin: 0; font-size: 0.65rem; }
  .library-nav { display: flex; gap: 5px; overflow-x: auto; margin: 0 -14px; padding: 0 14px 3px; }
  .nav-link { min-width: max-content; min-height: 45px; padding: 8px 10px; font-size: 0.84rem; }
  .nav-link svg { width: 18px; height: 18px; }
  .sidebar-foot { display: none; }
  .library-main { padding: 26px 16px 52px; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 18px; }
  .page-header .button { width: 100%; }
  .header-copy { font-size: 1rem; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 1.7rem; }
  .filter-panel { padding: 14px; }
  .filter-topline { align-items: flex-start; flex-direction: column; gap: 4px; }
  .filter-fields, .advanced-fields { grid-template-columns: 1fr; }
  .clear-filter { grid-column: auto; width: 100%; }
  .browser-controls { align-items: flex-start; flex-direction: column; }
  .post-collection.gallery, .articles-grid { grid-template-columns: 1fr; }
  .post-media { grid-template-columns: 1fr; }
  .media-frame { min-height: 150px; }
  .calendar-weekdays, .calendar-grid { display: none; }
  .calendar-agenda { display: grid; gap: 9px; }
  .agenda-day { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 1px solid #b9d7d0; border-radius: 8px; color: var(--navy); background: #f5fbf9; text-align: left; font-weight: 700; }
  .agenda-day[aria-pressed="true"] { border-color: var(--navy); background: var(--mint); }
  .agenda-day span:last-child { color: var(--teal-dark); font-size: 0.82rem; }
  .calendar-caption { display: none; }
}

@media (max-width: 410px) {
  .stat-label { font-size: 0.7rem; }
  .stat-note { font-size: 0.69rem; }
  .platform-tab { padding-inline: 11px; }
  .control-cluster { width: 100%; }
  .control-cluster select { flex: 1; min-width: 0; }
  .post-collection.timeline { padding-left: 19px; }
  .post-collection.timeline > .post-card::before { left: -20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* Source limitations and dates carry meaning; do not shrink them into fine print. */
.source-notice,
.post-time,
.source-scope,
.source-list span,
.holds-list span,
.timestamp-list,
.source-state code,
.calendar-caption,
.view-heading .batch-summary { font-size: 1rem; }
.field input, .field select, .nav-link { min-height: 48px; }

.field input, .field select { min-width: 0; max-width: 100%; }
.field label { min-width: 0; overflow-wrap: anywhere; }
