:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --ink: #1c2520;
  --muted: #647067;
  --panel: #fffdfa;
  --line: #d9ded4;
  --accent: #146c63;
  --accent-strong: #0f4d47;
  --gold: #f2b544;
  --pink: #d9577d;
  --shadow: 0 18px 44px rgba(34, 46, 39, 0.14);
}

* {
  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;
  color: var(--ink);
  background:
    linear-gradient(rgba(20, 108, 99, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 108, 99, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 12% 18%, rgba(242, 181, 68, 0.28), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(217, 87, 125, 0.18), transparent 30%),
    var(--bg);
  background-size: 38px 38px, 38px 38px, auto, auto, auto;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
}

.site-label {
  margin: 0 0 4px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--accent);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 7vw, 4.8rem);
  line-height: 0.95;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.icon-button span {
  font-size: 1.45rem;
  line-height: 1;
}

.practice-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 18px;
  align-items: start;
  padding-bottom: 32px;
}

.practice-panel,
.completed-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: var(--shadow);
}

.practice-panel {
  padding: clamp(18px, 4vw, 30px);
}

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

.stats div {
  min-height: 82px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 14px;
  background: #f3faf7;
}

.stats span {
  display: block;
  font-size: 2rem;
  line-height: 1;
  font-weight: 900;
  color: var(--accent-strong);
}

.stats small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
}

.flashcard {
  min-height: 390px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(20, 108, 99, 0.08) 48% 52%, transparent 52%),
    #fff;
  padding: clamp(20px, 5vw, 38px);
}

.card-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  text-transform: uppercase;
}

.problem {
  min-height: 1.1em;
  font-size: clamp(4rem, 16vw, 9rem);
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: 0;
}

.answer-form {
  width: min(100%, 430px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
}

.answer-form input {
  min-width: 0;
  height: 64px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0 18px;
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  background: #fdf7e8;
}

.answer-form button,
.actions button {
  min-height: 46px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.answer-form button {
  height: 64px;
  background: var(--ink);
}

.feedback {
  min-height: 1.45em;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.feedback.good {
  color: var(--accent-strong);
}

.feedback.slow,
.feedback.bad {
  color: #9d2d4b;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.actions button {
  background: #e5eee9;
  color: var(--ink);
}

.completed-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.panel-heading span {
  font-weight: 900;
  color: var(--accent-strong);
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eee9;
  margin: 14px 0 16px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.completed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  max-height: 66vh;
  overflow: auto;
  padding-right: 2px;
}

.completed-chip {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f3faf7;
  border: 1px solid #c6d7cf;
  color: var(--accent-strong);
  font-weight: 900;
  font-size: 0.88rem;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 78px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
  padding: 12px;
}

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
  }

  .practice-shell {
    grid-template-columns: 1fr;
  }

  .completed-grid {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .app-header,
  .practice-shell {
    width: min(100% - 20px, 1120px);
  }

  .answer-form {
    grid-template-columns: 1fr;
  }

  .answer-form button {
    width: 100%;
  }

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

  .problem {
    font-size: clamp(3.3rem, 20vw, 5rem);
  }
}
