:root {
  --paper: #f7f1e4;
  --paper-strong: #efe5d2;
  --paper-soft: rgba(247, 241, 228, 0.72);
  --ink: #1f1b18;
  --ink-muted: #5e564f;
  --line: rgba(37, 31, 25, 0.12);
  --line-strong: rgba(37, 31, 25, 0.24);
  --olive: #536143;
  --olive-soft: #dde5d3;
  --brick: #935b46;
  --test: #8d6a12;
  --test-soft: #f3e7bf;
  --shadow: 0 18px 50px rgba(47, 38, 28, 0.08);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --content-width: min(1180px, calc(100vw - 32px));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(156, 133, 88, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(83, 97, 67, 0.12), transparent 24%),
    linear-gradient(180deg, #fbf7ef 0%, #f4edde 100%);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

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

.site-header {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(251, 247, 239, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wordmark-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--paper-strong);
  font-size: 22px;
}

.wordmark strong,
.wordmark small {
  display: block;
}

.wordmark strong,
.hero h1,
.section-heading h2,
.overlay-panel h2,
.overlay-panel h3 {
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.wordmark small,
.site-nav a,
.section-note,
.meta-label,
.eyebrow {
  color: var(--ink-muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
}

.site-nav a {
  padding: 6px 0;
  font-size: 0.95rem;
}

.hero,
.section,
.status-banner,
.site-footer,
.overlay-panel,
.filters-panel {
  border: 1px solid var(--line);
  background: var(--paper-soft);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 24px;
  padding: 34px;
  border-radius: var(--radius-lg);
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 4.2rem);
  line-height: 1.08;
}

.hero-subtitle {
  max-width: 44rem;
  margin: 18px 0 0;
  color: var(--ink-muted);
  font-size: 1.02rem;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover,
.button:focus-visible,
.card-button:hover,
.card-button:focus-visible,
.overlay-close:hover,
.overlay-close:focus-visible {
  transform: translateY(-1px);
}

.button-primary {
  color: #f9f4ea;
  background: var(--ink);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.45);
}

.button-small {
  min-height: 38px;
  padding: 0 16px;
}

.hero-aside {
  display: grid;
  gap: 16px;
}

.note-card,
.stat-card,
.module-card,
.archive-card,
.explorer-card,
.frog-card,
.feature-letter,
.minor-letter {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.42);
}

.note-card {
  padding: 20px;
}

.note-label {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.note-value {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.65;
}

.status-banner {
  min-height: 66px;
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
}

.status-banner.is-error {
  border-color: rgba(147, 91, 70, 0.4);
  background: rgba(147, 91, 70, 0.08);
}

.status-banner.is-warning {
  border-color: rgba(141, 106, 18, 0.45);
  background: rgba(243, 231, 191, 0.45);
}

.status-banner.is-loading {
  border-color: rgba(83, 97, 67, 0.3);
}

.section {
  margin-top: 24px;
  padding: 26px;
  border-radius: var(--radius-lg);
}

.section-heading,
.archive-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.section-note {
  margin: 0;
  max-width: 28rem;
  line-height: 1.7;
}

.card-grid,
.stats-grid,
.module-grid,
.explorer-grid,
.minor-letters,
.chat-layout,
.chat-sidebar,
.chat-main,
.chat-frog-list {
  display: grid;
  gap: 16px;
}

.frog-grid,
.stats-grid,
.module-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-top: 22px;
}

.frog-card,
.stat-card,
.module-card {
  padding: 22px;
}

.frog-card {
  grid-column: span 4;
  text-align: left;
}

.frog-card h3,
.archive-card h3,
.feature-letter h3,
.minor-letter h3,
.explorer-card h3,
.overlay-panel h2,
.overlay-panel h3 {
  margin: 0;
  font-size: 1.35rem;
}

.meta-list,
.detail-grid,
.explorer-list,
.timeline-list,
.letter-list,
.item-group-list,
.media-list,
.event-list {
  display: grid;
  gap: 12px;
}

.meta-row,
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.meta-row strong,
.detail-row strong {
  flex: 0 0 42%;
  color: var(--ink-muted);
  font-weight: 500;
}

.meta-row span,
.detail-row span {
  flex: 1;
  text-align: right;
}

.card-header,
.letter-meta,
.archive-meta,
.timeline-meta,
.system-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.card-kicker,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.card-kicker {
  background: var(--paper-strong);
}

.badge {
  border: 1px solid var(--line);
  color: var(--ink-muted);
}

.badge-test {
  border-color: rgba(141, 106, 18, 0.3);
  background: var(--test-soft);
  color: var(--test);
}

.badge-formal {
  background: rgba(83, 97, 67, 0.1);
  color: var(--olive);
}

.test-banner {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--test-soft);
  color: var(--test);
  font-size: 0.94rem;
  line-height: 1.6;
}

.card-summary,
.empty-copy,
.letter-body,
.module-copy,
.archive-card p,
.explorer-card p,
.feature-letter p,
.minor-letter p {
  color: var(--ink-muted);
  line-height: 1.8;
}

.card-button,
.archive-card button {
  width: 100%;
}

.card-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.stat-card {
  grid-column: span 2;
}

.stat-label {
  margin: 0;
  color: var(--ink-muted);
}

.stat-value {
  margin: 8px 0 0;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(2rem, 5vw, 3rem);
}

.stats-footnote {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink-muted);
}

.letters-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  gap: 16px;
  margin-top: 22px;
}

.feature-letter,
.minor-letter {
  padding: 24px;
}

.minor-letters {
  grid-template-columns: 1fr;
}

.filters-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
  padding: 18px;
  border-radius: var(--radius-md);
}

.chat-layout {
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.35fr);
  margin-top: 22px;
}

.chat-frog-button {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.44);
  text-align: left;
}

.chat-frog-button.is-active {
  border-color: rgba(31, 27, 24, 0.3);
  background: rgba(31, 27, 24, 0.08);
}

.chat-field {
  display: grid;
  gap: 8px;
  color: var(--ink-muted);
}

.chat-field input,
.chat-field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.chat-field textarea {
  min-height: 120px;
  resize: vertical;
}

.chat-toggle {
  display: flex;
  align-items: start;
  gap: 10px;
  margin-top: 14px;
}

.chat-runtime-banner {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(83, 97, 67, 0.08);
  color: var(--ink-muted);
}

.chat-runtime-banner.is-warning {
  background: rgba(243, 231, 191, 0.6);
  color: var(--test);
}

.chat-runtime-banner.is-error {
  background: rgba(147, 91, 70, 0.12);
  color: var(--brick);
}

.chat-thread {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.chat-message {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

.chat-message-user {
  background: rgba(31, 27, 24, 0.06);
}

.chat-message-assistant {
  background: rgba(83, 97, 67, 0.08);
}

.chat-message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.chat-message-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.8;
}

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

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.chat-draft {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.chat-draft-block {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.42);
}

.filters-panel label {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.filters-panel select,
.filters-panel input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.filter-search {
  grid-column: span 2;
}

.archive-toolbar {
  margin-top: 18px;
}

.archive-toolbar p {
  margin: 0;
  color: var(--ink-muted);
}

.stack-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.archive-card,
.explorer-card {
  padding: 22px;
}

.explorer-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
}

.explorer-list,
.timeline-list,
.letter-list,
.item-group-list,
.media-list,
.event-list {
  padding-left: 0;
  list-style: none;
}

.timeline-list li,
.letter-list li,
.item-group-list li,
.media-list li,
.event-list li {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.timeline-list li:first-child,
.letter-list li:first-child,
.item-group-list li:first-child,
.media-list li:first-child,
.event-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.module-card {
  grid-column: span 3;
}

.module-copy {
  margin: 14px 0 0;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 24px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  color: var(--ink-muted);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.overlay.is-hidden {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 17, 13, 0.52);
  backdrop-filter: blur(8px);
}

.overlay-panel {
  position: relative;
  width: min(900px, calc(100vw - 20px));
  max-height: calc(100vh - 24px);
  margin: 12px auto;
  padding: 26px;
  overflow: auto;
  border-radius: var(--radius-lg);
}

.overlay-panel-wide {
  width: min(1040px, calc(100vw - 20px));
}

.overlay-close {
  position: sticky;
  top: 0;
  left: calc(100% - 42px);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  font-size: 1.4rem;
}

.overlay-section + .overlay-section {
  margin-top: 28px;
}

.panel-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
}

.detail-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.45);
}

.letter-body {
  margin: 18px 0 0;
  white-space: pre-wrap;
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.32);
}

.muted {
  color: var(--ink-muted);
}

@media (max-width: 1024px) {
  .hero,
  .letters-grid,
  .panel-columns,
  .explorer-grid,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .frog-card,
  .stat-card,
  .module-card {
    grid-column: span 6;
  }

  .filters-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 12px;
  }

  .site-header,
  .section-heading,
  .archive-toolbar,
  .site-footer,
  .meta-row,
  .detail-row {
    align-items: start;
    flex-direction: column;
  }

  .site-header {
    position: static;
    border-radius: 24px;
  }

  .site-nav {
    justify-content: start;
  }

  .hero,
  .section,
  .overlay-panel {
    padding: 20px;
  }

  .frog-grid,
  .stats-grid,
  .module-grid,
  .filters-panel {
    grid-template-columns: 1fr;
  }

  .frog-card,
  .stat-card,
  .module-card,
  .filter-search {
    grid-column: span 1;
  }

  .meta-row span,
  .detail-row span {
    text-align: left;
  }

  .card-actions,
  .panel-actions,
  .hero-actions,
  .chat-actions {
    flex-direction: column;
  }

  .button,
  .card-button {
    width: 100%;
  }
}
