/* ============ 全局 ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'PingFang SC', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  background: linear-gradient(160deg, #1b2242 0%, #2a2f5e 40%, #3b3160 70%, #4a3a6b 100%);
  background-attachment: fixed;
  color: #e6e9ff;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 星空 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 15% 70%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 85%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 50%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 65%, #fff 50%, transparent 51%);
  opacity: 0.7;
  animation: twinkle 6s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes twinkle {
  0% { opacity: 0.5; }
  100% { opacity: 0.9; }
}

/* 返回按钮 */
.back-fab {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  left: 1rem;
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e6e9ff;
  font-size: 1.3rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: all 0.22s ease;
}
.back-fab:active { transform: scale(0.92); }

/* ============ 主容器 ============ */
.voice-app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 头部 */
.app-header {
  text-align: center;
  padding: 0.4rem 0.6rem 0.2rem;
}

.title-icon {
  font-size: 2.2rem;
  margin-bottom: 0.2rem;
  filter: drop-shadow(0 0 16px rgba(255, 220, 160, 0.4));
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.title-text {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(120deg, #ffd9b3, #ffb3d9, #b3c7ff, #ffd9b3);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 6s ease-in-out infinite;
  margin-bottom: 0.3rem;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.title-sub {
  font-size: 0.85rem;
  color: rgba(230, 235, 255, 0.6);
}

/* ============ 声音树 ============ */
.tree-stage {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 400 / 480;
  position: relative;
  filter: drop-shadow(0 20px 40px rgba(120, 100, 180, 0.35));
}

.tree-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tree-trunk, .tree-branch {
  filter: drop-shadow(0 2px 6px rgba(120, 100, 180, 0.3));
}

/* 叶子 */
.tree-leaf {
  cursor: pointer;
  transition: all 0.3s ease;
  transform-origin: center;
  transform-box: fill-box;
}

.tree-leaf .leaf-shape {
  fill: url(#trunkGrad);
  opacity: 0.85;
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(120, 100, 180, 0.3));
}

.tree-leaf:hover .leaf-shape {
  opacity: 1;
  filter: drop-shadow(0 4px 12px rgba(255, 200, 240, 0.6));
}

/* 播放中的叶子 */
.tree-leaf.playing .leaf-shape {
  fill: #ffd9b3;
  filter: drop-shadow(0 0 16px rgba(255, 220, 180, 0.9));
  animation: leafPulse 1.2s ease-in-out infinite;
}

@keyframes leafPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* 新叶子生长动画 */
.tree-leaf.growing {
  animation: leafGrow 0.8s cubic-bezier(0.2, 0.8, 0.3, 1.4);
}

@keyframes leafGrow {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* 叶子编号 */
.leaf-num {
  font-size: 8px;
  fill: #2a2f5e;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.tree-leaf:hover .leaf-num {
  opacity: 1;
}

/* ============ 录音按钮 ============ */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0 0.5rem;
}

.record-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, rgba(160, 180, 255, 0.25), rgba(200, 160, 255, 0.25));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #e6e9ff;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 12px 36px rgba(140, 160, 240, 0.35);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.record-btn:hover {
  transform: scale(1.04);
  border-color: rgba(180, 200, 255, 0.4);
}

.record-btn.recording {
  background: linear-gradient(135deg, rgba(255, 120, 120, 0.4), rgba(255, 180, 120, 0.4));
  border-color: rgba(255, 150, 150, 0.6);
  box-shadow: 0 12px 40px rgba(255, 120, 120, 0.5);
  animation: recordPulse 1.4s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.record-icon { font-size: 2.2rem; line-height: 1; }
.record-text { font-size: 0.82rem; font-weight: 600; letter-spacing: 1px; }

.record-timer {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 200, 200, 0.9);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

.upload-status {
  text-align: center;
  font-size: 0.82rem;
  color: rgba(230, 235, 255, 0.7);
  min-height: 1.2em;
  transition: all 0.3s;
}
.upload-status.success { color: rgba(180, 230, 180, 0.9); }
.upload-status.error { color: rgba(255, 150, 150, 0.9); }
.upload-status.uploading { color: rgba(255, 220, 150, 0.9); }

/* ============ 空状态 ============ */
.empty-hint {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(230, 235, 255, 0.5);
  padding: 0.5rem 1rem;
  line-height: 1.6;
}

/* ============ 播放中提示 ============ */
.playing-toast {
  position: fixed;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 9998;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.3, 1.2);
  pointer-events: none;
}

.playing-toast.show {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.playing-toast-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem 0.7rem 1.1rem;
  background: rgba(30, 35, 70, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(180, 200, 255, 0.25);
  border-radius: 40px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
}

.playing-toast-icon {
  font-size: 1.1rem;
  animation: toastPulse 1.2s ease-in-out infinite;
}

@keyframes toastPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

.playing-toast-text {
  font-size: 0.85rem;
  color: #e6e9ff;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

.playing-toast-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #e6e9ff;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.playing-toast-close:active { background: rgba(255, 255, 255, 0.2); }

/* ============ 删除确认弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 30, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(160deg, #232849, #2e2a52);
  border: 1px solid rgba(180, 200, 255, 0.2);
  border-radius: 24px;
  padding: 1.6rem 1.4rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.7rem;
}

.modal-text {
  font-size: 0.85rem;
  color: rgba(230, 235, 255, 0.6);
  margin-bottom: 1.3rem;
  word-break: break-word;
}

.modal-actions {
  display: flex;
  gap: 0.7rem;
}

.modal-actions button {
  flex: 1;
  padding: 0.75rem;
  border-radius: 12px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s;
  letter-spacing: 0.5px;
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(230, 235, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}
.btn-cancel:active { background: rgba(255, 255, 255, 0.15); }

.btn-delete {
  background: rgba(255, 120, 120, 0.25);
  color: #ffb0b0;
  border: 1px solid rgba(255, 150, 150, 0.4) !important;
}
.btn-delete:active { background: rgba(255, 120, 120, 0.4); }

/* ============ 响应式 ============ */
@media (max-width: 480px) {
  .voice-app { padding-top: 2.8rem; gap: 0.8rem; }
  .tree-stage { max-width: 340px; }
  .record-btn { width: 100px; height: 100px; }
  .record-icon { font-size: 1.8rem; }
  .record-text { font-size: 0.78rem; }
  .playing-toast-text { max-width: 50vw; }
}