.btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 48px;
  padding: 0 1.15rem;
  border: 0;
  border-radius: 18px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  color: white;
  background: var(--blue);
  box-shadow: 0 4px 0 0 var(--blue-deep);
  transition: transform .16s ease, box-shadow .16s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 0 var(--blue-deep); }
.btn-lg { min-height: 56px; padding: 0 1.4rem; font-size: 1.05rem; }
.btn-sm { min-height: 40px; padding: 0 .9rem; font-size: .92rem; }
.btn-secondary {
  background: var(--navy-soft);
  color: var(--navy);
  border: 2px solid rgb(36 48 74 / .1);
  box-shadow: none;
}
.btn-secondary:hover { background: #e3e8f2; border-color: rgb(36 48 74 / .18); }
.btn-secondary:active { background: #d9e0ed; box-shadow: none; }
.btn-navy { background: var(--navy); box-shadow: 0 4px 0 0 #151b2b; }
.btn-yellow { background: var(--yellow); color: var(--navy); box-shadow: 0 4px 0 0 #d7ac45; }
.btn-green { background: var(--green); box-shadow: 0 4px 0 0 #3aa36d; }
.btn-purple { background: var(--purple); box-shadow: 0 4px 0 0 #6f54c4; }
.btn-ghost { background: transparent; color: var(--navy); box-shadow: none; }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: white; cursor: pointer;
  color: var(--navy);
  display: inline-grid; place-items: center;
  padding: 0;
  box-shadow: 0 3px 0 0 rgb(36 48 74 / .12);
  transition: transform .08s ease, box-shadow .08s ease, background .12s ease;
}
.icon-btn:hover {
  background: var(--navy-soft);
  transform: translateY(-1px);
}
.icon-btn:active {
  transform: translateY(2px) scale(.94);
  box-shadow: 0 0 0 0 rgb(36 48 74 / .12);
  background: var(--navy-soft);
}
.icon-svg {
  width: 22px; height: 22px; display: block;
  transition: transform .08s ease;
}
.icon-btn:active .icon-svg { transform: scale(.88); }
.icon-btn.menu-toggle { display: none; }
@media (max-width: 760px) {
  .icon-btn.menu-toggle { display: inline-grid; }
}
.sound-toggle .icon-sound-off { display: none; }
.sound-toggle.is-muted .icon-sound-on { display: none; }
.sound-toggle.is-muted .icon-sound-off { display: block; }
.streak-button {
  appearance: none;
  min-height: 40px;
  padding: 0 .7rem;
  border: 1px solid rgb(36 48 74 / .08);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--yellow-soft);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}
.streak-button .icon-svg { width: 19px; height: 19px; color: #d99816; }
.streak-button__label { font-size: .82rem; }
.header-actions { position: relative; }
.streak-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + .65rem);
  right: 0;
  width: min(320px, calc(100vw - 2rem));
  padding: 1rem;
  border-radius: 20px;
  background: white;
  box-shadow: 0 20px 55px rgb(36 48 74 / .2);
  color: var(--navy);
}
.streak-panel[hidden] { display: none; }
.streak-panel dl { display: grid; gap: .4rem; margin: .8rem 0; }
.streak-panel dl div { display: flex; justify-content: space-between; gap: 1rem; }
.streak-panel dt { color: var(--muted); font-weight: 700; }
.streak-panel dd { margin: 0; font-weight: 900; }
.streak-today { margin: 0; padding-top: .7rem; border-top: 1px solid var(--line); color: var(--muted); font-weight: 700; }
@media (max-width: 600px) {
  .streak-button__label { display: none; }
  .streak-button { min-width: 40px; padding-inline: .55rem; }
}
.avatar {
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--yellow); color: var(--navy);
  display: grid; place-items: center; font-weight: 900; text-decoration: none;
}
.text-btn {
  appearance: none; background: none; border: 0; color: var(--muted); font-weight: 800;
  text-decoration: none; cursor: pointer;
  border-radius: 10px;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.formula-sheet {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  max-height: min(88vh, 820px);
  overflow: auto;
  overscroll-behavior: contain;
  z-index: 51;
  background: white;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -20px 50px rgb(36 48 74 / .18);
}
.formula-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  background: rgb(255 255 255 / .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.formula-content { padding: .4rem 1.25rem 1.5rem; }
.formula-section { padding-top: 1.1rem; }
.formula-section + .formula-section { margin-top: .5rem; border-top: 1px solid var(--line); }
.formula-section h3 { font-size: 1.2rem; margin-bottom: .4rem; color: var(--navy); }
.formula-row { display: grid; gap: .5rem; padding: .8rem 0; }
.formula-label { color: var(--muted); font-weight: 800; }
.formula-math {
  min-width: 0;
  overflow-x: auto;
  padding: .7rem .85rem;
  border-radius: 16px;
  background: var(--blue-soft);
  font-size: 1.04rem;
  text-align: center;
}
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgb(36 48 74 / .28);
}
@media (min-width: 620px) {
  .formula-row { grid-template-columns: minmax(150px, .65fr) minmax(0, 1.35fr); align-items: center; }
  .formula-math { text-align: left; }
}
@media (min-width: 800px) {
  .formula-sheet {
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 48px));
    max-height: min(84vh, 820px);
    border-radius: 28px;
  }
}
.choice-card {
  display: grid;
  gap: .4rem;
  text-align: left;
  background: white;
  border: 3px solid transparent;
  border-radius: 28px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.choice-card:hover, .choice-card:focus { border-color: var(--blue); }
.choice-card h3 { font-size: 1.25rem; }
.choice-card p { margin: 0; color: var(--muted); font-weight: 700; }

.soft-blue { background: var(--blue-soft); }
.soft-yellow { background: var(--yellow-soft); }
.soft-green { background: var(--green-soft); }
.soft-purple { background: var(--purple-soft); }
.soft-coral { background: var(--coral-soft); }

.chip {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 0 .95rem;
  border-radius: 999px;
  border: 0;
  background: var(--navy-soft);
  color: var(--navy);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: transform .08s ease, background .12s ease, color .12s ease;
}
.chip:hover { transform: translateY(-1px); }
.chip:active { transform: translateY(1px) scale(.96); }
.chip-num {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 1px 0 0;
  line-height: 1;
}
.chip.selected, .chip[aria-pressed="true"] { background: var(--blue); color: white; }
.chip.correct { background: var(--green); color: white; }
.chip.wrong { background: var(--coral); color: white; }

.form-control,
.answer-input {
  appearance: none;
  width: 100%;
  min-height: 56px;
  border: 2px solid rgb(36 48 74 / .12);
  border-radius: 22px;
  padding: 0 1rem;
  font-weight: 800;
  font-size: 1.15rem;
  background: white;
  color: var(--navy);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.form-control:hover,
.answer-input:hover { border-color: rgb(36 48 74 / .24); }
.form-control:focus,
.answer-input:focus { border-color: var(--blue); }
.form-control:focus-visible,
.answer-input:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgb(74 124 247 / .16);
}
.form-control:disabled,
.answer-input:disabled {
  opacity: 1;
  background: var(--navy-soft);
  color: var(--navy);
  cursor: default;
}
.answer-input.is-correct { border-color: var(--green); box-shadow: 0 0 0 4px rgb(85 198 138 / .15); }
.answer-input.is-incorrect { border-color: var(--coral); box-shadow: 0 0 0 4px rgb(255 122 114 / .12); }

.password-field { position: relative; display: block; }
.password-field .answer-input { padding-right: 3.4rem; }
.password-toggle {
  position: absolute;
  right: .45rem;
  top: 50%;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease;
}
.password-toggle:hover { color: var(--navy); background: var(--navy-soft); }
.password-toggle:active { background: #e1e6ef; }
.password-toggle .icon-svg { width: 21px; height: 21px; }

.feedback {
  border-radius: 22px;
  padding: 1rem 1.1rem;
  font-weight: 800;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(8px);
  animation: feedback-in .32s ease forwards;
}
.feedback.ok { background: var(--green-soft); }
.feedback.bad { background: var(--coral-soft); }
.feedback.almost { background: var(--yellow-soft); }
.feedback-title { display: flex; align-items: center; gap: .55rem; margin: 0; }
.feedback-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
}
.feedback.bad .feedback-icon { background: var(--coral); }
.feedback.almost .feedback-icon { background: var(--yellow); color: var(--navy); }
.feedback-icon::after {
  content: "";
  width: 7px;
  height: 12px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}
.feedback.bad .feedback-icon::after {
  content: "!";
  width: auto;
  height: auto;
  border: 0;
  transform: none;
  font-size: .9rem;
}
.feedback + .step-actions { animation: feedback-in .28s .08s ease both; }

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 .85rem;
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
  font-weight: 800;
  margin: 0;
}
.status-learning { color: #345fbf; background: var(--blue-soft); }
.status-mastered { color: #27734c; background: var(--green-soft); }
.status-developing, .status-proficient { color: var(--navy); background: var(--yellow-soft); }
.status-needs-review { color: #9a3d32; background: var(--coral-soft); }

@keyframes feedback-in {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .feedback { opacity: 1; transform: none; }
}

.stat-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: white; border-radius: 24px; padding: 1rem; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.8rem; }

.hidden { display: none !important; }
