:root {
  --bg-1: #f3f6fb;
  --bg-2: #e7edf7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --border: rgba(28, 52, 84, 0.12);
  --text: #1f2937;
  --muted: #5f6b7a;
  --accent: #1e5aa8;
  --accent-soft: #e8f1ff;
  --shadow: 0 20px 50px rgba(12, 31, 61, 0.12);
  --shadow-soft: 0 10px 24px rgba(12, 31, 61, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --max-width: 1100px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(30, 90, 168, 0.12), transparent 32%),
    radial-gradient(circle at top right, rgba(17, 138, 178, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  line-height: 1.55;
}

a {
  color: inherit;
}

.page {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.hero {
  padding: 1.75rem 0 1rem;
}

.hero-card {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 {
  margin: 1rem 0 0.5rem;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.05;
}

.hero p {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.stat {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
}

.stat-label {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem 1rem;
}

.search-wrap {
  flex: 1 1 320px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 0.95rem 1rem 0.95rem 2.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.86);
  box-shadow: var(--shadow-soft);
  font: inherit;
  color: var(--text);
}

.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.1rem;
}

.result-count {
  white-space: nowrap;
  background: white;
  padding: 0.95rem 16px;
  border-radius: 999px;
  font-size: 14px;
  color: #3b4a5a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  white-space: nowrap;
}

.letters {
  display: grid;
  gap: 1.1rem;
}

.letter {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  padding: 1.2rem;
}

.letter.reply {
  background: rgba(248, 251, 255, 0.96);
  border-left: 4px solid rgba(30, 90, 168, 0.24);
}

.letter-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.letter-title {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.83rem;
}

.meta {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.meta-row {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.65rem;
  align-items: start;
}

.meta-label {
  color: var(--muted);
  font-weight: 700;
}

.meta-value {
  overflow-wrap: anywhere;
}

.description {
  margin: 0;
  white-space: pre-line;
  color: #243140;
}

.children {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(28, 52, 84, 0.08);
}

.empty-state {
  display: none;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  background: rgba(255,255,255,0.7);
  border: 1px dashed rgba(28, 52, 84, 0.18);
  border-radius: var(--radius-xl);
}

.footer {
  padding: 1.5rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 840px) {
  .page {
    width: min(calc(100% - 1rem), var(--max-width));
  }

  .hero {
    padding-inline: 0;
  }

  .hero-card {
    padding: 1.15rem;
  }

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

  .meta-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

@media (max-width: 560px) {
  html {
    font-size: 15px;
  }

  .letter,
  .letter.reply {
    padding: 1rem;
    border-radius: 18px;
  }

  .letter-header {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    padding-inline: 0;
  }
}
