/* 勼拓 · 数学引导 H5 · 局域网试用
   设计口径：纸白底、墨青主色、铜色提示；单题操作台，不做聊天大厅。 */

:root {
  --ink: #234843;
  --ink-deep: #1a3733;
  --copper: #b77146;
  --copper-deep: #995a34;
  --copper-soft: #f3e6d8;
  --paper: #f6f3ec;
  --paper-card: #fffcf5;
  --paper-deep: #ece5d8;
  --body: #243631;
  --muted: #56645e;
  --line: rgba(35, 72, 67, 0.16);
  --line-strong: rgba(35, 72, 67, 0.3);
  --ink-soft: #e7efe9;
  --danger: #9c4a3c;
  --danger-soft: #f7e7e1;
  --shadow-card: 0 18px 50px rgba(35, 72, 67, 0.1);
  --shadow-sheet: 0 28px 80px rgba(24, 48, 44, 0.28);
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", Georgia,
    "Times New Roman", serif;
  --topbar: 58px;
  --radius: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(35, 72, 67, 0.032) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
  color: var(--body);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 3px solid rgba(183, 113, 70, 0.62);
  outline-offset: 2px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--topbar) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) clamp(16px, 4vw, 44px) 0;
  background: rgba(246, 243, 236, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(120%) blur(10px);
  -webkit-backdrop-filter: saturate(120%) blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand-mark {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.trial-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--copper);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.net-state {
  color: var(--danger);
  font-size: 11px;
  white-space: nowrap;
}

.mute-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.mute-btn .icon {
  width: 18px;
  height: 18px;
}

.mute-btn .slash {
  display: none;
}

.mute-btn:hover {
  background: rgba(35, 72, 67, 0.06);
}

.mute-btn[aria-pressed="true"] {
  color: var(--copper-deep);
  background: var(--copper-soft);
}

.mute-btn[aria-pressed="true"] .wave {
  display: none;
}

.mute-btn[aria-pressed="true"] .slash {
  display: block;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.view {
  width: 100%;
}

/* ---------- 打开 / 门禁 / 故障 ---------- */

.boot,
.gate,
.fatal {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
}

.boot-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.boot-mark {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(183, 113, 70, 0.24);
  border-top-color: var(--copper);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.gate-card {
  width: min(100%, 520px);
  padding: clamp(24px, 5vw, 44px);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
}

.gate-card h1 {
  margin: 14px 0 16px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 46px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.28;
}

.gate-copy {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.85;
}

.gate-copy code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--ink);
  font-size: 0.9em;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--copper-deep);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.5;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--copper);
  flex: 0 0 auto;
}

/* ---------- 通用按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--ink);
  color: #fdfaf3;
  box-shadow: 0 8px 20px rgba(35, 72, 67, 0.18);
}

.btn-primary:hover {
  background: var(--ink-deep);
}

.btn-quiet {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.btn-quiet:hover {
  background: rgba(35, 72, 67, 0.05);
}

.btn-wide {
  width: 100%;
}

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

.btn:disabled {
  opacity: 0.42;
  box-shadow: none;
  transform: none;
}

/* ---------- 首页 ---------- */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.86fr);
  align-items: center;
  gap: clamp(32px, 6vw, 84px);
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: clamp(26px, 6vh, 68px) clamp(20px, 4vw, 44px)
    calc(34px + env(safe-area-inset-bottom));
}

.home-intro {
  min-width: 0;
}

.home-intro h1 {
  margin: 16px 0 20px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(38px, 5.2vw, 62px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.2;
}

.home-intro h1 em {
  font-style: normal;
  border-bottom: 3px solid var(--copper);
  padding-bottom: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.intro-copy {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 1.4vw, 17px);
  line-height: 1.9;
}

.ritual {
  display: grid;
  gap: 11px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.ritual li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--body);
  font-size: 14.5px;
  line-height: 1.6;
}

.ritual-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--copper-deep);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
}

.media-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.media-note::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--copper);
}

.entry-card {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 480px;
  padding: clamp(20px, 2.6vw, 28px);
  background: linear-gradient(180deg, #fffdf8 0%, #fbf6ec 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
}

.entry-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 28px;
  width: 64px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--copper);
}

.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.entry-label {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.entry-note {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.photo-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 170px;
  padding: 20px 16px;
  border: 1.5px dashed rgba(183, 113, 70, 0.5);
  border-radius: 16px;
  background: rgba(246, 240, 230, 0.65);
  color: var(--ink);
  text-align: center;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}

.photo-slot:hover {
  border-color: var(--copper);
  background: rgba(243, 230, 216, 0.55);
  transform: translateY(-1px);
}

.photo-slot:active {
  transform: translateY(0);
}

.photo-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-card);
  color: var(--copper-deep);
}

.photo-icon .icon {
  width: 24px;
  height: 24px;
}

.photo-slot-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.photo-slot-sub {
  max-width: 24em;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.photo-preview {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-deep);
}

.photo-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}

.photo-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

textarea {
  display: block;
  width: 100%;
  min-height: 92px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fffefa;
  color: var(--body);
  font-size: 16px;
  line-height: 1.65;
  resize: vertical;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea::placeholder {
  color: #7d8983;
}

textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(183, 113, 70, 0.18);
}

.field-error {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--copper);
  border-radius: 4px 8px 8px 4px;
  background: var(--copper-soft);
  color: #6e4328;
  font-size: 12.5px;
  line-height: 1.65;
}

.field-error.is-info {
  border-left-color: var(--ink);
  background: var(--ink-soft);
  color: var(--ink);
}

.home-start {
  margin-top: 12px;
  min-height: 54px;
  font-size: 16.5px;
}

.home-start .icon {
  width: 19px;
  height: 19px;
}

.fineprint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

/* ---------- 活动页 ---------- */

.active {
  height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  min-height: 0;
}

.active-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  width: min(100%, 1460px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
}

.problem-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: clamp(18px, 2.6vw, 34px) clamp(18px, 3vw, 40px);
  border-right: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.42);
  overflow: auto;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.pane-kicker {
  color: var(--copper-deep);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.phase-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.phase-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--copper);
}

.phase-chip.is-idle::before {
  background: #8ba099;
}

.problem-media {
  flex: 0 1 auto;
  min-height: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-deep);
}

.problem-media img {
  width: 100%;
  max-height: min(43vh, 430px);
  object-fit: contain;
  border-radius: 9px;
  background: #fff;
}

.problem-question {
  flex: 0 0 auto;
  margin: 0;
  color: var(--body);
  font-size: 16.5px;
  line-height: 1.82;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.restore-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 11px;
  border-left: 3px solid var(--copper);
  background: rgba(243, 230, 216, 0.56);
  color: #6e4328;
  font-size: 12px;
  line-height: 1.65;
}

.history {
  flex: 0 0 auto;
  margin-top: auto;
  border-top: 1px dashed var(--line-strong);
}

.history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  list-style: none;
}

.history summary::-webkit-details-marker {
  display: none;
}

.history summary::after {
  content: "+";
  margin-left: 6px;
  color: var(--copper-deep);
  font-size: 18px;
  line-height: 1;
}

.history[open] summary::after {
  content: "−";
}

.history-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.history-list {
  max-height: min(26vh, 260px);
  margin: 0 0 8px;
  padding: 0;
  overflow: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.history-list li {
  padding: 8px 0;
  border-bottom: 1px dotted var(--line);
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.history-list li:last-child {
  border-bottom: 0;
}

.msg-role {
  display: block;
  margin-bottom: 2px;
  color: var(--copper-deep);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.msg-assistant .msg-role {
  color: var(--ink);
}

/* ---------- 引导区 ---------- */

.coach-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}

.latest-block {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: clamp(20px, 3.3vw, 40px) clamp(18px, 3.4vw, 44px) 12px;
  overflow: auto;
  overscroll-behavior: contain;
}

.coach-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 0 0 rgba(183, 113, 70, 0.35);
  animation: pulse 2.4s ease-out infinite;
}

.latest-text {
  max-width: 32em;
  margin: 13px 0 0;
  color: var(--body);
  font-size: clamp(22px, 2.15vw, 28px);
  font-weight: 500;
  letter-spacing: 0.004em;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.voice-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 12px;
  flex: 0 0 auto;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-card);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.voice-btn .icon {
  width: 16px;
  height: 16px;
}

.voice-btn:hover:not(:disabled) {
  border-color: var(--copper);
  color: var(--copper-deep);
}

.voice-btn:disabled {
  opacity: 0.42;
}

.voice-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.voice-bar.is-playing .voice-state::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--copper);
  animation: pulse 1.2s ease-out infinite;
}

.voice-link {
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--copper-deep);
  font-size: 11.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.voice-link:hover {
  color: var(--ink);
}

.recovery {
  flex: 0 0 auto;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(183, 113, 70, 0.34);
  border-left: 3px solid var(--copper);
  border-radius: 12px;
  background: var(--copper-soft);
}

.status-stack {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  padding-inline: clamp(16px, 3.4vw, 44px);
  min-height: 0;
}

.status-stack:has(> :not([hidden])) {
  padding-bottom: 8px;
}

.status-stack > * {
  margin-top: 0;
}

/* 恢复条已经说明了“没放出来”，此时再留一条语音状态会重复占高度。 */
.coach-pane:has(#recovery:not([hidden])) .voice-bar {
  display: none;
}

.recovery-text {
  margin: 0 0 10px;
  color: #6e4328;
  font-size: 13px;
  line-height: 1.65;
}

.recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recovery-note {
  margin: 8px 0 0;
  color: #8a6449;
  font-size: 11px;
  line-height: 1.5;
}

.poll-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-top: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--ink-soft);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.5;
}

.poll-box.is-warn {
  background: var(--copper-soft);
  color: #6e4328;
}

.spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid rgba(35, 72, 67, 0.2);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.poll-box.is-warn .spinner {
  border-color: rgba(183, 113, 70, 0.25);
  border-top-color: var(--copper-deep);
}

.poll-error,
.send-error {
  flex: 0 0 auto;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(156, 74, 60, 0.28);
  border-left: 3px solid var(--danger);
  border-radius: 12px;
  background: var(--danger-soft);
}

.poll-error p,
.send-error p {
  margin: 0;
  color: #74352b;
  font-size: 12.5px;
  line-height: 1.65;
}

.poll-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.send-error .btn {
  margin-top: 10px;
}

/* ---------- 输入区 ---------- */

.composer {
  flex: 0 0 auto;
  padding: 9px clamp(16px, 3vw, 30px) calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.96);
}

.composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.composer-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.char-count {
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.composer-tools {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
}

.tool-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 92px;
  min-height: 54px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.tool-btn .icon {
  width: 19px;
  height: 19px;
}

.tool-btn:hover:not(:disabled) {
  background: rgba(35, 72, 67, 0.05);
  border-color: var(--ink);
}

.talk-btn {
  display: grid;
  grid-template-columns: 24px auto;
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: center;
  column-gap: 9px;
  flex: 1;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid rgba(183, 113, 70, 0.5);
  border-radius: 12px;
  background: var(--copper-soft);
  color: #6e4328;
  text-align: left;
}

.talk-btn .icon {
  grid-row: 1 / 3;
  width: 23px;
  height: 23px;
}

.talk-main {
  align-self: end;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.talk-sub {
  align-self: start;
  color: #8a6449;
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.35;
}

.talk-btn:hover {
  border-color: var(--copper);
  background: #efdccb;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 60px;
  max-height: 140px;
  padding: 10px 12px;
  resize: none;
  border-radius: 12px;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 13px;
  background: var(--ink);
  color: #fdfaf3;
  box-shadow: 0 6px 16px rgba(35, 72, 67, 0.2);
  transition: background-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.send-btn .icon {
  width: 21px;
  height: 21px;
}

.send-btn:hover:not(:disabled) {
  background: var(--ink-deep);
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.38;
  box-shadow: none;
}

.talk-hint {
  margin: 8px 0 0;
  padding: 9px 11px;
  border-left: 3px solid var(--copper);
  border-radius: 4px 8px 8px 4px;
  background: var(--copper-soft);
  color: #6e4328;
  font-size: 12px;
  line-height: 1.65;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
}

.link-btn {
  min-height: 44px;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.link-btn:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

#end-btn:hover {
  color: var(--copper-deep);
}

/* ---------- 收尾 ---------- */

.ended {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
}

.ended-card {
  width: min(100%, 600px);
  padding: clamp(26px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper-card);
  box-shadow: var(--shadow-card);
}

.ended-card h1 {
  margin: 14px 0 14px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 50px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.25;
}

.ended-copy {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.85;
}

.ended-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ended-note {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

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

.sheet {
  width: min(92vw, 450px);
  max-width: 450px;
  max-height: 88dvh;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--body);
  overflow: visible;
}

.sheet::backdrop {
  background: rgba(24, 48, 44, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sheet-card {
  max-height: 88dvh;
  padding: 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper-card);
  box-shadow: var(--shadow-sheet);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.sheet-close:hover {
  background: rgba(35, 72, 67, 0.06);
  color: var(--ink);
}

.sheet-card h2 {
  margin: 12px 0 8px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(25px, 5vw, 31px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.35;
}

.sheet-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.75;
}

.outcome-list {
  display: grid;
  gap: 8px;
}

.outcome-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefa;
  color: var(--body);
  text-align: left;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.outcome-btn:hover {
  border-color: var(--copper);
  background: rgba(243, 230, 216, 0.36);
}

.outcome-btn .icon {
  width: 21px;
  height: 21px;
  color: var(--ink);
}

.outcome-btn strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.outcome-btn small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.outcome-dot {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.outcome-dash {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  position: relative;
}

.outcome-dash::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 9px;
  height: 1px;
  background: var(--muted);
}

.sheet-cancel {
  margin-top: 12px;
}

.sheet-actions {
  display: grid;
  gap: 8px;
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink-deep);
  color: #fdfaf3;
  box-shadow: 0 12px 32px rgba(24, 48, 44, 0.28);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  transform: translateX(-50%);
}

/* ---------- 响应式 ---------- */

@media (max-width: 960px) {
  .home {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    max-width: 720px;
    padding-top: 24px;
  }

  .home-intro h1 {
    margin-top: 13px;
    font-size: clamp(36px, 8vw, 54px);
  }

  .entry-card {
    justify-self: stretch;
    max-width: none;
  }
}

@media (max-width: 1100px) and (orientation: portrait) {
  .active {
    height: auto;
    min-height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  }

  .active-layout {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
    min-height: 0;
  }

  .problem-pane {
    flex: 0 0 auto;
    max-height: 32dvh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: auto;
  }

  .coach-pane {
    flex: 1;
    min-height: 0;
  }
}

@media (max-width: 767px) {
  .recovery {
    padding: 10px 12px;
  }

  .recovery-text {
    margin-bottom: 8px;
  }

  .recovery-note {
    display: none;
  }

  .coach-pane:has(#recovery:not([hidden])) .latest-text {
    font-size: 18px;
    line-height: 1.5;
  }

  .active {
    height: auto;
    min-height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  }

  .active-layout {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
    min-height: 0;
  }

  .problem-pane {
    flex: 0 0 auto;
    max-height: 31dvh;
    padding: 11px 16px 6px;
    gap: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: auto;
  }

  .pane-head {
    min-height: 24px;
  }

  .problem-media {
    max-height: 16dvh;
    padding: 4px;
    border-radius: 10px;
  }

  .problem-media img {
    max-height: 15dvh;
    border-radius: 6px;
  }

  .problem-question {
    font-size: 14px;
    line-height: 1.62;
  }

  .restore-note {
    padding: 6px 9px;
    font-size: 11px;
  }

  .history {
    margin-top: 0;
  }

  .history summary {
    min-height: 38px;
    font-size: 11.5px;
  }

  .history-list {
    max-height: 17dvh;
  }

  .coach-pane {
    flex: 1;
    min-height: 0;
  }

  .latest-block {
    padding: 13px 16px 8px;
  }

  .coach-label {
    font-size: 10.5px;
  }

  .latest-text {
    margin-top: 9px;
    font-size: clamp(21px, 5.6vw, 26px);
    line-height: 1.66;
  }

  .voice-bar {
    margin-top: 11px;
    padding-top: 9px;
    gap: 5px 10px;
  }

  .voice-btn {
    min-height: 44px;
    padding: 0 11px;
    font-size: 12px;
  }

  .voice-state {
    font-size: 10.5px;
  }

  .recovery,
  .poll-box,
  .poll-error,
  .send-error {
    margin-top: 9px;
    padding: 9px 11px;
  }

  .recovery-note {
    display: none;
  }

  .composer {
    padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
  }

  .composer-top {
    margin-bottom: 5px;
  }

  .char-count {
    display: none;
  }

  .composer-tools {
    margin-bottom: 6px;
  }

  .tool-btn {
    min-width: 84px;
    min-height: 50px;
    padding: 0 10px;
    font-size: 11.5px;
  }

  .talk-btn {
    min-height: 50px;
    padding: 0 12px;
  }

  .talk-main {
    font-size: 15px;
  }

  .talk-sub {
    font-size: 10px;
  }

  .input-row textarea {
    min-height: 54px;
    max-height: 112px;
    padding: 8px 10px;
    font-size: 16px;
    line-height: 1.55;
  }

  .send-btn {
    width: 48px;
    height: 48px;
  }

  .composer-foot {
    margin-top: 0;
  }

  .link-btn {
    min-height: 44px;
    font-size: 11.5px;
  }
}

@media (max-width: 430px) {
  .topbar {
    gap: 9px;
    padding-left: 14px;
    padding-right: 12px;
  }

  .trial-badge {
    padding: 0 8px;
    font-size: 10px;
  }

  .mute-btn {
    padding: 0 9px;
    font-size: 11px;
  }

  .home {
    padding-left: 16px;
    padding-right: 16px;
  }

  .home-intro h1 {
    font-size: clamp(35px, 10vw, 43px);
  }

  .intro-copy {
    font-size: 14.5px;
  }

  .entry-card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  .photo-slot {
    min-height: 150px;
    padding: 16px 12px;
  }

  .latest-block {
    padding-left: 14px;
    padding-right: 14px;
  }

  .latest-text {
    font-size: clamp(20px, 5.9vw, 24px);
  }

  .problem-pane {
    max-height: 30dvh;
    padding-left: 14px;
    padding-right: 14px;
  }

  .voice-link {
    font-size: 10.5px;
  }

  .talk-sub {
    max-width: 16em;
  }

  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto auto 0;
  }

  .sheet-card {
    border-radius: 22px 22px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .composer-hint {
    font-size: 10px;
  }

  .tool-btn {
    min-width: 76px;
  }

  .talk-sub {
    font-size: 9.5px;
  }
}

@media (max-height: 560px) {
  .active {
    height: auto;
    min-height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  }

  .active-layout {
    height: auto;
    min-height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  }

  .problem-pane {
    max-height: none;
  }

  .coach-pane {
    min-height: 460px;
  }
}

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

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

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(183, 113, 70, 0.35);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(183, 113, 70, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(183, 113, 70, 0);
  }
}

/* ---------------------------------------------------------------- */
/* 收尾卡：三步方法 + 同类题                                          */
/* ---------------------------------------------------------------- */

.summary-card,
.similar-card {
  margin: 0 0 22px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.similar-card {
  background: var(--copper-soft);
  border-color: rgba(183, 113, 70, 0.34);
}

.summary-state {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.summary-list {
  margin: 0;
  display: grid;
  gap: 14px;
}

.summary-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: start;
}

.summary-row dt {
  padding-top: 2px;
  color: var(--copper-deep);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.summary-row dd {
  margin: 0;
  color: var(--body);
  font-size: 15px;
  line-height: 1.75;
}

.summary-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: var(--body);
  font-size: 15px;
  line-height: 1.7;
}

.summary-steps li::marker {
  color: var(--copper);
  font-weight: 700;
}

.similar-same {
  margin: 6px 0 10px;
  color: #7a5138;
  font-size: 13px;
  line-height: 1.6;
}

.similar-question {
  margin: 0 0 16px;
  color: var(--ink-deep);
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.85;
}

.similar-answer {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--copper);
  border-radius: 8px;
  background: var(--paper-card);
  color: var(--ink-deep);
  font-size: 15px;
  line-height: 1.75;
}

/* 按住说话：按住时高亮，松手即发 */
.talk-btn {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.talk-btn.holding,
.talk-btn.recording {
  transform: scale(0.97);
  box-shadow: 0 0 0 3px rgba(183, 113, 70, 0.28);
}

.talk-btn.holding .talk-main::after {
  content: "…";
}

.composer-hint {
  margin: 10px 0 0;
  color: #7a5138;
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
}
