:root {
  --bg: #f7f8fc;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --text: #171a2d;
  --muted: #6f748a;
  --line: #e8eaf2;
  --primary: #5146e5;
  --primary-dark: #3d34bd;
  --primary-soft: #eeedff;
  --accent: #23b38e;
  --accent-soft: #e7faf4;
  --warning: #ef9f27;
  --danger: #e55868;
  --shadow-sm: 0 8px 24px rgba(38, 39, 70, 0.07);
  --shadow-lg: 0 24px 70px rgba(52, 51, 100, 0.14);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, textarea, select, input { font: inherit; }
button { cursor: pointer; }

.page-glow {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(10px);
  pointer-events: none;
}

.page-glow-one {
  width: 440px;
  height: 440px;
  right: -150px;
  top: 90px;
  background: radial-gradient(circle, rgba(116, 108, 255, 0.18), rgba(116, 108, 255, 0));
}

.page-glow-two {
  width: 520px;
  height: 520px;
  left: -250px;
  top: 620px;
  background: radial-gradient(circle, rgba(34, 194, 154, 0.15), rgba(34, 194, 154, 0));
}

.site-header {
  width: min(calc(100% - 36px), var(--max));
  min-height: 76px;
  margin: 16px auto 0;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  position: sticky;
  top: 12px;
  z-index: 20;
  border: 1px solid rgba(227, 229, 241, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  min-width: 230px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--primary);
  border-radius: 14px;
  background: var(--primary-soft);
}

.brand-mark svg { width: 30px; height: 30px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 15px; letter-spacing: -0.01em; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-size: 11px; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: #f4f5fa;
}

.nav-link {
  min-width: 84px;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  color: #62667b;
  background: transparent;
  transition: 0.2s ease;
}

.nav-link:hover { color: var(--text); }
.nav-link.is-active {
  color: var(--primary-dark);
  background: white;
  box-shadow: 0 4px 14px rgba(50, 51, 85, 0.08);
  font-weight: 700;
}

.mobile-menu {
  display: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #f4f5fa;
}
.mobile-menu span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  border-radius: 4px;
  background: var(--text);
}

#app {
  width: min(calc(100% - 36px), var(--max));
  min-height: calc(100vh - 200px);
  margin: 0 auto;
  outline: none;
}

.view { animation: viewIn 0.35s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  align-items: center;
  gap: 64px;
  padding: 86px 28px 54px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid #dedcff;
  border-radius: 999px;
  color: var(--primary-dark);
  background: rgba(238, 237, 255, 0.72);
  font-size: 13px;
  font-weight: 700;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 179, 142, 0.12);
}

.hero h1 {
  max-width: 650px;
  margin: 22px 0 20px;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.hero h1 em {
  display: block;
  color: var(--primary);
  font-style: normal;
}

.hero-copy > p {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 750;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  color: white;
  background: var(--primary);
  box-shadow: 0 12px 26px rgba(81, 70, 229, 0.24);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 15px 30px rgba(81, 70, 229, 0.28); }
.btn-secondary {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.88);
}
.btn-secondary:hover { background: white; box-shadow: var(--shadow-sm); }
.btn-ghost { color: var(--primary); background: var(--primary-soft); }
.btn-danger { color: var(--danger); background: #fff0f2; }
.btn-icon svg { width: 18px; height: 18px; }
.btn-wide { min-width: 180px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.hero-visual { position: relative; min-height: 460px; }
.demo-card {
  position: absolute;
  inset: 10px 14px 26px;
  padding: 30px;
  border: 1px solid rgba(226, 227, 241, 0.9);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-lg);
  transform: rotate(1.2deg);
}

.demo-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-chip, .level-chip, .topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.demo-chip, .level-chip { color: var(--primary-dark); background: var(--primary-soft); }
.topic-chip { color: #15785f; background: var(--accent-soft); }

.demo-progress { color: var(--muted); font-size: 13px; }
.demo-question-label { margin-top: 28px; color: var(--muted); font-size: 13px; }
.demo-question { margin: 9px 0 22px; font-size: 22px; line-height: 1.55; font-weight: 760; }
.demo-input {
  min-height: 98px;
  padding: 16px;
  border: 1.5px solid #dcddeb;
  border-radius: 16px;
  color: #3c4055;
  background: #fbfbfd;
}
.demo-caret {
  display: inline-block;
  width: 2px;
  height: 18px;
  margin-left: 3px;
  vertical-align: -3px;
  background: var(--primary);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.demo-feedback {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  border-radius: 15px;
  background: var(--accent-soft);
}
.demo-check {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-weight: 900;
}
.demo-feedback strong { display: block; font-size: 14px; }
.demo-feedback span { color: #327664; font-size: 12px; }

.floating-badge {
  position: absolute;
  z-index: 2;
  padding: 12px 15px;
  border: 1px solid rgba(226, 227, 241, 0.9);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 750;
}
.floating-badge.score { left: -6px; bottom: 65px; }
.floating-badge.streak { right: 0; top: 68px; }
.floating-badge span { color: var(--primary); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0 28px 32px;
}
.stat-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(40, 42, 74, 0.04);
}
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 5px; font-size: 26px; letter-spacing: -0.03em; }
.stat-card small { color: var(--accent); }

.section { padding: 58px 28px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.section-kicker { margin: 0 0 5px; color: var(--primary); font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.section h2, .page-heading h1 { margin: 0; font-size: clamp(30px, 4vw, 42px); line-height: 1.2; letter-spacing: -0.035em; }
.section-head > p, .page-heading > p { max-width: 620px; margin: 0; color: var(--muted); }

.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step-card {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
}
.step-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 900;
}
.step-card h3 { margin: 20px 0 8px; font-size: 19px; }
.step-card p { margin: 0; color: var(--muted); }

.page-wrap { padding: 58px 28px 70px; }
.page-heading { margin-bottom: 30px; }
.page-heading.inline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.setup-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
}
.setup-form { padding: 30px; }
.form-section + .form-section { margin-top: 34px; padding-top: 30px; border-top: 1px solid var(--line); }
.form-section h2 { margin: 0 0 5px; font-size: 19px; }
.form-section > p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.choice-card, .topic-card, .segment-button {
  border: 1.5px solid var(--line);
  color: var(--text);
  background: white;
  transition: 0.18s ease;
}
.choice-card {
  min-height: 94px;
  padding: 15px 8px;
  border-radius: 15px;
  text-align: center;
}
.choice-card strong { display: block; font-size: 20px; }
.choice-card span { color: var(--muted); font-size: 12px; }
.choice-card:hover, .topic-card:hover, .segment-button:hover { border-color: #c9c5ff; transform: translateY(-1px); }
.choice-card.is-selected, .topic-card.is-selected, .segment-button.is-selected {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(81, 70, 229, 0.08);
}

.topic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.topic-card {
  min-height: 94px;
  padding: 16px;
  border-radius: 15px;
  text-align: left;
}
.topic-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 10px;
  background: #f4f5fa;
  font-size: 17px;
}
.topic-card strong { display: block; font-size: 14px; }
.topic-card span { color: var(--muted); font-size: 11px; }

.segmented { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.segment-button { min-width: 82px; padding: 10px 15px; border-radius: 12px; }
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: 15px;
  background: white;
  cursor: pointer;
}
.mode-card input { accent-color: var(--primary); width: 18px; height: 18px; }
.mode-card strong { display: block; font-size: 14px; }
.mode-card span { color: var(--muted); font-size: 12px; }
.mode-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.setup-summary { position: sticky; top: 108px; padding: 26px; }
.summary-orb {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 22px;
  color: white;
  background: linear-gradient(135deg, var(--primary), #8a78f4);
  box-shadow: 0 14px 28px rgba(81, 70, 229, 0.24);
  font-size: 26px;
  font-weight: 900;
}
.setup-summary h3 { margin: 0 0 6px; font-size: 22px; }
.setup-summary > p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.summary-list { margin: 0 0 24px; padding: 0; list-style: none; }
.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.summary-list li span { color: var(--muted); }
.summary-list li strong { text-align: right; }
.setup-summary .btn { width: 100%; }
.prototype-note { margin-top: 14px; color: var(--muted); font-size: 11px; text-align: center; }

.practice-shell { max-width: 900px; margin: 0 auto; padding: 48px 0 72px; }
.practice-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.practice-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.practice-count { color: var(--muted); font-size: 14px; }
.progress-track { height: 8px; margin-bottom: 24px; overflow: hidden; border-radius: 999px; background: #e8e9f2; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #7d6ff2); transition: width 0.35s ease; }

.practice-card { padding: clamp(24px, 5vw, 44px); }
.prompt-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.prompt-label svg { width: 17px; height: 17px; }
.chinese-prompt { margin: 14px 0 10px; font-size: clamp(25px, 4vw, 36px); line-height: 1.48; letter-spacing: -0.02em; font-weight: 760; }
.prompt-subtext { margin: 0 0 28px; color: var(--muted); font-size: 13px; }
.hint-box {
  display: none;
  margin: -10px 0 22px;
  padding: 14px 16px;
  border: 1px solid #e0defd;
  border-radius: 14px;
  color: #554d98;
  background: #f6f5ff;
  font-size: 14px;
}
.hint-box.is-visible { display: block; animation: viewIn 0.2s ease; }
.answer-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; font-size: 14px; font-weight: 760; }
.answer-label span:last-child { color: var(--muted); font-size: 12px; font-weight: 500; }
.answer-input {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 18px 18px 50px;
  border: 1.5px solid #dfe1eb;
  border-radius: 17px;
  color: var(--text);
  background: #fbfbfd;
  outline: none;
  transition: border 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.answer-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(81, 70, 229, 0.09); }
.answer-wrap { position: relative; }
.mic-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: var(--primary);
  background: var(--primary-soft);
}
.mic-button svg { width: 18px; height: 18px; }
.mic-button.is-listening { color: white; background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229,88,104,.3); } 50% { box-shadow: 0 0 0 9px rgba(229,88,104,0); } }

.practice-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; }
.left-actions { display: flex; gap: 8px; }
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}
.text-button:hover { color: var(--primary); background: var(--primary-soft); }
.text-button svg { width: 16px; height: 16px; }
.keyboard-tip { margin-top: 16px; color: #9699aa; font-size: 11px; text-align: right; }

.feedback-layout { max-width: 980px; margin: 0 auto; padding: 48px 0 72px; }
.feedback-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 28px;
  margin-bottom: 20px;
}
.score-block { display: flex; align-items: center; gap: 18px; }
.score-ring {
  --score: 82;
  width: 94px;
  height: 94px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: conic-gradient(var(--primary) calc(var(--score) * 1%), #e9eaf2 0);
  position: relative;
}
.score-ring::before { content: ""; position: absolute; width: 75px; height: 75px; border-radius: inherit; background: white; }
.score-ring strong { position: relative; z-index: 1; font-size: 27px; }
.score-copy h1 { margin: 0 0 4px; font-size: 25px; }
.score-copy p { margin: 0; color: var(--muted); font-size: 14px; }
.feedback-top-actions { display: flex; gap: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card { padding: 17px; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-value { display: flex; align-items: center; justify-content: space-between; margin: 7px 0 9px; }
.metric-value strong { font-size: 20px; }
.metric-bar { height: 6px; overflow: hidden; border-radius: 99px; background: #ebecf3; }
.metric-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.feedback-grid { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 20px; }
.feedback-column { display: grid; gap: 20px; align-content: start; }
.feedback-card { padding: 24px; }
.card-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
}
.card-icon svg, .dash-icon svg { width: 18px; height: 18px; }
.card-icon.good { color: #128464; background: var(--accent-soft); }
.card-icon.warn { color: #9a6819; background: #fff6e8; }
.card-heading h2 { margin: 0; font-size: 17px; }
.user-answer {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  color: #40445a;
  background: #f6f7fa;
  font-size: 16px;
}
.feedback-list { margin: 0; padding: 0; list-style: none; }
.feedback-list li { position: relative; padding-left: 24px; color: #4b5066; }
.feedback-list li + li { margin-top: 12px; }
.feedback-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 900; }
.feedback-list.issues li::before { content: "!"; color: var(--warning); }
.issue-title { display: block; color: var(--text); font-weight: 760; }
.issue-detail { color: var(--muted); font-size: 13px; }

.sentence-option { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: #fbfbfd; }
.sentence-option + .sentence-option { margin-top: 10px; }
.sentence-option-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.sentence-option-head span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.play-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: var(--primary);
  background: var(--primary-soft);
}
.play-button svg { width: 15px; height: 15px; }
.sentence-option p { margin: 0; font-size: 16px; line-height: 1.6; }
.pattern-box { padding: 17px; border-radius: 15px; background: linear-gradient(135deg, #f1efff, #f7f6ff); }
.pattern-box code { color: var(--primary-dark); font-family: inherit; font-size: 16px; font-weight: 800; }
.pattern-box p { margin: 7px 0 0; color: #625d87; font-size: 13px; }
.next-practice { margin-top: 14px; padding-top: 14px; border-top: 1px dashed #d9d7ef; }
.next-practice span { color: var(--muted); font-size: 12px; }
.next-practice p { margin: 4px 0 0; font-weight: 720; }
.feedback-actions { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }

.empty-state { padding: 64px 24px; text-align: center; }
.empty-illustration {
  width: 90px;
  height: 90px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 28px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 38px;
}
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { max-width: 500px; margin: 0 auto 22px; color: var(--muted); }

.review-list { display: grid; gap: 14px; }
.review-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 20px;
}
.review-score {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 900;
}
.review-copy h3 { margin: 0 0 3px; font-size: 16px; }
.review-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.review-reference { margin-top: 7px !important; color: #3c4055 !important; }
.review-actions { display: flex; gap: 8px; }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: white;
}
.icon-button:hover { color: var(--primary); border-color: #cecafd; }
.icon-button svg { width: 17px; height: 17px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.dashboard-stat { padding: 22px; }
.dashboard-stat .dash-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
}
.dashboard-stat span { color: var(--muted); font-size: 12px; }
.dashboard-stat strong { display: block; margin-top: 3px; font-size: 28px; }
.dashboard-stat small { color: var(--accent); }

.dashboard-content { display: grid; grid-template-columns: 1.4fr .8fr; gap: 20px; }
.chart-card, .skill-card { padding: 25px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.card-title-row h2 { margin: 0; font-size: 18px; }
.card-title-row span { color: var(--muted); font-size: 12px; }
.bar-chart { min-height: 230px; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 12px; padding-top: 20px; }
.bar-column { height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 8px; }
.bar-column i { width: min(32px, 80%); min-height: 8px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #7e71ee, var(--primary)); }
.bar-column strong { color: #42465a; font-size: 11px; }
.bar-column span { color: var(--muted); font-size: 11px; }
.skill-list { display: grid; gap: 20px; }
.skill-row-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 13px; }
.skill-row-top span:last-child { color: var(--muted); }
.skill-track { height: 8px; overflow: hidden; border-radius: 999px; background: #ebecf3; }
.skill-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.insight-card { grid-column: 1 / -1; padding: 25px; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; }
.insight-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; color: #a76812; background: #fff4df; font-size: 24px; }
.insight-card h3 { margin: 0 0 4px; font-size: 16px; }
.insight-card p { margin: 0; color: var(--muted); font-size: 13px; }

.complete-card { max-width: 760px; margin: 62px auto 80px; padding: 46px; text-align: center; }
.complete-icon {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  border-radius: 26px;
  color: white;
  background: linear-gradient(135deg, var(--accent), #57ceb0);
  box-shadow: 0 15px 30px rgba(35, 179, 142, .24);
  font-size: 36px;
}
.complete-card h1 { margin: 0; font-size: 34px; }
.complete-card > p { margin: 8px 0 28px; color: var(--muted); }
.complete-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.complete-stat { padding: 18px; border-radius: 16px; background: #f7f7fb; }
.complete-stat span { color: var(--muted); font-size: 12px; }
.complete-stat strong { display: block; margin-top: 4px; font-size: 25px; }
.complete-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.site-footer {
  width: min(calc(100% - 36px), var(--max));
  margin: 0 auto;
  padding: 24px 12px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #999cad;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 28px;
  max-width: min(90vw, 520px);
  padding: 12px 18px;
  border-radius: 13px;
  color: white;
  background: #25283a;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .22s ease;
  font-size: 13px;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 62px; }
  .hero-copy { text-align: center; }
  .hero-copy > p { margin-inline: auto; }
  .hero-actions { justify-content: center; }
  .hero-visual { width: min(100%, 560px); margin: 0 auto; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .setup-layout { grid-template-columns: 1fr; }
  .setup-summary { position: static; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-content { grid-template-columns: 1fr; }
  .insight-card { grid-column: auto; }
}

@media (max-width: 820px) {
  .site-header { flex-wrap: wrap; }
  .brand { min-width: auto; }
  .mobile-menu { display: block; }
  .main-nav {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    order: 3;
    background: transparent;
  }
  .main-nav.is-open { display: flex; }
  .nav-link { width: 100%; text-align: left; }
  .steps-grid { grid-template-columns: 1fr; }
  .feedback-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .site-header, #app, .site-footer { width: min(calc(100% - 24px), var(--max)); }
  .site-header { top: 8px; margin-top: 8px; padding: 10px 12px; }
  .brand-copy small { display: none; }
  .hero { padding: 52px 6px 32px; }
  .hero h1 { font-size: 42px; }
  .hero-copy > p { font-size: 16px; }
  .hero-actions .btn { width: 100%; }
  .hero-visual { min-height: 430px; }
  .demo-card { inset: 6px 0 34px; padding: 23px; }
  .demo-question { font-size: 19px; }
  .floating-badge.score { left: 4px; bottom: 24px; }
  .floating-badge.streak { right: 4px; top: 55px; }
  .stats-strip, .dashboard-grid { grid-template-columns: 1fr 1fr; padding-inline: 6px; }
  .section, .page-wrap { padding-inline: 6px; }
  .section-head, .page-heading.inline { align-items: start; flex-direction: column; }
  .setup-form, .setup-summary { padding: 22px; }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .topic-grid, .mode-row { grid-template-columns: 1fr; }
  .practice-shell, .feedback-layout { padding-top: 32px; }
  .practice-topbar { align-items: start; }
  .practice-card { padding: 24px 20px; }
  .practice-actions { align-items: stretch; flex-direction: column; }
  .practice-actions > .btn { width: 100%; }
  .left-actions { justify-content: space-between; }
  .feedback-banner { align-items: start; flex-direction: column; }
  .feedback-top-actions { width: 100%; }
  .feedback-top-actions .btn { flex: 1; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .review-item { grid-template-columns: auto 1fr; }
  .review-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .insight-card { grid-template-columns: auto 1fr; }
  .insight-card .btn { grid-column: 1 / -1; width: 100%; }
  .complete-card { padding: 30px 20px; }
  .complete-stats { grid-template-columns: 1fr; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ================================================================
   Focus typing experience — redesigned to mirror the annotated,
   word-by-word practice screen requested for Say It in English.
   ================================================================ */
body.practice-focus {
  overflow: hidden;
  background: #ffffff;
}

body.practice-focus .site-header,
body.practice-focus .site-footer,
body.practice-focus .page-glow {
  display: none !important;
}

body.practice-focus #app {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  margin: 0;
}

body.practice-focus .toast {
  bottom: 126px;
}

.typing-practice {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 82px 84px minmax(0, 1fr) 112px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(45, 112, 236, 0.035), transparent 35%),
    linear-gradient(180deg, #ffffff 0%, #fdfefe 100%);
  color: #101526;
}

.typing-header {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(240px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 14px clamp(24px, 3vw, 48px);
  border-bottom: 1px solid #eceff4;
  background: rgba(255, 255, 255, 0.94);
}

.typing-brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  color: #111628;
  background: transparent;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.typing-brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, #296fe7 0%, #5246e5 52%, #12aa93 100%);
  box-shadow: 0 8px 20px rgba(55, 75, 189, 0.18);
}

.typing-brand-mark svg {
  width: 27px;
  height: 27px;
}

.typing-mode-title {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 10px 22px;
  border: 1px solid #e5e9f0;
  border-radius: 999px;
  color: #7a8192;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(20, 31, 61, 0.04);
  font-size: 13px;
  white-space: nowrap;
}

.typing-mode-title i {
  color: #a6adba;
  font-style: normal;
}

.typing-mode-title strong {
  color: #246ddf;
  font-weight: 800;
}

.typing-tools {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-tools button {
  min-width: 62px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 6px 9px;
  border: 0;
  border-radius: 12px;
  color: #5f687b;
  background: transparent;
  font-size: 11px;
  transition: 0.18s ease;
}

.typing-tools button:hover {
  color: #1f66d7;
  background: #f2f6fd;
}

.typing-tools svg {
  width: 23px;
  height: 23px;
}

.typing-progress-row {
  width: min(100%, 1540px);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 18px clamp(28px, 4vw, 64px) 6px;
}

.typing-progress-block {
  width: 190px;
}

.typing-progress-number {
  display: flex;
  align-items: baseline;
  margin-bottom: 8px;
  color: #7b8495;
  line-height: 1;
}

.typing-progress-number strong {
  color: #1f6fdf;
  font-size: 25px;
  font-weight: 850;
}

.typing-progress-number span {
  font-size: 18px;
  font-weight: 550;
}

.typing-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f5;
}

.typing-progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2875e6, #4f63df);
  box-shadow: 0 2px 8px rgba(40, 117, 230, 0.25);
  transition: width 0.3s ease;
}

.typing-session-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 3px;
}

.typing-session-meta > span:last-child {
  min-width: 70px;
  color: #8b93a2;
  font-size: 12px;
  text-align: right;
}

.typing-stage {
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 8px clamp(26px, 6vw, 96px) 18px;
  outline: none;
  cursor: text;
}

.typing-stage-note {
  min-height: 20px;
  margin-bottom: 18px;
  color: #a0a7b4;
  font-size: 11px;
  letter-spacing: 0.01em;
  text-align: center;
}

.word-canvas {
  width: min(100%, 1360px);
  min-height: 218px;
  display: flex;
  align-content: center;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: clamp(12px, 1.5vw, 26px);
  row-gap: 44px;
  padding: 8px 8px 24px;
}

.word-canvas.is-empty {
  align-items: center;
}

.typing-word {
  min-width: max-content;
  position: relative;
  display: grid;
  grid-template-rows: 24px auto 4px 25px;
  justify-items: stretch;
  align-items: end;
  padding: 0;
  border: 0;
  color: #0d1220;
  background: transparent;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.typing-word:hover {
  transform: translateY(-3px);
}

.typing-word:focus-visible {
  border-radius: 8px;
  outline: 3px solid rgba(43, 113, 226, 0.2);
  outline-offset: 7px;
}

.typing-phonetic {
  min-height: 22px;
  align-self: start;
  color: #8b93a2;
  font-family: "Segoe UI", "Arial Unicode MS", sans-serif;
  font-size: clamp(12px, 1.05vw, 16px);
  font-weight: 450;
  letter-spacing: 0.01em;
  line-height: 1.15;
  white-space: nowrap;
}

.typing-word-text {
  display: block;
  padding: 0 2px 8px;
  font-size: clamp(39px, 4.5vw, 70px);
  font-weight: 460;
  letter-spacing: -0.045em;
  line-height: 0.98;
  white-space: nowrap;
}

.typing-word-line {
  width: 100%;
  height: 4px;
  display: block;
  border-radius: 99px;
  background: #2875e6;
  box-shadow: 0 2px 7px rgba(40, 117, 230, 0.17);
}

.typing-word.tone-1 .typing-word-line { background: #17b77c; box-shadow: 0 2px 7px rgba(23, 183, 124, 0.16); }
.typing-word.tone-2 .typing-word-line { background: #6d55df; box-shadow: 0 2px 7px rgba(109, 85, 223, 0.16); }
.typing-word.tone-3 .typing-word-line { background: #168fa9; box-shadow: 0 2px 7px rgba(22, 143, 169, 0.16); }

.typing-word.is-unknown .typing-phonetic,
.typing-word.is-unknown .typing-gloss {
  color: #a9afba;
}

.typing-word.is-unknown .typing-word-line {
  height: 3px;
  background: repeating-linear-gradient(90deg, #afb5c1 0 6px, transparent 6px 10px);
  box-shadow: none;
}

.typing-gloss {
  min-height: 24px;
  max-width: 180px;
  justify-self: center;
  overflow: hidden;
  padding-top: 8px;
  color: #838b9b;
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-punctuation {
  align-self: center;
  margin: 0 0 27px -12px;
  color: #0d1220;
  font-size: clamp(39px, 4.5vw, 70px);
  font-weight: 500;
  line-height: 1;
}

.typing-caret-slot {
  min-width: 8px;
  height: 83px;
  display: inline-flex;
  align-items: center;
  align-self: center;
  margin: 1px 0 20px -12px;
}

.typing-live-caret {
  width: 3px;
  height: clamp(38px, 4.1vw, 62px);
  display: inline-block;
  border-radius: 99px;
  background: #2875e6;
  animation: typingBlink 1.05s steps(1, end) infinite;
}

@keyframes typingBlink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

.typing-empty-state {
  width: 100%;
  display: grid;
  place-items: center;
  gap: 12px;
  color: #a3a9b5;
  text-align: center;
}

.typing-empty-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.typing-empty-text {
  color: #727b8d;
  font-size: clamp(28px, 3.4vw, 50px);
  font-weight: 430;
  letter-spacing: -0.035em;
}

.typing-empty-state .typing-live-caret {
  height: clamp(34px, 3.3vw, 48px);
}

.typing-empty-state p {
  margin: 0;
  color: #a1a8b4;
  font-size: 13px;
}

.typing-hint {
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: min(100%, 900px);
  margin: -4px 0 12px;
  padding: 10px 16px;
  border: 1px solid #dfe8f8;
  border-radius: 13px;
  color: #44536c;
  background: #f6f9fe;
  font-size: 12px;
}

.typing-hint.is-visible {
  display: flex;
  animation: viewIn 0.18s ease both;
}

.typing-hint span {
  color: #2470dd;
  font-weight: 800;
}

.typing-hint strong {
  color: #1e2737;
  font-size: 13px;
}

.typing-hint p {
  margin: 0;
  color: #9299a7;
}

.typing-prompt {
  width: min(100%, 1100px);
  margin-top: 5px;
  text-align: center;
}

.typing-prompt > span {
  display: block;
  margin-bottom: 5px;
  color: #929aa8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.typing-prompt p {
  margin: 0;
  color: #4f586a;
  font-size: clamp(16px, 1.45vw, 22px);
  font-weight: 540;
  line-height: 1.7;
}

.typing-prompt small {
  display: block;
  margin-top: 5px;
  color: #a0a7b4;
  font-size: 11px;
}

.typing-capture {
  position: fixed;
  z-index: -1;
  left: 50%;
  bottom: 108px;
  width: 2px;
  height: 2px;
  padding: 0;
  border: 0;
  opacity: 0.01;
  resize: none;
  outline: 0;
  caret-color: transparent;
}

.typing-controls {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 86px;
  align-items: center;
  gap: 20px;
  padding: 14px clamp(28px, 4vw, 64px) 20px;
  border-top: 1px solid #eff1f5;
  background: rgba(255, 255, 255, 0.97);
}

.typing-nav-button {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  justify-self: end;
  border: 1px solid #e0e5ed;
  border-radius: 17px;
  color: #11182a;
  background: white;
  box-shadow: 0 7px 18px rgba(24, 36, 66, 0.06);
  transition: 0.18s ease;
}

.typing-nav-button.is-back {
  justify-self: start;
}

.typing-nav-button:hover {
  color: white;
  border-color: #2a72df;
  background: #2a72df;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(42, 114, 223, 0.22);
}

.typing-nav-button svg {
  width: 28px;
  height: 28px;
}

.typing-shortcuts {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.typing-shortcut {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 6px 12px;
  border: 1px solid #e1e6ee;
  border-radius: 11px;
  color: #566074;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(25, 37, 66, 0.025);
  font-size: 12px;
  font-weight: 650;
  transition: 0.17s ease;
}

.typing-shortcut:hover {
  color: #1f68d5;
  border-color: #bfd3f3;
  background: #f7faff;
}

.typing-shortcut.is-primary {
  color: #1f67d4;
  border-color: #cbdcf7;
  background: #f4f8ff;
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-shortcut kbd {
  min-width: 26px;
  padding: 3px 6px;
  border: 1px solid #e2e6ed;
  border-bottom-width: 2px;
  border-radius: 6px;
  color: #30394a;
  background: #fafbfd;
  font-family: inherit;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.25;
}

.shortcut-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #2470dd;
  background: #edf4ff;
}

.shortcut-icon svg {
  width: 16px;
  height: 16px;
}

.typing-mic.is-listening {
  color: white;
  border-color: #e55868;
  background: #e55868;
  animation: pulse 1.2s infinite;
}

.typing-mic.is-listening .shortcut-icon {
  color: #e55868;
  background: white;
}

@media (max-width: 1180px) {
  .typing-practice { grid-template-rows: 78px 78px minmax(0, 1fr) 122px; }
  .typing-header { grid-template-columns: 1fr auto 1fr; padding-inline: 24px; }
  .typing-brand { font-size: 15px; }
  .typing-tools button { min-width: 48px; }
  .typing-tools button span { display: none; }
  .typing-shortcuts { gap: 7px; }
  .typing-shortcut { padding-inline: 9px; }
  .word-canvas { row-gap: 36px; }
  .typing-word-text, .typing-punctuation { font-size: clamp(37px, 4.8vw, 58px); }
}

@media (max-width: 860px) {
  body.practice-focus { overflow: auto; }
  body.practice-focus .toast { bottom: 24px; }
  .typing-practice {
    min-height: 100dvh;
    overflow: visible;
    grid-template-rows: auto auto minmax(520px, 1fr) auto;
  }
  .typing-header {
    grid-template-columns: 1fr auto;
    padding: 12px 18px;
  }
  .typing-mode-title { display: none; }
  .typing-tools { grid-column: 2; }
  .typing-progress-row { padding: 14px 18px 0; }
  .typing-progress-block { width: 145px; }
  .typing-session-meta .level-chip,
  .typing-session-meta .topic-chip { display: none; }
  .typing-stage { overflow: visible; padding: 16px 18px 28px; }
  .word-canvas {
    min-height: 250px;
    column-gap: 13px;
    row-gap: 32px;
    padding-inline: 0;
  }
  .typing-word { grid-template-rows: 20px auto 3px 22px; }
  .typing-phonetic { font-size: 11px; }
  .typing-word-text, .typing-punctuation { font-size: clamp(31px, 8vw, 46px); }
  .typing-gloss { max-width: 112px; font-size: 10px; }
  .typing-controls {
    grid-template-columns: 56px 1fr 56px;
    gap: 10px;
    padding: 12px 14px 18px;
  }
  .typing-nav-button { width: 52px; height: 52px; border-radius: 14px; }
  .typing-nav-button svg { width: 23px; height: 23px; }
  .typing-shortcut { min-height: 38px; }
  .typing-shortcut:nth-child(3),
  .typing-shortcut:nth-child(5) { display: none; }
}

@media (max-width: 560px) {
  .typing-header { padding-inline: 14px; }
  .typing-brand-mark { width: 36px; height: 36px; }
  .typing-brand > span:last-child { font-size: 13px; }
  .typing-tools { gap: 1px; }
  .typing-tools button { min-width: 38px; padding-inline: 5px; }
  .typing-tools svg { width: 20px; height: 20px; }
  .typing-progress-row { align-items: center; }
  .typing-progress-block { width: 120px; }
  .typing-progress-number strong { font-size: 21px; }
  .typing-progress-number span { font-size: 15px; }
  .typing-stage-note { margin-bottom: 8px; }
  .word-canvas { min-height: 310px; align-content: center; row-gap: 28px; }
  .typing-word { grid-template-rows: 18px auto 3px 20px; }
  .typing-word-text, .typing-punctuation { font-size: clamp(28px, 9.8vw, 39px); }
  .typing-word-line { height: 3px; }
  .typing-punctuation { margin-left: -8px; margin-bottom: 22px; }
  .typing-caret-slot { margin-left: -8px; }
  .typing-empty-text { font-size: 27px; }
  .typing-empty-state p { max-width: 280px; font-size: 11px; }
  .typing-prompt p { font-size: 16px; }
  .typing-prompt small { display: none; }
  .typing-hint p { display: none; }
  .typing-controls { grid-template-columns: 50px 1fr 50px; padding-inline: 10px; }
  .typing-nav-button { width: 46px; height: 46px; }
  .typing-shortcuts { gap: 5px; }
  .typing-shortcut {
    min-height: 36px;
    padding: 5px 8px;
    border-radius: 9px;
  }
  .typing-shortcut > span:last-child { display: none; }
  .typing-shortcut.is-primary > span:last-child { display: inline; }
  .typing-shortcut:nth-child(3),
  .typing-shortcut:nth-child(4),
  .typing-shortcut:nth-child(5) { display: none; }
}

/* ========================================================================
   Focus typing practice — word-by-word sentence canvas
   ======================================================================== */
body.practice-focus {
  min-height: 100vh;
  overflow-x: hidden;
  background: #ffffff;
}

body.practice-focus .page-glow,
body.practice-focus .site-header,
body.practice-focus .site-footer {
  display: none;
}

body.practice-focus #app {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
}

.typing-practice {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 22px 30px 24px;
  color: #101527;
  background:
    radial-gradient(circle at 50% 30%, rgba(67, 122, 255, 0.035), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fefeff 100%);
}

.typing-header,
.typing-progress-row,
.typing-stage,
.typing-controls {
  width: min(100%, 1500px);
  margin-inline: auto;
}

.typing-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 2px 4px 14px;
  border-bottom: 1px solid #eef0f5;
}

.typing-brand {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 4px;
  border: 0;
  border-radius: 13px;
  color: #12172a;
  background: transparent;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.025em;
}

.typing-brand:hover { background: #f6f8fc; }

.typing-brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  color: #ffffff;
  background: linear-gradient(135deg, #4f46e5 4%, #206fe7 50%, #18b793 100%);
  box-shadow: 0 9px 22px rgba(48, 92, 213, 0.2);
}

.typing-brand-mark svg { width: 28px; height: 28px; }

.typing-mode-title {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 8px 20px;
  border: 1px solid #e4e7ef;
  border-radius: 999px;
  color: #747a8d;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 18px rgba(37, 45, 78, 0.045);
  font-size: 14px;
  white-space: nowrap;
}

.typing-mode-title i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #99a0b1;
  font-style: normal;
  color: transparent;
}

.typing-mode-title strong { color: #2563eb; font-weight: 800; }

.typing-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.typing-tools button {
  min-width: 62px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 7px 8px;
  border: 0;
  border-radius: 12px;
  color: #3f465b;
  background: transparent;
  font-size: 11px;
}

.typing-tools button:hover {
  color: #1e5fd0;
  background: #f3f6fb;
}

.typing-tools svg { width: 25px; height: 25px; }

.typing-progress-row {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 4px 6px;
}

.typing-progress-block { width: 190px; }

.typing-progress-number {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: 8px;
  color: #81879a;
  font-variant-numeric: tabular-nums;
}

.typing-progress-number strong {
  color: #1769e0;
  font-size: 24px;
  line-height: 1;
}

.typing-progress-number span { font-size: 18px; }

.typing-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9edf4;
}

.typing-progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1769e0, #4c7df1);
  box-shadow: 0 0 14px rgba(23, 105, 224, 0.23);
  transition: width 0.3s ease;
}

.typing-session-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.typing-session-meta > span:last-child {
  min-width: 70px;
  padding-left: 8px;
  color: #888fa2;
  font-size: 12px;
  text-align: right;
}

.typing-stage {
  min-height: 600px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 54px 60px 34px;
  outline: none;
}

.typing-stage::before {
  content: "";
  position: absolute;
  inset: 20% 10%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 122, 238, 0.035), transparent 68%);
  pointer-events: none;
}

.typing-stage-note {
  position: absolute;
  top: 15px;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  color: #a2a7b5;
  font-size: 12px;
  white-space: nowrap;
}

.word-canvas {
  width: min(100%, 1320px);
  min-height: 310px;
  position: relative;
  z-index: 2;
  display: flex;
  align-content: center;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: clamp(16px, 2.2vw, 34px);
  row-gap: clamp(30px, 4vh, 50px);
  padding: 28px 6px;
}

.word-canvas.is-empty { min-height: 270px; }

.typing-word {
  --word-accent: #1f6fd9;
  min-width: 38px;
  display: inline-grid;
  grid-template-rows: 24px auto 4px 30px;
  align-items: center;
  justify-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  color: #101527;
  background: transparent;
  text-align: center;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.typing-word:hover { transform: translateY(-2px); }
.typing-word:focus-visible { outline: 3px solid rgba(31, 111, 217, 0.16); outline-offset: 8px; border-radius: 8px; }
.typing-word.tone-0 { --word-accent: #1769e0; }
.typing-word.tone-1 { --word-accent: #12a56d; }
.typing-word.tone-2 { --word-accent: #5b50e6; }
.typing-word.tone-3 { --word-accent: #0b8aa9; }

.typing-phonetic {
  min-height: 20px;
  color: #747b8f;
  font-family: "Segoe UI", "Arial Unicode MS", sans-serif;
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 450;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.typing-word-text {
  color: #0d1222;
  font-size: clamp(38px, 4.25vw, 66px);
  font-weight: 460;
  line-height: 1.04;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

.typing-word-line {
  width: calc(100% + 2px);
  min-width: 34px;
  height: 3px;
  border-radius: 99px;
  background: var(--word-accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--word-accent) 20%, transparent);
}

.typing-gloss {
  min-height: 24px;
  color: #777f92;
  font-size: clamp(11px, 1vw, 14px);
  line-height: 1.35;
  white-space: nowrap;
}

.typing-word.is-unknown .typing-phonetic,
.typing-word.is-unknown .typing-gloss { color: #a7acb8; }
.typing-word.is-unknown .typing-word-line { opacity: 0.48; }

.typing-punctuation {
  align-self: center;
  margin-left: clamp(-26px, -1.6vw, -12px);
  padding: 16px 0 22px;
  color: #101527;
  font-size: clamp(38px, 4.1vw, 64px);
  line-height: 1;
}

.typing-caret-slot {
  width: 3px;
  height: clamp(44px, 4.2vw, 66px);
  display: inline-flex;
  align-items: stretch;
  align-self: center;
  margin-left: -18px;
  margin-bottom: 2px;
}

.typing-live-caret {
  width: 2px;
  display: inline-block;
  border-radius: 99px;
  background: #1769e0;
  animation: typingCaret 1s steps(1, end) infinite;
}

@keyframes typingCaret { 0%, 48% { opacity: 1; } 49%, 100% { opacity: 0; } }

.typing-empty-state {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 38px 16px;
  text-align: center;
}

.typing-empty-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.typing-empty-text {
  padding: 0 0 8px;
  border-bottom: 3px solid #cfd8ec;
  color: #9da4b3;
  font-size: clamp(30px, 4vw, 56px);
  font-weight: 430;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.typing-empty-line .typing-live-caret { height: clamp(36px, 4vw, 56px); }
.typing-empty-state p { margin: 0; color: #9ba1b0; font-size: 13px; }

.typing-hint {
  width: min(100%, 880px);
  max-height: 0;
  position: relative;
  z-index: 2;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  border: 1px solid transparent;
  border-radius: 15px;
  background: #f7f8ff;
  transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.18s ease, padding 0.22s ease, margin 0.22s ease;
  text-align: center;
}

.typing-hint.is-visible {
  max-height: 150px;
  margin: 2px 0 22px;
  padding: 13px 18px;
  border-color: #e2e4fa;
  opacity: 1;
  transform: translateY(0);
}

.typing-hint span {
  display: block;
  margin-bottom: 2px;
  color: #8079bc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.typing-hint strong { color: #4f46a5; font-size: 15px; }
.typing-hint p { margin: 3px 0 0; color: #8d91a5; font-size: 11px; }

.typing-prompt {
  width: min(100%, 940px);
  position: relative;
  z-index: 2;
  margin-top: 24px;
  text-align: center;
}

.typing-prompt > span {
  color: #8790a3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.typing-prompt p {
  margin: 8px 0 5px;
  color: #3f4659;
  font-size: clamp(17px, 1.65vw, 23px);
  font-weight: 520;
  line-height: 1.65;
}

.typing-prompt small { color: #a0a5b2; font-size: 11px; }

.typing-capture {
  width: 1px;
  height: 1px;
  position: fixed;
  left: -10000px;
  bottom: -10000px;
  z-index: -1;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  pointer-events: none;
}

.typing-controls {
  min-height: 86px;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 66px;
  align-items: center;
  gap: 20px;
  padding: 12px 4px 0;
  border-top: 1px solid #f1f2f6;
}

.typing-nav-button {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid #e1e5ed;
  border-radius: 15px;
  color: #101827;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(38, 48, 74, 0.06);
  transition: transform 0.17s ease, border-color 0.17s ease, box-shadow 0.17s ease;
}

.typing-nav-button:hover {
  transform: translateY(-2px);
  border-color: #bac9e7;
  box-shadow: 0 12px 28px rgba(38, 48, 74, 0.1);
}

.typing-nav-button svg { width: 30px; height: 30px; }
.typing-nav-button.is-back { justify-self: start; }
.typing-controls > .typing-nav-button:last-child { justify-self: end; }

.typing-shortcuts {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}

.typing-shortcut {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 7px 12px;
  border: 1px solid #e4e7ed;
  border-radius: 11px;
  color: #3f4659;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(31, 43, 70, 0.035);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.typing-shortcut:hover {
  color: #1f5fc8;
  border-color: #cbd6ec;
  background: #f8faff;
}

.shortcut-keys { display: inline-flex; align-items: center; gap: 4px; }

.typing-shortcut kbd {
  min-width: 26px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border: 1px solid #e1e5ec;
  border-bottom-color: #cfd5df;
  border-radius: 6px;
  color: #333b4f;
  background: #f8f9fb;
  box-shadow: 0 1px 0 #d8dde6;
  font-family: inherit;
  font-size: 10px;
  font-weight: 750;
}

.typing-shortcut.is-primary {
  color: #ffffff;
  border-color: #4f46e5;
  background: #5146e5;
  box-shadow: 0 8px 20px rgba(81, 70, 229, 0.2);
}

.typing-shortcut.is-primary:hover { color: #ffffff; background: #4037c3; }
.typing-shortcut.is-primary kbd { color: #443bc2; border-color: #ffffff; background: #ffffff; box-shadow: none; }
.shortcut-icon { display: grid; place-items: center; }
.shortcut-icon svg { width: 18px; height: 18px; }

.typing-mic.is-listening {
  color: #ffffff;
  border-color: #e55868;
  background: #e55868;
  animation: pulse 1.2s infinite;
}

body.practice-focus .toast { z-index: 1000; }

@media (max-width: 1120px) {
  .typing-practice { padding-inline: 22px; }
  .typing-stage { min-height: 560px; padding-inline: 28px; }
  .word-canvas { min-height: 280px; column-gap: 22px; }
  .typing-header { grid-template-columns: 1fr auto 1fr; }
  .typing-shortcut { padding-inline: 9px; }
}

@media (max-width: 860px) {
  .typing-practice { padding: 14px 16px 18px; }
  .typing-header {
    min-height: 64px;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding-bottom: 10px;
  }
  .typing-mode-title { display: none; }
  .typing-tools button { min-width: 48px; }
  .typing-tools button span { display: none; }
  .typing-progress-row { min-height: 64px; padding-top: 10px; }
  .typing-stage { min-height: 520px; padding: 44px 10px 24px; }
  .word-canvas { min-height: 250px; row-gap: 31px; }
  .typing-word { grid-template-rows: 20px auto 3px 25px; gap: 5px; }
  .typing-controls { grid-template-columns: 52px minmax(0, 1fr) 52px; gap: 10px; }
  .typing-nav-button { width: 48px; height: 48px; border-radius: 13px; }
  .typing-nav-button svg { width: 25px; height: 25px; }
  .typing-shortcuts {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 8px 4px 10px;
    scrollbar-width: none;
  }
  .typing-shortcuts::-webkit-scrollbar { display: none; }
}

@media (max-width: 620px) {
  body.practice-focus #app { width: 100%; }
  .typing-practice { padding: 10px 11px 14px; }
  .typing-brand { gap: 8px; font-size: 14px; }
  .typing-brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .typing-brand-mark svg { width: 24px; height: 24px; }
  .typing-tools { gap: 2px; }
  .typing-tools button { min-width: 38px; padding-inline: 5px; }
  .typing-tools svg { width: 22px; height: 22px; }
  .typing-progress-block { width: 120px; }
  .typing-progress-number strong { font-size: 20px; }
  .typing-progress-number span { font-size: 15px; }
  .typing-session-meta .level-chip,
  .typing-session-meta .topic-chip { display: none; }
  .typing-stage { min-height: calc(100vh - 235px); padding: 36px 2px 16px; }
  .typing-stage-note { top: 7px; font-size: 10px; }
  .word-canvas {
    min-height: 220px;
    justify-content: flex-start;
    column-gap: 15px;
    row-gap: 25px;
    padding-inline: 8px;
  }
  .typing-word { min-width: 30px; grid-template-rows: 17px auto 3px 22px; gap: 4px; }
  .typing-word-text { font-size: clamp(29px, 9vw, 42px); }
  .typing-phonetic, .typing-gloss { font-size: 10px; }
  .typing-punctuation { margin-left: -11px; padding-top: 11px; font-size: 35px; }
  .typing-caret-slot { height: 38px; margin-left: -10px; }
  .typing-empty-text { font-size: 30px; }
  .typing-empty-state p { max-width: 270px; font-size: 11px; }
  .typing-prompt { margin-top: 12px; }
  .typing-prompt p { font-size: 16px; }
  .typing-prompt small { display: none; }
  .typing-controls { min-height: 68px; grid-template-columns: 44px minmax(0, 1fr) 44px; padding-top: 7px; }
  .typing-nav-button { width: 42px; height: 42px; }
  .typing-shortcut { min-height: 38px; padding: 6px 9px; }
  .typing-shortcut kbd { height: 22px; min-width: 22px; }
}

/* Keep the keyboard capture field available to focus without extending the page. */
.typing-capture {
  position: fixed;
  top: 0;
  left: 0;
  bottom: auto;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}

/* Keep the navigation/shortcut bar pinned inside the viewport on desktop. */
@media (min-width: 861px) {
  .typing-practice {
    height: 100dvh;
    min-height: 0;
  }
  .typing-stage {
    min-height: 0;
  }
}

.typing-inline-punctuation {
  display: inline;
  margin-left: 0.025em;
  color: inherit;
}

@media (max-width: 560px) {
  .typing-shortcut.is-primary > span:last-child { display: none; }
}

/* ========================================================================
   Listening + sentence completion update
   The full sentence skeleton is visible before the learner starts typing.
   ======================================================================== */
.word-canvas.sentence-slots {
  align-items: center;
  align-content: center;
  column-gap: clamp(14px, 1.7vw, 28px);
  row-gap: clamp(26px, 3.7vh, 46px);
}

.word-canvas.sentence-slots .typing-word {
  width: var(--slot-width, 132px);
  min-width: 0;
  grid-template-rows: 22px minmax(58px, auto) 4px 27px;
  gap: 5px;
  cursor: text;
}

.word-canvas.sentence-slots .typing-word-text {
  width: 100%;
  min-width: 0;
  min-height: 1.08em;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 0 1px 8px;
  overflow: visible;
  text-align: center;
}

.typing-word-entry {
  min-width: 1px;
  overflow: visible;
  white-space: nowrap;
}

.word-canvas.sentence-slots .typing-word-line {
  width: 100%;
  opacity: 0.86;
  transition: opacity 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.word-canvas.sentence-slots .typing-word.is-empty-slot .typing-phonetic,
.word-canvas.sentence-slots .typing-word.is-empty-slot .typing-gloss {
  visibility: hidden;
}

.word-canvas.sentence-slots .typing-word.is-empty-slot .typing-word-entry {
  opacity: 0;
}

.word-canvas.sentence-slots .typing-word.is-empty-slot .typing-word-line {
  opacity: 0.62;
  box-shadow: 0 1px 5px color-mix(in srgb, var(--word-accent) 12%, transparent);
}

.word-canvas.sentence-slots .typing-word.is-active .typing-word-line {
  opacity: 1;
  transform: scaleY(1.25);
  box-shadow: 0 3px 14px color-mix(in srgb, var(--word-accent) 30%, transparent);
  animation: slotLinePulse 1.45s ease-in-out infinite;
}

.word-canvas.sentence-slots .typing-word.is-active .typing-word-text {
  color: #1769e0;
}

.word-canvas.sentence-slots .typing-word.is-filled .typing-word-line {
  opacity: 0.92;
}

.word-canvas.sentence-slots .typing-word.is-committed .typing-word-line {
  opacity: 1;
}

.word-canvas.sentence-slots.is-complete .typing-word-line {
  opacity: 1;
}

.typing-inline-caret {
  width: 2px;
  height: 0.9em;
  display: inline-block;
  flex: 0 0 auto;
  align-self: flex-end;
  margin: 0 1px 0 0;
  border-radius: 99px;
  background: #1769e0;
  animation: typingCaret 1s steps(1, end) infinite;
}

.typing-inline-punctuation.is-target-punctuation {
  display: inline-block;
  margin-left: 0.02em;
  color: #101527;
  opacity: 0.78;
}

.word-canvas.sentence-slots .typing-word.is-empty-slot .is-target-punctuation {
  opacity: 0.42;
}

.word-canvas.sentence-slots .typing-word.is-overflow {
  --word-accent: #dc5968;
}

.word-canvas.sentence-slots .typing-word.is-overflow .typing-word-line {
  background: #dc5968;
  box-shadow: 0 2px 10px rgba(220, 89, 104, 0.18);
}

.word-canvas.sentence-slots .typing-word.is-overflow .typing-gloss {
  color: #bd4c5a;
}

.word-canvas.sentence-slots.is-long {
  column-gap: clamp(12px, 1.3vw, 22px);
  row-gap: clamp(24px, 3.1vh, 38px);
}

.word-canvas.sentence-slots.is-long .typing-word {
  width: min(var(--slot-width, 132px), 230px);
}

.word-canvas.sentence-slots.is-long .typing-word-text {
  font-size: clamp(31px, 3.35vw, 54px);
}

.word-canvas.sentence-slots.is-very-long {
  column-gap: 12px;
  row-gap: 28px;
}

.word-canvas.sentence-slots.is-very-long .typing-word {
  width: min(var(--slot-width, 122px), 205px);
  grid-template-rows: 19px minmax(48px, auto) 3px 23px;
}

.word-canvas.sentence-slots.is-very-long .typing-word-text {
  font-size: clamp(27px, 2.85vw, 46px);
}

.word-canvas.sentence-slots.is-very-long .typing-phonetic,
.word-canvas.sentence-slots.is-very-long .typing-gloss {
  font-size: 10px;
}

.typing-shortcut.is-listen-primary {
  color: #145fcf;
  border-color: #bad2f7;
  background: linear-gradient(180deg, #f5f9ff 0%, #edf5ff 100%);
  box-shadow: 0 7px 18px rgba(42, 111, 215, 0.1);
}

.typing-shortcut.is-listen-primary:hover {
  color: #0e55be;
  border-color: #91b8ef;
  background: #eaf3ff;
}

.typing-shortcut.is-listen-primary .shortcut-icon {
  color: #1769e0;
  background: #dcecff;
}

.typing-shortcut.is-listen-primary.is-playing {
  color: #ffffff;
  border-color: #1769e0;
  background: #1769e0;
  box-shadow: 0 9px 24px rgba(23, 105, 224, 0.25);
}

.typing-shortcut.is-listen-primary.is-playing .shortcut-icon {
  color: #1769e0;
  background: #ffffff;
  animation: listeningPulse 1.1s ease-in-out infinite;
}

@keyframes slotLinePulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

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

@media (max-width: 1120px) {
  .word-canvas.sentence-slots .typing-word {
    width: var(--slot-tablet-width, 112px);
  }

  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    width: min(var(--slot-tablet-width, 112px), 205px);
  }
}

@media (max-width: 620px) {
  .word-canvas.sentence-slots {
    justify-content: center;
    column-gap: 12px;
    row-gap: 24px;
    padding-inline: 3px;
  }

  .word-canvas.sentence-slots .typing-word,
  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    width: var(--slot-mobile-width, 82px);
    grid-template-rows: 16px minmax(38px, auto) 3px 20px;
    gap: 3px;
  }

  .word-canvas.sentence-slots .typing-word-text,
  .word-canvas.sentence-slots.is-long .typing-word-text,
  .word-canvas.sentence-slots.is-very-long .typing-word-text {
    font-size: clamp(27px, 8.2vw, 38px);
    padding-bottom: 6px;
  }

  .word-canvas.sentence-slots .typing-phonetic,
  .word-canvas.sentence-slots .typing-gloss {
    font-size: 9px;
  }

  .typing-shortcut.is-my-sentence {
    display: none;
  }
}


/* Listening result: word-by-word source sentence comparison. */
.comparison-note {
  margin: -3px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.dictation-comparison {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dictation-token {
  min-width: 74px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: center;
}

.dictation-token strong {
  font-size: 15px;
  line-height: 1.2;
}

.dictation-token small {
  max-width: 130px;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dictation-token.is-correct {
  color: #147451;
  border-color: #bde8d7;
  background: #effbf6;
}

.dictation-token.is-wrong {
  color: #af4350;
  border-color: #f0c3c9;
  background: #fff3f4;
}

.dictation-extra {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #af4350;
  background: #fff3f4;
  font-size: 12px;
}

.dictation-extra span { color: #be6873; }

@media (max-width: 620px) {
  .dictation-comparison { gap: 7px; }
  .dictation-token { min-width: 64px; padding: 8px 9px; }
}


/* Prominent listening callout for the sentence-completion flow. */
.listening-callout {
  width: min(100%, 760px);
  position: relative;
  z-index: 3;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 14px;
}

.listen-hero-button,
.listen-speed-button {
  border: 1px solid #dfe5ef;
  border-radius: 16px;
  box-shadow: 0 9px 24px rgba(39, 52, 86, 0.07);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.listen-hero-button {
  min-width: 360px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 18px 11px 11px;
  color: #ffffff;
  border-color: #4e51df;
  background: linear-gradient(135deg, #5146e5 0%, #2563eb 100%);
  text-align: left;
  box-shadow: 0 13px 30px rgba(68, 70, 211, 0.22);
}

.listen-hero-button:hover,
.listen-hero-button.is-playing {
  transform: translateY(-2px);
  box-shadow: 0 17px 36px rgba(68, 70, 211, 0.28);
}

.listen-hero-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #5146e5;
  background: #ffffff;
}

.listen-hero-icon svg { width: 20px; height: 20px; margin-left: 2px; }
.listen-hero-button > span:last-child { display: grid; gap: 1px; }
.listen-hero-button strong { font-size: 14px; line-height: 1.35; }
.listen-hero-button small { color: rgba(255, 255, 255, 0.77); font-size: 10px; }

.listen-speed-button {
  min-width: 118px;
  display: grid;
  place-content: center;
  gap: 1px;
  padding: 8px 15px;
  color: #4c5368;
  background: #ffffff;
  font-size: 11px;
}

.listen-speed-button strong { color: #2f64c8; font-size: 14px; }
.listen-speed-button:hover,
.listen-speed-button.is-playing {
  transform: translateY(-2px);
  color: #2458bc;
  border-color: #b9cdef;
  background: #f7faff;
}

.listen-hero-button.is-playing .listen-hero-icon,
.listen-speed-button.is-playing {
  animation: listeningPulse 1.1s ease-in-out infinite;
}

@media (max-width: 760px) {
  .listening-callout { flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
  .listen-hero-button { width: 100%; min-width: 0; justify-content: center; }
  .listen-speed-button { min-width: 150px; }
}

@media (max-width: 620px) {
  .listen-hero-button { padding: 8px 12px 8px 8px; }
  .listen-hero-icon { width: 36px; height: 36px; }
  .listen-hero-button strong { font-size: 13px; }
  .listen-hero-button small { display: none; }
  .listen-speed-button { min-height: 36px; padding-block: 5px; }
}


/* ========================================================================
   Real-time word validation + automatic focus advance
   Each underline is now an independent input box.
   ======================================================================== */
.word-canvas.sentence-slots .typing-word-text {
  position: relative;
  overflow: visible;
}

.word-slot-input {
  width: 0;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  padding: 0 2px 8px;
  border: 0;
  outline: 0;
  border-radius: 0;
  color: #101527;
  background: transparent;
  caret-color: #1769e0;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  transition: color 0.16s ease, text-shadow 0.16s ease;
}

.word-slot-input:focus {
  outline: none;
}

.word-slot-input::selection {
  color: #0f4fad;
  background: rgba(87, 153, 239, 0.2);
}

.word-canvas.sentence-slots .typing-word.is-empty-slot .word-slot-input {
  color: #1769e0;
}

.word-canvas.sentence-slots .typing-word.is-partial {
  --word-accent: #2979e8;
}

.word-canvas.sentence-slots .typing-word.is-partial .word-slot-input {
  color: #1769e0;
}

.word-canvas.sentence-slots .typing-word.is-partial .typing-phonetic,
.word-canvas.sentence-slots .typing-word.is-partial .typing-gloss {
  visibility: visible;
  color: #8a96aa;
}

.word-canvas.sentence-slots .typing-word.is-wrong {
  --word-accent: #e3485d;
}

.word-canvas.sentence-slots .typing-word.is-wrong .word-slot-input {
  color: #d9344c;
  text-shadow: 0 3px 14px rgba(227, 72, 93, 0.12);
}

.word-canvas.sentence-slots .typing-word.is-wrong .typing-word-line {
  opacity: 1;
  background: #e3485d;
  box-shadow: 0 3px 13px rgba(227, 72, 93, 0.28);
}

.word-canvas.sentence-slots .typing-word.is-wrong .typing-phonetic,
.word-canvas.sentence-slots .typing-word.is-wrong .typing-gloss {
  visibility: visible;
  color: #d04457;
  font-weight: 650;
}

.word-canvas.sentence-slots .typing-word.is-correct {
  --word-accent: #13a873;
}

.word-canvas.sentence-slots .typing-word.is-correct .word-slot-input {
  color: #087d56;
  font-weight: 560;
}

.word-canvas.sentence-slots .typing-word.is-correct .typing-word-line {
  opacity: 1;
  background: #13a873;
  box-shadow: 0 3px 13px rgba(19, 168, 115, 0.23);
}

.word-canvas.sentence-slots .typing-word.is-correct .typing-phonetic,
.word-canvas.sentence-slots .typing-word.is-correct .typing-gloss {
  visibility: visible;
}

.word-canvas.sentence-slots .typing-word.is-active:not(.is-wrong):not(.is-correct) .typing-word-line {
  background: #1769e0;
}

.word-canvas.sentence-slots .typing-word.is-active {
  transform: translateY(-2px);
}

.word-canvas.sentence-slots.is-complete {
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(236, 253, 247, 0.6), rgba(255, 255, 255, 0));
}

.word-canvas.sentence-slots.is-complete .typing-word {
  --word-accent: #13a873;
}

.typing-word.is-error-bump {
  animation: wordErrorBump 0.4s ease;
}

@keyframes wordErrorBump {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  45% { transform: translateX(5px); }
  68% { transform: translateX(-3px); }
  84% { transform: translateX(2px); }
}

@media (max-width: 620px) {
  .word-slot-input {
    padding-bottom: 5px;
  }
}

/* ========================================================================
   Complete viewport layout + optional source sentence reveal
   Keeps the header and controls visible, prevents word/gloss clipping,
   and lets the practice stage scroll internally only when truly necessary.
   ======================================================================== */
body.practice-focus {
  height: 100dvh;
  overflow: hidden;
}

body.practice-focus #app {
  height: 100dvh;
  min-height: 0;
}

.typing-practice {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: 70px 62px minmax(0, 1fr) 78px;
  padding: 10px 26px 12px;
}

.typing-header {
  min-height: 0;
  padding: 0 4px 10px;
}

.typing-progress-row {
  min-height: 0;
  padding: 10px 4px 4px;
}

.typing-stage {
  min-height: 0;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 14px;
  padding: 8px 24px 18px;
  scrollbar-width: thin;
  scrollbar-color: #dbe3f0 transparent;
}

.typing-stage::-webkit-scrollbar { width: 7px; }
.typing-stage::-webkit-scrollbar-track { background: transparent; }
.typing-stage::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #dbe3f0;
}

.typing-stage-note {
  position: static;
  top: auto;
  left: auto;
  z-index: 2;
  transform: none;
  max-width: 900px;
  margin: 0 auto 10px;
  color: #949bad;
  line-height: 1.5;
  text-align: center;
  white-space: normal;
}

.listening-callout {
  width: min(100%, 900px);
  align-items: stretch;
  gap: 9px;
  margin: 0 auto 10px;
}

.listen-hero-button {
  min-width: 0;
  flex: 1 1 390px;
}

.listen-speed-button {
  min-width: 108px;
  flex: 0 0 108px;
}

.listen-reveal-button {
  min-width: 154px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex: 0 0 154px;
  padding: 8px 13px;
  border: 1px solid #dfe5ef;
  border-radius: 16px;
  color: #3f4860;
  background: #ffffff;
  box-shadow: 0 9px 24px rgba(39, 52, 86, 0.07);
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.listen-reveal-button:hover {
  transform: translateY(-2px);
  color: #1d5ecb;
  border-color: #b9cdef;
  background: #f7faff;
  box-shadow: 0 13px 28px rgba(39, 52, 86, 0.1);
}

.listen-reveal-button.is-active {
  color: #ffffff;
  border-color: #2563eb;
  background: #2563eb;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22);
}

.listen-reveal-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: #2563eb;
  background: #edf4ff;
}

.listen-reveal-button.is-active .listen-reveal-icon {
  color: #2563eb;
  background: #ffffff;
}

.listen-reveal-icon svg { width: 18px; height: 18px; }
.listen-reveal-button > span:last-child { display: grid; gap: 1px; }
.listen-reveal-button strong { font-size: 13px; line-height: 1.3; }
.listen-reveal-button small { color: #8a93a7; font-size: 9px; line-height: 1.3; }
.listen-reveal-button.is-active small { color: rgba(255, 255, 255, 0.76); }

.original-sentence-panel {
  width: min(100%, 1040px);
  display: none;
  position: relative;
  z-index: 2;
  margin: 0 auto 10px;
  padding: 14px 18px 13px;
  border: 1px solid #cfe0fb;
  border-radius: 16px;
  color: #1c3157;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f8ff 100%);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.08);
}

.original-sentence-panel.is-visible {
  display: grid;
  animation: originalPanelIn 0.2s ease both;
}

@keyframes originalPanelIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.original-sentence-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.original-sentence-head > span {
  color: #5c73a0;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.original-sentence-head button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1px solid #cfe0fb;
  border-radius: 9px;
  color: #245fc7;
  background: #ffffff;
  font-size: 10px;
  font-weight: 750;
}

.original-sentence-head button:hover { background: #edf5ff; }
.original-sentence-head svg { width: 15px; height: 15px; }

.original-sentence-panel p {
  margin: 0;
  color: #172b4d;
  font-size: clamp(18px, 1.75vw, 25px);
  font-weight: 650;
  line-height: 1.55;
  letter-spacing: -0.018em;
  text-align: center;
  overflow-wrap: anywhere;
}

.original-sentence-panel > small {
  display: block;
  margin-top: 5px;
  color: #8290a8;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

.word-canvas.sentence-slots {
  width: min(100%, 1420px);
  min-height: 0;
  align-content: flex-start;
  column-gap: clamp(9px, 1.1vw, 17px);
  row-gap: clamp(21px, 2.6vh, 30px);
  padding: 12px 2px 8px;
}

.word-canvas.sentence-slots .typing-word {
  grid-template-rows: 18px minmax(46px, auto) 3px minmax(20px, auto);
  gap: 4px;
}

.word-canvas.sentence-slots .typing-word-text {
  min-height: 46px;
  padding-bottom: 6px;
}

.word-canvas.sentence-slots.is-long {
  column-gap: clamp(8px, 0.95vw, 14px);
  row-gap: clamp(19px, 2.4vh, 27px);
}

.word-canvas.sentence-slots.is-long .typing-word-text {
  font-size: clamp(31px, 3vw, 48px);
}

.word-canvas.sentence-slots.is-very-long .typing-word-text {
  font-size: clamp(27px, 2.55vw, 42px);
}

.word-canvas.sentence-slots .typing-phonetic,
.word-canvas.sentence-slots .typing-gloss {
  width: 100%;
  max-width: 100%;
  text-align: center;
}

.word-canvas.sentence-slots .typing-gloss {
  min-height: 20px;
  padding-inline: 2px;
  line-height: 1.22;
  white-space: normal;
  overflow-wrap: anywhere;
}

.word-canvas.sentence-slots .typing-phonetic {
  overflow: hidden;
  text-overflow: ellipsis;
}

.typing-hint {
  width: min(100%, 960px);
}

.typing-hint.is-visible {
  margin: 4px 0 12px;
  padding: 10px 16px;
}

.typing-prompt {
  margin-top: 10px;
  padding-bottom: 2px;
}

.typing-prompt p {
  margin-block: 5px 3px;
  font-size: clamp(16px, 1.45vw, 21px);
  line-height: 1.55;
}

.typing-controls {
  min-height: 0;
  height: 78px;
  padding-top: 8px;
  background: rgba(255, 255, 255, 0.96);
}

.typing-shortcuts {
  flex-wrap: nowrap;
  justify-content: center;
  overflow-x: auto;
  padding: 4px 3px 7px;
  scrollbar-width: none;
}

.typing-shortcuts::-webkit-scrollbar { display: none; }

@media (min-width: 861px) and (max-height: 840px) {
  .typing-practice {
    grid-template-rows: 58px 52px minmax(0, 1fr) 66px;
    padding: 7px 18px 9px;
  }

  .typing-header { padding-bottom: 7px; }
  .typing-brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .typing-brand-mark svg { width: 24px; height: 24px; }
  .typing-tools button { padding-block: 4px; }
  .typing-tools svg { width: 21px; height: 21px; }
  .typing-progress-row { padding-top: 7px; }
  .typing-progress-number { margin-bottom: 5px; }
  .typing-progress-number strong { font-size: 21px; }
  .typing-progress-number span { font-size: 16px; }
  .typing-stage { padding: 5px 18px 12px; }
  .typing-stage-note { margin-bottom: 7px; font-size: 10px; }
  .listening-callout { margin-bottom: 7px; }
  .listen-hero-button { padding-block: 8px; }
  .listen-hero-icon { width: 36px; height: 36px; }
  .listen-speed-button,
  .listen-reveal-button { border-radius: 13px; }
  .original-sentence-panel { margin-bottom: 7px; padding-block: 10px; }
  .original-sentence-panel p { font-size: clamp(17px, 1.55vw, 22px); }
  .word-canvas.sentence-slots {
    row-gap: 18px;
    padding-block: 8px 5px;
  }
  .word-canvas.sentence-slots .typing-word {
    grid-template-rows: 16px minmax(40px, auto) 3px minmax(18px, auto);
    gap: 3px;
  }
  .word-canvas.sentence-slots.is-long .typing-word-text { font-size: clamp(29px, 2.7vw, 43px); }
  .typing-prompt { margin-top: 6px; }
  .typing-prompt p { margin-block: 3px 1px; font-size: clamp(15px, 1.3vw, 19px); }
  .typing-controls { height: 66px; padding-top: 5px; }
  .typing-nav-button { width: 48px; height: 48px; }
  .typing-shortcut { min-height: 36px; padding-block: 5px; }
}

@media (max-width: 1060px) and (min-width: 861px) {
  .listen-reveal-button {
    min-width: 52px;
    flex-basis: 52px;
    padding-inline: 10px;
  }
  .listen-reveal-button > span:last-child { display: none; }
  .listen-reveal-icon { width: 31px; height: 31px; }
}

@media (max-width: 860px) {
  body.practice-focus {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  body.practice-focus #app {
    height: auto;
    min-height: 100dvh;
  }

  .typing-practice {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    grid-template-rows: auto auto minmax(0, auto) auto;
    padding: 12px 14px 16px;
  }

  .typing-stage {
    min-height: 0;
    overflow: visible;
    padding: 12px 8px 22px;
  }

  .typing-stage-note {
    margin-bottom: 8px;
    padding-inline: 8px;
  }

  .listening-callout {
    flex-wrap: wrap;
    width: min(100%, 680px);
  }

  .listen-hero-button {
    width: 100%;
    flex-basis: 100%;
  }

  .listen-speed-button,
  .listen-reveal-button {
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
  }

  .listen-reveal-button > span:last-child { display: grid; }

  .original-sentence-panel {
    width: min(100%, 680px);
  }

  .word-canvas.sentence-slots {
    width: 100%;
    align-content: flex-start;
    justify-content: center;
    padding-inline: 0;
  }

  .typing-controls {
    height: auto;
    min-height: 68px;
  }
}

@media (max-width: 620px) {
  .typing-practice { padding-inline: 9px; }
  .typing-stage { padding-inline: 1px; }
  .listen-hero-button { justify-content: flex-start; }
  .listen-speed-button,
  .listen-reveal-button { min-height: 46px; }
  .listen-reveal-button { border-radius: 13px; }
  .original-sentence-panel { padding: 12px 13px; border-radius: 13px; }
  .original-sentence-panel p { font-size: 17px; line-height: 1.5; }
  .word-canvas.sentence-slots {
    justify-content: center;
    column-gap: 8px;
    row-gap: 18px;
  }
  .word-canvas.sentence-slots .typing-word,
  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    grid-template-rows: 15px minmax(36px, auto) 3px minmax(18px, auto);
  }
  .word-canvas.sentence-slots .typing-word-text,
  .word-canvas.sentence-slots.is-long .typing-word-text,
  .word-canvas.sentence-slots.is-very-long .typing-word-text {
    min-height: 36px;
    font-size: clamp(25px, 7.8vw, 35px);
  }
  .word-canvas.sentence-slots .typing-gloss { font-size: 8.5px; }
  .typing-prompt { padding-inline: 10px; }
}

/* ========================================================================
   V4 learning flow refinements
   - 5 / 10 / 30 / 50 / 100 question sessions
   - complete word glyph rendering (including descenders and punctuation)
   - six-stage playback speed control
   - phrase, usage, and transfer analysis on the feedback page
   ======================================================================== */

.practice-count-options {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: 10px;
}

.practice-count-options .segment-button {
  min-width: 0;
  justify-content: center;
  padding-inline: 14px;
}

/* Six-stage playback-speed selector. */
.listen-speed-control {
  min-width: 226px;
  flex: 0 0 226px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 9px 11px 8px;
  border: 1px solid #dfe5ef;
  border-radius: 16px;
  color: #46516a;
  background: #ffffff;
  box-shadow: 0 9px 24px rgba(39, 52, 86, 0.07);
}

.speed-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-weight: 750;
}

.speed-control-head span { color: #7e889d; }
.speed-control-head strong {
  color: #245fc7;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.speed-control-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 6px;
}

.speed-control-row button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d7e2f4;
  border-radius: 9px;
  color: #245fc7;
  background: #f6f9ff;
  font-size: 18px;
  font-weight: 650;
  line-height: 1;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.speed-control-row button:hover {
  transform: translateY(-1px);
  border-color: #9dbcec;
  background: #eaf2ff;
}

.speed-control-row select {
  width: 100%;
  height: 30px;
  padding: 0 27px 0 10px;
  border: 1px solid #d7e2f4;
  border-radius: 9px;
  outline: none;
  color: #243553;
  background:
    linear-gradient(45deg, transparent 50%, #6e7d97 50%) calc(100% - 13px) 12px / 5px 5px no-repeat,
    linear-gradient(135deg, #6e7d97 50%, transparent 50%) calc(100% - 8px) 12px / 5px 5px no-repeat,
    #ffffff;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.speed-control-row select:focus {
  border-color: #6e9ee6;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.listen-speed-control > small {
  color: #9aa3b5;
  font-size: 8.5px;
  line-height: 1.25;
  text-align: center;
}

/*
 * Native text inputs can crop p/g/y descenders when their line-height is too
 * tight. Give every word a real text line box, reserve punctuation separately,
 * and let the slot width follow the longest target/typed form.
 */
.word-canvas.sentence-slots .typing-word,
.word-canvas.sentence-slots.is-long .typing-word,
.word-canvas.sentence-slots.is-very-long .typing-word {
  width: var(--slot-width, 132px);
  max-width: min(100%, 440px);
  grid-template-rows: 20px minmax(68px, auto) 3px minmax(22px, auto);
  gap: 4px;
  overflow: visible;
}

.word-canvas.sentence-slots .typing-word-text,
.word-canvas.sentence-slots.is-long .typing-word-text,
.word-canvas.sentence-slots.is-very-long .typing-word-text {
  width: 100%;
  min-width: 0;
  min-height: 68px;
  position: relative;
  display: block;
  padding: 0 var(--slot-punctuation-space, 0em) 0 0;
  overflow: visible;
  box-sizing: border-box;
  line-height: 1.22;
}

.word-slot-input {
  width: calc(100% - var(--slot-punctuation-space, 0em));
  min-width: 0;
  max-width: none;
  min-height: 1.36em;
  display: block;
  box-sizing: border-box;
  margin: 0;
  padding: 0.045em 0.14em 0.17em;
  overflow: visible;
  color: #101527;
  font-family: inherit;
  font-size: var(--slot-word-font-size, 1em);
  font-weight: inherit;
  line-height: 1.2;
  letter-spacing: -0.022em;
  text-indent: 0;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
  vertical-align: bottom;
}

.word-canvas.sentence-slots .typing-word.is-long-word .word-slot-input {
  letter-spacing: -0.026em;
}

.word-canvas.sentence-slots .typing-word.is-extra-long-word .word-slot-input {
  letter-spacing: -0.03em;
}

.typing-inline-punctuation.is-target-punctuation {
  width: var(--slot-punctuation-space, 0em);
  position: absolute;
  right: 0;
  bottom: 0.16em;
  display: block;
  margin: 0;
  padding: 0;
  color: currentColor;
  font-size: 0.92em;
  line-height: 1.15;
  text-align: left;
  pointer-events: none;
}

.word-canvas.sentence-slots .typing-word-line {
  width: calc(100% - 2px);
}

.word-canvas.sentence-slots .typing-phonetic {
  overflow: visible;
  text-overflow: clip;
}

/* Rich phrase and transfer analysis. */
.learning-analysis-card,
.transfer-card {
  overflow: hidden;
}

.sentence-structure-box {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  padding: 15px 16px;
  border: 1px solid #dedcff;
  border-radius: 14px;
  background: linear-gradient(135deg, #f4f2ff 0%, #fafaff 100%);
}

.sentence-structure-box > span {
  color: #7770a9;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sentence-structure-box code {
  color: #3930b9;
  font-family: inherit;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.sentence-structure-box p {
  margin: 0;
  color: #625f7f;
  font-size: 12px;
  line-height: 1.65;
}

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

.phrase-analysis-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #e3e7f0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 7px 20px rgba(35, 47, 78, 0.045);
}

.phrase-analysis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phrase-analysis-head > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.phrase-analysis-head span {
  color: #969daf;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.phrase-analysis-head code {
  color: #17233c;
  font-family: inherit;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.phrase-meaning {
  margin: 0;
  color: #147452;
  font-size: 12px;
  font-weight: 750;
}

.phrase-usage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  border-radius: 10px;
  color: #667087;
  background: #f6f8fc;
  font-size: 11px;
  line-height: 1.55;
}

.phrase-usage strong { color: #46516a; }

.phrase-example {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.phrase-example > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.phrase-example strong {
  color: #263550;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.phrase-example span {
  color: #8b93a5;
  font-size: 10px;
  line-height: 1.45;
}

.mini-play-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  background: #5a4bea;
  transition: transform 0.16s ease, background 0.16s ease;
}

.mini-play-button:hover {
  transform: translateY(-1px);
  background: #4538d4;
}

.mini-play-button.is-soft {
  color: #4d43d1;
  background: #eeecff;
}

.mini-play-button.is-soft:hover { background: #e3e0ff; }
.mini-play-button svg { width: 15px; height: 15px; }

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

.transfer-example {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #e4e8f1;
  border-radius: 12px;
  background: #ffffff;
}

.transfer-example > span {
  color: #6a61d7;
  font-size: 10px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.transfer-example > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.transfer-example strong {
  color: #22314c;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.transfer-example p {
  margin: 0;
  color: #8a93a6;
  font-size: 10px;
  line-height: 1.45;
}

.transfer-challenge {
  display: grid;
  gap: 5px;
  margin-top: 13px;
  padding: 14px 15px;
  border: 1px dashed #cfcaf8;
  border-radius: 13px;
  background: #f7f6ff;
}

.transfer-challenge > span {
  color: #655bd2;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.05em;
}

.transfer-challenge p {
  margin: 0;
  color: #39375a;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.6;
}

.transfer-challenge small,
.transfer-empty {
  color: #8c8aa4;
  font-size: 10px;
  line-height: 1.5;
}

.transfer-empty { margin: 0; }

@media (max-width: 1120px) {
  .word-canvas.sentence-slots .typing-word,
  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    width: var(--slot-tablet-width, 112px);
    max-width: min(100%, 380px);
  }
}

@media (max-width: 980px) {
  .practice-count-options {
    grid-template-columns: repeat(3, minmax(86px, 1fr));
  }

  .listen-speed-control {
    min-width: 206px;
    flex-basis: 206px;
  }
}

@media (max-width: 860px) {
  .listen-speed-control,
  .listen-reveal-button {
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
  }
}

@media (max-width: 620px) {
  .practice-count-options {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
  }

  .listen-speed-control {
    min-height: 70px;
    padding: 8px 9px;
  }

  .word-canvas.sentence-slots .typing-word,
  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    width: min(var(--slot-mobile-width, 82px), calc(100vw - 34px));
    max-width: calc(100vw - 34px);
    grid-template-rows: 16px minmax(52px, auto) 3px minmax(19px, auto);
  }

  .word-canvas.sentence-slots .typing-word-text,
  .word-canvas.sentence-slots.is-long .typing-word-text,
  .word-canvas.sentence-slots.is-very-long .typing-word-text {
    min-height: 52px;
  }

  .word-slot-input {
    min-height: 1.38em;
    padding-bottom: 0.18em;
    line-height: 1.2;
  }

  .phrase-analysis-item { padding: 12px; }
  .phrase-usage { grid-template-columns: 1fr; gap: 3px; }
  .transfer-example { grid-template-columns: 24px minmax(0, 1fr) 30px; padding-inline: 10px; }
}

/* Final word-box sizing correction: reserve punctuation once, not twice. */
.word-slot-input {
  width: 100%;
}

/* Measured input shell keeps every glyph visible and places punctuation next to the word. */
.word-canvas.sentence-slots .typing-word-text,
.word-canvas.sentence-slots.is-long .typing-word-text,
.word-canvas.sentence-slots.is-very-long .typing-word-text {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 0;
}

.typing-input-shell {
  min-width: 1.15em;
  max-width: calc(100% - var(--slot-punctuation-space, 0em));
  position: relative;
  display: inline-grid;
  grid-template-areas: "word";
  align-items: center;
  justify-items: stretch;
  overflow: visible;
}

.typing-word-measure,
.word-slot-input {
  grid-area: word;
  box-sizing: border-box;
  margin: 0;
  padding: 0.045em 0.14em 0.17em;
  font-family: inherit;
  font-size: var(--slot-word-font-size, 1em);
  font-weight: inherit;
  line-height: 1.2;
  letter-spacing: -0.022em;
  white-space: pre;
}

.typing-word-measure {
  width: max-content;
  min-width: 1.15em;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.word-slot-input {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
}

.typing-inline-punctuation.is-target-punctuation {
  width: auto;
  position: absolute;
  left: calc(100% - 0.08em);
  right: auto;
  bottom: 0.16em;
  white-space: nowrap;
}

/* Keep commas and full stops visually attached to the completed word. */
.typing-inline-punctuation.is-target-punctuation {
  left: calc(100% - 0.36em);
  color: #101527;
  opacity: 0.82;
}

/* ========================================================================== */
/* Say It in English V5 — real learning loop                                  */
/* ========================================================================== */

.resume-banner {
  width: min(100%, 1050px);
  margin: 28px auto -28px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border-color: #dcd9ff;
  background: linear-gradient(120deg, rgba(245, 244, 255, .96), rgba(238, 252, 248, .96));
}

.resume-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #4d43d4;
  background: #ebe9ff;
}

.resume-icon svg { width: 23px; height: 23px; }
.resume-copy { min-width: 0; display: grid; gap: 2px; }
.resume-copy > span { color: #655bd2; font-size: 11px; font-weight: 850; letter-spacing: .04em; }
.resume-copy strong { overflow: hidden; color: #20243b; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.resume-copy small { color: var(--muted); font-size: 11px; }
.resume-actions { display: flex; gap: 8px; }

.v5-hero { padding-top: 76px; }
.hero-trust-row { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px 18px; color: #6e7287; font-size: 12px; }
.hero-trust-row span { display: inline-flex; align-items: center; gap: 6px; }
.hero-trust-row svg { width: 15px; height: 15px; color: var(--primary); }
.v5-demo-card .demo-input { min-height: 94px; }
.v5-demo-feedback .demo-check { width: 42px; height: 42px; font-size: 13px; font-weight: 900; }
.four-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.learning-loop-section { padding-bottom: 88px; }

.setup-resume {
  margin-bottom: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-color: #dedbff;
  background: #f8f7ff;
}
.setup-resume > div { display: grid; gap: 2px; }
.setup-resume strong { font-size: 14px; }
.setup-resume span { color: var(--muted); font-size: 12px; }

.phase-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}
.phase-pill.is-attempt { color: #4a43c7; background: #eeecff; }
.phase-pill.is-correction { color: #087b59; background: #e4f8f1; }

body.practice-focus { overflow: hidden; background: #fbfcff; }
body.practice-focus #app { width: 100%; max-width: none; min-height: 100vh; margin: 0; }
.v5-practice {
  width: 100%;
  height: 100vh;
  min-height: 620px;
  padding: 0 clamp(14px, 3vw, 54px) 12px;
  display: grid;
  grid-template-rows: 72px 66px minmax(0, 1fr) 82px;
  background:
    radial-gradient(circle at 50% 18%, rgba(86, 75, 230, .065), transparent 29%),
    linear-gradient(#fff, #fbfcff);
}

.v5-practice .typing-header { min-height: 72px; padding-inline: 0; }
.v5-practice .typing-progress-row { min-height: 66px; padding-inline: 2px; }
.v5-practice .typing-session-meta { flex-wrap: wrap; justify-content: flex-end; }
.v5-practice .typing-stage {
  min-height: 0;
  padding: 9px clamp(2px, 2vw, 28px) 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.v5-practice .typing-stage::before { opacity: .25; }
.v5-practice .typing-stage-note {
  position: sticky;
  top: 0;
  z-index: 8;
  width: fit-content;
  max-width: calc(100% - 20px);
  margin: 0 auto 10px;
  padding: 7px 13px;
  border: 1px solid #e6e8f2;
  border-radius: 999px;
  color: #74798f;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 18px rgba(52, 54, 90, .06);
  backdrop-filter: blur(12px);
  font-size: 11px;
  line-height: 1.4;
}

.v5-listening-callout {
  width: min(100%, 1020px);
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: minmax(280px, 1.35fr) minmax(310px, .95fr) minmax(165px, .58fr);
  align-items: stretch;
  gap: 10px;
}
.v5-listening-callout .listen-hero-button,
.v5-listening-callout .listen-speed-panel,
.v5-listening-callout .listen-reveal-button { min-height: 72px; }

.attempt-summary-strip {
  width: min(100%, 1040px);
  margin: 0 auto 10px;
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid #cceee3;
  border-radius: 18px;
  background: linear-gradient(115deg, #effcf8, #f8fbff);
}
.attempt-score-mini {
  width: 58px;
  height: 58px;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 17px;
  color: #087b59;
  background: white;
  box-shadow: 0 8px 18px rgba(15, 128, 91, .09);
}
.attempt-score-mini strong { font-size: 24px; line-height: 1; }
.attempt-score-mini span { margin-top: 3px; color: #71817c; font-size: 9px; }
.attempt-summary-copy { min-width: 0; display: grid; justify-items: start; gap: 3px; }
.attempt-summary-copy > strong { color: #1f3c34; font-size: 14px; }
.attempt-summary-copy > small { color: #72827d; font-size: 10px; }
.attempt-process-mini { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; color: #71817c; font-size: 10px; }
.attempt-process-mini > span:not(.assistance-badge) { padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.8); }

.assistance-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}
.assistance-badge.is-independent { color: #087b59; background: #dcf7ed; }
.assistance-badge.is-hint { color: #9a6106; background: #fff2d7; }
.assistance-badge.is-letters { color: #6a50bb; background: #f0e9ff; }
.assistance-badge.is-reference { color: #b44b5a; background: #ffe7eb; }

.word-canvas.sentence-slots {
  width: min(100%, 1280px);
  min-height: 178px;
  margin: 4px auto 12px;
  padding: clamp(12px, 2.2vw, 24px) clamp(8px, 2.2vw, 24px);
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(13px, 1.6vw, 25px) clamp(8px, 1.25vw, 20px);
  overflow: visible;
  border: 1px solid rgba(229, 232, 242, .82);
  border-radius: 24px;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 1px rgba(255,255,255,.9), 0 18px 50px rgba(39, 47, 84, .045);
}
.word-canvas.sentence-slots .typing-word,
.word-canvas.sentence-slots.is-long .typing-word,
.word-canvas.sentence-slots.is-very-long .typing-word {
  min-width: 64px;
  max-width: 100%;
  display: grid;
  grid-template-rows: 20px minmax(54px, auto) 3px minmax(23px, auto);
  align-items: center;
  gap: 4px;
  overflow: visible;
  transform: none;
}
.word-canvas.sentence-slots .typing-word:hover { transform: none; }
.word-canvas.sentence-slots .typing-word-text,
.word-canvas.sentence-slots.is-long .typing-word-text,
.word-canvas.sentence-slots.is-very-long .typing-word-text {
  min-height: 54px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: visible;
  font-size: clamp(32px, 3.4vw, 53px);
  line-height: 1.12;
}
.word-canvas.sentence-slots.is-long .typing-word-text { font-size: clamp(29px, 3vw, 47px); }
.word-canvas.sentence-slots.is-very-long .typing-word-text { font-size: clamp(26px, 2.65vw, 42px); }
.word-entry-wrap { max-width: 100%; display: inline-flex; align-items: flex-end; justify-content: center; overflow: visible; }
.word-slot-input {
  width: auto;
  min-width: 34px;
  max-width: none;
  padding: 0 .08em .08em;
  overflow: visible;
  border: 0;
  outline: 0;
  color: #182036;
  background: transparent;
  text-align: center;
  font: inherit;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.035em;
  caret-color: #4f46e5;
}
.word-slot-input:focus { outline: 0; }
.typing-inline-punctuation.is-target-punctuation {
  position: static;
  margin-left: -.08em;
  padding-bottom: .08em;
  color: #1c2438;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.1;
}
.word-help-trigger.typing-phonetic {
  min-height: 20px;
  padding: 0;
  border: 0;
  color: #8a90a3;
  background: transparent;
  font-size: 11px;
  line-height: 1.2;
}
.word-help-trigger.typing-phonetic:focus-visible { outline: 2px solid #b7b2ff; outline-offset: 2px; border-radius: 5px; }
.typing-gloss { min-height: 22px; color: #7c8194; font-size: 11px; line-height: 1.35; text-align: center; white-space: normal; overflow-wrap: anywhere; }
.typing-word-line { width: 100%; min-width: 46px; height: 3px; border-radius: 999px; background: #dce0eb; opacity: 1; transition: .18s ease; }

/* The first attempt never leaks correctness. */
.phase-attempt .typing-word.is-first-attempt .word-slot-input,
.phase-attempt .typing-word.is-first-attempt.is-filled .word-slot-input { color: #2f3650 !important; }
.phase-attempt .typing-word.is-first-attempt .typing-word-line { background: #cfd4e3 !important; box-shadow: none !important; }
.phase-attempt .typing-word.is-first-attempt.is-neutral-entry .typing-word-line { background: #6b63df !important; }
.phase-attempt .typing-word.is-first-attempt.is-active .typing-word-line { height: 4px; background: #4f46e5 !important; box-shadow: 0 0 0 5px rgba(79,70,229,.08) !important; }
.phase-attempt .typing-word.is-first-attempt .typing-phonetic,
.phase-attempt .typing-word.is-first-attempt .typing-gloss { color: transparent !important; pointer-events: none; }
.phase-attempt .typing-word.is-first-attempt .typing-inline-punctuation { color: #9da2b1; }

/* Correction phase keeps explicit red/green feedback and full-width words. */
.phase-correction .typing-word.is-correction-slot.is-wrong .word-slot-input { color: #df3f54 !important; }
.phase-correction .typing-word.is-correction-slot.is-wrong .typing-word-line { background: #ef5063 !important; }
.phase-correction .typing-word.is-correction-slot.is-correct .word-slot-input { color: #07845b !important; }
.phase-correction .typing-word.is-correction-slot.is-correct .typing-word-line { background: #10ad78 !important; }
.phase-correction .typing-word.is-correction-slot.is-partial .word-slot-input { color: #3e54c6 !important; }
.phase-correction .typing-word.is-correction-slot.is-partial .typing-word-line { background: #526be0 !important; }

.typing-hint {
  width: min(100%, 870px);
  margin: 0 auto 12px;
  padding: 0 16px;
  display: none;
  border: 1px solid #dcd9ff;
  border-radius: 16px;
  background: #f8f7ff;
}
.typing-hint.is-visible { display: grid; gap: 8px; padding-block: 13px; }
.hint-level-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 13px; }
.hint-level-row span,
.initial-hint span { color: #7c76b7; font-size: 10px; font-weight: 850; }
.hint-level-row strong { color: #4239b4; font-size: 14px; }
.initial-hint { display: grid; gap: 5px; padding-top: 8px; border-top: 1px dashed #d9d5f6; text-align: center; }
.initial-hint code { color: #4f46a5; font-size: 13px; letter-spacing: .08em; white-space: normal; }
.typing-hint .text-button { justify-self: center; }
.typing-hint p { margin: 0; color: #8b8fa3; font-size: 10px; text-align: center; }

.v5-practice .typing-prompt {
  width: min(100%, 920px);
  margin: 2px auto 8px;
  padding: 6px 16px 8px;
}
.v5-practice .typing-prompt p { font-size: clamp(20px, 2vw, 28px); }
.v5-practice .typing-prompt small { font-size: 10px; }

.v5-controls { min-height: 82px; padding-inline: 0; }
.v5-controls .typing-shortcuts { gap: 7px; }
.mobile-more-toggle { display: none !important; }
.mobile-tools-sheet { display: none; }

/* Feedback is divided into usable tabs instead of one endless page. */
.v5-feedback-layout { width: min(100%, 1180px); padding-bottom: 70px; }
.v5-feedback-banner { margin-top: 34px; }
.score-ring { position: relative; }
.score-ring > span { position: absolute; bottom: 16px; color: #7b7896; font-size: 9px; font-weight: 800; }
.feedback-tabs {
  position: sticky;
  top: 102px;
  z-index: 12;
  margin: 14px 0 20px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(16px);
}
.feedback-tabs button {
  min-height: 44px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  color: #6e7287;
  background: transparent;
  font-size: 13px;
  font-weight: 750;
}
.feedback-tabs button:hover { color: #3028a7; background: #f5f4ff; }
.feedback-tabs button.is-active { color: white; background: linear-gradient(135deg, #5b4eea, #4438d4); box-shadow: 0 9px 22px rgba(79,70,229,.22); }
.tab-check { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 999px; color: #087b59; background: #dff8ee; font-size: 10px; }
.v5-metric-grid { margin-bottom: 18px; }
.metric-note { display: block; margin-top: 7px; color: #9a9eae; font-size: 9px; }
.v5-result-grid { align-items: start; }
.feedback-card .card-heading > div { min-width: 0; }
.feedback-card .card-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.compact-feedback-card { grid-column: 1 / -1; }
.diagnosis-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.diagnosis-columns h3 { margin: 0 0 8px; font-size: 13px; }
.process-card { padding: 22px; }
.process-status { margin: 14px 0; padding: 13px; display: flex; align-items: center; gap: 10px; border-radius: 14px; background: #f7f8fc; }
.process-status p { margin: 0; color: #74798e; font-size: 11px; }
.process-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.process-stat-grid > div { padding: 12px; display: grid; gap: 4px; border: 1px solid #eceef4; border-radius: 13px; background: #fff; }
.process-stat-grid span { color: #8a8fa2; font-size: 10px; }
.process-stat-grid strong { color: #252a42; font-size: 17px; }
.next-step-card { padding: 23px; border-color: #d9d5ff; background: linear-gradient(135deg, #f7f6ff, #f1fbf8); }
.next-step-card > span { color: #6a61d7; font-size: 10px; font-weight: 850; }
.next-step-card h2 { margin: 7px 0 5px; font-size: 18px; }
.next-step-card p { margin: 0 0 15px; color: var(--muted); font-size: 12px; }

.phrase-overview-card {
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr);
  align-items: center;
  gap: 24px;
}
.phrase-overview-card h2 { margin: 5px 0 8px; font-size: 25px; }
.phrase-overview-card p { margin: 0; color: var(--muted); }
.pattern-hero { padding: 18px; display: grid; gap: 8px; border-radius: 16px; background: #f3f1ff; }
.pattern-hero span { color: #746db7; font-size: 10px; font-weight: 850; }
.pattern-hero code { color: #4438c7; font-size: 18px; font-weight: 850; white-space: normal; }
.pattern-hero small { color: #7d7a93; }
.v5-phrase-grid { margin-top: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.v5-phrase-grid .phrase-study-card { box-shadow: var(--shadow-sm); }
.pattern-memory-card { margin-top: 18px; padding: 24px; display: grid; grid-template-columns: 1fr .9fr; gap: 22px; }
.pattern-memory-copy > span,
.pattern-replacement-demo > span { color: #7168d4; font-size: 10px; font-weight: 850; }
.pattern-memory-copy h2 { margin: 6px 0; font-size: 22px; }
.pattern-memory-copy p { margin: 0; color: var(--muted); }
.pattern-replacement-demo { padding: 17px; border-radius: 15px; background: #f7f6ff; }
.pattern-replacement-demo p { margin: 6px 0 14px; font-weight: 700; }

.transfer-tab-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.transfer-workspace { padding: clamp(20px, 3vw, 32px); }
.transfer-instruction h2 { margin: 5px 0 8px; font-size: clamp(24px, 3vw, 34px); }
.transfer-instruction p { margin: 0; color: var(--muted); }
.transfer-frame-box { margin-top: 20px; padding: 15px 17px; display: grid; gap: 5px; border: 1px solid #ddd9ff; border-radius: 15px; background: #f6f4ff; }
.transfer-frame-box span { color: #776fb8; font-size: 10px; font-weight: 850; }
.transfer-frame-box code { color: #4539c6; font-size: 17px; font-weight: 850; white-space: normal; }
.transfer-frame-box small { color: #848096; }
.transfer-question-box { margin: 16px 0; padding: 17px; border-radius: 15px; background: #f6faf9; }
.transfer-question-box span { color: #278c6e; font-size: 10px; font-weight: 850; }
.transfer-question-box h3 { margin: 7px 0 0; font-size: 20px; }
.transfer-input-label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.transfer-textarea { width: 100%; min-height: 130px; padding: 15px; resize: vertical; border: 1px solid #dfe2ed; border-radius: 15px; color: #20243a; background: #fff; outline: none; line-height: 1.7; }
.transfer-textarea:focus { border-color: #7b72eb; box-shadow: 0 0 0 4px rgba(79,70,229,.09); }
.transfer-actions { margin-top: 12px; display: flex; justify-content: flex-end; gap: 9px; }
.transfer-tips-card { padding: 22px; }
.transfer-tips-card h2 { margin: 0 0 14px; }
.transfer-tips-card ol { margin: 0; padding: 0; display: grid; gap: 13px; list-style: none; counter-reset: transfer; }
.transfer-tips-card li { position: relative; padding-left: 34px; display: grid; gap: 2px; counter-increment: transfer; }
.transfer-tips-card li::before { content: counter(transfer); position: absolute; left: 0; top: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: #5146df; background: #eeecff; font-size: 10px; font-weight: 900; }
.transfer-tips-card li strong { font-size: 12px; }
.transfer-tips-card li span { color: var(--muted); font-size: 11px; }
.transfer-tips-card .text-button { margin-top: 18px; }
.transfer-result { margin-top: 18px; padding: 16px; display: grid; grid-template-columns: 68px minmax(0, 1fr) 38px; gap: 14px; align-items: start; border: 1px solid #f0d8a4; border-radius: 16px; background: #fffaf0; }
.transfer-result.is-passed { border-color: #bfe9da; background: #effbf7; }
.transfer-result-score { width: 62px; height: 62px; display: grid; place-content: center; text-align: center; border-radius: 17px; color: #a26a0d; background: white; }
.transfer-result.is-passed .transfer-result-score { color: #087b59; }
.transfer-result-score strong { font-size: 23px; line-height: 1; }
.transfer-result-score span { margin-top: 3px; font-size: 9px; }
.transfer-result-copy h3 { margin: 0 0 8px; font-size: 15px; }
.transfer-result-copy p { margin: 7px 0 0; color: #62677c; font-size: 11px; }
.transfer-check-list { display: flex; flex-wrap: wrap; gap: 6px; }
.transfer-check-list span { padding: 4px 7px; border-radius: 999px; color: #9a6209; background: #fff1d1; font-size: 9px; font-weight: 750; }
.transfer-check-list span.is-passed { color: #087b59; background: #dff7ee; }

.shadow-tab-content { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.shadow-workspace { padding: clamp(20px, 3vw, 30px); }
.shadow-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.shadow-heading h2 { margin: 5px 0 7px; font-size: 28px; }
.shadow-heading p { margin: 0; color: var(--muted); }
.shadow-chunks { margin-top: 20px; display: grid; gap: 9px; }
.shadow-chunk { width: 100%; padding: 13px 15px; display: grid; grid-template-columns: 32px minmax(0, 1fr) 24px; align-items: center; gap: 10px; border: 1px solid #e4e7f0; border-radius: 14px; color: #293047; background: white; text-align: left; }
.shadow-chunk:hover { border-color: #bdb8f5; background: #f8f7ff; }
.shadow-chunk > span { color: #6c63d7; font-size: 10px; font-weight: 900; }
.shadow-chunk strong { font-size: 14px; }
.shadow-chunk svg { width: 18px; color: #5d54d8; }
.shadow-record-card { margin-top: 18px; padding: 17px; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 13px; border-radius: 16px; background: #f4f5fa; }
.shadow-record-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: #5146df; background: #e9e7ff; }
.shadow-record-icon svg { width: 22px; }
.shadow-record-card h3 { margin: 0 0 3px; font-size: 14px; }
.shadow-record-card p { margin: 0; color: var(--muted); font-size: 10px; }
.shadow-tips-card { padding: 21px; }
.shadow-tips-card h2 { margin: 0 0 12px; }
.shadow-tips-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.shadow-tips-card li + li { margin-top: 9px; }
.shadow-result { margin-top: 16px; padding: 15px; display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 12px; border: 1px solid #edd5a0; border-radius: 15px; background: #fffaf1; }
.shadow-result.is-good { border-color: #bce8d8; background: #effbf7; }
.shadow-result > div { display: grid; place-content: center; text-align: center; }
.shadow-result > div strong { font-size: 24px; }
.shadow-result > div span { font-size: 9px; }
.shadow-result p { margin: 0; display: grid; gap: 3px; color: #42485e; }
.shadow-result p span { color: #858a9e; font-size: 9px; font-weight: 800; }
.shadow-result > small { grid-column: 1 / -1; color: #7f8497; }

.v5-feedback-actions { margin-top: 20px; }

.break-card,
.v5-complete-card { width: min(calc(100% - 24px), 860px); margin: 70px auto; padding: clamp(28px, 5vw, 54px); }
.break-icon { width: 64px; height: 64px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 21px; color: #5146df; background: #eceaff; }
.break-icon svg { width: 28px; height: 28px; }
.break-card { text-align: center; }
.break-card h1 { margin: 5px 0 8px; font-size: clamp(30px, 5vw, 48px); }
.break-card > p { margin: 0 auto 24px; max-width: 620px; color: var(--muted); }
.break-stats { grid-template-columns: repeat(4, 1fr); }
.break-tip { margin: 20px auto 0; max-width: 650px; padding: 14px 17px; display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 14px; background: #f6f5ff; }
.break-tip strong { color: #554bcf; }
.break-tip span { color: #6f7489; }

.review-summary-grid { margin-bottom: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.review-summary-card { padding: 18px; display: grid; gap: 3px; }
.review-summary-card span { color: var(--muted); font-size: 11px; }
.review-summary-card strong { font-size: 28px; }
.review-summary-card small { color: #9a9ead; }
.v5-review-item { grid-template-columns: 76px minmax(0, 1fr) auto; }
.v5-review-item .review-score { width: 64px; height: 64px; display: grid; place-content: center; text-align: center; }
.v5-review-item .review-score strong { font-size: 24px; line-height: 1; }
.v5-review-item .review-score span { font-size: 9px; }
.review-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.review-status { padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; }
.review-status.is-due { color: #b54152; background: #ffe8eb; }
.review-status.is-learning { color: #92600a; background: #fff2d7; }
.review-status.is-mastered { color: #087b59; background: #def7ee; }
.review-detail-row { display: flex; flex-wrap: wrap; gap: 7px 14px; color: #8c91a2; font-size: 10px; }
.v5-review-actions { align-items: center; }
.btn-small { min-height: 36px; padding: 7px 12px; font-size: 11px; }

.v5-dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.data-tools-card { grid-column: 1 / -1; padding: 21px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.data-tools-card h2 { margin: 0 0 4px; font-size: 17px; }
.data-tools-card p { margin: 0; color: var(--muted); font-size: 11px; }
.data-tool-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 1040px) {
  .four-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v5-listening-callout { grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr); }
  .v5-listening-callout .listen-reveal-button { grid-column: 1 / -1; min-height: 58px; }
  .phrase-overview-card,
  .pattern-memory-card { grid-template-columns: 1fr; }
  .transfer-tab-content,
  .shadow-tab-content { grid-template-columns: 1fr; }
  .transfer-tips-card,
  .shadow-tips-card { display: none; }
}

@media (max-width: 860px) {
  .resume-banner { grid-template-columns: 44px 1fr; }
  .resume-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .v5-dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feedback-tabs { top: 10px; }
  .diagnosis-columns { grid-template-columns: 1fr; }
  .v5-phrase-grid { grid-template-columns: 1fr; }
  .break-stats { grid-template-columns: repeat(2, 1fr); }
  .review-summary-grid { grid-template-columns: 1fr 1fr 1fr; }
  .v5-review-item { grid-template-columns: 64px 1fr; }
  .v5-review-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 760px) {
  body.practice-focus { overflow: hidden; }
  .v5-practice {
    min-height: 100dvh;
    height: 100dvh;
    padding: 0 9px max(6px, env(safe-area-inset-bottom));
    grid-template-rows: 54px 54px minmax(0, 1fr) 68px;
  }
  .v5-practice .typing-header { min-height: 54px; }
  .v5-practice .typing-brand { font-size: 13px; }
  .v5-practice .typing-brand-mark { width: 34px; height: 34px; }
  .v5-practice .typing-mode-title { display: none; }
  .v5-practice .typing-tools { display: none; }
  .v5-practice .typing-progress-row { min-height: 54px; }
  .typing-progress-block { min-width: 94px; }
  .typing-progress-number strong { font-size: 20px; }
  .v5-practice .typing-session-meta { gap: 4px; }
  .v5-practice .typing-session-meta .topic-chip { display: none; }
  .v5-practice .typing-session-meta > span { font-size: 8px; }
  .v5-practice .typing-stage { padding: 4px 0 10px; scrollbar-gutter: auto; }
  .v5-practice .typing-stage-note { top: 0; margin-bottom: 7px; padding: 5px 9px; font-size: 9px; }

  .attempt-summary-strip {
    margin-bottom: 7px;
    padding: 8px 9px;
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 9px;
    border-radius: 14px;
  }
  .attempt-score-mini { width: 46px; height: 46px; border-radius: 13px; }
  .attempt-score-mini strong { font-size: 19px; }
  .attempt-summary-copy > strong { font-size: 11px; }
  .attempt-summary-copy > small { display: none; }
  .attempt-process-mini { grid-column: 1 / -1; justify-content: flex-start; }

  .v5-listening-callout {
    width: 100%;
    margin-bottom: 7px;
    grid-template-columns: minmax(0, 1fr) 94px;
    gap: 6px;
  }
  .v5-listening-callout .listen-hero-button { min-width: 0; min-height: 58px; padding: 8px 10px; border-radius: 14px; }
  .v5-listening-callout .listen-hero-button strong { font-size: 12px; }
  .v5-listening-callout .listen-hero-button small { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .v5-listening-callout .listen-hero-icon { width: 34px; height: 34px; }
  .v5-listening-callout .listen-speed-panel { grid-column: 1 / -1; min-height: auto; padding: 7px 8px; overflow-x: auto; border-radius: 13px; }
  .listen-speed-heading { display: none; }
  .listen-speed-options { min-width: max-content; grid-template-columns: repeat(6, 54px); }
  .listen-rate-option { min-height: 34px; }
  .v5-listening-callout .listen-reveal-button { grid-column: 2; grid-row: 1; min-width: 0; min-height: 58px; padding: 7px; border-radius: 14px; }
  .v5-listening-callout .listen-reveal-button strong { font-size: 10px; }
  .v5-listening-callout .listen-reveal-button small { display: none; }
  .listen-reveal-icon { width: 28px; height: 28px; }

  .original-sentence-panel { margin-bottom: 7px; padding: 10px 11px; border-radius: 13px; }
  .original-sentence-panel p { font-size: 16px; line-height: 1.5; }
  .original-sentence-panel > small { font-size: 8px; }

  .word-canvas.sentence-slots {
    min-height: 160px;
    margin-bottom: 7px;
    padding: 12px 6px;
    gap: 12px 7px;
    border-radius: 16px;
  }
  .word-canvas.sentence-slots .typing-word,
  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    max-width: calc(100vw - 28px);
    grid-template-rows: 16px minmax(44px, auto) 3px minmax(19px, auto);
    gap: 3px;
  }
  .word-canvas.sentence-slots .typing-word-text,
  .word-canvas.sentence-slots.is-long .typing-word-text,
  .word-canvas.sentence-slots.is-very-long .typing-word-text {
    min-height: 44px;
    font-size: clamp(27px, 9vw, 38px);
  }
  .word-slot-input { max-width: calc(100vw - 44px); }
  .word-help-trigger.typing-phonetic { min-height: 16px; font-size: 9px; }
  .typing-gloss { min-height: 18px; font-size: 9px; }
  .typing-word-line { height: 3px; }

  .typing-hint { margin-bottom: 7px; border-radius: 13px; }
  .typing-hint.is-visible { padding: 9px 10px; }
  .hint-level-row strong { font-size: 11px; }
  .initial-hint code { font-size: 10px; }
  .typing-hint p { display: none; }

  .v5-practice .typing-prompt { margin-bottom: 3px; padding: 4px 8px 6px; }
  .v5-practice .typing-prompt p { margin: 4px 0; font-size: 18px; line-height: 1.55; }
  .v5-practice .typing-prompt small { font-size: 8px; }

  .v5-controls { min-height: 68px; grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 6px; padding: 4px 0 0; }
  .v5-controls .typing-nav-button { width: 42px; height: 42px; }
  .v5-controls .typing-shortcuts { justify-content: center; gap: 5px; overflow: visible; }
  .v5-controls .typing-shortcut { min-width: 48px; min-height: 45px; padding: 6px 8px; border-radius: 11px; }
  .v5-controls .typing-shortcut .shortcut-keys { display: none; }
  .v5-controls .typing-shortcut > span:last-child { font-size: 9px; }
  .v5-controls .typing-shortcut.is-speed-shortcut,
  .v5-controls .typing-shortcut.is-secondary-tool { display: none; }
  .v5-controls .typing-shortcut.is-listen-primary { min-width: 58px; }
  .v5-controls .typing-shortcut.is-primary { min-width: 78px; }
  .mobile-more-toggle { display: inline-flex !important; }

  .mobile-tools-sheet {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    z-index: 90;
    padding: 9px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    border: 1px solid #e2e4ee;
    border-radius: 17px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 18px 55px rgba(29, 32, 63, .2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: .18s ease;
  }
  .mobile-tools-sheet.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
  .mobile-tools-sheet button { min-height: 52px; padding: 7px; display: grid; place-items: center; gap: 3px; border: 0; border-radius: 12px; color: #484d64; background: #f5f6fa; font-size: 9px; }
  .mobile-tools-sheet svg { width: 19px; height: 19px; color: #5146df; }

  .feedback-tabs { top: 8px; grid-template-columns: repeat(2, 1fr); }
  .v5-feedback-banner { margin-top: 18px; }
  .v5-result-grid { grid-template-columns: 1fr; }
  .phrase-overview-card { padding: 18px; }
  .transfer-workspace,
  .shadow-workspace { padding: 18px; }
  .transfer-actions { flex-direction: column-reverse; }
  .transfer-actions .btn { width: 100%; }
  .transfer-result { grid-template-columns: 58px minmax(0, 1fr); }
  .transfer-result > .play-button { grid-column: 1 / -1; justify-self: end; }
  .shadow-heading { flex-direction: column; }
  .shadow-record-card { grid-template-columns: 42px minmax(0, 1fr); }
  .shadow-record-card .btn { grid-column: 1 / -1; width: 100%; }
  .data-tools-card { align-items: stretch; flex-direction: column; }
  .data-tool-actions .btn { flex: 1 1 180px; }
}

@media (max-width: 620px) {
  .resume-banner { margin-top: 18px; grid-template-columns: 1fr; }
  .resume-icon { display: none; }
  .resume-actions { grid-column: auto; justify-content: stretch; }
  .resume-actions .btn { flex: 1; }
  .four-steps { grid-template-columns: 1fr; }
  .review-summary-grid { grid-template-columns: 1fr; }
  .v5-dashboard-grid { grid-template-columns: 1fr 1fr; }
  .v5-review-item { grid-template-columns: 54px 1fr; padding: 14px; }
  .v5-review-item .review-score { width: 50px; height: 50px; }
  .v5-review-actions .btn { flex: 1; }
  .break-stats { grid-template-columns: 1fr 1fr; }
  .break-tip { align-items: flex-start; flex-direction: column; text-align: left; }
  .process-stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .v5-dashboard-grid { grid-template-columns: 1fr; }
  .feedback-tabs button { min-height: 40px; font-size: 11px; }
  .v5-controls { grid-template-columns: 36px minmax(0, 1fr) 36px; }
  .v5-controls .typing-nav-button { width: 36px; height: 40px; }
  .v5-controls .typing-shortcut { min-width: 44px; padding-inline: 5px; }
  .v5-controls .typing-shortcut.is-primary { min-width: 70px; }
}

/* ========================================================================
   V5 real learning loop
   First-attempt scoring, correction, transfer, shadowing, spaced review,
   session restore, local-data tools, and focused mobile interactions.
   ======================================================================== */

/* Shared V5 primitives */
.section-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.btn-ghost {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--text);
  background: #f2f3f8;
}

.btn-danger {
  border: 1px solid #ffd5da;
  color: #c73b50;
  background: #fff6f7;
}

.btn-danger:hover {
  border-color: #f4a8b2;
  background: #fff0f2;
}

.btn-small {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 11px;
  font-size: 12px;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
}

.text-button:hover { text-decoration: underline; }

/* Restore session */
.resume-banner {
  margin: 28px 0 0;
  padding: 17px 19px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  border-color: #dcd9ff;
  background: linear-gradient(135deg, rgba(250, 249, 255, 0.98), rgba(243, 252, 249, 0.96));
}

.resume-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: var(--primary);
  background: #eae8ff;
}

.resume-icon svg { width: 23px; height: 23px; }

.resume-copy { min-width: 0; display: grid; gap: 1px; }
.resume-copy > span { color: var(--primary); font-size: 11px; font-weight: 800; }
.resume-copy > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-copy > small { color: var(--muted); font-size: 11px; }
.resume-actions { display: flex; align-items: center; gap: 8px; }

.setup-resume {
  margin: 0 0 20px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-color: #dedcff;
  background: #f8f7ff;
}

.setup-resume > div { display: grid; gap: 1px; }
.setup-resume span { color: var(--muted); font-size: 12px; }

/* Home */
.v5-hero { padding-top: 68px; }
.v5-hero .hero-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-top: 24px;
  color: #555b71;
  font-size: 12px;
  font-weight: 650;
}

.v5-hero .hero-trust-row span { display: inline-flex; align-items: center; gap: 7px; }
.v5-hero .hero-trust-row svg { width: 17px; height: 17px; color: var(--primary); }
.v5-demo-card .demo-input { font-size: 14px; }
.v5-demo-feedback .demo-check {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--primary);
  font-weight: 850;
}

.learning-loop-section { padding-top: 38px; }
.four-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.four-steps .step-card { min-height: 216px; }

/* Practice phase banner */
.phase-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #355d9c;
  background: #eaf2ff;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.phase-pill.is-attempt {
  color: #5b46c7;
  background: #eeebff;
}

.phase-pill.is-correction {
  color: #087b59;
  background: #e2f8f0;
}

.attempt-summary-strip {
  width: min(100%, 1080px);
  margin: 0 auto 12px;
  padding: 12px 15px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid #caebdf;
  border-radius: 18px;
  background: linear-gradient(135deg, #f4fffb, #f8f7ff);
  box-shadow: 0 12px 28px rgba(39, 105, 82, 0.08);
}

.attempt-score-mini {
  width: 62px;
  height: 62px;
  display: grid;
  place-content: center;
  border-radius: 18px;
  color: #087b59;
  background: #ddf8ee;
  text-align: center;
}

.attempt-score-mini strong { font-size: 25px; line-height: 1; }
.attempt-score-mini span { margin-top: 3px; font-size: 9px; font-weight: 800; }
.attempt-summary-copy { min-width: 0; display: grid; gap: 3px; }
.attempt-summary-copy strong { font-size: 14px; }
.attempt-summary-copy small { color: var(--muted); font-size: 10px; }
.attempt-process-mini { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.attempt-process-mini > span:not(.assistance-badge) {
  padding: 5px 8px;
  border: 1px solid #e3e5ed;
  border-radius: 999px;
  color: #6a7083;
  background: #fff;
  font-size: 9px;
  font-weight: 700;
}

.assistance-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.assistance-badge.is-independent { color: #087b59; background: #dcf7ed; }
.assistance-badge.is-hint { color: #745315; background: #fff1c8; }
.assistance-badge.is-letters { color: #a4511c; background: #ffe7d7; }
.assistance-badge.is-reference { color: #b63c51; background: #ffe4e8; }
.assistance-badge.is-review { color: #555f78; background: #edf0f6; }

/* Playback panel */
.v5-listening-callout {
  width: min(100%, 1140px);
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(330px, 0.95fr) minmax(150px, 0.42fr);
  gap: 10px;
}

.listen-speed-panel {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 9px 11px;
  border: 1px solid #dfe5ef;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(39, 52, 86, 0.07);
}

.listen-speed-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #7e8798;
  font-size: 9px;
  font-weight: 800;
}

.listen-speed-heading strong { color: #245fc7; font-size: 13px; font-variant-numeric: tabular-nums; }

.listen-speed-options {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.listen-rate-option {
  min-width: 0;
  min-height: 28px;
  padding: 4px 2px;
  border: 1px solid #e0e6f0;
  border-radius: 8px;
  color: #657086;
  background: #f8faff;
  font-size: 9px;
  font-weight: 800;
  transition: 0.16s ease;
}

.listen-rate-option:hover { color: #245fc7; border-color: #b7cdf0; background: #edf4ff; }
.listen-rate-option.is-selected { color: #fff; border-color: #356de3; background: #356de3; box-shadow: 0 5px 14px rgba(53, 109, 227, 0.24); }

/* First attempt is intentionally neutral. */
.phase-attempt .word-canvas.sentence-slots .typing-word,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-filled,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-partial,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-correct,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-wrong {
  --word-accent: #5a64df;
}

.phase-attempt .word-canvas.sentence-slots .word-slot-input,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-filled .word-slot-input,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-partial .word-slot-input,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-correct .word-slot-input,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-wrong .word-slot-input {
  color: #20263a;
  text-shadow: none;
}

.phase-attempt .word-canvas.sentence-slots .typing-word-line,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-filled .typing-word-line,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-partial .typing-word-line,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-correct .typing-word-line,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-wrong .typing-word-line {
  opacity: 0.62;
  background: #5a64df;
  box-shadow: 0 2px 8px rgba(90, 100, 223, 0.16);
}

.phase-attempt .word-canvas.sentence-slots .typing-word.is-active .typing-word-line {
  opacity: 1;
  background: #315fdd;
  box-shadow: 0 3px 13px rgba(49, 95, 221, 0.28);
}

.phase-attempt .word-canvas.sentence-slots .typing-phonetic,
.phase-attempt .word-canvas.sentence-slots .typing-gloss {
  visibility: hidden;
}

.phase-attempt .word-canvas.sentence-slots .typing-word.is-filled .typing-phonetic,
.phase-attempt .word-canvas.sentence-slots .typing-word.is-filled .typing-gloss {
  visibility: hidden;
}

.phase-correction .word-canvas.sentence-slots .typing-phonetic,
.phase-correction .word-canvas.sentence-slots .typing-gloss { visibility: visible; }

/* Guarantee complete word rendering. */
.word-canvas.sentence-slots .typing-word {
  min-width: var(--slot-width, 82px);
  width: var(--slot-width, 126px);
  max-width: min(100%, 520px);
  overflow: visible;
}

.word-canvas.sentence-slots .typing-word-text,
.word-canvas.sentence-slots .typing-input-shell,
.word-canvas.sentence-slots .word-slot-input,
.word-canvas.sentence-slots .typing-word-measure {
  overflow: visible;
  text-overflow: clip;
}

.word-canvas.sentence-slots .word-slot-input {
  min-height: 1.55em;
  padding-top: 0.08em;
  padding-bottom: 0.24em;
  line-height: 1.25;
}

/* Progressive hints */
.typing-hint {
  display: none;
  margin-inline: auto;
  border: 1px solid #dedcff;
  border-radius: 16px;
  color: #4b5170;
  background: #f8f7ff;
}

.typing-hint.is-visible { display: grid; gap: 8px; }
.hint-level-row,
.initial-hint { display: flex; align-items: flex-start; gap: 10px; }
.hint-level-row > span,
.initial-hint > span { flex: 0 0 auto; color: #7a73b8; font-size: 10px; font-weight: 850; }
.hint-level-row strong { color: #3f3a9e; font-size: 12px; }
.initial-hint code { color: #5e568f; font-size: 11px; white-space: normal; word-break: break-word; }
.typing-hint p { margin: 0; color: #8d91a3; font-size: 9px; }

/* Mobile tool sheet stays hidden on desktop. */
.mobile-more-toggle,
.mobile-tools-sheet { display: none; }

/* Feedback layout */
.v5-feedback-layout {
  max-width: 1120px;
  padding-top: 34px;
}

.v5-feedback-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 27px;
  border-color: #dedcff;
  background: linear-gradient(135deg, rgba(248, 247, 255, 0.98), rgba(245, 255, 251, 0.96));
}

.score-block { display: flex; align-items: center; gap: 18px; }
.score-copy { display: grid; gap: 3px; }
.score-copy h1 { margin: 3px 0 0; font-size: clamp(24px, 3vw, 36px); line-height: 1.15; }
.score-copy p { margin: 0; color: var(--muted); }

.score-ring {
  --score: 0;
  width: 92px;
  height: 92px;
  position: relative;
  display: grid;
  place-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--score) * 1%), #e8e9f4 0);
  text-align: center;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: inherit;
  background: #fff;
}

.score-ring strong,
.score-ring span { position: relative; z-index: 1; }
.score-ring strong { font-size: 30px; line-height: 1; }
.score-ring span { margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 800; }
.feedback-top-actions { display: flex; align-items: center; gap: 9px; }

.feedback-tabs {
  margin: 14px 0 18px;
  padding: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
  position: sticky;
  top: 102px;
  z-index: 8;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.feedback-tabs button {
  min-height: 42px;
  flex: 1 1 0;
  position: relative;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  color: #6c7184;
  background: transparent;
  font-weight: 750;
}

.feedback-tabs button:hover { color: var(--text); background: #f5f6fa; }
.feedback-tabs button.is-active { color: var(--primary-dark); background: var(--primary-soft); }
.tab-check {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  margin-left: 5px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 9px;
}

.feedback-tab-content { animation: tabIn 0.22s ease both; }
@keyframes tabIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

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

.metric-card { padding: 17px; }
.metric-card > span { color: var(--muted); font-size: 11px; font-weight: 750; }
.metric-value { display: flex; align-items: baseline; gap: 3px; margin: 5px 0 10px; }
.metric-value strong { font-size: 28px; line-height: 1; }
.metric-value small { color: #9da2b0; font-size: 9px; }
.metric-bar { height: 5px; overflow: hidden; border-radius: 99px; background: #eef0f5; }
.metric-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #7e75f1); }
.metric-hint { display: block; margin-top: 7px; color: #9498a8; font-size: 9px; }

.v5-result-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
}

.attempt-record-card,
.dictation-card,
.feedback-card,
.recommended-sentences { padding: 20px; }

.attempt-record-card .user-answer {
  margin: 13px 0;
  padding: 15px 16px;
  border-radius: 14px;
  color: #333a52;
  background: #f6f7fa;
  font-size: 15px;
  line-height: 1.65;
}

.attempt-telemetry { display: flex; flex-wrap: wrap; gap: 7px; }
.attempt-telemetry span {
  padding: 5px 8px;
  border-radius: 999px;
  color: #61677d;
  background: #f1f2f7;
  font-size: 9px;
  font-weight: 750;
}

.dictation-comparison { display: flex; flex-wrap: wrap; gap: 8px; }
.dictation-token {
  min-width: 66px;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid #e0e4ea;
  border-radius: 11px;
  background: #f8f9fb;
  text-align: center;
}
.dictation-token strong { font-size: 12px; }
.dictation-token small { color: #7e8496; font-size: 8px; }
.dictation-token.is-correct { border-color: #bce9d8; color: #087b59; background: #ecfbf5; }
.dictation-token.is-wrong,
.dictation-token.is-extra { border-color: #f3c4cc; color: #bd3f53; background: #fff3f5; }
.comparison-note { color: var(--muted); font-size: 10px; }

.compact-feedback-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

.feedback-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.feedback-list li { position: relative; padding-left: 19px; color: #4e5469; }
.feedback-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 850; }
.feedback-list.issues li::before { content: "!"; color: var(--warning); }
.issue-title,
.issue-detail { display: block; }
.issue-title { color: var(--text); font-weight: 800; }
.issue-detail { margin-top: 2px; color: var(--muted); font-size: 11px; }

/* Phrase learning */
.learning-analysis-card.is-tab-content { padding: 24px; }
.learning-analysis-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.learning-analysis-head .card-heading { align-items: flex-start; }
.learning-analysis-head .card-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.learning-count { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: #5d54c2; background: #efedff; font-size: 10px; font-weight: 800; }
.v5-phrase-grid,
.phrase-study-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 18px;
}

.phrase-study-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid #e3e4ee;
  border-radius: 17px;
  background: #fff;
}

.phrase-study-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.phrase-study-top > div { min-width: 0; display: flex; align-items: center; gap: 9px; }
.phrase-index { color: #a0a4b3; font-size: 9px; font-weight: 850; }
.phrase-study-card code {
  overflow-wrap: anywhere;
  color: #3e37a7;
  font-size: 14px;
  font-weight: 850;
}

.phrase-play-button,
.play-button,
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid #dedcff;
  border-radius: 12px;
  color: var(--primary);
  background: #f7f6ff;
}

.phrase-play-button:hover,
.play-button:hover,
.icon-button:hover { border-color: #bdb8fb; background: #eeecff; }
.phrase-play-button svg,
.play-button svg,
.icon-button svg { width: 17px; height: 17px; }
.phrase-meaning { display: block; margin: 11px 0 10px; color: #252a3d; font-size: 12px; }
.phrase-details { margin: 0; display: grid; gap: 7px; }
.phrase-details > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px; }
.phrase-details dt { color: #8b8f9e; font-size: 9px; font-weight: 800; }
.phrase-details dd { margin: 0; color: #585e70; font-size: 10px; }
.phrase-example { margin: 12px 0 0; padding-top: 11px; border-top: 1px dashed #e0e2e9; color: #4b5268; font-size: 11px; }
.phrase-example span { margin-right: 7px; color: var(--primary); font-size: 9px; font-weight: 850; }
.learning-frame-box.standalone-frame { margin-top: 15px; }

/* Transfer practice */
.transfer-tab-content {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(250px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.transfer-workspace { padding: 25px; }
.transfer-instruction h2 { margin: 2px 0 6px; font-size: 25px; line-height: 1.25; }
.transfer-instruction p { margin: 0; color: var(--muted); }
.transfer-frame-box,
.transfer-question-box {
  margin-top: 16px;
  padding: 15px 17px;
  border-radius: 15px;
}
.transfer-frame-box { border: 1px solid #dcd9ff; background: #f6f4ff; }
.transfer-frame-box > span,
.transfer-question-box > span { display: block; color: #7c78a3; font-size: 9px; font-weight: 850; letter-spacing: 0.06em; text-transform: uppercase; }
.transfer-frame-box code { display: block; margin: 6px 0 3px; color: #4038b2; font-size: 16px; font-weight: 850; overflow-wrap: anywhere; }
.transfer-frame-box small { color: #7b7f91; }
.transfer-question-box { border: 1px solid #ccecdf; background: #f1fcf8; }
.transfer-question-box h3 { margin: 6px 0 0; font-size: 18px; }
.transfer-input-label { display: block; margin: 17px 0 7px; color: #555b70; font-size: 11px; font-weight: 800; }
.transfer-textarea {
  width: 100%;
  resize: vertical;
  min-height: 116px;
  padding: 14px 15px;
  border: 1px solid #dfe1e9;
  border-radius: 15px;
  outline: none;
  color: var(--text);
  background: #fbfbfd;
  line-height: 1.65;
}
.transfer-textarea:focus { border-color: #958ef2; box-shadow: 0 0 0 4px rgba(81, 70, 229, 0.1); background: #fff; }
.transfer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 11px; }
.transfer-tips-card { padding: 21px; }
.transfer-tips-card h2 { margin: 0 0 13px; font-size: 18px; }
.transfer-tips-card ol { margin: 0 0 17px; padding-left: 21px; display: grid; gap: 13px; }
.transfer-tips-card li { color: var(--primary); }
.transfer-tips-card li strong,
.transfer-tips-card li span { display: block; color: var(--text); }
.transfer-tips-card li span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.transfer-result {
  margin-top: 15px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  border: 1px solid #f0cad1;
  border-radius: 15px;
  background: #fff5f6;
}
.transfer-result.is-passed { border-color: #bfe9da; background: #eefbf6; }
.transfer-result-score {
  width: 54px;
  height: 54px;
  display: grid;
  place-content: center;
  border-radius: 15px;
  color: #b84054;
  background: #ffe3e8;
  text-align: center;
}
.transfer-result.is-passed .transfer-result-score { color: #087b59; background: #d9f6eb; }
.transfer-result-score strong { font-size: 22px; line-height: 1; }
.transfer-result-score span { font-size: 8px; font-weight: 800; }
.transfer-result-copy h3 { margin: 0 0 3px; font-size: 14px; }
.transfer-result-copy p { margin: 6px 0 0; color: #555c70; font-size: 10px; }
.transfer-check-list { display: flex; flex-wrap: wrap; gap: 5px; }
.transfer-check-list span { padding: 4px 7px; border-radius: 999px; color: #8d5b63; background: #fff; font-size: 8px; font-weight: 750; }
.transfer-check-list span.is-passed { color: #087b59; }

/* Shadowing */
.shadow-tab-content {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(250px, 0.55fr);
  gap: 16px;
  align-items: start;
}
.shadow-workspace { padding: 24px; }
.shadow-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.shadow-heading h2 { margin: 2px 0 5px; font-size: 25px; }
.shadow-heading p { margin: 0; color: var(--muted); }
.shadow-chunks { display: grid; gap: 9px; margin-top: 18px; }
.shadow-chunk {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid #e1e3ea;
  border-radius: 14px;
  color: var(--text);
  background: #fbfbfd;
  text-align: left;
}
.shadow-chunk:hover { border-color: #c5c0fb; background: #f7f6ff; }
.shadow-chunk > span { color: #a1a5b3; font-size: 9px; font-weight: 850; }
.shadow-chunk strong { font-size: 14px; }
.shadow-chunk svg { width: 18px; height: 18px; color: var(--primary); }
.shadow-record-card {
  margin-top: 16px;
  padding: 15px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  border: 1px solid #dcd9ff;
  border-radius: 16px;
  background: #f8f7ff;
}
.shadow-record-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: var(--primary); background: #e7e4ff; }
.shadow-record-icon svg { width: 22px; height: 22px; }
.shadow-record-card h3 { margin: 0; font-size: 14px; }
.shadow-record-card p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.shadow-tips-card { padding: 21px; }
.shadow-tips-card h2 { margin: 0 0 12px; font-size: 18px; }
.shadow-tips-card ul { margin: 0; padding-left: 18px; color: #555b6f; display: grid; gap: 10px; }
.shadow-result {
  margin-top: 14px;
  padding: 13px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  border-radius: 15px;
  color: #8b4e59;
  background: #fff3f5;
}
.shadow-result.is-good { color: #087b59; background: #ecfaf5; }
.shadow-result > div { width: 54px; height: 54px; display: grid; place-content: center; border-radius: 14px; background: #fff; text-align: center; }
.shadow-result strong { font-size: 21px; line-height: 1; }
.shadow-result span { font-size: 8px; font-weight: 800; }
.shadow-result p { margin: 0; color: #4e556b; }
.shadow-result p span { display: block; color: #9296a6; }
.shadow-result small { grid-column: 2; color: #7c8192; }

.v5-feedback-actions {
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px auto 0;
}

/* Completion */
.v5-complete-card {
  max-width: 860px;
  padding: 40px;
}

.completion-score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  margin: 24px 0;
}
.completion-score-grid > div {
  padding: 15px;
  border: 1px solid #e3e4ec;
  border-radius: 15px;
  background: #fbfbfd;
}
.completion-score-grid span,
.completion-score-grid small { display: block; color: var(--muted); font-size: 9px; }
.completion-score-grid strong { display: block; margin: 3px 0; font-size: 25px; }

/* Spaced review */
.review-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}
.review-summary-card { padding: 18px; }
.review-summary-card span,
.review-summary-card small { display: block; color: var(--muted); }
.review-summary-card span { font-size: 11px; font-weight: 750; }
.review-summary-card strong { display: block; margin: 3px 0; font-size: 29px; }
.review-summary-card small { font-size: 9px; }
.v5-review-list { gap: 12px; }
.v5-review-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
}
.review-score {
  width: 62px;
  height: 62px;
  display: grid;
  place-content: center;
  border-radius: 17px;
  color: #4d45be;
  background: #eeecff;
  text-align: center;
}
.review-score strong { font-size: 25px; line-height: 1; }
.review-score span { font-size: 8px; font-weight: 800; }
.review-copy { min-width: 0; }
.review-copy h3 { margin: 6px 0 2px; font-size: 16px; }
.review-reference { margin: 0; color: #50576c; }
.review-meta-row,
.review-detail-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.review-detail-row { margin-top: 7px; color: #85899a; font-size: 9px; }
.review-status { padding: 4px 7px; border-radius: 999px; font-size: 8px; font-weight: 850; }
.review-status.is-due { color: #bd3f53; background: #ffe9ed; }
.review-status.is-learning { color: #75611f; background: #fff3cd; }
.review-status.is-mastered { color: #087b59; background: #e2f8f0; }
.v5-review-actions { display: flex; align-items: center; gap: 6px; }

/* Progress */
.v5-dashboard-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.v5-dashboard-grid .dashboard-stat { min-width: 0; }
.data-tools-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 21px;
}
.data-tools-card h2 { margin: 0; font-size: 18px; }
.data-tools-card p { margin: 3px 0 0; color: var(--muted); }
.data-tool-actions { display: flex; align-items: center; gap: 8px; }

/* Small desktop and tablet */
@media (max-width: 1080px) {
  .four-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v5-listening-callout { grid-template-columns: minmax(260px, 1fr) minmax(280px, 0.9fr); }
  .v5-listening-callout .listen-reveal-button { grid-column: 1 / -1; min-height: 44px; width: 100%; }
  .v5-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v5-dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .resume-banner { grid-template-columns: auto minmax(0, 1fr); }
  .resume-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .v5-hero .hero-trust-row { justify-content: center; }
  .attempt-summary-strip { grid-template-columns: auto minmax(0, 1fr); }
  .attempt-process-mini { grid-column: 1 / -1; justify-content: flex-start; }
  .v5-listening-callout { grid-template-columns: 1fr; }
  .v5-listening-callout .listen-reveal-button { grid-column: auto; }
  .listen-speed-panel { width: 100%; }
  .transfer-tab-content,
  .shadow-tab-content,
  .v5-result-grid { grid-template-columns: 1fr; }
  .phrase-study-grid,
  .v5-phrase-grid { grid-template-columns: 1fr; }
  .v5-feedback-banner { align-items: flex-start; }
  .feedback-top-actions { flex-direction: column; align-items: stretch; }
  .v5-review-item { grid-template-columns: auto minmax(0, 1fr); }
  .v5-review-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Phone-first practice behavior */
@media (max-width: 620px) {
  .resume-banner {
    margin-top: 18px;
    grid-template-columns: 1fr;
    text-align: center;
  }
  .resume-icon { margin: 0 auto; }
  .resume-copy > strong { white-space: normal; }
  .resume-actions { grid-column: auto; display: grid; grid-template-columns: 1fr 1fr; }
  .setup-resume { align-items: stretch; flex-direction: column; }
  .four-steps { grid-template-columns: 1fr; }
  .four-steps .step-card { min-height: 0; }
  .practice-count-options { grid-template-columns: repeat(3, 1fr); }
  .practice-count-options .segment-button:nth-child(n + 4) { grid-column: span 1; }

  .v5-practice {
    min-height: 100dvh;
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .typing-session-meta { gap: 5px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
  .typing-session-meta::-webkit-scrollbar { display: none; }
  .phase-pill { min-height: 24px; font-size: 8px; }

  .attempt-summary-strip {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 10px;
    gap: 10px;
    border-radius: 15px;
  }
  .attempt-score-mini { width: 52px; height: 52px; border-radius: 14px; }
  .attempt-score-mini strong { font-size: 21px; }
  .attempt-summary-copy strong { font-size: 12px; }
  .attempt-summary-copy small { font-size: 8px; }
  .attempt-process-mini { display: none; }

  .v5-listening-callout { gap: 7px; }
  .listen-speed-panel { padding: 8px; border-radius: 13px; }
  .listen-speed-heading { display: none; }
  .listen-speed-options { gap: 3px; }
  .listen-rate-option { min-height: 34px; font-size: 8px; }
  .listen-reveal-button { min-height: 44px; }

  .word-canvas.sentence-slots {
    width: 100%;
    max-width: 100%;
    column-gap: 7px;
    row-gap: 15px;
    padding: 8px 1px;
  }
  .word-canvas.sentence-slots .typing-word {
    min-width: min(var(--slot-width, 74px), 100%);
    max-width: 100%;
  }
  .word-canvas.sentence-slots .typing-word-text,
  .word-canvas.sentence-slots.is-long .typing-word-text,
  .word-canvas.sentence-slots.is-very-long .typing-word-text {
    font-size: clamp(23px, 7.3vw, 34px);
  }
  .word-canvas.sentence-slots .word-slot-input {
    min-height: 1.62em;
    padding-bottom: 0.28em;
  }

  .typing-hint.is-visible { margin-inline: 6px; }
  .hint-level-row,
  .initial-hint { flex-direction: column; gap: 3px; }

  .typing-controls.v5-controls {
    min-height: 74px;
    height: auto;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid #e8eaf1;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(18px);
  }
  .v5-controls > .typing-nav-button { display: none; }
  .v5-controls .typing-shortcuts {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr);
    gap: 7px;
    overflow: visible;
    padding: 0;
  }
  .v5-controls .typing-shortcut {
    min-width: 0;
    min-height: 52px;
    justify-content: center;
    border-radius: 14px;
  }
  .v5-controls .typing-shortcut.is-listen-primary { display: inline-flex; }
  .v5-controls .typing-shortcut.is-primary { display: inline-flex; }
  .v5-controls .typing-shortcut.is-speed-shortcut,
  .v5-controls .typing-shortcut:not(.is-listen-primary):not(.is-primary):not(.mobile-more-toggle) { display: none; }
  .v5-controls .shortcut-keys { display: none; }
  .mobile-more-toggle { display: inline-flex !important; }
  .mobile-tools-sheet {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 40;
    padding: 12px;
    border: 1px solid #e1e3eb;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 22px 60px rgba(30, 34, 61, 0.22);
    transform: translateY(18px);
    opacity: 0;
    visibility: hidden;
    transition: 0.18s ease;
  }
  .mobile-tools-sheet.is-visible { transform: none; opacity: 1; visibility: visible; }
  .mobile-tools-sheet button {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #e4e5ec;
    border-radius: 13px;
    color: #4e556a;
    background: #f8f9fb;
  }
  .mobile-tools-sheet svg { width: 18px; height: 18px; color: var(--primary); }

  .v5-feedback-layout { padding-top: 21px; }
  .v5-feedback-banner { align-items: stretch; flex-direction: column; padding: 17px; }
  .score-block { align-items: flex-start; }
  .score-ring { width: 74px; height: 74px; }
  .score-ring strong { font-size: 24px; }
  .score-copy h1 { font-size: 23px; }
  .feedback-top-actions { display: grid; grid-template-columns: 1fr 1fr; }

  .feedback-tabs {
    top: 80px;
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }
  .feedback-tabs::-webkit-scrollbar { display: none; }
  .feedback-tabs button { min-width: 108px; flex: 0 0 auto; }

  .v5-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { padding: 13px; }
  .metric-value strong { font-size: 23px; }
  .compact-feedback-grid { grid-template-columns: 1fr; }
  .learning-analysis-card.is-tab-content,
  .transfer-workspace,
  .shadow-workspace { padding: 17px; }
  .learning-analysis-head { flex-direction: column; }
  .learning-count { align-self: flex-start; }
  .phrase-details > div { grid-template-columns: 64px minmax(0, 1fr); }
  .transfer-instruction h2,
  .shadow-heading h2 { font-size: 21px; }
  .transfer-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .transfer-result { grid-template-columns: auto minmax(0, 1fr); }
  .transfer-result > .play-button { grid-column: 1 / -1; width: 100%; }
  .shadow-heading { flex-direction: column; }
  .shadow-heading .btn { width: 100%; }
  .shadow-record-card { grid-template-columns: auto minmax(0, 1fr); }
  .shadow-record-card .btn { grid-column: 1 / -1; width: 100%; }
  .v5-feedback-actions { grid-template-columns: 1fr; }

  .completion-score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v5-complete-card { padding: 25px 17px; }
  .review-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .review-summary-card { padding: 12px 9px; }
  .review-summary-card strong { font-size: 22px; }
  .v5-review-item { grid-template-columns: 1fr; }
  .review-score { width: 52px; height: 52px; }
  .v5-review-actions { justify-content: flex-start; flex-wrap: wrap; }
  .v5-dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-tools-card { align-items: stretch; flex-direction: column; }
  .data-tool-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .listen-speed-options { grid-template-columns: repeat(3, 1fr); }
  .v5-controls .typing-shortcuts { grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr); }
  .v5-metric-grid,
  .completion-score-grid,
  .v5-dashboard-grid { grid-template-columns: 1fr; }
  .review-summary-grid { grid-template-columns: 1fr; }
  .feedback-top-actions,
  .resume-actions,
  .transfer-actions,
  .data-tool-actions { grid-template-columns: 1fr; }
}

/* V5 mobile action bar: make the three primary actions fill the viewport.
   The desktop grid includes hidden left/right navigation cells; on phones the
   shortcut row must span the entire bar instead of inheriting the first cell. */
@media (max-width: 760px) {
  .typing-controls.v5-controls {
    display: block;
    width: 100%;
  }

  .v5-controls .typing-shortcuts {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
  }

  .v5-controls .typing-shortcut.is-listen-primary,
  .v5-controls .typing-shortcut.is-primary {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 390px) {
  .v5-controls .typing-shortcuts {
    grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .v5-controls .typing-shortcut.is-primary > span:last-child {
    display: inline !important;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  .typing-brand,
  .typing-progress-number,
  .typing-prompt p,
  .attempt-summary-copy strong {
    color: #20263c;
  }

  .typing-stage-note,
  .typing-prompt small,
  .typing-session-meta,
  .attempt-summary-copy small {
    color: #70778f;
  }
}

/* V5.1: long sentences must expand naturally on phones.
   Earlier flex centering could shrink a multi-row sentence canvas and place
   the first rows above the visible box. Keep every word slot in normal flow. */
.word-canvas.sentence-slots {
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .word-canvas.sentence-slots,
  .word-canvas.sentence-slots.is-long,
  .word-canvas.sentence-slots.is-very-long {
    height: auto !important;
    max-height: none !important;
    min-height: 160px;
    align-content: flex-start !important;
    align-items: flex-start;
    overflow: visible !important;
  }
}

/* ========================================================================
   V6.1 mobile-first refinement
   - iPhone-class feedback actions stay near the top and remain reachable.
   - The Chinese prompt appears before the sentence slots on phones.
   - First-attempt slots collapse hidden phonetic/gloss rows to avoid tall gaps.
   - Playback speed remains available from the mobile tools sheet.
   ======================================================================== */
.mobile-feedback-actions,
.mobile-speed-control {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --mobile-feedback-tabs-top: calc(env(safe-area-inset-top) + 82px);
    --mobile-feedback-actions-top: calc(env(safe-area-inset-top) + 136px);
  }

  html {
    scroll-padding-top: calc(env(safe-area-inset-top) + 150px);
  }

  body.feedback-focus .site-footer {
    display: none;
  }

  body.feedback-focus #app {
    min-height: calc(100dvh - env(safe-area-inset-top));
  }

  /* Practice: put the task before the answer slots on phones. */
  .v5-practice .typing-stage {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    scroll-padding-block: 12px calc(96px + env(safe-area-inset-bottom));
  }

  .v5-practice .attempt-summary-strip { order: 0; }
  .v5-practice .typing-stage-note { order: 1; }
  .v5-practice .typing-prompt { order: 2; }
  .v5-practice .original-sentence-panel { order: 3; }
  .v5-practice .word-canvas.sentence-slots { order: 4; }
  .v5-practice .typing-hint { order: 5; }
  .v5-practice .v5-listening-callout { order: 6; }

  .v5-practice .typing-prompt {
    width: calc(100% - 4px);
    margin: 2px auto 10px;
    padding: 12px 13px 11px;
    border: 1px solid #e1e4ef;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(247, 247, 255, 0.98), rgba(245, 253, 250, 0.98));
    box-shadow: 0 10px 28px rgba(43, 48, 81, 0.06);
    text-align: left;
  }

  .v5-practice .typing-prompt > span {
    display: block;
    color: #6d66c8;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.02em;
    text-align: left;
  }

  .v5-practice .typing-prompt p {
    margin: 6px 0 4px;
    color: #20263c;
    font-size: clamp(18px, 5.25vw, 22px);
    font-weight: 760;
    line-height: 1.48;
    letter-spacing: -0.025em;
    text-align: left;
  }

  .v5-practice .typing-prompt small {
    display: block;
    color: #858b9f;
    font-size: 9px;
    line-height: 1.45;
    text-align: left;
  }

  /* The fixed phone toolbar already contains playback and More. Keep the
     full desktop playback panel out of the way, while preserving every
     control inside the More sheet below. */
  .v5-practice .v5-listening-callout {
    display: none;
  }

  .v5-practice .word-canvas.sentence-slots,
  .v5-practice .word-canvas.sentence-slots.is-long,
  .v5-practice .word-canvas.sentence-slots.is-very-long {
    flex: 0 0 auto;
    width: 100%;
    height: auto !important;
    min-height: 190px;
    max-height: none !important;
    margin: 0 auto 8px;
    padding: 15px 6px 13px;
    align-content: flex-start !important;
    align-items: flex-start;
    justify-content: center;
    column-gap: 7px;
    row-gap: 18px;
    overflow: visible !important;
    border-radius: 17px;
  }

  /* In the neutral first attempt the phonetic and gloss are hidden. Removing
     them from layout prevents each row from reserving two invisible lines. */
  .phase-attempt .word-canvas.sentence-slots .typing-word,
  .phase-attempt .word-canvas.sentence-slots.is-long .typing-word,
  .phase-attempt .word-canvas.sentence-slots.is-very-long .typing-word {
    grid-template-rows: minmax(43px, auto) 3px !important;
    gap: 3px !important;
  }

  .phase-attempt .word-canvas.sentence-slots .typing-phonetic,
  .phase-attempt .word-canvas.sentence-slots .typing-gloss {
    display: none !important;
  }

  .phase-attempt .word-canvas.sentence-slots .typing-word-text,
  .phase-attempt .word-canvas.sentence-slots.is-long .typing-word-text,
  .phase-attempt .word-canvas.sentence-slots.is-very-long .typing-word-text {
    min-height: 43px;
    align-items: flex-end;
  }

  .phase-correction .word-canvas.sentence-slots .typing-word,
  .phase-correction .word-canvas.sentence-slots.is-long .typing-word,
  .phase-correction .word-canvas.sentence-slots.is-very-long .typing-word {
    grid-template-rows: 16px minmax(43px, auto) 3px minmax(18px, auto) !important;
    gap: 3px !important;
  }

  .mobile-speed-control {
    grid-column: 1 / -1;
    display: grid;
    gap: 7px;
    padding: 9px;
    border: 1px solid #e1e5ef;
    border-radius: 14px;
    background: #f7f9fd;
  }

  .mobile-speed-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #72798e;
    font-size: 10px;
    font-weight: 800;
  }

  .mobile-speed-head strong {
    color: #245fc7;
    font-size: 12px;
  }

  .mobile-speed-options {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .mobile-tools-sheet .mobile-speed-option {
    min-width: 0;
    min-height: 34px;
    padding: 4px 2px;
    border: 1px solid #dfe5ef;
    border-radius: 9px;
    color: #626c82;
    background: #fff;
    font-size: 9px;
    font-weight: 850;
  }

  .mobile-tools-sheet .mobile-speed-option.is-selected {
    color: #fff;
    border-color: #356de3;
    background: #356de3;
    box-shadow: 0 5px 13px rgba(53, 109, 227, 0.22);
  }

  /* Feedback: all three high-frequency actions are visible immediately and
     stay underneath the sticky result tabs while the learner reviews cards. */
  .v5-feedback-layout {
    padding-top: 14px;
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
  }

  .v5-feedback-banner {
    margin-top: 0;
    padding: 15px;
    border-radius: 20px;
  }

  .feedback-top-actions {
    grid-template-columns: 1fr !important;
  }

  .feedback-top-actions [data-action="retry-question"] {
    display: none;
  }

  .feedback-tabs {
    top: var(--mobile-feedback-tabs-top) !important;
    z-index: 18;
    margin: 8px 0 6px;
    padding: 5px;
    border-radius: 16px;
    box-shadow: 0 10px 26px rgba(36, 41, 73, 0.08);
  }

  .mobile-feedback-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    position: sticky;
    top: var(--mobile-feedback-actions-top);
    z-index: 17;
    margin: 0 0 12px;
    padding: 6px;
    border: 1px solid rgba(224, 226, 239, 0.95);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 30px rgba(36, 41, 73, 0.11);
    backdrop-filter: blur(18px);
  }

  .mobile-feedback-action {
    min-width: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 5px;
    border: 1px solid #e1e3ec;
    border-radius: 12px;
    color: #50576c;
    background: #f8f9fc;
    font-size: 10px;
    font-weight: 820;
    line-height: 1.2;
    white-space: nowrap;
  }

  .mobile-feedback-action svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }

  .mobile-feedback-action.is-transfer {
    color: #443bc4;
    border-color: #d8d4ff;
    background: #f1efff;
  }

  .mobile-feedback-action.is-transfer.is-current {
    box-shadow: inset 0 0 0 1px #9d96f3;
  }

  .mobile-feedback-action.is-next {
    color: #fff;
    border-color: #5146e5;
    background: linear-gradient(135deg, #5b4eea, #4438d4);
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22);
  }

  .v5-feedback-actions {
    display: none !important;
  }

  .result-tab-content .next-step-card {
    display: none;
  }

  .feedback-tab-content {
    margin-top: 0;
  }
}

/* iPhone Pro-sized viewports (roughly 393-430 CSS px). */
@media (max-width: 430px) {
  .site-header,
  #app {
    width: min(calc(100% - 20px), var(--max));
  }

  .site-header {
    top: calc(7px + env(safe-area-inset-top));
    min-height: 70px;
    margin-top: 7px;
    padding: 9px 10px;
    border-radius: 18px;
  }

  .brand { gap: 9px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
  .brand-mark svg { width: 28px; height: 28px; }
  .brand-copy strong { font-size: 15px; }
  .mobile-menu { width: 42px; height: 42px; }

  .v5-practice {
    padding-inline: 8px;
  }

  .v5-practice .typing-header {
    padding-inline: 2px;
  }

  .v5-practice .typing-brand {
    gap: 8px;
    font-size: 14px;
  }

  .v5-practice .typing-prompt {
    padding: 11px 12px 10px;
    border-radius: 15px;
  }

  .v5-practice .typing-prompt p {
    font-size: clamp(18px, 5.3vw, 21px);
  }

  .v5-practice .word-canvas.sentence-slots,
  .v5-practice .word-canvas.sentence-slots.is-long,
  .v5-practice .word-canvas.sentence-slots.is-very-long {
    min-height: 178px;
    padding-inline: 4px;
    column-gap: 6px;
    row-gap: 16px;
  }

  .word-canvas.sentence-slots .typing-word,
  .word-canvas.sentence-slots.is-long .typing-word,
  .word-canvas.sentence-slots.is-very-long .typing-word {
    max-width: calc(100vw - 30px);
  }

  .mobile-feedback-actions {
    gap: 5px;
    padding: 5px;
  }

  .mobile-feedback-action {
    min-height: 46px;
    gap: 4px;
    padding-inline: 3px;
    font-size: 9.5px;
  }

  .feedback-tabs button {
    min-width: 106px;
    min-height: 43px;
    font-size: 11px;
  }

  .mobile-speed-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
