:root {
  color-scheme: light;
  --bg: #f4f0e8;
  --ink: #13221f;
  --muted: #64706c;
  --panel: #fffaf1;
  --panel-strong: #ffffff;
  --line: rgba(19, 34, 31, 0.12);
  --green: #12312b;
  --green-2: #1f6b58;
  --gold: #c78a2f;
  --blue: #2c65a8;
  --red: #b34f45;
  --shadow: 0 18px 45px rgba(18, 49, 43, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(31, 107, 88, 0.16), rgba(244, 240, 232, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 16px;
}

.eyebrow,
.status-label,
.prompt-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.24;
}

.icon-button,
.secondary-button,
.ghost-button,
.success-button,
.primary-button,
.tab-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.68);
  color: var(--green);
  font-size: 22px;
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-panel > div:first-child,
.card-head > div,
.section-head > div {
  min-width: 0;
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, var(--panel) 72%, transparent 74% 100%),
    conic-gradient(var(--green-2) var(--progress, 0deg), rgba(19, 34, 31, 0.12) 0);
  color: var(--green);
  font-weight: 800;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.tab-button {
  min-width: 0;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.tab-button.active {
  background: var(--green);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.daily-summary,
.home-action,
.ai-panel,
.roleplay-panel,
.trainer-card,
.empty-state,
.list-item,
.plan-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.home-action {
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
}

.home-action span,
.item-meta {
  color: var(--muted);
  font-size: 13px;
}

.home-action strong {
  color: var(--green);
  font-size: 15px;
  line-height: 1.25;
}

.home-action.active {
  border-color: rgba(31, 107, 88, 0.35);
  background: rgba(31, 107, 88, 0.08);
}

.daily-summary {
  padding: 14px;
  margin-bottom: 12px;
}

.ai-panel {
  padding: 16px;
}

.daily-summary p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.page-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.tag.life {
  background: var(--green-2);
}

.tag.business {
  background: var(--blue);
}

.tag.tcm {
  background: var(--gold);
}

.trainer-card {
  padding: 18px;
}

.card-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.scene-pill,
.step-count,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.scene-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(31, 107, 88, 0.12);
  color: var(--green);
  font-weight: 800;
}

.chinese {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
}

.tip {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.action-row,
.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.card-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.action-row .primary-button {
  grid-column: 1 / -1;
}

.voice-row {
  display: grid;
  grid-template-columns: auto minmax(112px, 1fr);
  gap: 8px 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.voice-select {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(19, 34, 31, 0.16);
  border-radius: 8px;
  padding: 0 10px;
  background: #fffaf1;
  color: var(--green);
  font: inherit;
  font-weight: 800;
}

.voice-row span {
  grid-column: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button,
.success-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  font-weight: 800;
  min-width: 0;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.success-button {
  background: var(--green-2);
  color: #fff;
}

.secondary-button {
  border: 1px solid rgba(19, 34, 31, 0.16);
  background: #f9f4eb;
  color: var(--green);
}

.ghost-button {
  border: 1px solid rgba(19, 34, 31, 0.14);
  background: #fff;
  color: var(--muted);
}

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

.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.wide {
  width: 100%;
}

.speech-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f4f0e8;
  color: var(--muted);
  line-height: 1.45;
}

.page-complete {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(31, 107, 88, 0.18);
  border-radius: 8px;
  background: rgba(31, 107, 88, 0.08);
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(19, 34, 31, 0.16);
  border-radius: 8px;
  padding: 13px;
  background: #fffaf1;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  outline: none;
}

textarea:focus {
  border-color: rgba(31, 107, 88, 0.65);
  box-shadow: 0 0 0 3px rgba(31, 107, 88, 0.12);
}

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

.quick-row .secondary-button.active {
  background: rgba(31, 107, 88, 0.14);
  border-color: rgba(31, 107, 88, 0.45);
  color: var(--green);
}

.ai-answer {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #f4f0e8;
  color: var(--ink);
  line-height: 1.58;
  white-space: pre-wrap;
}

.ai-answer.loading {
  color: var(--muted);
}

.ai-answer.error {
  border: 1px solid rgba(179, 79, 69, 0.25);
  background: rgba(179, 79, 69, 0.08);
}

.roleplay-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
}

.roleplay-panel h3 {
  font-size: 18px;
}

.roleplay-panel p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.page-review-panel {
  margin-top: 12px;
}

.section-head h2 {
  font-size: 22px;
}

.review-all-head {
  margin-top: 18px;
}

.list,
.plan-list {
  display: grid;
  gap: 10px;
}

.list-item,
.plan-item,
.empty-state {
  padding: 14px;
}

.list-item h3,
.plan-item h3 {
  font-size: 18px;
}

.compact-list .list-item h3 {
  font-size: 16px;
}

.list-item.is-known {
  border-color: rgba(31, 107, 88, 0.22);
}

.list-item p,
.plan-item p,
.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.plan-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
}

.day-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(44, 101, 168, 0.12);
  color: var(--blue);
  font-weight: 900;
}

.bottom-actions {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 10px;
  width: 100%;
  padding: 12px 0 0;
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 25px;
  }

  h3 {
    font-size: 21px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .card-actions,
  .home-actions,
  .bottom-actions,
  .page-controls {
    grid-template-columns: 1fr;
  }

  .tabs {
    gap: 6px;
  }

  .tab-button {
    font-size: 13px;
  }

  .quick-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .home-actions {
    grid-template-columns: 1fr;
  }

  .page-controls .small {
    padding: 0 8px;
    font-size: 13px;
  }
}
