:root {
  color-scheme: dark;
  --ink: #101714;
  --ink-soft: #19231f;
  --panel: #202b26;
  --paper: #f3f0e7;
  --muted: #9ba8a1;
  --line: #3b4842;
  --jade: #53b79b;
  --jade-dark: #276b5c;
  --cinnabar: #e75b45;
  --gold: #e9bf57;
  --focus: #f5d77d;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
a,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible + .switch {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--ink);
}

.app-bar {
  position: sticky;
  z-index: 10;
  top: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) 18px 8px;
  background: rgba(16, 23, 20, 0.96);
  border-bottom: 1px solid var(--line);
}

.icon-link,
.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--ink-soft);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
}

.icon-link {
  font-size: 1.5rem;
}

.wordmark {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 750;
  white-space: nowrap;
}

.wordmark-han {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: var(--cinnabar);
  color: #fff;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 0.82rem;
}

.streak {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.streak-count {
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 800;
}

.screen {
  width: 100%;
}

.hidden {
  display: none !important;
}

.setup-banner {
  min-height: 210px;
  display: flex;
  align-items: end;
  padding: 40px 28px 26px;
  background-color: #263c34;
  background-image: url("/mandarin/mandarin-road.jpg");
  background-position: center;
  background-size: cover;
  border-bottom: 1px solid var(--line);
}

.setup-banner-copy {
  max-width: 540px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--jade);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

.setup-banner h1,
.complete-screen h1 {
  margin: 0;
  color: #fff;
  font-size: 3.4rem;
  line-height: 1.02;
  letter-spacing: 0;
}

.setup-banner p:last-child {
  max-width: 510px;
  margin: 12px 0 0;
  color: #dce4df;
  font-size: 0.98rem;
  line-height: 1.55;
}

.setup-content {
  padding: 24px 22px max(30px, env(safe-area-inset-bottom));
}

.course-variant {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin: 0 0 22px;
  color: #d7dfda;
  font-size: 0.78rem;
}

.course-variant span {
  color: var(--jade);
  font-weight: 800;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.section-heading > span {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.pinyin-entry {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid #5d5032;
  border-radius: 8px;
  background: #292719;
  color: var(--paper);
  text-align: left;
  cursor: pointer;
}

.pinyin-entry:hover {
  border-color: var(--gold);
}

.pinyin-entry-sample {
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 800;
  white-space: nowrap;
}

.pinyin-entry-copy strong,
.pinyin-entry-copy small {
  display: block;
}

.pinyin-entry-copy strong {
  margin-bottom: 3px;
}

.pinyin-entry-copy small {
  color: #b8b5a9;
  font-size: 0.74rem;
  line-height: 1.35;
}

.pinyin-entry-arrow {
  color: var(--gold);
  font-size: 1.25rem;
}

.review-entry {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #16231e;
  color: var(--paper);
  text-align: left;
}

.review-entry.ready {
  border-color: var(--jade);
  background: #183129;
  cursor: pointer;
}

.review-entry:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.72;
}

.review-entry-icon,
.review-count {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #26362f;
  color: var(--jade);
  font-weight: 800;
}

.review-entry-icon {
  font-size: 1.35rem;
}

.review-entry.ready .review-entry-icon,
.review-entry.ready .review-count {
  background: var(--jade);
  color: var(--ink);
}

.review-entry-copy {
  min-width: 0;
}

.review-entry-copy strong,
.review-entry-copy small {
  display: block;
}

.review-entry-copy strong {
  margin-bottom: 3px;
  font-size: 0.98rem;
}

.review-entry-copy small {
  color: var(--muted);
  font-size: 0.76rem;
}

.review-count {
  font-size: 0.9rem;
}

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

.lesson-option {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-soft);
  color: var(--paper);
  text-align: left;
  cursor: pointer;
}

.lesson-option[aria-checked="true"] {
  border-color: var(--jade);
  background: #203a32;
  box-shadow: inset 4px 0 0 var(--jade);
}

.lesson-number {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #2c3933;
  color: var(--jade);
  font-size: 0.9rem;
  font-weight: 800;
}

.lesson-option[aria-checked="true"] .lesson-number {
  background: var(--jade);
  color: var(--ink);
}

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

.lesson-copy strong,
.lesson-copy small {
  display: block;
}

.lesson-level {
  display: block;
  margin-bottom: 2px;
  color: var(--jade);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.lesson-copy strong {
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.lesson-copy small,
.lesson-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.lesson-status {
  color: var(--gold);
  font-size: 1.05rem;
}

.preferences {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-top: 22px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.preference-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 750;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 230px);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segment button {
  min-height: 38px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment button + button {
  border-left: 1px solid var(--line);
}

.segment button.active {
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
}

.switch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch-row small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: #52605a;
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch-row input:checked + .switch {
  background: var(--jade-dark);
}

.switch-row input:checked + .switch::after {
  transform: translateX(20px);
}

.switch-row input:disabled + .switch {
  opacity: 0.4;
}

.safety-note {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  margin: 18px 0;
  color: #d8d2c3;
  font-size: 0.78rem;
  line-height: 1.45;
}

.safety-note > span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-weight: 850;
}

.primary-action {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 14px 20px;
  border: 0;
  border-radius: 7px;
  background: var(--cinnabar);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.primary-action:hover {
  background: #f0644d;
}

.primary-action:active {
  background: #c84331;
}

.support-note {
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
  text-align: center;
}

.session-screen {
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 15px 22px max(24px, env(safe-area-inset-bottom));
}

.session-top {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 16px;
}

.icon-button.quiet {
  background: transparent;
  border-color: transparent;
  font-size: 1.55rem;
}

.session-progress {
  min-width: 0;
}

.session-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.session-meta span:first-child {
  min-width: 0;
  overflow: hidden;
  color: var(--paper);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 4px;
  overflow: hidden;
  background: #344139;
  border-radius: 2px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--jade);
  transition: width 220ms ease;
}

.mic-indicator {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.mic-indicator span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #64726b;
}

.mic-indicator.listening span {
  background: var(--cinnabar);
  box-shadow: 0 0 0 7px rgba(231, 91, 69, 0.14);
  animation: mic-pulse 1.1s ease-in-out infinite;
}

@keyframes mic-pulse {
  50% { box-shadow: 0 0 0 12px rgba(231, 91, 69, 0); }
}

.session-stage {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0 12px;
}

.phase {
  min-height: 25px;
  margin-bottom: 15px;
  color: var(--jade);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.phrase-panel {
  width: min(100%, 620px);
  min-height: 270px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.phrase-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.phrase-panel.has-breakdown {
  min-height: 350px;
}

.phrase-panel.words-hidden .hanzi,
.phrase-panel.words-hidden .pinyin {
  visibility: hidden;
}

.word-breakdown {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  margin: 20px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.word-breakdown li {
  min-width: 94px;
  padding: 0;
  border-right: 1px solid var(--line);
  text-align: center;
}

.word-breakdown li:last-child {
  border-right: 0;
}

.word-pronunciation {
  position: relative;
  width: 100%;
  min-height: 58px;
  display: grid;
  gap: 1px;
  align-content: center;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.word-pronunciation::after {
  position: absolute;
  top: 6px;
  right: 7px;
  color: var(--jade);
  content: "\25B6";
  font-size: 0.52rem;
  opacity: 0.78;
}

.word-pronunciation:hover,
.word-pronunciation.playing {
  background: #2b3c34;
}

.word-pronunciation.playing {
  box-shadow: inset 0 0 0 1px var(--jade);
}

.word-breakdown b {
  color: #fff;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 1.05rem;
}

.word-breakdown span {
  color: var(--gold);
  font-size: 0.72rem;
}

.word-breakdown small {
  color: #c3ccc7;
  font-size: 0.68rem;
  line-height: 1.25;
}

.meaning {
  margin: 0 0 18px;
  color: #d8dedb;
  font-size: 1rem;
}

.hanzi {
  margin: 0;
  color: #fff;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 5.4rem;
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: 0;
}

.pinyin {
  min-height: 28px;
  margin: 13px 0 0;
  color: var(--gold);
  font-size: 1.35rem;
}

.audio-bars {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 18px;
}

.audio-bars span {
  width: 3px;
  height: 7px;
  border-radius: 2px;
  background: var(--jade);
}

.audio-bars.active span {
  animation: audio-bar 0.7s ease-in-out infinite alternate;
}

.audio-bars.active span:nth-child(2),
.audio-bars.active span:nth-child(4) {
  animation-delay: 180ms;
}

.audio-bars.active span:nth-child(3) {
  animation-delay: 340ms;
}

@keyframes audio-bar {
  to { height: 23px; }
}

.heard-text {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.heard-text.correct {
  color: var(--jade);
}

.manual-action {
  min-height: 42px;
  margin-top: 2px;
  padding: 9px 16px;
  border: 1px solid var(--jade);
  border-radius: 6px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.session-controls {
  display: grid;
  grid-template-columns: 64px 96px 64px;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding-top: 14px;
}

.control-button {
  width: 64px;
  height: 64px;
  font-size: 1.55rem;
}

.main-control {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--cinnabar);
  color: #fff;
  font-size: 1.65rem;
  cursor: pointer;
  box-shadow: 0 0 0 10px rgba(231, 91, 69, 0.12);
}

.main-control.paused {
  background: var(--jade);
  color: var(--ink);
  box-shadow: 0 0 0 10px rgba(83, 183, 155, 0.12);
}

.complete-screen {
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 24px max(34px, env(safe-area-inset-bottom));
  text-align: center;
}

.completion-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 2px solid var(--jade);
  border-radius: 50%;
  color: var(--jade);
  font-size: 2.1rem;
}

.complete-screen > p:not(.eyebrow) {
  max-width: 440px;
  margin: 14px 0 0;
  color: var(--muted);
}

.completion-stats {
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 34px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.completion-stats div {
  padding: 18px;
}

.completion-stats div + div {
  border-left: 1px solid var(--line);
}

.completion-stats strong,
.completion-stats span {
  display: block;
}

.completion-stats strong {
  color: var(--gold);
  font-size: 1.7rem;
}

.completion-stats span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.complete-screen .primary-action {
  max-width: 390px;
}

.text-action {
  margin-top: 18px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.pinyin-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-soft);
  color: var(--paper);
}

.pinyin-dialog::backdrop {
  background: rgba(3, 8, 6, 0.82);
}

.pinyin-dialog-shell {
  max-height: calc(100vh - 30px);
  max-height: calc(100dvh - 30px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.pinyin-dialog-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.pinyin-dialog-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.pinyin-dialog-header .eyebrow {
  margin-bottom: 3px;
}

.pinyin-dialog-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 22px;
}

.pinyin-lead {
  margin: 0 0 20px;
  color: #dce3df;
  font-size: 0.94rem;
  line-height: 1.55;
}

.primer-section {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.primer-step {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 1px solid var(--jade);
  border-radius: 50%;
  color: var(--jade);
  font-size: 0.78rem;
  font-weight: 850;
}

.primer-section h3 {
  margin: 3px 0 7px;
  color: #fff;
  font-size: 1.02rem;
}

.primer-section p:not(.primer-note) {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.syllable-examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.syllable-examples > span {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #d7dfda;
  font-size: 0.82rem;
}

.syllable-examples strong {
  color: var(--gold);
  font-size: 1.05rem;
}

.syllable-examples small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.tone-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.tone-grid button {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--paper);
  cursor: pointer;
}

.tone-grid button:hover,
.tone-grid button.playing,
.sound-list button:hover,
.sound-list button.playing {
  border-color: var(--jade);
  background: #203a32;
}

.tone-grid b {
  color: var(--gold);
  font-size: 1.25rem;
}

.tone-grid span {
  font-size: 0.68rem;
  font-weight: 750;
}

.tone-grid small {
  color: var(--muted);
  font-size: 0.64rem;
}

.primer-note {
  margin: 10px 0 0;
  color: #c5cdc9;
  font-size: 0.73rem;
  line-height: 1.4;
}

.sound-list {
  border-top: 1px solid var(--line);
}

.sound-list button {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  text-align: left;
  cursor: pointer;
}

.sound-list b {
  color: var(--gold);
  font-size: 1.15rem;
}

.sound-list span {
  font-size: 0.78rem;
}

.sound-list span strong {
  color: #fff;
}

.sound-list small {
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.variant-note {
  margin-top: 8px;
  padding: 14px;
  border-left: 3px solid var(--cinnabar);
  background: #252925;
  color: #c7d0cb;
  font-size: 0.76rem;
  line-height: 1.5;
}

.variant-note strong {
  display: block;
  margin-bottom: 3px;
  color: #fff;
}

.pinyin-dialog .primary-action {
  width: auto;
  margin: 12px 18px max(12px, env(safe-area-inset-bottom));
}

@media (max-width: 560px) {
  .app-bar {
    padding-right: 14px;
    padding-left: 14px;
  }

  .streak {
    grid-template-columns: auto;
    gap: 0;
    text-align: right;
  }

  .streak span:last-child {
    font-size: 0.62rem;
  }

  .setup-banner {
    min-height: 190px;
    padding: 32px 22px 22px;
    background-position: 62% center;
  }

  .setup-banner h1,
  .complete-screen h1 {
    font-size: 2.25rem;
  }

  .setup-content {
    padding-right: 16px;
    padding-left: 16px;
  }

  .pinyin-entry {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
  }

  .pinyin-entry-sample {
    grid-column: 1;
  }

  .pinyin-entry-copy {
    grid-column: 1;
  }

  .pinyin-entry-arrow {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .lesson-list {
    grid-template-columns: 1fr;
  }

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

  .switch-row {
    min-height: 48px;
  }

  .phrase-panel {
    min-height: 250px;
  }

  .phrase-panel.has-breakdown {
    min-height: 390px;
  }

  .phrase-panel.has-breakdown .hanzi {
    font-size: 3rem;
  }

  .word-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .word-breakdown li {
    min-width: 0;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .word-pronunciation {
    min-height: 64px;
    padding: 5px 8px;
  }

  .word-breakdown li:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .pinyin-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .pinyin-dialog-shell {
    max-height: calc(100dvh - 18px);
  }

  .pinyin-dialog-content {
    padding: 16px;
  }

  .syllable-examples,
  .tone-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tone-grid button:last-child {
    grid-column: 1 / -1;
  }

  .sound-list button {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .sound-list small {
    grid-column: 2;
    white-space: normal;
  }

  .hanzi {
    font-size: 3.6rem;
  }

  .pinyin {
    font-size: 1.1rem;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .app-bar {
    height: 50px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .session-screen {
    min-height: calc(100dvh - 50px);
    padding: 4px 18px max(5px, env(safe-area-inset-bottom));
  }

  .session-top .icon-button,
  .session-top .mic-indicator {
    width: 40px;
    height: 40px;
  }

  .session-stage {
    padding: 0;
  }

  .phase {
    min-height: 18px;
    margin-bottom: 2px;
  }

  .phrase-panel {
    min-height: 126px;
    padding: 8px 14px;
  }

  .phrase-panel.has-breakdown {
    width: min(100%, 760px);
    min-height: 136px;
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
    gap: 12px;
  }

  .phrase-panel.has-breakdown .hanzi {
    font-size: 2rem;
  }

  .phrase-panel.has-breakdown .word-breakdown {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-content: center;
    margin: 0;
    padding: 0 0 0 12px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .phrase-panel.has-breakdown .word-breakdown li {
    min-width: 0;
    gap: 0;
    padding: 0;
    border: 0;
  }

  .phrase-panel.has-breakdown .word-pronunciation {
    min-height: 44px;
    padding: 2px 5px;
  }

  .phrase-panel.has-breakdown .word-breakdown b {
    font-size: 0.86rem;
  }

  .phrase-panel.has-breakdown .word-breakdown small {
    font-size: 0.58rem;
  }

  .phrase-panel.has-breakdown .audio-bars {
    display: none;
  }

  .meaning {
    margin-bottom: 2px;
  }

  .hanzi {
    font-size: 2.35rem;
  }

  .pinyin {
    min-height: 22px;
    margin-top: 2px;
  }

  .audio-bars {
    height: 17px;
    margin-top: 2px;
  }

  .heard-text {
    min-height: 15px;
    margin-top: 2px;
  }

  .session-controls {
    grid-template-columns: 48px 62px 48px;
    gap: 20px;
    padding-top: 0;
  }

  .control-button {
    width: 48px;
    height: 48px;
  }

  .main-control {
    width: 62px;
    height: 62px;
    box-shadow: 0 0 0 6px rgba(231, 91, 69, 0.12);
  }
}

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