:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --paper: #ffffff;
  --ink: #17202a;
  --muted: #657083;
  --line: #dfe5ee;
  --teal: #0f8b8d;
  --teal-dark: #0a686a;
  --coral: #e85d4f;
  --gold: #f4b740;
  --green: #2f9e6d;
  --red: #cf3f3f;
  --shadow: 0 18px 48px rgba(31, 43, 62, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.10), transparent 34%),
    linear-gradient(225deg, rgba(232, 93, 79, 0.08), transparent 32%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 8px;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral), var(--green));
  z-index: 30;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 10px;
  font-size: 15px;
}

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

.icon-button,
.ghost-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.icon-button {
  width: 42px;
  height: 42px;
  font-size: 30px;
  line-height: 1;
}

.ghost-button,
.primary-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.icon-button:hover,
.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(31, 43, 62, 0.14);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 880px);
  gap: 18px;
  align-items: start;
  justify-content: center;
}

.panel,
.activity-card {
  border: 1px solid rgba(223, 229, 238, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 14px;
}

.controls-panel section + section {
  margin-top: 18px;
}

.meter-block {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
}

.meter-block strong {
  display: block;
  font-size: 19px;
}

.meter-block span {
  color: var(--muted);
  font-size: 13px;
}

.ring {
  display: grid;
  place-items: center;
  width: 64px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--pct, 0deg), #e8edf4 0deg);
  position: relative;
  font-weight: 900;
  color: var(--teal-dark);
  transition: background 420ms ease;
}

.ring::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--paper);
}

.ring span {
  position: relative;
  z-index: 1;
  color: var(--teal-dark);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip small {
  display: inline-grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #52606f;
  font-size: 11px;
}

.chip.active {
  border-color: rgba(15, 139, 141, 0.36);
  background: rgba(15, 139, 141, 0.10);
  color: var(--teal-dark);
}

.chip.active small {
  background: var(--teal);
  color: #fff;
}

.select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.activity-list {
  display: grid;
  gap: 8px;
}

.activity-link {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.activity-link:hover,
.activity-link.active {
  border-color: rgba(15, 139, 141, 0.45);
  background: rgba(15, 139, 141, 0.08);
  transform: translateX(2px);
}

.activity-link span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--muted);
  font-weight: 900;
  grid-row: 1 / span 2;
}

.activity-link.active span {
  background: var(--teal);
  color: #fff;
}

.activity-link.done::after {
  content: "✓";
  position: absolute;
  top: 11px;
  right: 10px;
  color: var(--green);
  font-weight: 900;
  animation: pop 260ms ease both;
}

.activity-link small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.practice-stage {
  min-width: 0;
}

.activity-card {
  min-height: calc(100vh - 112px);
  padding: 24px;
  animation: cardIn 260ms ease both;
  overflow: hidden;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  margin: 0 0 8px;
  font-size: 23px;
  line-height: 1.25;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef5f5;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.badge.alt {
  background: #fff3df;
  color: #935f00;
}

.focus-box,
.passage,
.feedback {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
  padding: 13px;
}

.focus-box {
  margin-bottom: 16px;
  color: var(--muted);
}

.passage {
  margin: 12px 0 18px;
  color: #263241;
  line-height: 1.78;
  white-space: pre-wrap;
}

.question-stack,
.item-stack {
  display: grid;
  gap: 14px;
}

.question {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.question:has(.correct),
.question:has(.feedback.good) {
  border-color: rgba(47, 158, 109, 0.34);
  box-shadow: 0 12px 26px rgba(47, 158, 109, 0.08);
}

.question h3 {
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.55;
}

.option-grid {
  display: grid;
  gap: 9px;
}

.option,
.tf-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px 12px;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.option:hover,
.tf-button:hover {
  transform: translateX(2px);
  border-color: rgba(15, 139, 141, 0.5);
}

.option.selected,
.tf-button.selected {
  border-color: var(--teal);
  background: rgba(15, 139, 141, 0.10);
}

.option.correct,
.tf-button.correct,
.input.correct,
.select.correct {
  border-color: rgba(47, 158, 109, 0.75);
  background: rgba(47, 158, 109, 0.09);
  animation: correctPop 320ms ease both;
}

.option.wrong,
.tf-button.wrong,
.input.wrong,
.select.wrong {
  border-color: rgba(207, 63, 63, 0.75);
  background: rgba(207, 63, 63, 0.08);
  animation: gentleShake 260ms ease both;
}

.letter {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--ink);
  font-weight: 900;
}

.match-row,
.fill-row,
.dialogue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: center;
}

.match-row + .match-row,
.fill-row + .fill-row,
.dialogue-row + .dialogue-row {
  margin-top: 10px;
}

.match-row .feedback,
.fill-row .feedback,
.dialogue-row .feedback {
  grid-column: 1 / -1;
}

.input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: #fff;
}

.bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.bank-token {
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff3df;
  color: #7f5300;
  font-weight: 900;
  font-size: 13px;
}

.speaker {
  color: var(--teal-dark);
  font-weight: 900;
}

.inline-input {
  width: min(210px, 100%);
  margin: 0 5px;
}

.tf-row {
  display: grid;
  grid-template-columns: 1fr 82px 82px;
  gap: 9px;
  align-items: center;
}

.tick-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius);
}

.tick-table th,
.tick-table td {
  border: 1px solid var(--line);
  padding: 12px;
  text-align: center;
  background: #fff;
}

.tick-table th:first-child,
.tick-table td:first-child {
  text-align: left;
  font-weight: 900;
}

.tick-cell input {
  width: 21px;
  height: 21px;
  accent-color: var(--teal);
}

.writing-area {
  width: 100%;
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.feedback {
  margin-top: 16px;
  line-height: 1.65;
  animation: feedbackIn 260ms ease both;
}

.feedback.good {
  border-color: rgba(47, 158, 109, 0.35);
  background: rgba(47, 158, 109, 0.08);
}

.feedback.warn {
  border-color: rgba(244, 183, 64, 0.48);
  background: rgba(244, 183, 64, 0.10);
}

.feedback strong {
  display: block;
  margin-bottom: 6px;
}

.celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  overflow: hidden;
}

.celebration i {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  background: hsl(calc(var(--i) * 31), 72%, 56%);
}

.celebration.play i {
  animation: confetti 850ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i) * 22ms);
}

@keyframes correctPop {
  0% {
    transform: scale(0.985);
  }
  55% {
    transform: scale(1.018);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes gentleShake {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(3px);
  }
}

@keyframes feedbackIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    transform: scale(0.4);
  }
  to {
    transform: scale(1);
  }
}

@keyframes confetti {
  0% {
    opacity: 0;
    transform: translateY(0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(78vh) rotate(240deg);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: -12px -12px 10px;
    padding: 12px;
    background: rgba(245, 247, 251, 0.9);
    backdrop-filter: blur(14px);
  }

  h1 {
    font-size: 22px;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .ghost-button {
    min-height: 38px;
    padding: 0 10px;
  }

  .top-actions .icon-button {
    width: 38px;
    height: 38px;
  }

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

  .practice-stage {
    order: 1;
  }

  .controls-panel {
    order: 2;
    position: static;
    max-height: none;
  }

  .activity-list {
    grid-template-columns: 1fr;
  }

  .activity-card {
    min-height: 0;
    padding: 16px;
  }

  .card-head {
    display: block;
  }

  .match-row,
  .fill-row,
  .dialogue-row,
  .tf-row {
    grid-template-columns: 1fr;
  }

  .tf-row {
    gap: 7px;
  }

  .footer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .chip {
    flex: 1 1 auto;
  }

  .tick-table th,
  .tick-table td {
    padding: 9px 6px;
    font-size: 13px;
  }
}
