:root {
  color-scheme: light;
  --ink: #17322b;
  --muted: #61706b;
  --line: #dce7e1;
  --surface: #ffffff;
  --wash: #f5f8f3;
  --leaf: #20b86f;
  --leaf-dark: #138552;
  --sun: #ffd45d;
  --sky: #4aa7e8;
  --coral: #ef6f5e;
  --shadow: 0 18px 48px rgba(24, 56, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(255, 212, 93, 0.18), transparent 34%),
    linear-gradient(230deg, rgba(74, 167, 232, 0.13), transparent 38%),
    var(--wash);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  70% {
    opacity: 1;
    transform: translateY(-4px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulseWin {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 54px;
  height: 54px;
  padding: 6px;
  border-radius: 16px;
  background: #e6fff2;
  border: 1px solid #bdebd3;
}

.brand p {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
}

.brand span,
.language-panel label,
.eyebrow,
.streak-box small,
.quiz-meta,
.daily-card p:last-child {
  color: var(--muted);
  font-size: 0.82rem;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #eaf3ee;
}

.nav-item.active {
  background: #e7f8ef;
  color: var(--leaf-dark);
}

.language-panel {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.language-panel select,
.phrasebook-head input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 34px 32px 54px;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.2rem;
}

.streak-box {
  display: grid;
  place-items: center;
  min-width: 92px;
  min-height: 92px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.streak-box span {
  color: var(--coral);
  font-size: 2rem;
  font-weight: 800;
}

.install-button {
  min-height: 44px;
  padding: 0 16px;
  color: white;
  background: var(--ink);
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(23, 50, 43, 0.24);
}

.help-button {
  color: var(--leaf-dark);
  background: #e7f8ef;
  box-shadow: 0 5px 0 #c5e8d3;
}

.sound-toggle {
  background: var(--sky);
  box-shadow: 0 5px 0 #2d78ab;
}

.progress-band {
  padding: 18px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.progress-band > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 800;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  background: #e8efe9;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--leaf), var(--sun));
  transition: width 240ms ease;
}

.profile-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.profile-title {
  display: grid;
  gap: 4px;
  grid-column: 1 / -1;
}

.profile-title strong {
  font-size: 1.1rem;
}

.how-to-card {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 18px;
  background:
    linear-gradient(130deg, rgba(74, 167, 232, 0.16), transparent 52%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.how-to-card[hidden] {
  display: none;
}

.how-to-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.how-to-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.how-to-grid article {
  padding: 14px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.how-to-grid strong {
  display: block;
  margin-bottom: 6px;
}

.how-to-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  color: white;
  background: var(--leaf);
  border-radius: 18px;
  font-size: 2rem;
  font-weight: 800;
}

.profile-avatar.blue {
  background: var(--sky);
}

.profile-avatar.coral {
  background: var(--coral);
}

.profile-avatar.purple {
  background: #6b62d9;
}

.profile-fields {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 10px;
}

.profile-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.profile-stats div {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 8px;
  background: #f1f7f3;
  border-radius: 8px;
}

.profile-stats strong {
  font-size: 1.25rem;
}

.profile-stats span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mission-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mission-strip article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 78px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(255, 212, 93, 0.22), transparent 58%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mission-strip article > span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #e7f8ef;
  border-radius: 8px;
  font-size: 1.35rem;
}

.mission-strip strong,
.mission-strip small {
  display: block;
}

.mission-strip small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.3;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.level-tab {
  display: grid;
  gap: 5px;
  min-height: 74px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.level-tab strong {
  font-size: 0.95rem;
}

.level-tab span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.level-tab.active {
  border-color: var(--leaf);
  background: #e7f8ef;
  color: var(--leaf-dark);
}

.lesson-grid {
  display: grid;
  gap: 28px;
}

.level-section {
  display: grid;
  gap: 14px;
}

.level-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.level-section-head p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.level-section-head span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.lesson-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.lesson-card,
.daily-card,
.phrase-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lesson-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.lesson-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.level-badge {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--leaf-dark);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: white;
  background: var(--sky);
  border-radius: 8px;
  font-size: 1.3rem;
  font-weight: 800;
}

.lesson-card.intermediate .lesson-icon {
  background: var(--coral);
}

.lesson-card.hard .lesson-icon {
  background: #6b62d9;
}

.lesson-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.crown-row {
  display: flex;
  gap: 5px;
  color: #d5ddd8;
  font-size: 1.05rem;
}

.crown-row .earned {
  color: #f1b72c;
}

.word-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-strip span,
.word-chip {
  padding: 7px 9px;
  background: #f1f5f2;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.word-chip,
.phrase-main,
.phrase-translation {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-align: left;
  border: 0;
}

.speakable {
  cursor: pointer;
}

.speakable::after {
  content: "🔊";
  display: inline-grid;
  place-items: center;
  min-width: 1.55em;
  height: 1.55em;
  margin-left: 0.45em;
  color: var(--leaf-dark);
  background: #e7f8ef;
  border: 1px solid #bdebd3;
  border-radius: 999px;
  font-size: 0.78em;
  line-height: 1;
  vertical-align: middle;
  box-shadow: 0 2px 0 #c5e8d3;
}

.prompt-word.speakable::after {
  content: "🔊";
  min-width: 1.65em;
  height: 1.65em;
  margin-left: 0.25em;
  font-size: 0.22em;
  transform: translateY(-0.25em);
}

.daily-catalan.speakable::after {
  font-size: 0.42em;
}

.speak-inline.speakable::after {
  font-size: 0.78em;
}

.speakable:hover {
  outline: 2px solid rgba(32, 184, 111, 0.28);
  outline-offset: 3px;
}

.primary-button,
.ghost-button,
.sound-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  border: 0;
  font-weight: 800;
}

.primary-button {
  color: white;
  background: var(--leaf);
  box-shadow: 0 5px 0 var(--leaf-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ghost-button,
.sound-button {
  color: var(--leaf-dark);
  background: #e8f8ef;
}

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
}

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

.phone-stage {
  display: grid;
  justify-items: center;
  gap: 14px;
  min-height: 620px;
  padding: 22px;
  color: white;
  background:
    linear-gradient(170deg, rgba(255, 212, 93, 0.22), transparent 42%),
    linear-gradient(210deg, #17322b, #0c201b);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.phone-top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 800;
}

.avatar-wrap {
  display: grid;
  place-items: center;
  width: min(70vw, 230px);
  aspect-ratio: 1;
  margin-top: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.avatar-face {
  position: relative;
  width: 74%;
  aspect-ratio: 1;
  border-radius: 44% 44% 48% 48%;
  background: #20b86f;
  overflow: hidden;
}

.avatar-face.blue {
  background: #4aa7e8;
}

.avatar-face.coral {
  background: #ef6f5e;
}

.avatar-face.yellow {
  background: #ffd45d;
}

.avatar-face.purple {
  background: #6b62d9;
}

.avatar-hair {
  position: absolute;
  inset: 0 0 auto;
  height: 36%;
  background: rgba(23, 50, 43, 0.92);
  border-radius: 0 0 42% 42%;
}

.avatar-eye {
  position: absolute;
  top: 48%;
  width: 13%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #17322b;
}

.avatar-eye.left {
  left: 29%;
}

.avatar-eye.right {
  right: 29%;
}

.avatar-mouth {
  position: absolute;
  left: 38%;
  bottom: 24%;
  width: 24%;
  height: 10%;
  border-bottom: 9px solid #17322b;
  border-radius: 50%;
}

.phone-stage h2 {
  font-size: 2rem;
}

.phone-stage p {
  margin: -8px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.call-bubble {
  width: 100%;
  min-height: 94px;
  padding: 16px;
  color: var(--ink);
  background: white;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.35;
}

.call-controls {
  display: flex;
  gap: 14px;
  margin-top: auto;
}

.round-button {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 800;
}

.round-button.speak {
  width: 76px;
  height: 76px;
  color: white;
  background: var(--leaf);
}

.round-button.end {
  color: white;
  background: var(--coral);
}

.call-panel {
  display: grid;
  gap: 18px;
}

.scenario-list,
.answer-options {
  display: grid;
  gap: 10px;
}

.scenario-button,
.answer-choice,
.answer-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scenario-button,
.answer-choice {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.scenario-button span,
.answer-choice span,
#heardText {
  color: var(--muted);
}

.scenario-button.active {
  border-color: var(--leaf);
  background: #e7f8ef;
}

.answer-box {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.answer-choice strong {
  font-size: 1rem;
}

.quiz-card {
  min-height: 460px;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.prompt-word {
  margin: 4px 0 10px;
  color: var(--ink);
  font-size: clamp(2.4rem, 8vw, 5.4rem);
  font-weight: 800;
  line-height: 1;
}

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

.option-button {
  min-height: 76px;
  padding: 12px;
  color: var(--ink);
  background: #fbfdfb;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.option-button.selected {
  border-color: var(--sky);
  background: #ebf6ff;
}

.option-button.correct {
  border-color: var(--leaf);
  background: #e6fbef;
  animation: pulseWin 420ms ease;
}

.option-button.wrong {
  border-color: var(--coral);
  background: #fff0ed;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
}

.feedback {
  min-height: 24px;
  margin: 0;
  font-weight: 800;
}

.daily-card {
  align-self: start;
  display: grid;
  gap: 12px;
  padding: 18px;
  background:
    linear-gradient(160deg, rgba(255, 212, 93, 0.24), transparent 60%),
    var(--surface);
}

.daily-catalan {
  margin: 8px 0 0;
  font-size: 2rem;
  line-height: 1.05;
  font-weight: 800;
}

.phrasebook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.phrasebook-head input {
  max-width: 320px;
}

.phrase-list {
  display: grid;
  gap: 10px;
}

.phrase-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 100px auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.phrase-row strong,
.phrase-main {
  font-size: 1rem;
  font-weight: 800;
}

.phrase-row span,
.phrase-translation {
  color: var(--muted);
}

.phrase-main,
.phrase-translation {
  background: transparent;
  padding: 0;
}

.phrase-row small {
  color: var(--leaf-dark);
  font-weight: 800;
}

.tiny-button {
  width: 38px;
  height: 38px;
  color: var(--leaf-dark);
  background: #e8f8ef;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.reward-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(320px, calc(100vw - 40px));
  padding: 14px 18px;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
}

.reward-toast.show {
  animation: popIn 260ms ease forwards;
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .nav-item span {
    display: none;
  }

  .language-panel {
    margin: 0;
  }

  main {
    padding: 22px 14px 42px;
  }

  .lesson-cards,
  .call-layout,
  .profile-card,
  .how-to-grid,
  .practice-layout {
    grid-template-columns: 1fr;
  }

  .profile-fields,
  .profile-stats,
  .mission-strip {
    grid-template-columns: 1fr;
  }

  .level-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .phrase-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    align-items: end;
    flex-direction: column-reverse;
  }

  .streak-box {
    min-width: 68px;
    min-height: 68px;
  }

  .streak-box span {
    font-size: 1.5rem;
  }

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

  .phrasebook-head {
    align-items: stretch;
    flex-direction: column;
  }

  .phrasebook-head input {
    max-width: none;
  }

  .level-tabs {
    grid-template-columns: 1fr;
  }
}
