/* 小学生向：大字号、大点击区、暖色纸感、圆润但不幼稚 */
:root {
  --paper: #fff6ea;
  --paper-2: #fffdf8;
  --ink: #2f2a25;
  --ink-2: #6b6259;
  --ink-3: #a49a8f;
  --orange: #ff8a3d;
  --orange-deep: #f06a16;
  --teal: #18a892;
  --teal-soft: #e3f6f1;
  --line: #efe4d5;
  --shadow: 0 10px 30px rgba(180, 130, 70, 0.12);
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: #f3e8d8;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.phone {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  background: var(--paper);
  background-image: radial-gradient(rgba(255, 255, 255, 0.85) 1px, transparent 1px),
    radial-gradient(rgba(214, 180, 140, 0.18) 1px, transparent 1px);
  background-size: 28px 28px, 28px 28px;
  background-position: 0 0, 14px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.screen.is-active {
  display: flex;
}

/* ---------------- 首页 ---------------- */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 20px 4px;
  color: var(--ink-2);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.brand-mark {
  font-size: 18px;
}

.home {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px calc(24px + var(--safe-bottom));
}

.hero {
  text-align: center;
  padding: 10px 0 16px;
}
.hero-face {
  font-size: 54px;
  line-height: 1;
  animation: bob 3.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-7px) rotate(2deg); }
}
.hero h1 {
  font-size: 24px;
  margin: 10px 0 6px;
  letter-spacing: 0.01em;
}
.hero-sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
}

.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-card {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  margin-top: 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips-suggest {
  margin-bottom: 6px;
}

.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 15px;
  color: var(--ink-2);
  transition: all 0.15s;
}
.chip:active {
  transform: scale(0.96);
}
.chip.is-selected {
  border-color: var(--orange);
  background: #fff0e2;
  color: var(--orange-deep);
  font-weight: 600;
}
.chip-mini {
  padding: 7px 13px;
  font-size: 13.5px;
  color: var(--ink-3);
}

.text-input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.text-input::placeholder {
  color: var(--ink-3);
}
.text-input:focus {
  border-color: var(--orange);
}

.btn-primary {
  margin-top: 10px;
  border: none;
  border-radius: 16px;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff9a52, var(--orange-deep));
  box-shadow: 0 8px 20px rgba(240, 106, 22, 0.28);
  transition: transform 0.12s;
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.5;
  box-shadow: none;
}

.hint {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 4px 0 0;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 246, 234, 0.92);
  backdrop-filter: blur(8px);
}
.topbar-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar-title strong {
  font-size: 16.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title span {
  font-size: 12px;
  color: var(--ink-3);
}
.topbar-spacer {
  width: 40px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 17px;
  flex: none;
}
.icon-btn:active {
  background: #f6ecdf;
}
.icon-btn[aria-pressed="false"] {
  opacity: 0.45;
}

.btn-ghost {
  border: 1.5px solid var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  flex: none;
}
.btn-ghost:active {
  transform: scale(0.96);
}

/* ---------------- 聊天 ---------------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: pop 0.22s ease-out;
}
.msg > .col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-ai {
  align-self: flex-start;
}
.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffe4cc;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex: none;
  margin-top: 2px;
}
.msg-user .avatar {
  background: var(--teal-soft);
}

.bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 16.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-ai .bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
  box-shadow: 0 4px 14px rgba(180, 130, 70, 0.08);
}
.msg-user .bubble {
  background: linear-gradient(180deg, #27bda6, var(--teal));
  color: #fff;
  border-top-right-radius: 6px;
}
.msg-error .bubble {
  background: #fff3f0;
  border-color: #ffd3c8;
  color: #b23c2a;
}

.bubble-tools {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.speak-btn {
  border: 1px solid var(--line);
  background: #fffaf3;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  line-height: 1.4;
}
.speak-btn:active {
  background: #f6ecdf;
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.sys-note {
  align-self: center;
  font-size: 12.5px;
  color: var(--ink-3);
  background: #fdf3e5;
  border: 1px dashed #e8d7c2;
  border-radius: 999px;
  padding: 5px 14px;
}

/* ---------------- 输入区 ---------------- */
.composer {
  padding: 8px 12px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(255, 246, 234, 0), var(--paper) 18%);
  border-top: 1px solid var(--line);
}
.quick-row {
  display: flex;
  gap: 8px;
  padding: 4px 2px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-row::-webkit-scrollbar { display: none; }
.quick {
  flex: none;
  border: 1.5px solid #ecdcc7;
  background: #fffdf8;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
}
.quick:active {
  background: #fff0e2;
  border-color: var(--orange);
  color: var(--orange-deep);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-row .text-input {
  flex: 1;
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 16px;
}
.send-btn {
  width: 46px;
  height: 46px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff9a52, var(--orange-deep));
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(240, 106, 22, 0.3);
  display: grid;
  place-items: center;
  padding-bottom: 2px;
}
.send-btn:disabled {
  opacity: 0.45;
  box-shadow: none;
}

/* ---------------- 报告 ---------------- */
.report {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px calc(30px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.report-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.report-card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--orange-deep);
  display: flex;
  align-items: center;
  gap: 7px;
}
.report-card p {
  margin: 0;
  font-size: 15.5px;
  color: var(--ink);
}
.report-card ul {
  margin: 0;
  padding-left: 20px;
  font-size: 15.5px;
}
.report-card li + li {
  margin-top: 6px;
}
.word-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.word-item:last-child {
  border-bottom: none;
}
.word-item b {
  color: var(--teal);
  flex: none;
  font-size: 16px;
}
.word-item span {
  color: var(--ink-2);
  font-size: 14.5px;
}
.report-footer {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}
.report-footer button {
  flex: 1;
  border-radius: 16px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
}
.report-empty {
  color: var(--ink-3);
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}

/* ---------------- toast ---------------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translate(-50%, 10px);
  background: rgba(47, 42, 37, 0.9);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  max-width: 80%;
  text-align: center;
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------- 首页朗读入口 ---------------- */
.entry-card {
  margin-top: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1.5px dashed #e8d3b8;
  background: linear-gradient(180deg, #fff9f0, #fff4e4);
  text-align: left;
  transition: transform 0.12s;
}
.entry-card:active {
  transform: scale(0.99);
}
.entry-emoji {
  font-size: 24px;
}
.entry-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.entry-text strong {
  font-size: 15.5px;
}
.entry-text small {
  font-size: 12.5px;
  color: var(--ink-2);
}
.entry-arrow {
  font-size: 22px;
  color: var(--ink-3);
}

/* ---------------- 麦克风按钮 ---------------- */
.icon-btn-sm {
  width: 36px;
  height: 36px;
  font-size: 15px;
}
.mic-btn.is-recording {
  background: #ffe2d1;
  border-color: var(--orange);
  animation: micPulse 1.1s infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 106, 22, 0.35); }
  50% { box-shadow: 0 0 0 9px rgba(240, 106, 22, 0); }
}
.mic-btn.is-busy {
  opacity: 0.5;
}

/* ---------------- 朗读练习 ---------------- */
.reading-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(28px + var(--safe-bottom));
}
.step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step[hidden] {
  display: none;
}
.step-lead {
  margin: 4px 2px;
  font-size: 15px;
  color: var(--ink-2);
}

.passage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.passage-card {
  position: relative;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 26px;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 18px;
  transition: all 0.15s;
}
.passage-card.is-selected {
  border-color: var(--orange);
  background: #fff7ee;
  box-shadow: 0 6px 18px rgba(240, 106, 22, 0.12);
}
.passage-meta {
  font-size: 12.5px;
  color: var(--ink-3);
}
.passage-text {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.7;
}
.passage-len {
  position: absolute;
  right: 14px;
  bottom: 9px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.read-text {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  font-size: 20px;
  line-height: 1.9;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow);
}

.record-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 0 10px;
}
.record-btn {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  font-size: 38px;
  color: #fff;
  background: linear-gradient(180deg, #ff9a52, var(--orange-deep));
  box-shadow: 0 12px 30px rgba(240, 106, 22, 0.32);
  transition: transform 0.15s, box-shadow 0.2s;
}
.record-btn:active {
  transform: scale(0.96);
}
.record-btn.is-recording {
  background: linear-gradient(180deg, #ff7a6b, #e24636);
  animation: recPulse 1.2s infinite;
}
.record-btn.is-busy {
  opacity: 0.6;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 70, 54, 0.35); }
  50% { box-shadow: 0 0 0 16px rgba(226, 70, 54, 0); }
}
.record-time {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.record-tip {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.score-ring {
  --p: 0;
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--p) * 1%), #efe4d5 0);
  display: flex;
  align-items: baseline;
  justify-content: center;
}
.score-ring::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--paper-2);
}
.score-ring[data-level='try'] {
  background: conic-gradient(var(--orange) calc(var(--p) * 1%), #efe4d5 0);
}
.score-ring span {
  position: relative;
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}
.score-ring small {
  position: relative;
  font-size: 13px;
  color: var(--ink-3);
  margin-left: 2px;
}
.score-comment {
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.metric {
  display: grid;
  grid-template-columns: 3.6em 1fr 2.4em;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.metric b {
  text-align: right;
  font-size: 14px;
  color: var(--ink);
}
.bar {
  height: 8px;
  border-radius: 999px;
  background: #f2e8da;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb26b, var(--orange-deep));
  transition: width 0.55s ease;
}

.char-card {
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.char-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink-2);
}
.char-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 20px;
  line-height: 1.8;
}
.ch {
  display: inline-block;
  padding: 0 1px;
}
.ch.ok {
  color: var(--ink);
}
.ch.miss {
  color: #e24636;
  background: #ffeceb;
  border-radius: 4px;
  text-decoration: underline wavy #e24636;
}
.ch.punct {
  color: var(--ink-3);
}
.char-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}
.char-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.char-legend i.ok {
  background: var(--ink);
}
.char-legend i.miss {
  background: #e24636;
}

.result-actions {
  display: flex;
  gap: 10px;
}
.result-actions button {
  flex: 1;
  border-radius: 16px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
}
