:root {
  color-scheme: light;
  --ink: #16212f;
  --muted: #5b6676;
  --line: #d8dee8;
  --panel: #ffffff;
  --surface: #f4f7fb;
  --accent: #ffcc00;
  --accent-strong: #2f6fed;
  --success: #007a5a;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(22, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 204, 0, 0.2), rgba(47, 111, 237, 0.08) 34%, transparent 34%),
    var(--surface);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.05;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  max-width: 780px;
}

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

.stats span {
  min-width: 108px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

main {
  width: min(1220px, calc(100% - 32px));
  margin: 22px auto 60px;
}

.controls,
.tabs,
.modebar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.controls {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

input,
select,
button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input,
select {
  padding: 0 12px;
}

input {
  flex: 1 1 320px;
  min-width: 180px;
}

select {
  flex: 0 1 190px;
}

button {
  padding: 0 14px;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  border-color: var(--accent-strong);
}

.tabs {
  margin: 18px 0;
}

.tab.active,
#revealBtn {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.modebar {
  justify-content: center;
  margin-bottom: 14px;
}

#cardPosition {
  min-width: 130px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.flashcard {
  min-height: 310px;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 204, 0, 0.16), transparent 38%),
    var(--panel);
  box-shadow: var(--shadow);
}

.flashcard h2 {
  font-size: clamp(24px, 3.2vw, 44px);
  line-height: 1.12;
  max-width: 980px;
}

.card-meta,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef3fb;
  color: #31435c;
  font-size: 13px;
  font-weight: 700;
}

.answer {
  padding: 18px;
  border-left: 5px solid var(--accent);
  background: #fff9dc;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-line;
}

.hidden {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.mini-card,
.problem,
.source-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mini-card {
  padding: 16px;
  cursor: pointer;
}

.mini-card h3 {
  font-size: 16px;
  line-height: 1.35;
  margin: 10px 0;
}

.mini-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

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

.problem {
  padding: 18px;
}

.problem h2 {
  font-size: 21px;
  margin: 10px 0;
}

.problem p,
.problem li {
  line-height: 1.52;
  color: var(--muted);
}

.problem pre {
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #101827;
  color: #edf4ff;
}

.solution {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #f7fafc;
  border: 1px solid var(--line);
}

.source-panel {
  padding: 24px;
}

.source-panel p,
.source-panel li {
  line-height: 1.6;
}

.source-panel ul {
  margin: 16px 0 0;
  padding-left: 22px;
}

a {
  color: var(--accent-strong);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    position: static;
  }

  .topbar,
  .stats {
    flex-direction: column;
  }

  .stats,
  .stats span,
  button,
  select {
    width: 100%;
  }

  .flashcard {
    min-height: 360px;
  }
}
