:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --text: #18201f;
  --muted: #64716e;
  --line: #dbe3e0;
  --blue: #285f83;
  --green: #25735a;
  --green-soft: #e5f2ec;
  --shadow: 0 18px 50px rgba(24, 32, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
select {
  font: inherit;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

.topbar h1,
.review-header h2,
.summary h2 {
  margin: 0;
  line-height: 1.1;
}

.topbar h1 {
  font-size: clamp(1.6rem, 2.5vw, 2.35rem);
}

.topbar p,
.review-header p,
.chapter-deck {
  margin: 7px 0 0;
  color: var(--muted);
}

.topbar button,
.tab,
.ratings button,
#show-answer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
}

.topbar button {
  padding: 0 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.summary-panel,
.review-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-panel {
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 10px;
  color: var(--muted);
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
}

.summary {
  padding: 24px;
}

.summary h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.key-points {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.point {
  border-left: 4px solid var(--green);
  padding-left: 14px;
}

.point h3 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.point p {
  margin: 0;
  color: #34413e;
  line-height: 1.55;
}

.review-panel {
  padding: 18px;
  position: sticky;
  top: 16px;
}

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

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 8px;
}

.flashcard {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #cddbd6;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbfa);
}

.card-chapter {
  margin: 0;
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.flashcard h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.35;
  white-space: pre-line;
}

.answer {
  margin: 0;
  color: #34413e;
  line-height: 1.55;
  white-space: pre-line;
}

.hidden {
  visibility: hidden;
}

#show-answer {
  width: 100%;
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.ratings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.ratings button {
  padding: 0 6px;
}

.ratings button:nth-child(3),
.ratings button:nth-child(4) {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.queue {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.queue li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.source {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.source a {
  color: var(--blue);
}

@media (max-width: 860px) {
  .app {
    width: min(100% - 20px, 680px);
    padding-top: 14px;
  }

  .topbar,
  .review-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .review-panel {
    position: static;
  }
}
