:root {
  --teal: #18a999;
  --teal-dark: #0f8a7d;
  --teal-soft: #e6f7f4;
  --yellow: #f6c85f;
  --yellow-soft: #fff5d8;
  --coral: #ee7c6b;
  --ink: #1f2933;
  --muted: #7b8794;
  --line: #e6ebef;
  --panel: #ffffff;
  --bg: #f5f8f9;
  --shadow: 0 18px 48px rgba(31, 41, 51, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(24, 169, 153, 0.12), transparent 28%),
    linear-gradient(145deg, #f7fbfb 0%, #eef4f4 100%);
  font-family: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
}

.phone-frame {
  position: relative;
  width: min(390px, calc(100vw - 32px));
  height: 844px;
  overflow: hidden;
  border: 10px solid #111827;
  border-radius: 38px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.status-bar {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  height: 38px;
  padding: max(12px, env(safe-area-inset-top)) 24px 0;
  background: rgba(245, 248, 249, 0.94);
  font-size: 12px;
  font-weight: 700;
}

.status-icons {
  letter-spacing: 0;
}

.screen {
  position: absolute;
  inset: 38px 0 72px;
  display: none;
  overflow-y: auto;
  padding: 20px 18px 28px;
  scrollbar-width: none;
}

.screen::-webkit-scrollbar {
  display: none;
}

.screen.active {
  display: block;
}

.topbar,
.study-header,
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-header {
  display: block;
  margin-bottom: 18px;
}

.eyebrow,
.card-kicker {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  font-size: 25px;
  line-height: 1.1;
}

.page-header h2,
.complete-screen h2 {
  font-size: 28px;
  line-height: 1.12;
}

.page-header p,
.complete-screen > p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.icon-button,
.play-large {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 22px rgba(24, 169, 153, 0.27);
}

.stats-row,
.result-grid,
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.stats-row article,
.result-grid article,
.profile-stats article {
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.stats-row strong,
.result-grid strong,
.profile-stats strong {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.stats-row span,
.result-grid span,
.profile-stats span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.lesson-hero,
.study-card,
.pattern-card,
.quiz-card,
.speak-card,
.review-panel,
.core-pattern,
.phrase-panel,
.chips-panel,
.dialogue,
.week-card,
.word-progress {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 41, 51, 0.06);
}

.lesson-hero {
  padding: 20px;
}

.lesson-label {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: #8c620d;
  font-size: 12px;
  font-weight: 800;
}

.lesson-hero h2 {
  margin-top: 18px;
  font-size: 30px;
  line-height: 1.05;
}

.lesson-hero p {
  margin-top: 8px;
  color: var(--muted);
}

.lesson-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef1;
}

.lesson-hero .progress-track,
.word-progress .progress-track {
  margin: 9px 0 18px;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 12px 24px rgba(24, 169, 153, 0.24);
}

.secondary-button {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.quick-grid,
.course-week {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.course-week {
  margin-bottom: 10px;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.section-title h3 {
  font-size: 17px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.day-list {
  display: grid;
  gap: 9px;
}

.day-pill {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: left;
}

.day-pill.active {
  border-color: rgba(24, 169, 153, 0.35);
  background: var(--teal-soft);
}

.day-pill.completed {
  border-color: rgba(246, 200, 95, 0.55);
}

.day-pill strong {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: #fff;
  font-size: 13px;
}

.day-pill h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.15;
}

.day-pill p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.day-pill span {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.mini-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.mini-card h3,
.phrase-panel h3,
.chips-panel h3,
.week-card h3,
.can-say h3 {
  font-size: 16px;
}

.mini-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.mini-icon,
.scene-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--yellow-soft);
}

.mini-icon.teal,
.scene-icon {
  background: var(--teal-soft);
}

.scene-icon.yellow {
  background: var(--yellow-soft);
}

.scene-icon.blue {
  background: #e8f0ff;
}

.study-header {
  margin-bottom: 18px;
}

.study-header span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.study-header strong {
  font-size: 14px;
}

.text-button {
  padding: 8px 0;
  color: var(--teal-dark);
  background: transparent;
  font-weight: 800;
}

.study-card,
.pattern-card,
.quiz-card,
.speak-card,
.review-panel {
  min-height: 508px;
  padding: 24px 22px;
  text-align: center;
}

.review-panel {
  min-height: auto;
  text-align: left;
}

.review-panel h2 {
  font-size: 24px;
  line-height: 1.2;
}

.review-panel > p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.review-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-item strong {
  font-size: 17px;
}

.review-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.review-item button {
  justify-self: start;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 13px;
  font-weight: 800;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-actions button.remembered {
  color: #fff;
  background: var(--teal);
}

.empty-review {
  padding: 18px;
  border-radius: 8px;
  background: #f7fafb;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.study-card h2,
.speak-card h2 {
  margin-top: 60px;
  font-size: 39px;
  line-height: 1.06;
}

.meaning {
  margin-top: 12px;
  color: var(--muted);
  font-size: 18px;
}

.play-large {
  margin: 36px auto;
  width: 64px;
  height: 64px;
  font-size: 20px;
}

.example-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  background: #f7fafb;
}

.word-deck {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 22px;
}

.word-deck span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #d9e1e6;
}

.word-deck span.active {
  width: 26px;
  background: var(--teal);
}

.word-deck span.done {
  background: var(--yellow);
}

.example-box span,
.example-box em {
  display: block;
}

.example-box span {
  font-size: 18px;
  font-weight: 800;
}

.example-box em {
  margin-top: 7px;
  color: var(--muted);
  font-style: normal;
}

.fixed-actions {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: grid;
  gap: 10px;
}

.fixed-actions.two {
  grid-template-columns: 1fr 1fr;
}

.pattern-card h2 {
  margin-top: 46px;
  font-size: 38px;
}

.pattern-card h2 span,
.core-pattern h2 span {
  color: var(--teal);
}

.phrase-list,
.answer-list,
.phrase-panel,
.settings-list {
  display: grid;
  gap: 10px;
}

.phrase-list {
  margin-top: 34px;
}

.phrase-list button,
.answer-list button,
.phrase-panel button,
.settings-list button {
  min-height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  font-weight: 800;
}

.quiz-card {
  text-align: left;
}

.quiz-card h2 {
  margin: 42px 0 26px;
  font-size: 24px;
  line-height: 1.3;
}

.quiz-card.answered .answer-list button.correct {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.quiz-card.answered .answer-list button.wrong-selected {
  border-color: var(--coral);
  background: #fff0ee;
}

.feedback {
  display: none;
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 800;
}

.feedback.show {
  display: block;
}

.speak-card h2 {
  margin-top: 52px;
  font-size: 30px;
}

.hold-button {
  width: 158px;
  height: 158px;
  margin-top: 8px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(180deg, var(--teal), var(--teal-dark));
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 18px 35px rgba(24, 169, 153, 0.3);
}

.complete-screen {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.badge {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin: 0 auto 18px;
  border-radius: 50%;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 42px;
  font-weight: 800;
}

.can-say {
  margin: 8px 0 16px;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.can-say p {
  margin-top: 10px;
  color: var(--ink);
  font-weight: 800;
}

.complete-screen .secondary-button {
  margin-top: 10px;
}

.scene-quiz-start {
  margin: 4px 0 18px;
}

.primary-button:disabled {
  cursor: default;
  background: #b9c6cb;
  box-shadow: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: #e9eef1;
}

.segmented button {
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented .active {
  color: var(--teal-dark);
  background: #fff;
}

.scene-list,
.category-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.scene-card {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scene-card h3 {
  font-size: 17px;
}

.scene-card p {
  margin: 5px 0 9px;
  color: var(--muted);
  font-size: 12px;
}

.scene-card button {
  padding: 9px 12px;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.core-pattern {
  padding: 20px;
  margin-bottom: 12px;
}

.core-pattern h2 {
  margin-top: 8px;
  font-size: 30px;
}

.core-pattern p:last-child {
  margin-top: 9px;
  color: var(--muted);
}

.phrase-panel,
.chips-panel,
.dialogue,
.week-card,
.word-progress {
  padding: 15px;
  margin-bottom: 12px;
}

.phrase-panel h3,
.chips-panel h3 {
  margin-bottom: 10px;
}

.phrase-panel > div {
  display: grid;
  gap: 10px;
}

.chips-panel div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips-panel span {
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.dialogue p {
  width: fit-content;
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.dialogue p + p {
  margin-top: 8px;
}

.dialogue .left {
  background: #f0f3f5;
}

.dialogue .right {
  margin-left: auto;
  color: #fff;
  background: var(--teal);
}

.word-progress {
  margin-bottom: 14px;
}

.category-list article,
.category-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 17px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
  text-align: left;
}

.category-list strong {
  color: var(--teal-dark);
}

.category-list span em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.word-list {
  display: grid;
  gap: 12px;
}

.word-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(31, 41, 51, 0.05);
}

.word-item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.word-item h3 {
  font-size: 24px;
  line-height: 1.05;
}

.word-item p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.word-item .word-meaning {
  margin-top: 5px;
  color: var(--teal-dark);
  font-weight: 800;
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.word-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef7f4;
  color: #2f6f68;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.word-meta span:nth-child(2) {
  background: #fff4d8;
  color: #8a5a00;
}

.word-meta span:nth-child(3) {
  background: #f0f3f5;
  color: var(--muted);
}

.word-meta span.mastered {
  background: #def7ec;
  color: #08724f;
}

.word-item .word-example {
  padding: 12px;
  border-radius: 8px;
  background: #f7fafb;
}

.word-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.word-actions button {
  min-height: 40px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 13px;
  font-weight: 800;
}

.word-actions button.known {
  color: #fff;
  background: var(--teal);
}

.profile-stats {
  grid-template-columns: 1fr;
}

.profile-stats article {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  text-align: left;
}

.week-dots {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  margin-top: 14px;
}

.week-dots span {
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 8px;
  background: #eef2f4;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.week-dots .done {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.settings-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.bottom-nav {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(72px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.bottom-nav button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bottom-nav button span {
  font-size: 18px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--teal-dark);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(31, 41, 51, 0.9);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    min-height: 100vh;
    padding: 0;
  }

  .phone-frame {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .screen {
    inset: 38px 0 72px;
    inset: 38px 0 calc(72px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 760px) {
  .study-card,
  .pattern-card,
  .quiz-card,
  .speak-card {
    min-height: 430px;
  }

  .study-card h2,
  .speak-card h2 {
    margin-top: 32px;
  }
}
