:root {
  color-scheme: light;
  --bg: #f4fbf7;
  --surface: #ffffff;
  --surface-soft: #edf8f2;
  --ink: #17352b;
  --muted: #5e796e;
  --line: #cfe3da;
  --accent: #167a5b;
  --accent-strong: #0f5d44;
  --danger: #a94717;
  --shadow: 0 16px 42px rgba(24, 70, 51, 0.11);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

html[data-font-size="large"] {
  font-size: 18px;
}

html[data-font-size="xlarge"] {
  font-size: 20px;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(205, 236, 220, 0.75), transparent 28rem),
    linear-gradient(180deg, #fbfff9 0%, var(--bg) 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.app-shell {
  width: min(960px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow,
.section-kicker {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  line-height: 1.12;
}

h2 {
  font-size: 1.22rem;
  line-height: 1.25;
}

h3 {
  font-size: 1rem;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 1rem;
}

.ghost-button,
.secondary-button,
.primary-button,
.voice-button,
.send-button {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 700;
}

.ghost-button,
.secondary-button {
  border: 1px solid var(--line);
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.82);
}

.primary-button,
.voice-button,
.send-button {
  color: #fff;
  background: var(--accent);
}

.primary-button:hover,
.voice-button:hover,
.send-button:hover {
  background: var(--accent-strong);
}

.settings-panel,
.auth-card,
.today-card,
.course-section,
.practice-card,
.review-card,
.roleplay-card,
.chat-card,
.assessment-result,
.ai-card {
  border: 1px solid rgba(207, 227, 218, 0.78);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-panel,
.auth-card,
.today-card,
.course-section,
.practice-card,
.review-card,
.roleplay-card,
.chat-card {
  padding: 18px;
}

.settings-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-panel label,
.auth-form label,
.auth-user-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.settings-panel input,
.settings-panel select,
.auth-form input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
}

.auth-form,
.auth-user-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.wide-field,
.auth-hint,
.profile-summary {
  grid-column: 1 / -1;
}

.auth-hint,
.profile-summary {
  color: var(--muted);
  line-height: 1.7;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  width: 20px;
  min-height: 20px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-strip span,
.progress-chip,
.provider-pill {
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.status-strip .warn,
.provider-pill.warn,
.warn {
  color: var(--danger);
  background: #fff3e8;
}

.sentence-list {
  margin: 14px 0 12px;
  padding-left: 1.4rem;
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.45;
}

.progress-track,
.sentence-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9eee4;
}

.progress-track div,
.sentence-progress div {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.button-grid,
.audio-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.audio-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.scenario-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.scenario-card {
  min-height: 140px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.scenario-card p,
.scenario-card span,
.usage-text,
.chinese-sentence,
.assessment-details,
.empty-state,
.review-item p {
  color: var(--muted);
  line-height: 1.55;
}

.practice-card {
  display: grid;
  gap: 14px;
}

.sentence-card {
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.english-sentence {
  color: var(--ink);
  font-size: clamp(1.5rem, 5vw, 2.15rem);
  font-weight: 800;
  line-height: 1.22;
}

.english-sentence.small {
  font-size: 1.35rem;
}

.chinese-sentence {
  margin-top: 8px;
  font-size: 1.05rem;
}

.usage-text {
  margin-top: 8px;
}

.keyword-row,
.focus-words {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.keyword-row span,
.focus-words span {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #fff;
}

.record-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfffd;
}

#recordStatus {
  color: var(--muted);
  line-height: 1.5;
}

.record-button.recording {
  background: #b55321;
}

.assessment-result,
.ai-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.assessment-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.score-pill {
  min-width: 70px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 1.08rem;
}

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

.metric-grid span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 700;
}

.assessment-details {
  display: grid;
  gap: 5px;
}

.review-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.review-item,
.dialogue-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.chat-log {
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--accent);
}

.message.assistant {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--surface);
}

.tips {
  margin-top: 8px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.92rem;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
  margin-top: 12px;
}

.text-input-label {
  display: grid;
}

.text-input-label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

textarea {
  width: 100%;
  max-height: 130px;
  min-height: 48px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: var(--surface);
}

textarea::placeholder {
  color: #8aa098;
}

@media (max-width: 720px) {
  .app-shell {
    padding-inline: 12px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
  }

  .settings-panel,
  .auth-form,
  .auth-user-panel,
  .scenario-grid,
  .button-grid,
  .audio-actions,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr auto;
  }

  .voice-button {
    grid-column: 1 / -1;
  }

  .message {
    max-width: 94%;
  }
}
