:root {
  --bg: #f4f7f5;
  --card: #fff;
  --ink: #202b29;
  --muted: #6d7b78;
  --line: #dce6e2;
  --accent: #506f66;
  --accent2: #78958c;
  --good: #26784c;
  --bad: #a23e3e;
  --gold: #edb43f;
  --learning: #d58c2f;
  --new: #bac6c2;
  --shadow: 0 15px 35px rgba(38, 63, 56, .11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(#eef4f2, #fafcfb 55%, #fff);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

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

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(80, 111, 102, .24);
  outline-offset: 2px;
}

.wrap {
  max-width: 1040px;
  margin: auto;
  padding: 22px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
}

h2,
h3 {
  margin: 0;
}

.sub {
  color: var(--muted);
}

.card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1.25fr .7fr auto;
  gap: 12px;
  align-items: end;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.toggle {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.toggle button {
  flex: 1;
  padding: 11px 9px;
  border: 0;
  background: #fff;
}

.toggle button.active {
  background: var(--accent);
  color: #fff;
}

.primary,
.secondary,
.good,
.bad {
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
}

.primary {
  background: var(--accent);
  color: #fff;
}

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

.good {
  border: 1px solid #b8dec6;
  background: #eaf7ef;
  color: var(--good);
}

.bad {
  border: 1px solid #e5bcbc;
  background: #fff0f0;
  color: var(--bad);
}

.progress-overview {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid #dbe7e2;
  border-radius: 20px;
  background: linear-gradient(135deg, #f8fbfa, #fffdf7);
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.progress-heading h2 {
  margin: 3px 0;
  font-size: clamp(22px, 3.5vw, 30px);
}

.score-badge {
  min-width: 126px;
  padding: 12px 18px;
  border: 1px solid #ead8ab;
  border-radius: 18px;
  background: #fffaf0;
  text-align: center;
}

.score-badge strong {
  display: block;
  color: #835d0d;
  font-size: 31px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-badge span {
  color: #8c7546;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.overall-stars {
  display: flex;
  gap: 4px;
  margin: 13px 0 15px;
  font-size: 29px;
  line-height: 1;
}

.star {
  color: #d8dfdc;
  text-shadow: 0 1px 0 #fff;
}

.star.on {
  color: var(--gold);
  text-shadow: 0 1px 0 #a67716;
}

.mastery-bar {
  display: flex;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eeeb;
}

.mastery-bar span {
  display: block;
  height: 100%;
  transition: width .25s ease;
}

.mastery-known {
  background: #53a875;
}

.mastery-learning {
  background: #e7ad4c;
}

.mastery-new {
  background: var(--new);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.progress-summary {
  grid-template-columns: repeat(4, 1fr);
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .75);
  text-align: center;
}

.stat-known {
  border-color: #c8e4d3;
  background: #f3fbf6;
}

.stat-learning {
  border-color: #efdbb7;
  background: #fffaf1;
}

.stat-new {
  background: #f7f9f8;
}

.stat b {
  display: block;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}

.progress-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.progress-hint {
  color: var(--muted);
  font-size: 13px;
}

.progress-details {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.progress-tools {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 12px;
}

.progress-tools h3 {
  margin-bottom: 3px;
}

.progress-filter {
  width: min(240px, 100%);
}

.progress-list {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.progress-item {
  display: grid;
  grid-template-columns: minmax(210px, 1.5fr) 165px 145px auto;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 11px 14px;
  border-bottom: 1px solid #e8eeeb;
}

.progress-item:last-child {
  border-bottom: 0;
}

.word-pair {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.word-pair b {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.word-pair span {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.word-mastery {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mini-stars {
  display: flex;
  gap: 1px;
  font-size: 17px;
  line-height: 1;
  white-space: nowrap;
}

.word-percent,
.attempt-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.word-percent {
  min-width: 38px;
  font-weight: 750;
}

.status {
  justify-self: end;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-known {
  background: #e5f5eb;
  color: #246a43;
}

.status-learning {
  background: #fff3dd;
  color: #8c5b10;
}

.status-review {
  background: #fff0f0;
  color: #9a3838;
}

.status-new {
  background: #eef2f0;
  color: #64716d;
}

.study {
  display: none;
  margin-top: 18px;
}

.studyHead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.bar {
  flex: 1;
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7efec;
}

.bar > div {
  width: 0;
  height: 100%;
  background: var(--accent);
}

.flash {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.front {
  margin: 22px 0;
  font-size: clamp(40px, 8vw, 70px);
  font-weight: 850;
  line-height: 1.05;
}

.finish-title {
  margin-bottom: 14px;
  font-size: 50px;
}

.finish-score {
  margin-bottom: 20px;
  padding: 15px 26px;
  border: 1px solid #ead8ab;
  border-radius: 18px;
  background: #fffaf0;
}

.finish-score strong,
.finish-score span {
  display: block;
}

.finish-score strong {
  color: #835d0d;
  font-size: 36px;
}

.finish-score span {
  color: #8c7546;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.finish-score .overall-stars {
  justify-content: center;
  margin: 8px 0 0;
  font-size: 22px;
}

.instruction {
  max-width: 650px;
  color: var(--muted);
  font-size: 17px;
}

.back {
  display: none;
  width: min(100%, 700px);
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px dashed var(--line);
}

.back.show {
  display: block;
}

.answer {
  font-size: clamp(26px, 5vw, 42px);
  font-weight: 800;
}

.note {
  margin-top: 8px;
  color: var(--muted);
}

.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.speak {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
}

.foot {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.adminlink {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .progress-item {
    grid-template-columns: minmax(190px, 1fr) 160px auto;
  }

  .attempt-count {
    display: none;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 14px;
  }

  .top {
    flex-direction: column;
  }

  .card {
    padding: 17px;
    border-radius: 20px;
  }

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

  .progress-overview {
    padding: 16px;
  }

  .progress-heading {
    align-items: flex-start;
  }

  .score-badge {
    min-width: 104px;
    padding: 11px 12px;
  }

  .score-badge strong {
    font-size: 27px;
  }

  .progress-summary {
    grid-template-columns: 1fr 1fr;
  }

  .progress-actions,
  .progress-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .progress-filter {
    width: 100%;
  }

  .progress-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .word-mastery {
    grid-column: 1;
  }

  .status {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .flash {
    min-height: 390px;
  }
}
