:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #65716a;
  --bg: #eef1eb;
  --surface: #ffffff;
  --soft: #f6f8f5;
  --line: #d9dfd7;
  --accent: #17684f;
  --accent-soft: #e9f4ef;
  --blue: #2f5d83;
  --shadow: 0 18px 55px rgba(23, 32, 26, 0.12);
  --tailo-font: "Charis SIL", "Doulos SIL", "Noto Sans", "Noto Sans TC", "Arial",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

h1,
h2,
p {
  margin-top: 0;
  letter-spacing: 0;
}

.stage {
  display: grid;
  grid-template-columns: minmax(340px, 410px);
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.phone {
  position: relative;
  min-height: min(900px, calc(100vh - 48px));
  max-height: 900px;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 26, 0.12);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-status,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 12px 18px 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.status-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.screen {
  height: calc(100% - 48px);
  overflow: auto;
  padding: 14px 18px 84px;
}

.home-hero {
  margin: 16px 0 22px;
}

.home-hero.compact {
  margin-bottom: 18px;
}

.home-hero > .eyebrow {
  display: none;
}

.home-hero h1 {
  max-width: 13ch;
  margin-bottom: 8px;
  font-size: 1.9rem;
  line-height: 1.08;
}

.home-hero p:last-child {
  max-width: 28ch;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.42;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

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

.section-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.situation-list,
.review-list {
  display: grid;
  gap: 0;
}

.situation-card,
.review-card {
  width: 100%;
  border-top: 1px solid var(--line);
  padding: 15px 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.situation-card:last-child,
.review-card:last-child {
  border-bottom: 1px solid var(--line);
}

.situation-card strong,
.review-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.08rem;
  line-height: 1.25;
}

.situation-card small,
.review-card small,
.review-card span,
.situation-card em {
  display: block;
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.situation-card small,
.review-card small,
.chat-turn small,
#exchange-prompt-tailo,
#exchange-answer-tailo,
#exchange-reply-tailo {
  font-family: var(--tailo-font);
  font-weight: 500;
}

.situation-card em {
  margin-top: 3px;
  font-size: 0.9rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 800;
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 850;
}

#practice-top-label,
.practice-card > .eyebrow {
  display: none;
}

.lesson-card,
.practice-card,
.feedback-card,
.generated-card,
.exchange-card,
.empty-card {
  border-radius: 8px;
}

.lesson-card {
  padding: 0;
  background: transparent;
}

.practice-card,
.feedback-card,
.generated-card,
.exchange-card,
.empty-card {
  border: 1px solid var(--line);
  padding: 16px;
  background: var(--surface);
}

.lesson-card h2,
.exchange-card h2 {
  margin-bottom: 14px;
  font-size: 1.55rem;
  line-height: 1.12;
}

.ama-prompt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.1rem;
  font-weight: 850;
}

.answer-block small,
.generated-card small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.ama-prompt small {
  display: none;
}

.ama-prompt strong {
  display: block;
  font-size: 1.22rem;
  line-height: 1.2;
}

.ama-prompt p {
  margin: 3px 0 0;
  color: var(--muted);
}

.ama-prompt .prompt-tailo {
  margin: 5px 0 0;
}

.answer-block {
  margin: 0;
}

.answer-options {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.answer-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  cursor: pointer;
}

.answer-option.is-selected {
  border-color: rgba(23, 104, 79, 0.55);
  box-shadow: inset 3px 0 0 var(--accent);
}

.answer-option-header {
  display: block;
}

.answer-option-title {
  min-width: 0;
}

.answer-option .hanji-line {
  margin-bottom: 6px;
  font-size: 1.38rem;
}

.custom-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf3f8;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 850;
}

.option-actions {
  display: grid;
  grid-template-columns: minmax(62px, 0.72fr) auto minmax(86px, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.option-hear,
.option-practice,
.tts-voice-button {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 850;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

.option-hear {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.option-practice {
  background: var(--accent);
  color: white;
}

.tts-voice-group,
.tts-voice-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tts-voice-row {
  margin-top: 10px;
}

.tts-voice-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.tts-voice-button.is-active {
  border-color: rgba(23, 104, 79, 0.58);
  background: var(--accent-soft);
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
}

.option-hear.is-loading,
.tts-voice-button.is-loading,
.secondary-button.is-loading {
  border-color: rgba(23, 104, 79, 0.36);
  background: var(--accent-soft);
  color: var(--accent);
}

button.is-loading {
  opacity: 0.92;
}

button.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.82em;
  height: 0.82em;
  margin-left: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: audio-spin 800ms linear infinite;
}

@keyframes audio-spin {
  to {
    transform: rotate(360deg);
  }
}

.custom-line-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  border: 1px dashed rgba(47, 93, 131, 0.45);
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.custom-line-card span {
  color: var(--blue);
  font-weight: 850;
}

.custom-line-card small {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
}

.inline-custom-composer {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid rgba(47, 93, 131, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.inline-generated-card {
  margin-top: 0;
  border-left: 3px solid var(--blue);
  background: var(--surface);
}

.inline-custom-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
}

.hanji-line {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 850;
  line-height: 1.12;
}

.tailo-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 9px;
  color: var(--muted);
  font-family: var(--tailo-font);
  line-height: 1.45;
}

.tailo-token {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--tailo-font);
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}

button.tailo-token {
  color: var(--accent);
  text-decoration: none;
}

.tailo-token.is-generic-pron {
  color: var(--accent);
}

.tailo-token.is-static {
  color: var(--muted);
}

.meaning-line {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.34;
}

.option-status {
  min-height: 0;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.option-status:empty {
  display: none;
}

.line-audio-status,
.speech-status[data-audio-state] {
  min-height: 0;
  border: 1px solid rgba(47, 93, 131, 0.24);
  border-radius: 8px;
  padding: 9px 10px;
  background: #edf3f8;
  color: var(--blue);
  font-weight: 800;
}

.line-audio-status {
  margin: 10px 0 0;
  font-size: 0.84rem;
  line-height: 1.34;
}

.line-audio-status:empty {
  display: none;
}

.line-audio-status[data-audio-state="loading"],
.speech-status[data-audio-state="loading"] {
  border-color: rgba(23, 104, 79, 0.28);
  background: var(--accent-soft);
  color: var(--accent);
}

.line-audio-status[data-audio-state="success"],
.speech-status[data-audio-state="success"] {
  border-color: rgba(23, 104, 79, 0.36);
  background: var(--accent-soft);
  color: var(--accent);
}

.line-audio-status[data-audio-state="fallback"],
.speech-status[data-audio-state="fallback"] {
  border-color: rgba(47, 93, 131, 0.32);
  background: #edf3f8;
  color: var(--blue);
}

.practice-card .hanji-line,
.practice-card h2 {
  margin-bottom: 10px;
}

.practice-actions,
.feedback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.feedback-actions .primary-button {
  background: var(--accent);
}

.feedback-card {
  margin-top: 12px;
  background: var(--soft);
}

.feedback-card h2 {
  margin-bottom: 8px;
  font-size: 1.18rem;
}

.feedback-card p:last-of-type {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.42;
}

.speech-status {
  min-height: 0;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.feedback-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tailo-breakdown-heading {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.tailo-review-token {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  min-width: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--tailo-font);
  font-weight: 850;
  line-height: 1.25;
  text-align: left;
}

button.tailo-review-token {
  color: var(--accent);
}

.tailo-review-token.is-generic-pron {
  color: var(--accent);
}

.tailo-review-token.needs-work {
  border-color: rgba(23, 104, 79, 0.42);
  background: var(--accent-soft);
}

.tailo-review-token small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.2;
}

.tailo-review-token.needs-work small {
  color: var(--accent);
}

.feedback-focus {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.focus-chip {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(23, 104, 79, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

button.focus-chip strong {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.focus-chip strong,
.focus-chip span {
  display: block;
}

.focus-chip strong {
  font-family: var(--tailo-font);
  font-size: 0.95rem;
  line-height: 1.2;
}

.focus-chip span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.32;
}

.feedback-focus-heading {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.feedback-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.bottom-action {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 14px 18px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 32%);
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  background: var(--ink);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.thought-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.thought-field textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  color: var(--ink);
  line-height: 1.42;
}

.generated-card {
  margin-top: 12px;
}

.focus-note {
  margin: 12px 0 0;
  padding: 11px;
  border-radius: 8px;
  background: var(--soft);
}

.chat-turn {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.chat-turn.learner {
  grid-template-columns: 1fr;
  margin-left: 44px;
  padding: 12px;
  border-radius: 8px;
  background: var(--accent-soft);
}

.chat-turn.reply {
  opacity: 0.72;
}

.chat-turn strong,
.chat-turn small {
  display: block;
}

.chat-turn small {
  margin-top: 4px;
  color: var(--muted);
}

.pron-sheet {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  align-items: end;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 26, 0.34);
}

.pron-card {
  position: relative;
  z-index: 1;
  max-height: 82%;
  overflow: auto;
  border-radius: 18px 18px 0 0;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 -14px 36px rgba(23, 32, 26, 0.16);
}

.pron-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.pron-header small {
  color: var(--muted);
  font-weight: 800;
}

.pron-header h2 {
  margin: 0;
  font-size: 2.2rem;
}

.audio-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.pron-card section {
  margin-bottom: 15px;
}

.pron-card section p:last-child {
  margin-bottom: 0;
  color: var(--ink);
  line-height: 1.42;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-row span {
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.token-status {
  min-height: 0;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.token-status:empty {
  display: none;
}

@media (max-width: 520px) {
  .stage {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .phone {
    min-height: 100vh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .option-actions {
    grid-template-columns: minmax(58px, 0.72fr) auto minmax(82px, 1fr);
  }
}
