
:root {
  --bg: #f5efe4;
  --panel: rgba(255, 250, 240, 0.88);
  --panel-strong: rgba(255, 247, 232, 0.98);
  --ink: #1f2a30;
  --muted: #627078;
  --line: rgba(31, 42, 48, 0.12);
  --accent: #c44f2d;
  --accent-strong: #9f3518;
  --accent-soft: rgba(196, 79, 45, 0.12);
  --chip: rgba(47, 78, 90, 0.08);
  --shadow: 0 24px 60px rgba(39, 28, 18, 0.12);
  --radius: 20px;
  --content-width: min(1380px, calc(100vw - 32px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(circle at top left, rgba(196, 79, 45, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(53, 90, 100, 0.18), transparent 24%),
    linear-gradient(180deg, #f8f1e5 0%, #efe2cd 58%, #e7dac4 100%);
  min-height: 100vh;
}

a {
  color: inherit;
}

.site-shell {
  width: var(--content-width);
  margin: 0 auto;
  padding: 20px 0 48px;
}

.hero-shell,
.paper-hero,
.filters-card,
.results-shell,
.meta-card,
.paper-card,
.markdown-body,
.paper-sidebar {
  backdrop-filter: blur(18px);
}

.hero-shell,
.paper-hero {
  background: linear-gradient(135deg, rgba(255, 249, 239, 0.94), rgba(247, 236, 217, 0.92));
  border: 1px solid rgba(31, 42, 48, 0.09);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.9fr);
  gap: 24px;
  padding: 28px;
}

.eyebrow,
.brand-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.12;
}

.hero-grid h1,
.paper-hero h1 {
  font-size: clamp(32px, 4.6vw, 56px);
  letter-spacing: -0.04em;
  max-width: 16ch;
}

.hero-copy,
.hero-summary {
  margin-top: 14px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  max-width: 72ch;
}

.hero-panel,
.paper-sidebar,
.filters-card,
.results-shell,
.markdown-body,
.meta-card,
.paper-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.hero-stats div {
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.hero-stats strong {
  display: block;
  font-size: 28px;
}

.hero-stats span {
  color: var(--muted);
  font-size: 13px;
}

.lang-switch,
.topbar-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lang-btn,
.ghost-btn,
.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.lang-btn:hover,
.ghost-btn:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(196, 79, 45, 0.35);
}

.lang-btn.is-active,
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff5ef;
}

.ghost-btn.wide {
  justify-content: center;
  text-align: center;
}

.home-layout,
.paper-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
}

.filters-card,
.paper-sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
  padding: 18px;
}

.control-block + .control-block,
.meta-card + .meta-card {
  margin-top: 18px;
}

.control-block h2,
.meta-card h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.query-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
  color: var(--ink);
}

.chip-wrap,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.results-shell {
  padding: 18px;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.results-head span,
.meta-empty,
.paper-card p,
.stack-list p,
.toc-list a {
  color: var(--muted);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.paper-card {
  padding: 18px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 250px;
}

.paper-card:hover {
  transform: translateY(-2px);
}

.paper-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.paper-card h3 {
  font-size: 24px;
}

.paper-card p {
  margin: 0;
  line-height: 1.65;
  flex: 1;
}

.status-pill,
.meta-chip,
.tag,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.status-pill {
  background: rgba(31, 42, 48, 0.86);
  color: #fff7eb;
}

.meta-chip,
.tag,
.pill {
  background: var(--chip);
  color: var(--ink);
}

.tag.subtle {
  background: rgba(47, 78, 90, 0.06);
  color: var(--muted);
}

.paper-hero {
  padding: 24px 26px;
  margin-top: 8px;
}

.hero-meta {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.paper-article {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.markdown-body {
  padding: 28px;
  line-height: 1.75;
  font-size: 17px;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin-top: 30px;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.markdown-body p {
  margin: 14px 0;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
  margin: 12px 0;
}

.markdown-body li {
  margin: 8px 0;
}

.markdown-body code,
.pv-code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.markdown-body code {
  background: rgba(31, 42, 48, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

.pv-code {
  background: rgba(31, 42, 48, 0.94);
  color: #f7ead9;
  padding: 16px;
  border-radius: 18px;
  overflow-x: auto;
}

.pv-rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 30px 0;
}

.pv-math-block {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  border: 1px solid rgba(31, 42, 48, 0.08);
  padding: 14px;
  overflow-x: auto;
}

.pv-callout {
  padding: 18px 18px 16px;
  border-radius: 18px;
  border: 1px solid rgba(196, 79, 45, 0.18);
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.95), rgba(247, 239, 227, 0.82));
  margin: 20px 0;
}

.pv-proof {
  border-color: rgba(53, 90, 100, 0.18);
  background: linear-gradient(180deg, rgba(247, 251, 252, 0.96), rgba(236, 244, 246, 0.86));
}

.pv-callout-title,
.pv-proof summary {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
  cursor: pointer;
}

.pv-proof summary {
  color: #28596b;
  margin-bottom: 10px;
}

.stack-list,
.meta-list,
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stack-list li + li,
.meta-list li + li {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.stack-list p {
  margin: 6px 0 0;
}

.toc-list li + li {
  margin-top: 8px;
}

.toc-list .lv-3 {
  padding-left: 14px;
}

.topbar-inner {
  width: var(--content-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.chat-shell {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  width: min(460px, calc(100vw - 24px));
}

.chat-card {
  background: rgba(255, 249, 239, 0.98);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 22px 70px rgba(24, 18, 12, 0.18);
  padding: 16px;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.chat-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chat-log {
  margin-top: 14px;
  max-height: min(54vh, 520px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  border-radius: 18px;
  padding: 12px 14px;
}

.chat-msg.user {
  background: rgba(196, 79, 45, 0.11);
}

.chat-msg.assistant {
  background: rgba(47, 78, 90, 0.08);
}

.chat-role {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 6px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.chat-body {
  white-space: pre-wrap;
  line-height: 1.7;
}

.chat-form {
  margin-top: 14px;
}

.chat-form textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
}

.chat-actions {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

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

.pv-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(20px);
  background: rgba(245, 239, 228, 0.75);
  border-bottom: 1px solid rgba(31, 42, 48, 0.08);
  padding: 14px 0;
}

.brand {
  text-decoration: none;
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 22px;
  letter-spacing: -0.04em;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .home-layout,
  .paper-layout,
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .filters-card,
  .paper-sidebar {
    position: static;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-shell {
    width: min(100vw - 20px, 100%);
  }

  .hero-grid,
  .paper-hero,
  .results-shell,
  .filters-card,
  .markdown-body,
  .paper-sidebar {
    padding: 16px;
  }

  .hero-grid h1,
  .paper-hero h1 {
    max-width: none;
  }

  .topbar-inner {
    width: min(100vw - 20px, 100%);
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }
}
