:root {
  --bg: #f5f4ed;
  --surface: rgba(250, 249, 245, 0.96);
  --surface-strong: #fffaf2;
  --text: #2f2923;
  --muted: #6d6258;
  --border: #e7dccd;
  --accent: #c96442;
  --accent-soft: rgba(201, 100, 66, 0.12);
  --shadow: 0 20px 45px rgba(91, 68, 52, 0.08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(201, 100, 66, 0.08) 0%, transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(109, 98, 88, 0.08) 0%, transparent 22%),
    linear-gradient(180deg, #fbf6ef 0%, var(--bg) 54%, #efe4d6 100%);
  color: var(--text);
}

button,
select {
  font: inherit;
}

button {
  border: none;
}

.page-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 24px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(248, 242, 233, 0.94));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.brand-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.72rem;
}

.brand-note {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.nav-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link,
.primary-cta,
.secondary-cta {
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.nav-link {
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  border: 1px solid var(--border);
}

.nav-link.active,
.nav-link:hover {
  background: var(--accent-soft);
  color: #9b4e32;
  border-color: rgba(201, 100, 66, 0.25);
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

.hero,
.home-card,
.library-panel,
.reader-panel,
.inspector-card,
.mode-card,
.section-shell {
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(248, 242, 233, 0.94));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 24px;
  padding: 34px;
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 8px;
}

.hero h2,
.section-intro h2,
.reader-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.12;
}

.hero h2 {
  font-size: clamp(2.2rem, 3vw, 3.8rem);
  max-width: 14ch;
}

.hero-copy,
.section-intro p,
.panel-header p,
.reader-summary,
.reader-empty p,
.inspect-pos,
.inspect-block p,
.mode-card p,
.article-card p,
.home-card p {
  color: var(--muted);
}

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

.primary-cta {
  background: var(--accent);
  color: #fffaf2;
}

.secondary-cta {
  background: #ebe3d6;
  color: var(--text);
  border: 1px solid var(--border);
}

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

.stat-card {
  padding: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.stat-card span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 2rem;
}

.home-grid,
.mode-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.home-card,
.mode-card {
  padding: 20px;
}

.mode-card {
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.mode-card:hover,
.mode-card.active {
  transform: translateY(-2px);
  border-color: rgba(201, 100, 66, 0.4);
  background: rgba(201, 100, 66, 0.08);
}

.mode-card h3,
.home-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.section-shell {
  padding: 24px;
}

.section-intro {
  margin-bottom: 20px;
}

.full-panel,
.reading-room {
  width: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.panel-header-stack {
  align-items: stretch;
}

.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-header h2,
.reader-empty h2 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
}

.theme-filter {
  min-width: 150px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.article-list {
  display: grid;
  gap: 14px;
}

.article-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.38);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.article-card:hover,
.article-card.active {
  transform: translateY(-2px);
  border-color: rgba(201, 100, 66, 0.45);
  background: rgba(201, 100, 66, 0.1);
}

.article-card h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.article-card p {
  margin: 0;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #9c542f;
  font-size: 12px;
  font-weight: 600;
}

.two-column-reading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.reader-panel {
  min-height: 72vh;
  padding: 28px;
}

.reader-empty {
  display: grid;
  place-items: center;
  min-height: 56vh;
  text-align: center;
}

.reader-article.hidden {
  display: none;
}

.reader-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 24px;
}

.reader-theme {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
}

.reader-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.reader-content {
  max-width: 74ch;
  margin: 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.14rem;
  line-height: 1.95;
}

.reader-content p {
  margin: 0 0 1.35em;
}

.vocab-button {
  appearance: none;
  background: transparent;
  padding: 0 2px;
  margin: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: inset 0 -0.5em 0 rgba(201, 100, 66, 0.18);
}

.vocab-button:hover,
.vocab-button.active {
  background: rgba(201, 100, 66, 0.14);
}

.reading-side-panel {
  display: block;
}

.reading-side-card {
  position: fixed;
  right: max(24px, calc((100vw - 1520px) / 2 + 24px));
  top: 50%;
  transform: translateY(-50%);
  width: 340px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  z-index: 20;
}

.reader-toolbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 18px;
}

.reader-exit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inspector-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.inspect-block {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
}

.inspect-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.translation-popover {
  position: absolute;
  z-index: 1000;
  max-width: calc(100vw - 24px);
  padding: 16px;
  border: 1px solid rgba(201, 100, 66, 0.35);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.98);
  box-shadow: 0 24px 70px rgba(91, 68, 52, 0.22);
  backdrop-filter: blur(16px);
}

.translation-popover.hidden {
  display: none;
}

.popover-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#popover-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  cursor: pointer;
}

.popover-text {
  max-height: 76px;
  overflow: auto;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.popover-translation {
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.55;
  font-weight: 700;
}

.popover-explanation {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-line;
}

@media (max-width: 1200px) {
  .hero,
  .home-grid,
  .mode-strip,
  .two-column-reading {
    grid-template-columns: 1fr;
  }

  .reading-side-card {
    position: static;
    transform: none;
    width: 100%;
    max-height: none;
  }
}

@media (max-width: 900px) {
  .page-shell {
    padding: 16px;
  }

  .top-nav,
  .hero,
  .reader-header {
    flex-direction: column;
    align-items: stretch;
  }

  .hero {
    display: block;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 20px;
  }

  .filters-row,
  .reader-badges,
  .nav-links {
    justify-content: flex-start;
  }
}
