:root {
  --bg-top: #d6c2a4;
  --bg-bottom: #f4eedf;
  --panel: rgba(251, 247, 239, 0.88);
  --panel-strong: #fbf7ef;
  --ink: #26190f;
  --muted: #6f5e4f;
  --accent: #9e3d2c;
  --accent-dark: #6f2218;
  --line: rgba(73, 44, 21, 0.12);
  --gold: #c59b43;
  --shadow: 0 18px 60px rgba(62, 36, 16, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(158, 61, 44, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(197, 155, 67, 0.22), transparent 24%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 38px 38px;
  opacity: 0.18;
  pointer-events: none;
}

.app-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.hero,
.panel,
.mode-tabs {
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.eyebrow,
.panel-kicker,
.quiz-meta,
.study-era-badge {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--accent);
  font-weight: 800;
}

.hero h1,
.panel h2,
.quiz-progress h3 {
  margin: 0;
  font-family: "Forum", serif;
  line-height: 0.94;
}

.hero h1 {
  font-size: clamp(38px, 5vw, 66px);
}

.hero-text {
  max-width: 700px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 18px 0 0;
}

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

.stat-card {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 122px;
}

.stat-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.mode-tabs {
  display: inline-flex;
  gap: 8px;
  margin: 18px 0;
  background: rgba(251, 247, 239, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px;
}

.mode-tab,
.primary-btn,
.ghost-btn,
.option-btn,
.person-item {
  font: inherit;
}

.mode-tab,
.primary-btn,
.ghost-btn {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.mode-tab {
  padding: 12px 18px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff7ef;
}

.panel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

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

.learn-actions,
.quiz-setup,
.filters,
.quiz-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff7ef;
  padding: 14px 20px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(111, 34, 24, 0.22);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 13px 18px;
  font-weight: 700;
}

.mode-tab:hover,
.primary-btn:hover,
.ghost-btn:hover,
.option-btn:hover,
.person-item:hover {
  transform: translateY(-1px);
}

.filters {
  margin-bottom: 18px;
}

.search-box,
.select-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.search-box span,
.select-box span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
}

.learn-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.person-list {
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 8px;
  max-height: 72vh;
  overflow: auto;
}

.person-item {
  width: 100%;
  text-align: left;
  padding: 14px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.person-item.active {
  background: rgba(158, 61, 44, 0.1);
  border-color: rgba(158, 61, 44, 0.24);
}

.person-item.known .person-name::after {
  content: " ✓";
  color: var(--accent);
}

.person-name {
  font-weight: 800;
}

.person-era {
  color: var(--muted);
  font-size: 12px;
}

.study-card,
.quiz-card,
.answer-panel {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
}

.study-empty {
  padding: 42px;
  color: var(--muted);
}

.study-media,
.quiz-media {
  position: relative;
  height: clamp(320px, 36vw, 420px);
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.35), transparent 45%),
    linear-gradient(180deg, #d9c2a2, #b68b62);
}

.study-media img,
.quiz-media img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  object-position: center center;
  display: block;
}

.study-overlay,
.quiz-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 18px 22px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
  color: #fff8f0;
}

.study-body,
.answer-panel {
  padding: 22px;
}

.study-body h3 {
  margin: 0 0 10px;
  font-family: "Forum", serif;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 0.98;
}

.study-body p,
.answer-panel p {
  margin: 0;
  color: var(--ink);
  line-height: 1.7;
}

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

.meta-pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  font-size: 13px;
  font-weight: 700;
}

.quiz-setup {
  align-items: flex-end;
}

.quiz-stage.hidden,
.answer-panel.hidden,
.ghost-btn.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.quiz-stage {
  display: grid;
  gap: 18px;
}

.quiz-progress {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.quiz-progress h3 {
  font-size: clamp(28px, 3vw, 42px);
}

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

.option-btn {
  text-align: left;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  padding: 18px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.option-btn.correct {
  background: rgba(64, 131, 84, 0.18);
  border-color: rgba(64, 131, 84, 0.45);
}

.option-btn.wrong {
  background: rgba(170, 53, 53, 0.16);
  border-color: rgba(170, 53, 53, 0.45);
}

.answer-panel strong {
  color: var(--accent-dark);
}

.empty-state {
  color: var(--muted);
  padding: 18px;
}

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

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

  .study-media,
  .quiz-media {
    height: 260px;
  }
}
