/* ============================================
   拍题讲解 - 固定语音条 / 提问区 / 弹层
   ============================================ */

/* ===== 追问线程 ===== */
.thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.thread:empty { display: none; }
.thread-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-bubble {
  align-self: flex-end;
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(135deg, #EDE9FE, #F5F3FF);
  border: 1px solid #DDD6FE;
  color: #4C1D95;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

/* ===== 讲解完成提示 ===== */
.flow-done {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #A7F3D0;
  background: linear-gradient(150deg, #ECFDF5, #F0FDFA);
}
.flow-done-icon { font-size: 20px; line-height: 1.3; }
.flow-done strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #065F46;
}
.flow-done p {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.6;
  color: #0F766E;
}

/* 讲解完成后隐藏语音条与输入框 */
body.flow-finished .solve-page {
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}
body.flow-finished .toast {
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ===== 底部提问区 ===== */
.composer-shell {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 60;
  width: 100%;
  max-width: 430px;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(249, 249, 252, 0.7) 0%, var(--background) 24%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
}
.composer-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-input::placeholder { color: var(--text-placeholder); }
.composer-input:focus {
  border-color: #C4B5FD;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.composer-input:disabled {
  background: #F4F2F9;
  border-color: #E9E6F2;
  color: var(--text-muted);
  cursor: default;
}
.send-btn:disabled {
  opacity: 0.4;
  box-shadow: none;
  cursor: default;
}
.send-btn {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED, #6366F1);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
}
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn svg { width: 20px; height: 20px; }

/* ===== 听懂了 / 没听懂 ===== */
.composer-choice {
  display: flex;
  gap: 10px;
}
.choice-btn {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s, box-shadow 0.15s;
}
.choice-btn:active { transform: scale(0.97); }
.choice-btn svg { width: 20px; height: 20px; }
.choice-yes {
  border: none;
  background: linear-gradient(135deg, #34D399, #059669);
  color: #fff;
  box-shadow: 0 5px 14px rgba(5, 150, 105, 0.24);
}
.choice-no {
  border: 1.5px solid #FDE68A;
  background: #FFFBEB;
  color: #B45309;
}

/* ===== 固定语音条（输入框上方） ===== */
.listen-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  margin-bottom: 8px;
  padding: 0 12px 2px 8px;
  border: 1px solid #BBF7D0;
  border-radius: 16px;
  background: linear-gradient(135deg, #ECFDF5, #F0FDFA);
  box-shadow: 0 2px 10px rgba(5, 150, 105, 0.07);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.listen-bar:active { transform: scale(0.995); }
.listen-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: #059669;
}
.listen-icon svg { width: 20px; height: 20px; }
.listen-marquee {
  flex: 1;
  min-width: 0;
  height: 20px;
  overflow: hidden;
}
.listen-track {
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.listen-track span {
  display: block;
  height: 20px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  font-weight: 600;
  color: #065F46;
  letter-spacing: 0.2px;
}
.listen-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(5, 150, 105, 0.12);
  overflow: hidden;
}
.listen-progress i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 100%;
}
.listen-buffer {
  background: #A7F3D0;
  transition: width 0.3s linear;
}
.listen-buffer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  transform: translateX(-100%);
}
.listen-progress.is-streaming .listen-buffer::after {
  animation: stream-shimmer 1.2s linear infinite;
}
.listen-fill {
  background: linear-gradient(90deg, #34D399, #059669);
  transition: width 0.2s linear;
}
.listen-play,
.listen-retry {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s;
}
.listen-play {
  background: linear-gradient(135deg, #34D399, #059669);
  color: #fff;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.24);
}
.listen-play:active:not(:disabled),
.listen-retry:active { transform: scale(0.92); }
.listen-play:disabled {
  background: #A7F3D0;
  box-shadow: none;
  cursor: default;
}
.listen-play svg { width: 17px; height: 17px; }
.listen-play .i-pause { display: none; }
.listen-play[data-play-status="playing"] .i-play { display: none; }
.listen-play[data-play-status="playing"] .i-pause { display: block; }
.listen-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.listen-bar[data-status="generating"] .listen-spinner { display: block; }
.listen-bar[data-status="generating"] .listen-play .i-play,
.listen-bar[data-status="generating"] .listen-play .i-pause { display: none; }
.listen-retry {
  background: #fff;
  border: 1px solid #A7F3D0;
  color: #047857;
}
.listen-retry svg { width: 18px; height: 18px; }
.listen-bar[data-status="failed"] {
  border-color: #FECACA;
  background: linear-gradient(135deg, #FEF2F2, #FFF1F2);
}
.listen-bar[data-status="failed"] .listen-icon { color: #DC2626; }
.listen-bar[data-status="failed"] .listen-track span { color: #B91C1C; }

/* ===== 点踩原因弹层 ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  opacity: 0;
  transition: opacity 0.2s;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 430px;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.16);
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.sheet-overlay.show .sheet-mask { opacity: 1; }
.sheet-overlay.show .sheet { transform: translateY(0); opacity: 1; }
.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #E5E1F0;
}
.sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.sheet-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.reason-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 16px;
}
.reason {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.reason::after {
  content: '';
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  border: 1.5px solid #D7D3E6;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.reason.selected {
  border-color: #C4B5FD;
  background: var(--primary);
  color: var(--accent-dark);
  font-weight: 600;
}
.reason.selected::after {
  border-color: #7C3AED;
  background: #7C3AED;
  box-shadow: inset 0 0 0 3px #fff;
}
.sheet-actions {
  display: flex;
  gap: 10px;
}
.sheet-btn {
  flex: 1;
  min-height: 46px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s, opacity 0.15s;
}
.sheet-btn:active { transform: scale(0.98); }
.sheet-cancel {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}
.sheet-submit {
  border: none;
  background: linear-gradient(135deg, #7C3AED, #6366F1);
  color: #fff;
}
.sheet-submit:disabled {
  opacity: 0.4;
  cursor: default;
}
body.sheet-open { overflow: hidden; }

/* ===== 轻提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  z-index: 400;
  max-width: 300px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.85);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===== 动效 ===== */
@keyframes stream-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
