:root {
  --bg: #fefefd;
  --bg-ink-wash: #faf8f4;
  --surface: #ffffff;
  --surface-strong: #fcfbf8;
  --ink: #1f1d1a;
  --muted: #6a645e;
  --line: #e7e3dd;
  --line-strong: #ddd8d0;
  --accent: #7d6a52;
  --accent-deep: #5f503f;
  --accent-soft: #f2eee7;
  --shadow: rgba(24, 18, 12, 0.05);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-body: "Avenir Next", "Segoe UI", "Helvetica Neue", Helvetica, sans-serif;
  --font-code: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-ink-wash) 100%);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
}

a {
  color: var(--accent-deep);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-shell {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 253, 0.96);
  backdrop-filter: blur(2px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-shell-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

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

.site-shell-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.site-title-link {
  color: var(--ink);
  text-decoration: none;
}

.site-title-link:hover {
  color: var(--ink);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.site-byline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.site-byline strong {
  color: var(--ink);
  font-weight: 600;
}

.site-contact-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.contact-link {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.8);
}

.contact-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.contact-link:hover {
  text-decoration: none;
  color: var(--accent-deep);
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

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

.site-nav-link {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
}

.site-nav-link:hover {
  text-decoration: none;
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.site-nav-link.active {
  color: var(--accent-deep);
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.site-nav-link-repo {
  background: var(--accent-soft);
  border-color: var(--line-strong);
  color: var(--accent-deep);
  font-weight: 700;
}

.site-nav-link-repo:hover {
  background: #ede5d8;
  border-color: var(--accent);
  color: #4e4032;
}

main,
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px 24px 46px 24px;
}

.hero-banner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 8px 20px -24px var(--shadow);
  animation: rise-in 320ms ease-out;
}

.hero-kicker {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 600;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

h1 {
  margin: 6px 0 6px 0;
  font-size: clamp(30px, 4.8vw, 44px);
  line-height: 1.05;
}

h2 {
  margin: 22px 0 10px 0;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.14;
}

h3 {
  margin: 0 0 8px 0;
  font-size: clamp(19px, 1.8vw, 24px);
  line-height: 1.2;
}

.sub {
  margin: 6px 0 0 0;
  font-size: 15px;
  color: var(--muted);
}

.small {
  font-size: 13px;
  color: var(--muted);
}

.back-link {
  font-weight: 700;
}

.digest-about {
  margin: 16px 0 20px 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.digest-about h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

.digest-about p {
  margin: 0;
}

.controls {
  margin: 14px 0 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.control-row {
  display: grid;
  grid-template-columns: 2fr repeat(2, minmax(170px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.search-only-row {
  grid-template-columns: minmax(320px, 1fr) auto auto auto;
}

.month-controls-row {
  grid-template-columns: minmax(170px, 240px) auto;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-grow {
  min-width: 0;
}

.control span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"],
select,
button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.2;
  color: var(--ink);
  background: #fffefb;
}

input[type="text"]:focus,
select:focus,
button:focus,
input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(125, 106, 82, 0.2);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--surface-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.toggle-control {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.tag-filter-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

#digest-app[data-view="explore"] {
  max-width: 1240px;
}

#digest-app[data-view="explore"] .tag-filter-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tag-filter-grid.compact {
  margin-top: 10px;
}

.tag-filter {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px 10px 10px;
  background: var(--surface);
}

.tag-filter-paper_type {
  background: #f8f0ee;
  border-color: #ebddd9;
}

.tag-filter-paper_type legend {
  color: #7f665f;
}

.tag-filter-backbone {
  background: #eef2f8;
  border-color: #dde4ef;
}

.tag-filter-backbone legend {
  color: #556377;
}

.tag-filter-objective {
  background: #eef5f0;
  border-color: #dce8df;
}

.tag-filter-objective legend {
  color: #536a5b;
}

.tag-filter-tokenization {
  background: #f5f1ea;
  border-color: #e7ded0;
}

.tag-filter-tokenization legend {
  color: #736558;
}

.tag-filter-topology {
  background: #f2f1f7;
  border-color: #e2deee;
}

.tag-filter-topology legend {
  color: #635e79;
}

.tag-filter legend {
  font-size: 11px;
  color: var(--muted);
  padding: 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
}

.filter-help {
  margin: 9px 0 0 0;
}

.filter-collapse {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  background: var(--surface);
}

.filter-collapse summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

#home-results {
  margin-top: 8px;
}

.year-block {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.year-summary {
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.year-summary-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
}

.home-month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  padding: 14px;
}

.month-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  background: var(--surface);
  box-shadow: 0 6px 14px -20px var(--shadow);
  animation: rise-in 240ms ease-out;
  cursor: pointer;
}

.month-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px -24px rgba(36, 24, 12, 0.1);
}

.month-card[role="link"]:focus-visible {
  outline: 2px solid rgba(125, 106, 82, 0.35);
  outline-offset: 2px;
}

.month-head {
  position: relative;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.month-card h3 {
  font-size: 19px;
  margin: 0;
}

.month-stats {
  margin: 2px 0 0 0;
  text-align: right;
}

.featured-paper {
  position: relative;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.featured-title {
  margin: 4px 0 6px 0;
  font-weight: 700;
  line-height: 1.35;
}

#results-meta {
  margin: 10px 0 8px 0;
}

.paper-card,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 14px 0;
  box-shadow: 0 10px 20px -26px var(--shadow);
  animation: rise-in 280ms ease-out;
}

.paper-card.featured-card {
  border-color: #ddc9a6;
  background: #fffdf8;
  box-shadow: 0 0 0 1px #f1e7d6, 0 12px 24px -28px rgba(60, 42, 18, 0.22);
}

.paper-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px -26px rgba(36, 24, 12, 0.12);
}

.featured-card-badge {
  margin: 0 0 10px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #7a5b33;
  background: #fbf3e4;
  border: 1px solid #ecd9b6;
  border-radius: 999px;
  padding: 4px 10px;
}

.paper-card p {
  margin: 9px 0;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.summary-points {
  margin: 6px 0 12px 20px;
  padding: 0;
}

.summary-points li {
  margin: 5px 0;
}

.summary-detail {
  margin: 12px 0;
}

.summary-detail summary {
  cursor: pointer;
  color: var(--accent-deep);
  font-weight: 700;
}

.summary-detail p {
  margin-top: 8px;
}

.summary-failed {
  color: #5d5348;
  background: #f7f4ef;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
}

.chip-paper_type {
  background: #f8f0ee;
  border-color: #ebddd9;
  color: #7f665f;
}

.chip-backbone {
  background: #eef2f8;
  border-color: #dde4ef;
  color: #556377;
}

.chip-objective {
  background: #eef5f0;
  border-color: #dce8df;
  color: #536a5b;
}

.chip-tokenization {
  background: #f5f1ea;
  border-color: #e7ded0;
  color: #736558;
}

.chip-topology {
  background: #f2f1f7;
  border-color: #e2deee;
  color: #635e79;
}

.links {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.resource-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
}

.resource-btn:hover {
  text-decoration: none;
  background: var(--surface-strong);
  border-color: var(--accent);
}

.resource-btn-code {
  background: #f1f5fb;
  border-color: #d8e3f3;
  color: #3e5670;
}

.resource-btn-weights {
  background: #f8f2ea;
  border-color: #ead9c4;
  color: #6e5a44;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}

.archive-fallback {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 8px 10px;
}

.archive-fallback summary {
  cursor: pointer;
  font-weight: 700;
}

.archive-fallback ul {
  margin: 8px 0 0 20px;
}

.process-page .process-content {
  margin-top: 16px;
}

.process-content p {
  margin: 10px 0;
}

.process-content ul {
  margin: 8px 0 12px 20px;
}

.prompt-details {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  box-shadow: 0 8px 22px -24px var(--shadow);
}

.keyword-details {
  background: var(--surface-strong);
}

.keyword-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 8px 12px;
}

.keyword-grid section p {
  margin-bottom: 5px;
}

.keyword-grid ul {
  margin: 4px 0 0 0;
  padding-left: 18px;
}

.keyword-grid li {
  margin: 2px 0;
}

.keyword-grid code,
.prompt-block code {
  font-family: var(--font-code);
}

.prompt-block {
  margin: 8px 0 4px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 430px;
  overflow: auto;
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.5;
}

.compact-block {
  max-height: 170px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .site-shell-inner {
    padding: 12px 16px;
    gap: 12px;
  }

  .site-shell-top {
    align-items: flex-start;
  }

  .site-shell-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-top: 8px;
  }

  main,
  .container {
    padding: 24px 16px 36px 16px;
  }

  .site-title {
    font-size: 27px;
  }

  h1 {
    font-size: clamp(30px, 9vw, 42px);
  }

  .control-row,
  .month-controls-row {
    grid-template-columns: 1fr;
  }

  .home-month-grid {
    grid-template-columns: 1fr;
  }

  .month-head {
    flex-direction: column;
    align-items: start;
  }

  .month-stats {
    text-align: left;
  }
}

@media (max-width: 1240px) {
  #digest-app[data-view="explore"] .tag-filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}
