:root {
  --bg: #fdf9f3;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #5c5c64;
  --ink-mute: #8a8a93;
  --line: #ecdfce;
  --line-soft: #f4ecdd;
  --green: #0a7d3d;
  --green-soft: #e7f4ec;
  --red: #ce2b37;
  --red-soft: #fbe7e9;
  --amber: #c97a18;
  --amber-soft: #fbf0dc;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: 80px;
  min-height: 100vh;
}

.mockup-badge {
  position: fixed;
  top: 8px;
  right: 8px;
  background: var(--amber);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 999px;
  z-index: 100;
  box-shadow: var(--shadow);
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 10px; }
.app-header h1 { font-size: 19px; margin: 0; font-weight: 700; }
.app-header .sub { margin: 0; font-size: 12px; color: var(--ink-mute); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--line-soft); }

/* ===== Layout ===== */
main { max-width: 720px; margin: 0 auto; padding: 18px; }
.view { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.section-title { font-size: 17px; margin: 22px 0 4px; font-weight: 700; }
.section-sub { color: var(--ink-mute); font-size: 13px; margin: 0 0 14px; }

/* ===== Home: streak ===== */
.streak-card {
  background: linear-gradient(135deg, #0a7d3d 0%, #08623c 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.streak-num {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
  opacity: 0.95;
}
.streak-num .flame { font-size: 28px; line-height: 1; }
.streak-num strong { font-size: 44px; font-weight: 800; line-height: 1; }
.streak-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.2);
}
.streak-meta div { display: flex; flex-direction: column; font-size: 11px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.streak-meta strong { font-size: 22px; font-weight: 700; }

/* ===== Lesson cards ===== */
.lesson-cards { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.1s, border-color 0.1s;
}
.lesson-card:hover { border-color: var(--green); transform: translateY(-1px); }
.lc-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.lc-body { flex: 1; min-width: 0; }
.lc-body h3 { margin: 0 0 2px; font-size: 16px; }
.lc-body p { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); }
.lc-tag { font-size: 11px; color: var(--ink-mute); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.lc-arrow { font-size: 24px; color: var(--ink-mute); }

.quick-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.qa {
  flex: 1;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}
.qa:hover { background: var(--line-soft); }

/* ===== Lesson header (back nav) ===== */
.lesson-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.lesson-header h2 { margin: 0; font-size: 18px; }
.lesson-header .sub { margin: 0; font-size: 12px; color: var(--ink-mute); }
.lesson-header > div { flex: 1; }
.back-btn {
  background: transparent;
  border: 1px solid var(--line);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

/* ===== Chat ===== */
.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 90px;
}
.chat.compact { margin-bottom: 16px; }
.msg {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 86%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  font-size: 15px;
}
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg.ai {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.msg.me {
  background: var(--green);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.prompt-it {
  font-style: italic;
  background: var(--green-soft);
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--green);
  font-weight: 600;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { background: var(--green-soft); border-color: var(--green); }

/* ===== Composer ===== */
.composer {
  position: fixed;
  bottom: 64px;
  left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line-soft);
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.03);
}
.composer input[type=text] {
  flex: 1;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--bg);
  outline: none;
}
.composer input[type=text]:focus { border-color: var(--green); background: var(--surface); }
.mic { font-size: 18px; }
.primary {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { background: #086430; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  cursor: pointer;
  color: var(--ink-soft);
}

/* ===== Practice ===== */
.progress-pill {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}
.practice-bar {
  height: 6px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.practice-bar-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s;
}
.practice-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.practice-type {
  font-size: 11px;
  color: var(--ink-mute);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.practice-prompt {
  font-size: 22px;
  font-style: italic;
  color: var(--green);
  margin: 10px 0 18px;
  font-weight: 600;
}
.practice-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  resize: vertical;
}
.practice-feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.practice-feedback.ok { background: var(--green-soft); color: var(--green); }
.practice-feedback.no { background: var(--red-soft); color: var(--red); }
.practice-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}
.practice-aside {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink-soft);
}
.practice-aside summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.practice-aside p { margin: 8px 0 0; }

/* ===== Mission ===== */
.mission-scene {
  background: linear-gradient(135deg, #fbf0dc, #fdf9f3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
}
.scene-img { font-size: 56px; text-align: center; margin-bottom: 6px; }
.scene-desc { font-size: 15px; color: var(--ink-soft); margin: 0 0 16px; }
.scene-progress { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.step { color: var(--ink-mute); padding-left: 4px; }
.step.done { color: var(--green); font-weight: 600; }
.step.current { color: var(--ink); font-weight: 700; }

/* ===== Progress ===== */
.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 12px; color: var(--ink-mute); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.stat-big { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-foot { font-size: 12px; color: var(--ink-soft); }

.skill-bars { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.skill {
  display: grid;
  grid-template-columns: 90px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.skill .bar { height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.skill .bar > div { height: 100%; background: var(--green); border-radius: inherit; }
.skill em { color: var(--ink-mute); font-style: normal; font-weight: 600; font-size: 12px; text-align: right; }

.weak-list { list-style: none; padding: 0; margin: 0; }
.weak-list li {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.weak-tag {
  background: var(--red-soft);
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}

/* ===== Tab bar ===== */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line-soft);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
  z-index: 5;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 11px;
  color: var(--ink-mute);
  cursor: pointer;
  font-family: inherit;
}
.tab span { font-size: 20px; line-height: 1; }
.tab.active { color: var(--green); font-weight: 700; }

@media (min-width: 720px) {
  .composer { border-radius: 12px; bottom: 80px; left: 50%; transform: translateX(-50%); right: auto; width: 700px; }
  .tabbar { border-radius: 16px 16px 0 0; max-width: 720px; left: 50%; transform: translateX(-50%); right: auto; }
}
