:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-strong: #eef4ef;
  --text: #18211e;
  --muted: #65736e;
  --border: #d8e2dc;
  --primary: #1f6f5b;
  --primary-dark: #154d40;
  --accent: #b6462f;
  --warning: #9b681f;
  --success-bg: #e6f5ed;
  --success-text: #15593d;
  --error-bg: #fde9e4;
  --error-text: #8f2d1c;
  --shadow: 0 18px 45px rgb(28 48 41 / 10%);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

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

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tab-button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab-button.is-active {
  background: var(--primary);
  color: #ffffff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.task-panel,
.side-panel,
.dictionary-panel,
.editor-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.task-panel,
.dictionary-panel {
  min-height: 560px;
}

.side-panel,
.editor-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.task-area {
  padding: 24px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.task-meta span {
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--surface-strong);
}

.prompt {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.instruction {
  max-width: 620px;
  margin: 0 0 22px;
  color: var(--muted);
}

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

.choice-button {
  min-height: 68px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

.choice-button:hover,
.choice-button.is-selected {
  border-color: var(--primary);
  background: #edf7f2;
}

.answer-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 22px;
}

.answer-input {
  min-height: 52px;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(31 111 91 / 14%);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hint {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

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

.stats-grid > div {
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stats-grid strong {
  font-size: 22px;
  line-height: 1;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

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

.secondary-button:hover {
  border-color: var(--primary);
}

.audio-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 18px 0 22px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.audio-box audio {
  width: min(100%, 420px);
  min-width: 220px;
}

.audio-loading,
.audio-error,
.audio-meta {
  color: var(--muted);
  font-size: 14px;
}

.audio-error {
  color: var(--error-text);
}

.feedback {
  display: none;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 14px;
  border-radius: 8px;
}

.feedback.is-correct,
.feedback.is-wrong {
  display: flex;
  flex-wrap: wrap;
}

.feedback.is-correct {
  background: var(--success-bg);
  color: var(--success-text);
}

.feedback.is-wrong {
  background: var(--error-bg);
  color: var(--error-text);
}

.feedback-main {
  display: grid;
  gap: 2px;
  min-width: min(100%, 260px);
}

.quality-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quality-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-weight: 800;
}

.quality-button.is-selected {
  background: rgb(255 255 255 / 72%);
  box-shadow: inset 0 0 0 2px currentColor;
}

.empty-state {
  display: grid;
  gap: 6px;
  min-height: 160px;
  place-content: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state.error {
  color: var(--error-text);
}

.search-input {
  max-width: 260px;
}

.cards-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.card-row.is-disabled {
  opacity: 0.62;
}

.card-main {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.card-spanish {
  font-size: 17px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.card-translation {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.card-stats {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.card-form {
  display: grid;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  color: var(--text);
  font-weight: 700;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 880px) {
  .topbar,
  .section-heading,
  .answer-form,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .task-panel,
  .dictionary-panel {
    min-height: auto;
  }

  .search-input {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 12px;
  }

  .tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1 1 130px;
  }

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

  .card-stats {
    text-align: left;
  }

  .task-area {
    padding: 16px;
  }

  .prompt {
    font-size: 32px;
  }
}
