:root {
  --paper: #fbf6e9;
  --paper-deep: #f2ead9;
  --white: #fffdf7;
  --ink: #35443b;
  --muted: #7b877a;
  --line: #ded8c7;
  --yellow: #f3df9b;
  --yellow-soft: #fff5cf;
  --yellow-line: #d6b866;
  --mint: #e0eee3;
  --mint-line: #a7c6ae;
  --blue: #deedf0;
  --blue-line: #a7cbd0;
  --coral: #f8dfd4;
  --coral-line: #d99d87;
  --shadow: 0 5px 0 rgba(83, 97, 75, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #e8e3d8;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: #e8e3d8;
  font-family: "Nunito", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 3px solid #6ca294;
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

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

.app-stage {
  display: grid;
  min-height: 100svh;
  place-items: center;
}

.app-shell {
  position: relative;
  display: flex;
  width: 100%;
  height: 100svh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}

.app-shell::before,
.app-shell::after {
  position: absolute;
  z-index: 0;
  display: block;
  height: 4px;
  border-radius: 99px;
  content: "";
  opacity: 0.6;
}

.app-shell::before {
  top: 16px;
  left: 19%;
  width: 60px;
  background: #d7b9a8;
  transform: rotate(-4deg);
}

.app-shell::after {
  top: 28px;
  right: 16%;
  width: 35px;
  background: #9fc7bd;
  transform: rotate(5deg);
}

.app-content {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 25px 16px 104px;
  scrollbar-color: #c8d7c8 transparent;
  scrollbar-width: thin;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 56px;
}

.back-button {
  min-height: 43px;
  gap: 4px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 16px 14px 17px 15px;
  background: var(--white);
  box-shadow: 0 3px 0 rgba(79, 92, 72, 0.08);
  color: #5d6d60;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.back-button:active,
.primary-button:active,
.library-button:active,
.episode-card:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(79, 92, 72, 0.09);
}

.back-icon {
  color: #c59c4c;
  font-size: 19px;
  line-height: 1;
}

.page-heading {
  min-width: 0;
  text-align: center;
}

.page-kicker,
.eyebrow-label,
.episode-subtitle,
.episode-count,
.selected-episode,
.practice-tip,
.matching-card-title p,
.column-label,
.review-label,
.helper-note,
.action-feedback,
.library-feedback,
.picture-label {
  margin: 0;
}

.page-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.page-heading h1 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.level-badge {
  display: inline-flex;
  min-height: 35px;
  align-items: center;
  gap: 4px;
  padding: 7px 8px;
  border: 1.5px solid var(--yellow-line);
  border-radius: 14px 16px 13px 15px;
  background: var(--yellow);
  color: #796331;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.badge-dot {
  color: #c1943c;
  font-size: 8px;
}

.intro-strip {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 11px;
  margin: 14px 1px 16px;
  padding: 10px 13px;
  border: 1.5px solid var(--mint-line);
  border-radius: 22px 19px 24px 20px;
  background: var(--mint);
  box-shadow: var(--shadow);
  transform: rotate(-0.3deg);
}

.intro-sticker {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid #d5b768;
  border-radius: 14px 18px 13px 16px;
  background: var(--yellow-soft);
  color: #aa8238;
  font-size: 16px;
  font-weight: 900;
  transform: rotate(-6deg);
}

.intro-copy {
  min-width: 0;
  flex: 1;
}

.intro-copy p {
  margin: 0 0 2px;
  color: #74887b;
  font-size: 10px;
  font-weight: 800;
}

.intro-copy strong {
  display: block;
  color: #496255;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
}

.intro-spark {
  flex: 0 0 auto;
  color: #d1a85b;
  font-size: 19px;
  transform: rotate(10deg);
}

.workbench-panel {
  position: relative;
  margin-top: 14px;
  padding: 16px 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 26px 23px 28px 24px;
  background: rgba(255, 253, 247, 0.84);
  box-shadow: var(--shadow);
}

.workbench-panel::after {
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(95, 107, 88, 0.12);
  border-radius: 21px 18px 23px 20px;
  content: "";
  pointer-events: none;
}

.section-heading,
.section-title-group,
.practice-heading,
.matching-card-heading,
.matching-card-title,
.review-heading,
.subtitle-footer,
.helper-note,
.review-row {
  display: flex;
}

.section-heading {
  position: relative;
  z-index: 1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-title-group {
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.section-number {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid var(--yellow-line);
  border-radius: 13px 15px 12px 14px;
  background: var(--yellow-soft);
  color: #a47b30;
  font-size: 11px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.section-number-sun {
  border-color: var(--blue-line);
  background: var(--blue);
  color: #54828a;
  transform: rotate(4deg);
}

.eyebrow-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.section-heading h2,
.practice-heading h2,
.review-heading h2 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.episode-count,
.selected-episode,
.practice-tip {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 11px 13px 10px 12px;
  background: var(--paper-deep);
  color: #819081;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.episode-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.episode-card {
  display: grid;
  min-width: 0;
  min-height: 68px;
  grid-template-columns: 24px 35px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 6px;
  padding: 8px 7px;
  border: 1.5px solid #e5dfd0;
  border-radius: 17px 15px 18px 16px;
  background: #fffdf8;
  box-shadow: 0 2px 0 rgba(83, 97, 75, 0.05);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.episode-card:hover {
  border-color: #d8c386;
}

.episode-card.is-selected {
  border-color: var(--yellow-line);
  background: var(--yellow-soft);
  box-shadow: 0 3px 0 rgba(185, 151, 65, 0.12);
}

.episode-number {
  color: #9a9f8c;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.episode-picture {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px 14px 11px 13px;
  background: #f1eee2;
  font-size: 19px;
}

.episode-copy {
  min-width: 0;
}

.episode-title,
.episode-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-title {
  color: #4e5c4f;
  font-size: 11.5px;
  font-weight: 900;
}

.episode-subtitle {
  margin-top: 3px;
  color: #98a092;
  font-size: 9px;
  font-weight: 700;
}

.episode-check {
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid #c9cdbc;
  border-radius: 50%;
  color: transparent;
  font-size: 9px;
  line-height: 1;
}

.episode-card.is-selected .episode-check {
  border-color: var(--yellow-line);
  background: var(--yellow);
  color: #85662e;
}

.subtitle-panel {
  border-color: var(--blue-line);
  background: #fcfdf8;
}

.compact-heading {
  margin-bottom: 12px;
}

.subtitle-input {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 111px;
  padding: 12px 13px;
  border: 1.5px solid #d8e2da;
  border-radius: 17px 15px 18px 16px;
  outline: 0;
  background: #f7faf2;
  color: #52675a;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
  resize: vertical;
}

.subtitle-input:focus {
  border-color: var(--blue-line);
  background: #fcfff8;
}

.subtitle-footer {
  position: relative;
  z-index: 1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
}

.helper-note {
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: #899587;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
}

.helper-note-icon {
  flex: 0 0 auto;
  color: #72958b;
  font-size: 16px;
}

.primary-button,
.library-button {
  min-height: 45px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 13px;
  border: 1.5px solid var(--yellow-line);
  border-radius: 16px 14px 17px 15px;
  background: var(--yellow);
  box-shadow: 0 4px 0 rgba(185, 151, 65, 0.13);
  color: #6d562d;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.primary-button:hover,
.library-button:hover {
  background: #f5e4a7;
}

.button-mark {
  color: #b28739;
  font-size: 15px;
}

.action-feedback,
.library-feedback {
  position: relative;
  z-index: 1;
  min-height: 18px;
  margin-top: 8px;
  color: #829084;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.45;
}

.action-feedback[data-state="success"],
.library-feedback[data-state="success"] {
  color: #5e9671;
}

.action-feedback[data-state="error"],
.library-feedback[data-state="error"] {
  color: #c17c68;
}

.practice-area {
  position: relative;
  z-index: 1;
  margin-top: 20px;
}

.practice-heading {
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin: 0 3px 10px;
}

.practice-heading h2 {
  font-size: 19px;
}

.practice-tip {
  background: var(--mint);
  color: #6b8870;
}

.matching-grid {
  display: grid;
  gap: 14px;
}

.matching-card {
  position: relative;
  padding: 15px 11px 12px;
  border: 1.5px solid var(--yellow-line);
  border-radius: 24px 21px 25px 22px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.sentence-matching-card {
  border-color: var(--blue-line);
  background: #fbfdfb;
}

.matching-card-heading {
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.matching-card-title {
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.matching-index {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid var(--yellow-line);
  border-radius: 11px 13px 10px 12px;
  background: var(--yellow-soft);
  color: #a57e37;
  font-size: 12px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.matching-index-blue {
  border-color: var(--blue-line);
  background: var(--blue);
  color: #5d8790;
  transform: rotate(4deg);
}

.matching-card-title h3 {
  margin: 0;
  color: #4b5d50;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.matching-card-title p {
  margin-top: 3px;
  color: #89958b;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
}

.tiny-doodle {
  color: #d2aa59;
  font-size: 23px;
  transform: rotate(8deg);
}

.tiny-doodle-heart {
  color: #ca9c91;
  transform: rotate(-10deg);
}

.match-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr);
  align-items: stretch;
  gap: 6px;
}

.match-column {
  min-width: 0;
}

.column-label {
  margin: 0 0 6px 3px;
  color: #9a9f91;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.match-list {
  display: grid;
  gap: 7px;
}

.match-connector {
  display: grid;
  place-items: center;
  color: #ccb26e;
  font-size: 16px;
}

.sentence-matching-card .match-connector {
  color: #91afb1;
}

.match-tile {
  display: flex;
  min-width: 0;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 7px 8px 9px;
  border: 1.5px solid #e1dfd1;
  border-radius: 16px 14px 17px 15px;
  background: #fffef9;
  color: #4b5d50;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: border-color 160ms ease, background-color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.match-source {
  cursor: grab;
}

.match-source:active {
  cursor: grabbing;
}

.match-target {
  justify-content: center;
  text-align: center;
}

.match-tile:hover {
  border-color: #d3bb78;
}

.sentence-matching-card .match-tile:hover {
  border-color: #a5c4c7;
}

.match-tile:focus-visible {
  outline: 3px solid #6ca294;
  outline-offset: 2px;
}

.match-tile.is-selected {
  border-color: var(--yellow-line);
  background: var(--yellow-soft);
  transform: rotate(-0.6deg);
}

.sentence-matching-card .match-tile.is-selected {
  border-color: var(--blue-line);
  background: #eaf5f4;
}

.match-tile.is-over {
  border-color: #c49842;
  background: #fff2be;
}

.match-tile.is-matched {
  border-color: var(--mint-line);
  background: var(--mint);
  color: #52735b;
}

.match-tile.is-dragging {
  opacity: 0.58;
}

.match-tile.is-wrong {
  border-color: var(--coral-line);
  background: var(--coral);
  animation: gentle-nudge 260ms ease-in-out;
}

.tile-copy {
  display: block;
  min-width: 0;
  flex: 1;
}

.tile-main {
  display: block;
  overflow-wrap: anywhere;
  color: #4a5b4e;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
}

.sentence-main {
  font-size: 12px;
  line-height: 1.3;
}

.picture-tile {
  min-height: 68px;
  flex-direction: column;
  gap: 2px;
}

.picture-emoji {
  font-size: 28px;
  line-height: 1;
}

.picture-label {
  color: #98a193;
  font-size: 9px;
  font-weight: 800;
}

.meaning-tile {
  min-height: 68px;
  padding-right: 9px;
}

.meaning-text {
  overflow-wrap: anywhere;
  color: #52655a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.speak-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1.5px solid #ddd1a7;
  border-radius: 50%;
  background: #fff6d5;
  color: #8b6f36;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.speak-button:hover,
.speak-button.is-speaking {
  border-color: var(--yellow-line);
  background: var(--yellow);
  transform: scale(1.04);
}

.match-feedback {
  min-height: 19px;
  margin: 9px 2px 0;
  color: #8b968b;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.4;
}

.match-feedback[data-state="success"] {
  color: #5d9871;
}

.match-feedback[data-state="error"] {
  color: #c47d6a;
}

.review-panel {
  position: relative;
  margin-top: 15px;
  padding: 16px 13px 14px;
  border: 1.5px solid var(--mint-line);
  border-radius: 25px 22px 27px 23px;
  background: var(--mint);
  box-shadow: var(--shadow);
}

.review-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.review-heading h2 {
  font-size: 17px;
}

.review-star {
  color: #c49a44;
  font-size: 27px;
  line-height: 1;
  transform: rotate(8deg);
}

.review-columns {
  display: grid;
  gap: 10px;
  margin-top: 13px;
}

.review-block {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(142, 181, 151, 0.52);
  border-radius: 16px 14px 17px 15px;
  background: rgba(255, 253, 247, 0.65);
}

.review-label {
  margin-bottom: 7px;
  color: #718876;
  font-size: 10px;
  font-weight: 900;
}

.review-list {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.review-row {
  min-width: 0;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 4px 0;
}

.review-emoji {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px 13px 10px 12px;
  background: #fff3c8;
  font-size: 18px;
}

.review-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.review-en,
.review-zh {
  display: block;
  overflow-wrap: anywhere;
}

.review-en {
  color: #4c6754;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.review-zh {
  color: #809283;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.review-sentence-row {
  align-items: flex-start;
}

.review-sentence-row .speak-button {
  margin-top: 1px;
}

.library-button {
  width: 100%;
  margin-top: 13px;
  border-color: #90b99a;
  background: #f1dc91;
  color: #62512e;
}

.library-button > span:first-child {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid rgba(113, 88, 37, 0.3);
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}

.library-feedback {
  margin-bottom: 0;
  text-align: center;
}

.bottom-nav {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  min-height: 74px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  padding: 8px 7px max(8px, env(safe-area-inset-bottom));
  border-top: 1.5px solid #e2dccd;
  background: rgba(251, 246, 233, 0.97);
  box-shadow: 0 -4px 14px rgba(90, 104, 85, 0.06);
}

.bottom-nav-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  border-radius: 14px;
  background: transparent;
  color: #9a9d8f;
  cursor: pointer;
  flex-direction: column;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.bottom-nav-item.is-active {
  background: var(--yellow-soft);
  color: #8a6f35;
}

.bottom-nav-item.is-disabled,
.bottom-nav-item:disabled {
  cursor: default;
  opacity: 0.48;
}

.bottom-nav-icon {
  display: grid;
  min-height: 21px;
  place-items: center;
  color: currentColor;
  font-size: 19px;
  line-height: 1;
}

@keyframes gentle-nudge {
  0%,
  100% {
    transform: translateX(0);
  }

  40% {
    transform: translateX(-3px);
  }

  70% {
    transform: translateX(3px);
  }
}

@media (min-width: 700px) {
  .app-shell {
    --frame-width: min(56.25svh, 560px);
    width: var(--frame-width);
    height: calc(var(--frame-width) * 1.7777778);
    max-height: 100svh;
    border-radius: 30px;
    box-shadow: 0 18px 42px rgba(79, 91, 76, 0.13);
  }

  .app-content {
    padding-right: 19px;
    padding-left: 19px;
  }
}

@media (max-width: 360px) {
  .app-content {
    padding-right: 12px;
    padding-left: 12px;
  }

  .back-button {
    padding-right: 8px;
    padding-left: 8px;
  }

  .level-badge {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 9px;
  }

  .episode-card {
    grid-template-columns: 20px 31px minmax(0, 1fr) 12px;
    gap: 4px;
    padding-right: 5px;
    padding-left: 5px;
  }

  .episode-picture {
    width: 30px;
    height: 30px;
    font-size: 17px;
  }

  .episode-title {
    font-size: 10.5px;
  }

  .episode-subtitle {
    font-size: 8px;
  }

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

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

@media (max-height: 690px) and (min-width: 700px) {
  .app-content {
    padding-top: 17px;
  }

  .intro-strip {
    margin-top: 9px;
    margin-bottom: 10px;
  }

  .workbench-panel {
    margin-top: 10px;
    padding-top: 12px;
    padding-bottom: 10px;
  }
}
