:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5e6a7d;
  --line: #d8dee8;
  --paper: #f7f3ea;
  --panel: #ffffff;
  --accent: #176b87;
  --accent-2: #8b5e34;
  --good: #1f7a4d;
  --warn: #b66a00;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(35, 46, 73, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f7f3ea 0%, #edf3f6 100%);
  color: var(--ink);
}

button, input, select { font: inherit; }
button { cursor: pointer; border: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px clamp(16px, 4vw, 56px) 18px;
}

.eyebrow, .small-label {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 4vw, 3.2rem); line-height: 1.05; }
h2 { font-size: 1rem; }

.top-actions { display: flex; gap: 8px; }
.ghost {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(255,255,255,.75);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 1.1rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 56px) 26px;
}

.panel, .flashcard {
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(216, 222, 232, .95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar { padding: 18px; align-self: start; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}
.stats-grid strong { display: block; font-size: 1.45rem; }
.stats-grid span { color: var(--muted); font-size: .86rem; }

.field { display: grid; gap: 6px; margin: 14px 0; }
.field span { font-weight: 800; font-size: .86rem; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 18px 0 22px;
  padding: 4px;
  border-radius: 8px;
  background: #e8eef3;
}
.mode-tabs button {
  min-height: 38px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}
.mode-tabs button.active { background: white; color: var(--accent); box-shadow: 0 5px 14px rgba(20,33,61,.08); }

.topic-list { display: grid; gap: 8px; max-height: 280px; overflow: auto; padding-right: 4px; }
.topic-list button {
  text-align: left;
  border-radius: 8px;
  padding: 10px 11px;
  background: #f5f8fa;
  color: var(--ink);
  border: 1px solid transparent;
  line-height: 1.25;
}
.topic-list button:hover { border-color: var(--accent); }

.study-area { display: grid; gap: 16px; }
.progress-panel {
  display: grid;
  grid-template-columns: minmax(180px, 320px) 1fr;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
}
.progress-track { height: 12px; border-radius: 999px; background: #e1e7ee; overflow: hidden; }
.progress-track span { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); }

.flashcard { min-height: 410px; padding: clamp(18px, 4vw, 34px); display: grid; gap: 24px; align-content: space-between; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.card-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #eaf2f5;
  color: var(--accent);
  padding: 6px 11px;
  font-weight: 800;
  font-size: .83rem;
}
.subtopic {
  margin: 0 0 18px;
  color: var(--accent);
  font-weight: 900;
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  line-height: 1.25;
}
.term-label { margin-top: 2px; }
.card-face h2 { font-size: clamp(2rem, 5vw, 4.4rem); line-height: 1.02; margin-bottom: 18px; }
.primary {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}
.answer-box {
  border-left: 5px solid var(--accent-2);
  background: #fff8ea;
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 1.08rem;
  line-height: 1.55;
}
.exam-prompt { max-width: 680px; color: var(--muted); line-height: 1.5; }
.hidden { display: none !important; }

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}
.actions button {
  min-height: 52px;
  border-radius: 8px;
  color: white;
  font-weight: 900;
}
.danger { background: var(--danger); }
.warn { background: var(--warn); }
.ok { background: var(--good); }
.great { background: #195a8a; }

.queue-panel { padding: 16px 18px; }
.queue-panel ol { margin: 0; padding-left: 22px; color: var(--muted); }
.queue-panel li { margin: 7px 0; }
footer { padding: 0 clamp(16px, 4vw, 56px) 24px; color: var(--muted); }

@media (max-width: 860px) {
  .topbar { align-items: flex-start; }
  .layout { grid-template-columns: 1fr; }
  .progress-panel { grid-template-columns: 1fr; }
  .actions { grid-template-columns: repeat(2, 1fr); }
  .flashcard { min-height: 360px; }
}

@media (max-width: 520px) {
  .topbar { padding-top: 18px; }
  .actions { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .stats-grid div { padding: 8px; }
  .stats-grid strong { font-size: 1.05rem; }
  .stats-grid span { font-size: .7rem; }
}
