:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-muted: #f1f3ee;
  --ink: #1f2723;
  --muted: #68716c;
  --line: #d9ddd6;
  --accent: #2d6250;
  --accent-dark: #20483b;
  --accent-soft: #e2eee9;
  --danger: #9a3f3f;
  --ok: #2f6b4f;
  --shadow: 0 18px 50px rgba(26, 33, 29, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 247, 244, 0.96)),
    url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M18 36h46M18 52h78M18 68h54M102 118h42M84 134h60M112 150h32' stroke='%23d8ded6' stroke-width='3' stroke-linecap='round' opacity='.62'/%3E%3Cpath d='M130 32c9 0 16 7 16 16v24c0 9-7 16-16 16h-22l-18 14V88H50c-9 0-16-7-16-16V48c0-9 7-16 16-16h80Z' fill='none' stroke='%23c8d4ca' stroke-width='3' opacity='.42'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 3px 12px rgba(26, 33, 29, 0.06);
}

.icon-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.study-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.controls-panel {
  padding: 18px;
}

.control-group {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.83rem;
}

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

.segment.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.toggle-row input {
  width: 19px;
  height: 19px;
  accent-color: var(--accent);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.ghost-button {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.workspace {
  min-height: 650px;
  padding: 18px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stats-row > div {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
}

.stats-row span {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
}

.stats-row .fraction-stat .fraction span {
  display: inline;
}

.stats-row .fraction-stat .fraction {
  display: block;
  white-space: nowrap;
}

.stats-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.flashcard {
  display: grid;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(22px, 4vw, 44px);
  align-content: center;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.card-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.language-label,
.answer-label {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.answer-label {
  margin-top: 30px;
  color: var(--muted);
}

.flashcard h2 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.answer-text {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.15rem, 2.5vw, 1.75rem);
  line-height: 1.28;
}

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

.choice {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  line-height: 1.25;
}

.choice:hover {
  border-color: var(--accent);
}

.choice.correct {
  border-color: var(--ok);
  background: #e5f3eb;
}

.choice.wrong {
  border-color: var(--danger);
  background: #f8e8e8;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.card-actions .primary-button,
.card-actions .secondary-button {
  width: auto;
  min-width: 132px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding: 18px 0;
  }

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

  .workspace {
    min-height: auto;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .stats-row > div {
    min-height: 60px;
    padding: 10px;
  }

  .flashcard {
    min-height: 300px;
  }

  .card-actions {
    display: grid;
  }

  .card-actions .primary-button,
  .card-actions .secondary-button {
    width: 100%;
  }
}
