/* 小桌 · 虚拟形态原型 —— 移动优先，零依赖 */

:root {
  --cream: #fff6ec;
  --cream-deep: #f8e8d6;
  --paper: #fffdf9;
  --ink: #3a2a20;
  --ink-soft: #7a6555;
  --ink-faint: #a4907f;
  --coral: #ff8a65;
  --coral-deep: #ef6a45;
  --coral-soft: #ffe1d4;
  --teal: #2fb8a8;
  --teal-deep: #1f9487;
  --teal-soft: #d5f4ef;
  --sun: #ffbe4d;
  --rose: #f2709c;
  --line: rgba(122, 101, 85, 0.16);
  --shadow-sm: 0 2px 8px rgba(58, 42, 32, 0.08);
  --shadow-md: 0 10px 28px rgba(58, 42, 32, 0.12);
  --shadow-lg: 0 22px 60px rgba(58, 42, 32, 0.2);
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 12% -10%, #ffe3c8 0%, transparent 55%),
    radial-gradient(110% 70% at 100% 0%, #d8f5ef 0%, transparent 48%),
    var(--cream);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ---------- 骨架 ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 42%, #1c2231 0 38%, transparent 39%),
    linear-gradient(160deg, #ffd9c2, #ffb28f);
  border: 2px solid rgba(58, 42, 32, 0.16);
  box-shadow: inset 0 -3px 0 rgba(58, 42, 32, 0.08);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffd6a5;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px #ffd6a5;
}

.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge {
  font-size: 11px;
  color: var(--teal-deep);
  background: var(--teal-soft);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill-muted {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--line);
}

.pill-live {
  color: #fff;
  background: linear-gradient(120deg, var(--teal), var(--teal-deep));
}

/* 说话人标识：小桌记得谁在跟它说话 */
.speaker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 132px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(47, 184, 168, 0.32);
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.speaker-chip:hover {
  box-shadow: 0 3px 10px rgba(47, 184, 168, 0.22);
}

.speaker-chip:active {
  transform: scale(0.96);
}

.speaker-chip.hidden {
  display: none;
}

.speaker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 184, 168, 0.18);
  flex: 0 0 auto;
}

#speakerChipLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speaker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.speaker-row:last-child {
  border-bottom: 0;
}

.speaker-row .speaker-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.speaker-row .speaker-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.speaker-row .speaker-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.speaker-row input {
  width: 88px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 14px;
  color: var(--ink);
}

.speaker-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  background: #fff;
  color: var(--ink);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.is-on {
  color: var(--coral-deep);
  background: var(--coral-soft);
  border-color: rgba(239, 106, 69, 0.3);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- 模式 ---------- */

.mode-row {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 8px;
  padding: 4px;
  background: rgba(255, 250, 244, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.mode-chip {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.mode-chip.is-active {
  color: #fff;
  background: linear-gradient(130deg, var(--coral), var(--coral-deep));
  box-shadow: 0 4px 12px rgba(239, 106, 69, 0.32);
}

/* ---------- 机器人 ---------- */

.avatar-card {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: clamp(320px, 48vh, 560px);
  border-radius: var(--r-lg);
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: hidden;
  transition: background 600ms ease;
}

.avatar-glow {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 118%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow, rgba(255, 190, 77, 0.4)) 0%, transparent 62%);
  filter: blur(22px);
  transition: background 700ms ease;
  pointer-events: none;
}

.avatar-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: grid;
  place-items: center;
  padding: 6px 4px 0;
}

#avatar {
  position: absolute;
  left: 6px;
  top: 2px;
  width: calc(100% - 12px);
  height: calc(100% - 2px);
  display: block;
  overflow: visible;
}

#headGroup,
#bodyGroup {
  transform-box: view-box;
}

#headGroup {
  transform-origin: 150px 198px;
  transition: transform 700ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

#bodyGroup {
  transform-origin: 150px 300px;
  transition: transform 900ms ease;
}

.wing {
  transform-box: view-box;
  transform-origin: 100px 242px;
}

#wingR {
  transform-origin: 200px 242px;
}

.eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5.8s infinite;
}

@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  95%, 97% { transform: scaleY(0.08); }
}

.pupil {
  transition: transform 500ms ease;
}

.avatar-mount {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.avatar-canvas,
.avatar-fallback {
  width: 100%;
  height: 100%;
  display: block;
}

.avatar-fallback {
  object-fit: contain;
  border-radius: 50%;
}

.mirror-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 3;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(43, 184, 168, 0.92);
  box-shadow: 0 4px 12px rgba(43, 184, 168, 0.35);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 300ms ease, transform 300ms ease;
  pointer-events: none;
}

.mirror-badge.show {
  opacity: 1;
  transform: none;
}

.mic-gate {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(130deg, var(--coral), var(--coral-deep));
  box-shadow: 0 8px 20px rgba(239, 106, 69, 0.35);
  animation: gatePulse 2.2s ease-in-out infinite;
}

.mic-gate svg {
  width: 16px;
  height: 16px;
}

.mic-gate.hidden {
  display: none;
}

/* 首次开启常听时，机器人上的「轻点开启常听」就是唯一入口，避免底部出现第二个同义按钮。 */
body.mic-gate-open #ptt {
  visibility: hidden;
  pointer-events: none;
}

@keyframes gatePulse {
  0%, 100% { box-shadow: 0 8px 20px rgba(239, 106, 69, 0.32); }
  50% { box-shadow: 0 8px 28px rgba(239, 106, 69, 0.55); }
}

.emotion-line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 16px 14px;
  font-size: 13px;
  color: var(--ink-soft);
}

.emotion-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glow-solid, var(--sun));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--glow-solid, var(--sun)) 22%, transparent);
  transition: background 600ms ease, box-shadow 600ms ease;
}

.action-chip {
  font-size: 12px;
  color: var(--teal-deep);
  background: var(--teal-soft);
  padding: 3px 9px;
  border-radius: 999px;
  animation: chipIn 260ms ease;
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* 情绪配色（服务端下发，前端只映射视觉） */
.avatar-card[data-emotion="NEUTRAL"] { --glow: rgba(255, 190, 77, 0.34); --glow-solid: #ffbe4d; }
.avatar-card[data-emotion="ENCOURAGING"] { --glow: rgba(47, 184, 168, 0.36); --glow-solid: #2fb8a8; }
.avatar-card[data-emotion="CELEBRATING"] { --glow: rgba(255, 143, 143, 0.46); --glow-solid: #f2709c; }
.avatar-card[data-emotion="CONCERNED"] { --glow: rgba(120, 160, 255, 0.38); --glow-solid: #7a9ff5; }
.avatar-card[data-emotion="PLAYFUL"] { --glow: rgba(255, 120, 90, 0.42); --glow-solid: #ff7a5a; }
.avatar-card[data-emotion="QUIET"] {
  --glow: rgba(120, 120, 190, 0.34);
  --glow-solid: #8e8ec9;
}

.avatar-card[data-emotion="QUIET"] .avatar-wrap,
.avatar-card[data-emotion="QUIET"] #avatarMount {
  filter: brightness(0.78) saturate(0.9);
}

.avatar-card[data-emotion="QUIET"] .emotion-line {
  color: var(--ink-soft);
}

.avatar-card.is-speaking .avatar-glow {
  animation: breathe 1.7s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.65; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

.avatar-card.is-listening .avatar-glow {
  background: radial-gradient(circle, rgba(47, 184, 168, 0.45) 0%, transparent 64%);
  animation: breathe 1.1s ease-in-out infinite;
}

/* ---------- 复习卡 ---------- */

.review-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  animation: riseIn 300ms ease;
}

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.review-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--coral-deep);
  background: var(--coral-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

.review-kp {
  font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.review-prompt {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.55;
}

.review-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-btn {
  flex: 1 1 28%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--r-sm);
  font-size: 15px;
  cursor: pointer;
  transition: border 160ms ease, background 160ms ease, transform 120ms ease;
}

.option-btn:hover {
  border-color: var(--coral);
  background: #fff8f4;
}

.option-btn:active {
  transform: scale(0.97);
}

.option-btn.is-right {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 700;
}

.option-btn.is-wrong {
  border-color: var(--rose);
  background: #ffe9ef;
  color: #b23a5e;
}

.review-form {
  display: flex;
  gap: 8px;
}

.review-form input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 14px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

.review-form input:focus,
.text-form input:focus {
  outline: 2px solid rgba(255, 138, 101, 0.45);
  outline-offset: 1px;
  border-color: var(--coral);
}

/* ---------- 对话 ---------- */

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 96px;
  padding-bottom: 4px;
}

.msg {
  display: flex;
  max-width: 92%;
  animation: riseIn 280ms ease;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.msg-bot {
  align-self: flex-start;
}

.msg-user {
  align-self: flex-end;
  justify-content: flex-end;
}

.bubble {
  position: relative;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bot .bubble {
  border-bottom-left-radius: 6px;
}

.msg-user .bubble {
  background: linear-gradient(135deg, var(--coral), var(--coral-deep));
  border-color: transparent;
  color: #fff;
  border-radius: 18px 18px 6px 18px;
}

.msg-bot.is-crisis .bubble {
  border-color: rgba(122, 159, 245, 0.4);
  background: #f4f7ff;
}

.msg-bot.is-degraded .bubble::after {
  content: "简单模式";
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.5px;
}

.explain-btn {
  display: block;
  margin-top: 7px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 11px;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(164, 144, 127, 0.4);
  text-underline-offset: 3px;
}

.explain-btn:hover {
  color: var(--teal-deep);
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 1.62em;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: dot 1s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- 底部输入 ---------- */

.composer {
  flex: 0 0 auto;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(255, 246, 236, 0.98) 65%, rgba(255, 246, 236, 0));
}

.listen-hint {
  min-height: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--teal-deep);
  margin-bottom: 6px;
  transition: color 200ms ease;
}

.listen-hint.is-warn {
  color: var(--coral-deep);
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

.ptt {
  position: relative;
  flex: 0 1 auto;
  min-width: 148px;
  height: 58px;
  padding: 0 22px 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 10px 22px rgba(31, 148, 135, 0.34);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 200ms ease, background 200ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

.ptt:active,
.ptt.is-recording {
  transform: scale(0.97);
  background: linear-gradient(135deg, var(--coral), var(--coral-deep));
  box-shadow: 0 8px 20px rgba(239, 106, 69, 0.4);
}

.ptt-icon {
  width: 20px;
  height: 20px;
}

.ptt-ring {
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 2px solid rgba(47, 184, 168, 0.5);
  opacity: 0;
  pointer-events: none;
}

.ptt.is-recording .ptt-ring {
  animation: ring 1.2s ease-out infinite;
  border-color: rgba(255, 138, 101, 0.65);
}

@keyframes ring {
  from { opacity: 0.9; transform: scale(0.96); }
  to { opacity: 0; transform: scale(1.16); }
}

.text-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  animation: riseIn 200ms ease;
}

.text-form input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  font-size: 15px;
  background: #fff;
}

.btn {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(130deg, var(--coral), var(--coral-deep));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 0 20px;
  cursor: pointer;
  min-height: 44px;
  transition: transform 140ms ease, filter 160ms ease;
}

.btn:hover {
  filter: brightness(1.04);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-ghost {
  background: #fff;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn-small {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
}

.footnote {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--ink-faint);
}

.linklike {
  border: 0;
  background: none;
  padding: 0;
  color: var(--teal-deep);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ---------- toast / 弹层 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  max-width: 86vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(58, 42, 32, 0.92);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 90;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 30, 24, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 80;
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheetUp 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

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

.sheet-title {
  margin: 0;
  font-size: 18px;
}

.sheet-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.sheet-body h4 {
  margin: 16px 0 6px;
  color: var(--ink);
  font-size: 14px;
}

.sheet-body ul {
  margin: 4px 0 10px;
  padding-left: 18px;
}

.sheet-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-soft);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row b {
  color: var(--ink);
  font-weight: 600;
}

.trigger-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.trigger-list li {
  font-size: 12px;
  padding: 5px 9px;
  margin-bottom: 5px;
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink-soft);
}

/* ---------- 家长端 ---------- */

.parent-app {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 180ms ease;
}

.parent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 253, 249, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.parent-head h2 {
  margin: 0;
  font-size: 17px;
}

.parent-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.parent-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 160ms ease;
}

.tab-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.parent-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

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

.stat {
  border-radius: var(--r-sm);
  background: linear-gradient(160deg, #fff, var(--cream));
  border: 1px solid var(--line);
  padding: 10px 8px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.stat span {
  font-size: 11px;
  color: var(--ink-faint);
}

.narrative {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
}

.emotion-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.emotion-bar {
  display: grid;
  grid-template-columns: 74px 1fr 30px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.emotion-bar .track {
  height: 8px;
  border-radius: 999px;
  background: var(--cream-deep);
  overflow: hidden;
}

.emotion-bar .fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--coral), var(--sun));
}

.safety-item {
  border-left: 3px solid var(--rose);
  background: #fff4f7;
  border-radius: 0 10px 10px 0;
  padding: 8px 12px;
  font-size: 12px;
  color: #8c2f4e;
  margin-bottom: 6px;
}

.safety-item.lv2 {
  border-color: var(--sun);
  background: #fff9ea;
  color: #7a5a12;
}

.kp-row {
  display: grid;
  grid-template-columns: 1fr 90px 44px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.kp-row:last-child {
  border-bottom: 0;
}

.kp-meter {
  height: 7px;
  border-radius: 999px;
  background: var(--cream-deep);
  overflow: hidden;
}

.kp-meter > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--teal-deep));
}

.memory-item {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}

.memory-item p {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.55;
}

.memory-meta {
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.memory-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink-soft);
  min-height: 32px;
}

.mini-btn:hover {
  border-color: var(--coral);
  color: var(--coral-deep);
}

.mini-btn.danger:hover {
  border-color: var(--rose);
  color: #b23a5e;
  background: #fff4f7;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="time"],
.field input[type="number"],
.field select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(47, 184, 168, 0.4);
  outline-offset: 1px;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--coral);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
}

.switch-row:last-child {
  border-bottom: 0;
}

.switch-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--teal);
}

.hint-text {
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.6;
  margin: 6px 0 0;
}

.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  background: var(--cream);
  padding: 24px;
}

.pin-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.pin-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.pin-card p {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--ink-soft);
}

.pin-card input {
  width: 100%;
  height: 52px;
  text-align: center;
  font-size: 24px;
  letter-spacing: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.pinfeld {
  text-align: left;
  margin-bottom: 4px;
}

.pinfeld label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 6px 4px;
}

.pin-error {
  min-height: 18px;
  font-size: 12px;
  color: #b23a5e;
  margin-bottom: 8px;
}

/* ---------- 对话记录抽屉（默认隐藏，机器人优先） ---------- */

.voice-pick {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 6px 0 4px;
}

.voice-pick select {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.voice-pick select:focus {
  outline: 2px solid rgba(255, 138, 101, 0.45);
  outline-offset: 1px;
  border-color: var(--coral);
}

.chat-toggle {
  position: relative;
}

.chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--coral-deep);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(239, 106, 69, 0.4);
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(58, 42, 32, 0.32);
  backdrop-filter: blur(1px);
  animation: fadeIn 180ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.chat-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 72;
  transform: translateX(-50%);
  width: min(520px, 100%);
  height: min(72vh, 620px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 44px rgba(58, 42, 32, 0.18);
  animation: sheetUp 240ms cubic-bezier(0.22, 0.8, 0.3, 1);
}

@keyframes sheetUp {
  from { opacity: 0; transform: translate(-50%, 26px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.chat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.chat-panel .chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 10px;
}

.chat-empty {
  margin: 18px auto 0;
  max-width: 280px;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-faint);
}

.chat-panel .text-form {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.pill-warn {
  color: #8a4a16;
  background: #ffe9c7;
  border-color: rgba(196, 120, 32, 0.35);
}

/* ---------- 桌面加宽 ---------- */

@media (min-width: 720px) {
  body {
    background:
      radial-gradient(60% 50% at 8% 6%, #ffe3c8 0%, transparent 60%),
      radial-gradient(55% 45% at 96% 4%, #d8f5ef 0%, transparent 55%),
      var(--cream);
  }

  .app {
    max-width: 640px;
    padding-bottom: 18px;
  }

  .stage {
    padding: 10px 20px 16px;
  }

  .avatar-card {
    min-height: clamp(420px, 50vh, 620px);
  }

  .parent-app {
    max-width: 640px;
    top: 3vh;
    bottom: 3vh;
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 小本子 / 画像 / 机器人成长（v1.24.0） ---------- */

.task-badge {
  display: inline-block;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--coral-deep);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  vertical-align: 1px;
}

.speaker-facts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.speaker-facts.is-empty {
  color: var(--ink-faint);
}

.profile-bar {
  display: inline-block;
  flex: 0 0 auto;
  width: 54px;
  height: 4px;
  border-radius: 999px;
  background: var(--cream-deep);
  overflow: hidden;
}

.profile-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--sun));
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.7);
}

.task-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.task-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.task-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-soft);
}

.task-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.task-actions .btn {
  padding: 5px 9px;
  font-size: 12px;
}

.task-cancel {
  color: var(--coral-deep);
}

.task-empty {
  padding: 10px 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.fact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 4px;
}

.fact-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.fact-row span {
  flex: 0 0 48px;
  color: var(--ink-soft);
}

.fact-row b {
  font-weight: 500;
  color: var(--ink);
}

.robot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

.robot-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 12px;
  line-height: 1.4;
}

.robot-chip.is-muted {
  background: var(--coral-soft);
  color: var(--coral-deep);
}

.growth-line {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.growth-track {
  height: 8px;
  margin: 6px 0 4px;
  border-radius: 999px;
  background: var(--cream-deep);
  overflow: hidden;
}

.growth-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--sun));
  transition: width 400ms ease;
}

.thought-list {
  margin: 4px 0 8px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}
