:root {
  --c1: #00e5ff;
  --c2: #7c4dff;
  --glass: rgba(10, 14, 24, 0.76);
  --border: rgba(0, 229, 255, 0.24);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; height: 100dvh;
  background: #000000;
  color: #eef6ff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  touch-action: pan-x pan-y;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#stage-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000000;
  overflow: hidden;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
canvas#gl-canvas {
  width: min(92vw, 76dvh);
  height: min(92vw, 76dvh);
  display: block;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform: translateY(-2.5dvh) scale(1.20);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), width 0.38s ease, height 0.38s ease;
}
#mail-dialog, input, textarea {
  touch-action: pan-y;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}
body.immersive canvas#gl-canvas {
  width: min(98vw, 88dvh);
  height: min(98vw, 88dvh);
  transform: translateY(0) scale(1.30);
}
body.immersive .subtitle-zone,
body.immersive .subtitle-zone *,
body.immersive .bottom-dock,
body.immersive .bottom-dock * {
  pointer-events: none !important;
}
body.immersive .subtitle-zone,
body.immersive .bottom-dock {
  opacity: 0 !important;
  transform: translate(-50%, 16px) !important;
}
#immersive-voice-aura {
  position: fixed;
  bottom: max(4px, env(safe-area-inset-bottom)); left: 15%; right: 15%;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--c1), #ff2a6d, var(--c1), transparent);
  box-shadow: 0 0 8px var(--c1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 30;
}
body.listening-active #immersive-voice-aura {
  opacity: 0.9;
  animation: pulseDot 0.65s infinite alternate;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
  background: #00e676;
  box-shadow: 0 0 9px #00e676;
  transition: all 0.25s ease;
}
.status-dot.listening { background: #00e5ff; box-shadow: 0 0 13px #00e5ff; transform: scale(1.25); }
.status-dot.thinking  { background: #ffab00; box-shadow: 0 0 13px #ffab00; animation: pulseDot 0.7s infinite alternate; }
.status-dot.speaking  { background: #e040fb; box-shadow: 0 0 13px #e040fb; transform: scale(1.2); }
@keyframes pulseDot { from { opacity: 0.4; transform: scale(0.85); } to { opacity: 1.0; transform: scale(1.3); } }
.pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cde4ff;
  font-size: 12px; padding: 5px 11px;
  border-radius: 999px; cursor: pointer;
  transition: all 0.2s ease;
}
.pill-btn:hover { background: rgba(0, 229, 255, 0.16); border-color: var(--c1); color: #fff; }
.pill-btn.active {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.28), rgba(124, 77, 255, 0.28));
  border-color: var(--c1); color: #fff; font-weight: 600;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.28);
}
#immersive-toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 8px);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 14, 24, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(220, 236, 255, 0.9);
  font-size: 12px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#immersive-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
body:not(.immersive) #immersive-toast {
  opacity: 0 !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .subtitle-zone, .ai-subtitle, .speak-reply-btn, .copy-tip, .bottom-dock, #immersive-toast, canvas#gl-canvas { transition: none !important; }
  .ai-subtitle:active { transform: none !important; }
  .speak-reply-btn .wave-1, .speak-reply-btn .wave-2 { animation: none !important; }
}
/* Subtitle & Chat Bubble Overlay */
.subtitle-zone {
  position: fixed; bottom: 98px; left: 50%;
  transform: translateX(-50%);
  width: min(760px, 92vw);
  text-align: center;
  pointer-events: none; z-index: 18;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.user-echo {
  font-size: 13px; color: rgba(180, 215, 255, 0.78);
  background: rgba(12, 18, 30, 0.62);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 14px; border-radius: 999px;
  max-width: 85%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 0.25s ease;
}
.user-echo.show { opacity: 1; }
.ai-subtitle-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  pointer-events: auto;
}
.ai-subtitle {
  font-size: 16.5px; line-height: 1.55;
  color: #ffffff;
  background: rgba(8, 12, 22, 0.78);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  padding: 11px 44px; border-radius: 18px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.75);
  max-width: 100%;
  user-select: text; pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 229, 255, 0.14);
  transition: all 0.25s ease;
}
.ai-subtitle:active { transform: scale(0.992); }
.ai-subtitle-wrap[data-copied] .ai-subtitle {
  border-color: rgba(0, 229, 255, 0.7);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 229, 255, 0.28);
}
.ai-subtitle-wrap[data-failed] .ai-subtitle {
  border-color: rgba(255, 107, 107, 0.65);
}
.speak-reply-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-inline-size: 28px;
  min-block-size: 28px;
  padding: 5px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 232, 240, 0.84);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.78;
  touch-action: manipulation;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.speak-reply-btn[aria-pressed="true"],
.speak-reply-btn[data-loading] {
  opacity: 1;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.16);
  border-color: rgba(0, 229, 255, 0.48);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.22);
}
@keyframes speakerWave {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
.speak-reply-btn[aria-pressed="true"] .wave-1 { animation: speakerWave 0.9s ease-in-out infinite; }
.speak-reply-btn[aria-pressed="true"] .wave-2 { animation: speakerWave 0.9s ease-in-out 0.22s infinite; }
.speak-reply-btn:focus-visible {
  opacity: 1;
  outline: 3px solid #00e5ff;
  outline-offset: 2px;
}
@media (hover: hover) {
  .ai-subtitle-wrap:hover .ai-subtitle {
    border-color: rgba(0, 229, 255, 0.36);
    background: rgba(10, 16, 30, 0.86);
  }
  .speak-reply-btn:hover {
    opacity: 1;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
  }
  .speak-reply-btn[aria-pressed="true"]:hover,
  .speak-reply-btn[data-loading]:hover {
    color: #7df9ff;
    background: rgba(0, 229, 255, 0.22);
    border-color: rgba(0, 229, 255, 0.6);
  }
}
@media (pointer: coarse) {
  .speak-reply-btn { min-inline-size: 32px; min-block-size: 32px; }
}
.copy-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: rgba(8, 12, 22, 0.94);
  border: 1px solid rgba(0, 229, 255, 0.48);
  color: #7df9ff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ai-subtitle-wrap[data-copied] .copy-tip,
.ai-subtitle-wrap[data-failed] .copy-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ai-subtitle-wrap[data-failed] .copy-tip {
  border-color: rgba(255, 107, 107, 0.55);
  color: #ffb4b4;
}
/* Bottom Dock */
.bottom-dock {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  display: flex; align-items: center; gap: 6px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 6px 5px 8px;
  z-index: 20;
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.85);
}
.mic-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(226, 232, 240, 0.9);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}
.mic-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.mic-btn.recording {
  background: rgba(255, 42, 109, 0.85);
  border-color: #ff2a6d;
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 42, 109, 0.75);
  animation: pulseMic 1.0s infinite alternate;
}
@keyframes pulseMic { from { transform: scale(1.0); } to { transform: scale(1.08); } }
.dock-input-wrap {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  padding-left: 2px;
}
.chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #fff; font-size: 15.5px; padding: 6px 2px; min-width: 0;
}
.chat-input:focus-visible { outline: none; }
.bottom-dock:has(.chat-input:focus-visible) {
  border-color: var(--c1);
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(0, 229, 255, 0.25);
}
.chat-input::placeholder { color: rgba(190, 215, 245, 0.52); }
.send-btn {
  width: 34px; height: 34px;
  background: #2563eb;
  border: none; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  transition: filter 0.16s ease, transform 0.16s ease; flex-shrink: 0;
}
.send-btn:hover { filter: brightness(1.1); transform: scale(1.04); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
/* Mobile Responsive Adaptation (keep chat-input 16px so zoom never triggers without blocking page zoom) */
@media (max-width: 768px) {
  canvas#gl-canvas {
    width: min(96vw, 66dvh);
    height: min(96vw, 66dvh);
    transform: translateY(-3.5dvh) scale(1.20);
  }
  body.immersive canvas#gl-canvas {
    width: min(100vw, 84dvh);
    height: min(100vw, 84dvh);
    transform: translateY(0) scale(1.30);
  }
  .pill-btn { font-size: 12px; padding: 5px 10px; flex-shrink: 0; }
  .subtitle-zone { bottom: calc(76px + env(safe-area-inset-bottom)); width: 94vw; }
  .ai-subtitle { font-size: 14.5px; padding: 9px 44px; border-radius: 14px; }
  .speak-reply-btn { right: 6px; }
  .bottom-dock {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: 92vw; padding: 5px 6px 5px 8px; gap: 6px;
  }
  .dock-input-wrap { gap: 6px; padding-left: 2px; }
  .mic-btn, .send-btn { width: 34px; height: 34px; padding: 0; }
  .chat-input { font-size: 16px; }
  .bottom-dock,
  .ai-subtitle,
  .pill-btn,
  .top-hud .hud-pill {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}
/* Native Creator Email Draft Modal Dialog */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}
@keyframes mailGlassPopIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(14px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#mail-dialog {
  margin: auto;
  width: min(480px, 92vw);
  max-height: 90dvh;
  overflow-y: auto;
  color: #ffffff;
  border-radius: 28px;
  padding: 24px 26px 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.08) 42%, rgba(13, 20, 36, 0.62) 100%);
  backdrop-filter: blur(50px) saturate(200%) contrast(105%);
  -webkit-backdrop-filter: blur(50px) saturate(200%) contrast(105%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-top: 1.5px solid rgba(255, 255, 255, 0.55);
  border-left: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    inset 0 1.5px 1.5px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 1px 0 rgba(255, 255, 255, 0.08),
    0 32px 84px -10px rgba(0, 0, 0, 0.70),
    0 0 0 1px rgba(0, 0, 0, 0.22);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

#mail-dialog::-webkit-scrollbar {
  width: 5px;
}

#mail-dialog::-webkit-scrollbar-track {
  background: transparent;
}

#mail-dialog::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

#mail-dialog::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.45);
}

#mail-dialog[open] {
  animation: mailGlassPopIn 0.36s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#mail-dialog:modal {
  overscroll-behavior: contain;
}

#mail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.40);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  overscroll-behavior: contain;
  transition: backdrop-filter 0.3s ease;
}

.mail-card-header {
  margin-bottom: 16px;
}

.mail-top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mail-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.mail-icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  transform: scale(1.08);
}

.mail-glass-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.90);
  font-size: 0.78rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38ef7d;
  box-shadow: 0 0 8px #38ef7d;
}

.mail-title {
  font-size: 1.52rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  margin: 0;
  color: #ffffff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

.mail-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 方案1：极简收件人行 */
.mail-recipient-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 4px 16px;
  min-height: 48px;
  box-sizing: border-box;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
}

.mail-recipient-row:focus-within {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.18),
    inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.mail-recipient-label {
  font-size: 0.85rem;
  font-weight: 650;
  color: rgba(255, 255, 255, 0.70);
  white-space: nowrap;
  letter-spacing: 0.02em;
  user-select: none;
}

.mail-recipient-row input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 8px 0;
  outline: none;
  box-shadow: none;
  min-height: unset;
  box-sizing: border-box;
}

.mail-recipient-row input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.mail-recipient-row:has(input:is(:user-invalid, .user-invalid-fallback)) {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.14);
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.3);
}

/* 方案1：一体化微光信纸容器（主题 + 正文视觉融合） */
.mail-sheet-card {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top: 1.5px solid rgba(255, 255, 255, 0.32);
  border-radius: 20px;
  padding: 16px 18px 14px;
  box-sizing: border-box;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow:
    inset 0 1px 1.5px rgba(255, 255, 255, 0.22),
    0 8px 24px rgba(0, 0, 0, 0.25);
}

.mail-sheet-card:focus-within {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.50);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.16),
    inset 0 1px 1.5px rgba(255, 255, 255, 0.30),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

.mail-sheet-card:has(textarea:is(:user-invalid, .user-invalid-fallback)) {
  border-color: #f87171;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.3);
}

.mail-sheet-subject-row input {
  width: 100%;
  border: none;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  padding: 2px 0 6px;
  outline: none;
  box-shadow: none;
  min-height: unset;
  box-sizing: border-box;
}

.mail-sheet-subject-row input::placeholder {
  color: rgba(255, 255, 255, 0.42);
  font-weight: 550;
}

.mail-sheet-divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.08) 75%, transparent 100%);
  margin: 6px 0 10px;
}

.mail-sheet-body-row textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.94);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 2px 0 0;
  outline: none;
  box-shadow: none;
  min-height: 120px;
  resize: vertical;
  box-sizing: border-box;
  scrollbar-width: thin;
}

.mail-sheet-body-row textarea::placeholder {
  color: rgba(255, 255, 255, 0.36);
}

.mail-error-msg {
  display: none;
  color: #fca5a5;
  font-size: 0.81rem;
  line-height: 1.35;
  margin-top: -2px;
  padding-left: 4px;
}

.mail-recipient-row:has(input:is(:user-invalid, .user-invalid-fallback)) + .mail-error-msg,
.mail-sheet-card:has(textarea:is(:user-invalid, .user-invalid-fallback)) + .mail-error-msg {
  display: block;
}

.mail-status-line {
  min-height: 1.2em;
  font-size: 0.84rem;
  color: #a5f3fc;
  text-align: center;
}

.mail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.mail-btn-primary {
  width: 100%;
  min-height: 50px;
  border-radius: 999px;
  background: #ffffff !important;
  color: #0b0f19 !important;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.8);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
}

.mail-btn-primary:hover {
  transform: translateY(-1px);
  background: #f8fafc !important;
  box-shadow:
    0 8px 28px rgba(255, 255, 255, 0.35),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.mail-btn-primary:active {
  transform: translateY(1px) scale(0.99);
}

.mail-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  background: rgba(255, 255, 255, 0.8) !important;
}

@media (pointer: coarse) {
  .mail-recipient-row,
  .mail-btn-primary {
    min-height: 52px;
  }
}

@media (max-width: 480px) {
  #mail-dialog {
    width: 92vw;
    max-height: 84dvh;
    padding: 20px 18px 18px;
    border-radius: 24px;
    box-sizing: border-box;
  }
  .mail-title {
    font-size: 1.35rem;
  }
  .mail-sheet-card {
    padding: 12px 14px 10px;
    border-radius: 16px;
  }
  .mail-sheet-subject-row input {
    font-size: 1.05rem;
  }
  .mail-sheet-body-row textarea {
    font-size: 0.90rem;
    min-height: 96px;
    max-height: 32dvh;
  }
}

/* =====================================================================
   全屏沉浸式自适应画板 (Full-Screen Adaptive Lightbox Canvas)
   ===================================================================== */
#image-dialog {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: rgba(5, 8, 15, 0.94);
  backdrop-filter: blur(32px) saturate(160%);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  color: #f8fafc;
  box-sizing: border-box;
  overflow: hidden;
  animation: lightboxFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#image-dialog[open] {
  display: flex;
}

#image-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@keyframes lightboxFadeIn {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

.image-stage-backdrop {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(58px + env(safe-area-inset-top)) 24px calc(88px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.image-close-btn {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: 18px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  outline: none;
  cursor: pointer;
  transition: opacity 0.22s ease, transform 0.18s ease, background 0.18s ease;
}

.image-close-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.7);
}

.image-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: scale(1.06);
}

.image-stage-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  pointer-events: none;
}

.image-display-wrap {
  --stage-max-w: min(92vw, 1380px);
  --stage-max-h: calc(100dvh - 152px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  width: min(var(--stage-max-w), calc(var(--stage-max-h) * var(--canvas-ratio-num, 1)));
  aspect-ratio: var(--canvas-ratio-num, 1);
  max-height: var(--stage-max-h);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(12, 17, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(6, 182, 212, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  pointer-events: auto;
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1), border-radius 0.22s ease;
}

#image-dialog.hud-hidden {
  background: #000000;
}

#image-dialog.hud-hidden .image-stage-backdrop {
  padding: 0;
}

#image-dialog.hud-hidden .image-display-wrap {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  background: #000000;
  box-shadow: none;
}

.image-preview-img,
.image-preview-vid {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: transparent;
  cursor: zoom-in;
  animation: mediaReveal 0.32s ease;
  -webkit-touch-callout: default !important;
  -webkit-user-select: auto !important;
  user-select: auto !important;
  pointer-events: auto !important;
}

.image-preview-vid {
  cursor: pointer;
}

#image-dialog.hud-hidden .image-preview-img {
  cursor: zoom-out;
}

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

.image-skeleton-loader {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.09) 0%, rgba(15, 23, 42, 0.72) 72%);
}

.skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(6, 182, 212, 0.14) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.8s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes skeletonShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* 风格 1：极细底部发光进度轨 + 右下角静默等宽数字 */
.canvas-progress-hud {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 6;
  pointer-events: none;
}

.canvas-progress-meta {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(226, 232, 240, 0.76);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.canvas-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  z-index: 6;
  pointer-events: none;
}

.canvas-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #06b6d4 0%, #38bdf8 60%, #818cf8 100%);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.85), 0 0 4px rgba(6, 182, 212, 0.9);
  transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.image-status-toast {
  margin-top: 12px;
  font-size: 0.84rem;
  color: #fca5a5;
  text-align: center;
  max-width: min(88vw, 520px);
  line-height: 1.45;
  pointer-events: auto;
  transition: opacity 0.22s ease;
}

.image-status-toast:empty {
  display: none;
}

/* 底部悬浮毛玻璃操作坞 */
.image-dock {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9999px;
  background: rgba(16, 21, 34, 0.78);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: opacity 0.22s ease, transform 0.22s ease;
  max-width: 94vw;
}

.image-dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #f1f5f9;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
}

.image-dock-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.image-dock-btn.active {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.45);
  color: #a5f3fc;
}

.image-dock-btn-primary {
  background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.32);
}

.image-dock-btn-primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
}

/* 折叠式提示词浮层 */
.image-prompt-popover {
  position: fixed;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 32;
  width: min(92vw, 560px);
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(14, 19, 32, 0.88);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.62);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.image-prompt-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.image-meta-dims {
  font-size: 0.76rem;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 0.03em;
}

.image-copy-btn {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  font-size: 0.74rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.image-copy-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.image-prompt-caption {
  font-size: 0.84rem;
  line-height: 1.5;
  color: #cbd5e1;
  max-height: 110px;
  overflow-y: auto;
  word-break: break-word;
}

/* 纯净观图模式 (轻点画面隐藏 HUD) */
#image-dialog.hud-hidden .image-close-btn,
#image-dialog.hud-hidden .image-dock,
#image-dialog.hud-hidden .image-prompt-popover,
#image-dialog.hud-hidden .image-status-toast {
  opacity: 0;
  pointer-events: none;
}

#image-dialog.hud-hidden .image-dock {
  transform: translate(-50%, 14px);
}

@media (max-width: 640px) {
  .image-stage-backdrop {
    padding: calc(54px + env(safe-area-inset-top)) 10px calc(84px + env(safe-area-inset-bottom));
  }
  .image-display-wrap {
    --stage-max-w: 96vw;
    --stage-max-h: calc(100dvh - 144px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 14px;
  }
  .image-dock {
    padding: 6px 8px;
    gap: 6px;
  }
  .image-dock-btn {
    padding: 8px 12px;
    font-size: 0.82rem;
  }
}
