:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --surface: #ffffff;
  --canvas: #ffffff;
  --green: #c01914;
  --green-dark: #98120e;
  --green-soft: #fbe9e7;
  --coral: #d83932;
  --coral-soft: #fdebea;
  --yellow: #f2c14e;
  --success: #18764c;
  --success-soft: #e6f5ed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.site-header {
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.logout-form {
  margin-left: auto;
}

.logout-form button {
  min-height: 40px;
  padding: 8px 4px 8px 16px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.logout-form button:hover,
.logout-form button:focus-visible {
  color: var(--green-dark);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 7px;
  background: #ffffff;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.28);
}

main {
  width: min(100%, 960px);
  margin: 0 auto;
}

.home-section,
.exercise-section,
.result-section,
.login-section {
  padding: 42px 20px 56px;
}

.login-section {
  width: min(100%, 460px);
  margin: 0 auto;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 36px;
}

.login-form label {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 750;
}

.login-form input {
  width: 100%;
  height: 54px;
  padding: 0 14px;
  border: 2px solid #b7b7b7;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 17px;
}

.login-form input:focus {
  border-color: var(--green);
  outline: 3px solid var(--green-soft);
}

.login-error {
  margin: 6px 0;
  color: #a51a15;
  font-weight: 700;
}

.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;
}

.home-copy {
  max-width: 620px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.lead {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.practice-list {
  margin-top: 40px;
  border-top: 1px solid var(--line);
}

.practice-row {
  display: grid;
  grid-template-columns: 48px 1fr 24px;
  gap: 14px;
  align-items: center;
  min-height: 92px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.practice-row:hover,
.practice-row:focus-visible {
  background: #fafafa;
}

.practice-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-weight: 850;
}

.practice-icon::before {
  width: 24px;
  height: 24px;
  content: "";
  background: currentColor;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.practice-icon-match::before {
  -webkit-mask-image: url("/static/icons/arrow-right-left.svg");
  mask-image: url("/static/icons/arrow-right-left.svg");
}

.practice-icon-write::before {
  -webkit-mask-image: url("/static/icons/square-pen.svg");
  mask-image: url("/static/icons/square-pen.svg");
}

.practice-icon-sentence::before {
  -webkit-mask-image: url("/static/icons/square-pen.svg");
  mask-image: url("/static/icons/square-pen.svg");
}

.practice-icon-forms::before {
  -webkit-mask-image: url("/static/icons/arrow-right-left.svg");
  mask-image: url("/static/icons/arrow-right-left.svg");
  transform: rotate(90deg);
}

.practice-icon-gap::before {
  -webkit-mask-image: url("/static/icons/message-circle-question-mark.svg");
  mask-image: url("/static/icons/message-circle-question-mark.svg");
}

.practice-icon-progress::before {
  -webkit-mask-image: url("/static/icons/chart-no-axes-column-increasing.svg");
  mask-image: url("/static/icons/chart-no-axes-column-increasing.svg");
}

.practice-icon-coral {
  color: #a51a15;
  background: var(--coral-soft);
}

.practice-icon-yellow {
  color: #404040;
  background: #eeeeee;
}

.practice-copy {
  display: grid;
  gap: 4px;
}

.practice-copy strong {
  font-size: 17px;
}

.practice-copy small {
  color: var(--muted);
  font-size: 14px;
}

.arrow {
  color: var(--coral);
  font-size: 30px;
}

.home-motto {
  padding: 28px 4px 0;
  color: var(--muted);
  font-size: 15px;
  font-style: italic;
  text-align: center;
}

.exercise-heading {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.exercise-heading h1 {
  font-size: 27px;
}

.back-link {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  font-size: 30px;
  line-height: 1;
}

.progress-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin-top: 28px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--line);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

.progress-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.feedback {
  min-height: 24px;
  margin: 18px 0;
  color: var(--muted);
  font-weight: 650;
}

.matching-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.word-column {
  display: grid;
  align-content: start;
  gap: 10px;
}

.word-column h2 {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.word-option {
  width: 100%;
  min-height: 58px;
  padding: 10px 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
  overflow-wrap: anywhere;
}

.word-option:hover:not(:disabled) {
  border-color: #9a9a9a;
}

.word-option:focus-visible,
.form-option:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.back-link:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.word-option.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
  transform: translateY(-1px);
}

.word-option.is-correct {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
  cursor: default;
}

.word-option.is-wrong {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.forms-section {
  max-width: 760px;
  margin: 0 auto;
}

.forms-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.forms-feedback {
  margin-block: 12px;
}

.forms-board {
  margin-top: 20px;
}

.verb-form-question {
  max-width: 520px;
  margin: 0 auto;
}

.verb-form-base {
  margin-bottom: 28px;
  text-align: center;
}

.verb-form-base p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.verb-form-base h2 {
  margin: 0;
  font-size: 36px;
  line-height: 1.1;
  text-transform: uppercase;
}

.verb-form-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-choice-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.form-choice-group legend {
  width: 100%;
  margin-bottom: 10px;
  padding: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.form-choice-options {
  display: grid;
  gap: 8px;
}

.form-option {
  width: 100%;
  min-height: 52px;
  padding: 10px 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
  cursor: pointer;
}

.form-option.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
}

.form-option.is-correct {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.form-option.is-wrong {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.forms-check {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 18px auto 0;
}

.forms-solutions,
.forms-complete,
.forms-empty {
  margin-top: 30px;
}

.solution-list {
  margin: 16px 0 24px;
  border-block: 1px solid var(--line);
}

.solution-list div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.solution-list div:last-child {
  border-bottom: 0;
}

.forms-complete h2 {
  margin: 0 0 24px;
  font-size: 24px;
}

.forms-empty p {
  margin: 6px 0;
  color: var(--muted);
}

.forms-empty .primary-button {
  margin-top: 24px;
}

.evidence-label {
  color: var(--green-dark);
  font-weight: 750;
}

.evidence-list {
  border-top: 1px solid var(--line);
}

.evidence-row {
  display: grid;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.evidence-word {
  display: grid;
  gap: 3px;
}

.evidence-word strong {
  font-size: 18px;
}

.evidence-word small {
  color: var(--muted);
}

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

.evidence-metrics div {
  min-width: 0;
}

.evidence-metrics dt {
  color: var(--muted);
  font-size: 11px;
}

.evidence-metrics dd {
  margin: 3px 0 0;
  font-weight: 750;
}

.result-section {
  text-align: center;
}

.result-badge {
  display: grid;
  width: 110px;
  height: 110px;
  margin: 4px auto 24px;
  place-items: center;
  border: 10px solid var(--green-soft);
  border-radius: 50%;
  color: var(--green-dark);
  background: var(--surface);
  font-size: 26px;
  font-weight: 850;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 34px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-stats div {
  padding: 20px 6px;
}

.result-stats div + div {
  border-left: 1px solid var(--line);
}

.result-stats dt {
  color: var(--muted);
  font-size: 13px;
}

.result-stats dd {
  margin: 5px 0 0;
  font-size: 25px;
  font-weight: 850;
}

.result-actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button {
  display: grid;
  min-height: 52px;
  place-items: center;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.button-control {
  width: 100%;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.button-control:disabled {
  opacity: 0.62;
  cursor: wait;
}

.recall-section,
.narrow-section {
  max-width: 680px;
  margin: 0 auto;
}

.recall-workspace {
  margin-top: 38px;
}

.sentence-workspace {
  margin-top: 34px;
}

.sentence-target {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--muted);
  font-size: 14px;
}

.sentence-target strong {
  color: var(--ink);
  font-size: 20px;
  text-transform: uppercase;
}

.sentence-prompt {
  min-height: 72px;
  margin: 22px 0 26px;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.sentence-form {
  display: grid;
  gap: 14px;
}

.sentence-form textarea {
  width: 100%;
  min-height: 126px;
  padding: 14px 16px;
  resize: vertical;
  border: 2px solid #b7b7b7;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 18px;
  line-height: 1.5;
}

.sentence-form textarea:focus {
  border-color: var(--green);
  outline: 3px solid var(--green-soft);
}

.sentence-feedback {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 4px solid var(--coral);
}

.sentence-feedback.is-correct {
  border-top-color: var(--success);
}

.sentence-feedback h2 {
  margin: 0 0 20px;
  font-size: 24px;
}

.sentence-review {
  display: grid;
  gap: 18px;
  margin: 0 0 24px;
}

.sentence-review div {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.sentence-review dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sentence-review dd {
  margin: 6px 0 0;
  font-size: 17px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sentence-feedback .primary-button {
  width: 100%;
}

.sentence-empty {
  margin-top: 36px;
}

.recall-prompt {
  min-height: 54px;
  margin: 0 0 24px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.recall-form {
  display: grid;
  gap: 14px;
}

.answer-input,
.gap-form textarea {
  width: 100%;
  border: 2px solid #b7b7b7;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}

.answer-input {
  height: 58px;
  padding: 0 16px;
  font-size: 21px;
}

.answer-input:focus,
.gap-form textarea:focus {
  border-color: var(--green);
  outline: 3px solid var(--green-soft);
}

.answer-feedback {
  min-height: 76px;
  margin: 18px 0 14px;
  padding: 15px 16px;
  border-left: 4px solid var(--success);
  background: var(--success-soft);
}

.answer-feedback.is-incorrect,
.answer-feedback.is-error {
  border-left-color: var(--coral);
  background: var(--coral-soft);
}

.answer-feedback strong {
  font-size: 18px;
}

.answer-feedback p {
  margin: 5px 0 0;
}

.session-complete {
  margin-top: 42px;
}

.session-complete h2 {
  margin: 0;
  font-size: 28px;
}

.session-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 30px 0;
  border-block: 1px solid var(--line);
}

.session-summary div {
  padding: 20px 8px;
  text-align: center;
}

.session-summary div + div {
  border-left: 1px solid var(--line);
}

.session-summary dt,
.metrics-grid dt {
  color: var(--muted);
  font-size: 13px;
}

.session-summary dd,
.metrics-grid dd {
  margin: 5px 0 0;
  font-size: 25px;
  font-weight: 850;
}

.gap-form {
  display: grid;
  gap: 14px;
  margin-top: 36px;
}

.gap-form label {
  font-size: 18px;
  font-weight: 750;
}

.gap-form textarea {
  min-height: 150px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.5;
}

.save-status {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.save-status.is-success {
  color: var(--success);
}

.save-status.is-error {
  color: #a51a15;
}

.metrics-section,
.tense-progress,
.word-progress {
  margin-top: 38px;
}

.metrics-section h2,
.tense-progress h2,
.word-progress h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.tense-progress-list {
  border-top: 1px solid var(--line);
}

.tense-progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.tense-progress-row > div strong,
.tense-progress-row > div small {
  display: block;
}

.tense-progress-row > div small {
  margin-top: 4px;
  color: var(--success);
}

.tense-progress-row.is-locked > div small {
  color: var(--muted);
}

.tense-progress-row dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, auto));
  gap: 20px;
  margin: 0;
}

.tense-progress-row dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.tense-progress-row dd {
  margin: 4px 0 0;
  font-weight: 800;
  text-align: right;
}

@media (max-width: 540px) {
  .tense-progress-row {
    grid-template-columns: 1fr;
  }

  .tense-progress-row dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tense-progress-row dd {
    text-align: left;
  }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
}

.metrics-grid div {
  min-width: 0;
  padding: 16px 8px 16px 0;
  border-bottom: 1px solid var(--line);
}

.metrics-grid dd {
  overflow-wrap: anywhere;
}

.word-table-wrap {
  overflow-x: auto;
  border-block: 1px solid var(--line);
}

.word-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
  text-align: right;
}

.word-table th,
.word-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
}

.word-table thead th {
  color: var(--muted);
  font-size: 12px;
}

.word-table th:first-child {
  padding-left: 0;
  text-align: left;
}

.word-table th small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
}

.empty-state {
  padding: 24px 0;
  border-block: 1px solid var(--line);
  color: var(--muted);
}

.primary-button {
  color: white;
  background: var(--green);
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
}

@media (max-width: 679px) {
  .word-table-wrap {
    overflow: visible;
  }

  .word-table {
    min-width: 0;
  }

  .word-table thead {
    display: none;
  }

  .word-table tbody,
  .word-table tr {
    display: grid;
  }

  .word-table tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
  }

  .word-table th,
  .word-table td {
    padding: 7px 0;
    border: 0;
    text-align: left;
  }

  .word-table th:first-child {
    grid-column: 1 / -1;
    padding-top: 0;
    font-size: 18px;
  }

  .word-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
  }
}

@media (min-width: 680px) {
  .site-header {
    padding-inline: 32px;
  }

  .home-section,
  .exercise-section,
  .result-section,
  .login-section {
    padding: 64px 32px 80px;
  }

  h1 {
    font-size: 44px;
  }

  .exercise-heading h1 {
    font-size: 36px;
  }

  .matching-board {
    gap: 22px;
  }

  .word-option {
    min-height: 64px;
    padding: 12px 18px;
    font-size: 17px;
  }

  .form-option {
    min-height: 56px;
    padding: 14px 18px;
    font-size: 16px;
  }

  .verb-form-columns {
    gap: 18px;
  }

  .form-choice-group legend {
    font-size: 16px;
  }

  .evidence-row {
    grid-template-columns: minmax(130px, 1fr) 120px minmax(0, 3fr);
    align-items: center;
  }

  .evidence-metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .result-section {
    max-width: 620px;
    margin: 0 auto;
  }

  .result-actions {
    grid-template-columns: 1fr 1fr;
  }

  .recall-prompt {
    font-size: 38px;
  }

  .sentence-prompt {
    font-size: 34px;
  }

  .metrics-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.unit-selector {
  display: grid;
  gap: 8px;
  margin: 24px 0;
  max-width: 520px;
}

.unit-selector label {
  font-weight: 700;
}

.unit-selector select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  background: #fff;
  color: #191919;
  font: inherit;
}

.unit-selector small {
  color: #666;
}

.unit-theme {
  --green: var(--unit-accent, #207daf);
  --green-dark: var(--unit-accent, #17628c);
  --green-soft: var(--unit-soft, #e7f4fd);
  --coral: var(--unit-accent, #207daf);
  --coral-soft: var(--unit-soft, #e7f4fd);
}

.unit-theme .practice-icon-coral {
  color: var(--green-dark);
}

.unit-theme .unit-selector select {
  border-color: var(--green);
  background: var(--green-soft);
}

.unit-theme .unit-selector select:focus-visible {
  outline: 3px solid var(--green-soft);
  border-color: var(--green);
}

.unit-theme .practice-row:hover,
.unit-theme .practice-row:focus-visible {
  background: var(--green-soft);
}

.sentence-status {
  color: var(--green-dark);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  font-weight: 600;
}
.sentence-status[hidden] { display: none; }
[aria-busy="true"] .sentence-status::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sentence-spin .8s linear infinite;
}
.sentence-feedback { scroll-margin-top: 24px; }
[aria-busy="true"] [data-sentence-next] { pointer-events: none; opacity: .6; }
@keyframes sentence-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  [aria-busy="true"] .sentence-status::before { animation: none; }
}
