/* 虫洞通讯 - H5 移动端样式 */
:root {
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --bg-dark: #0a0a1a;
  --bg-card: rgba(255,255,255,0.08);
  --text: #fff;
  --text-secondary: #999;
  --danger: #ff4757;
  --success: #2ed573;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 50%, #16213e 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 页面容器 */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page-hidden { display: none !important; }

/* 顶部栏 */
.header {
  padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.header h1 { font-size: 18px; color: var(--primary); }
.header .user-info { font-size: 13px; color: var(--text-secondary); }

/* 通用按钮 */
.btn {
  padding: 12px 24px; border-radius: 8px; border: none;
  font-size: 15px; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); transform: scale(0.97); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.2); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }

/* 认证页 */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-box {
  width: 100%; max-width: 360px;
  background: var(--bg-card); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 16px;
  padding: 32px 24px;
}
.auth-box h2 { text-align: center; font-size: 20px; margin-bottom: 8px; }
.auth-box .subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 12px 16px; border-radius: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: 15px; outline: none;
}
.form-group input:focus { border-color: var(--primary); }
.form-group input::placeholder { color: rgba(255,255,255,0.3); }

.error-msg { color: var(--danger); font-size: 13px; margin: 8px 0; text-align: center; }

.toggle-btn {
  display: block; text-align: center; color: var(--primary);
  font-size: 14px; margin-top: 16px; cursor: pointer; border: none; background: none;
}

/* 操作按钮区域 */
.action-buttons {
  margin-top: 140px;
  text-align: center;
  position: relative;
  z-index: 30;
}

/* 虫洞主界面 */
.wormhole-page { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 20px; }

/* 虫洞容器 */
.wormhole-container {
  position: relative;
  width: 280px; height: 280px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.3s;
  overflow: visible;
}
.wormhole-container:active { transform: scale(0.95); }

/* 虫洞主体 */
.wormhole {
  position: relative;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, #1a1a2e 0%, #0f0f1e 70%, #000 100%);
  box-shadow: 0 0 50px rgba(102,126,234,0.3), inset 0 0 50px rgba(118,75,162,0.2);
  animation: wh-rotate 20s linear infinite;
  transition: all 0.3s;
}

/* 虫洞核心 */
.wormhole-core {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle, #000 0%, #1a1a2e 100%);
  box-shadow: 0 0 30px rgba(0,0,0,0.8);
}

/* 光环 */
.wormhole-ring {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  border: 2px solid rgba(102,126,234,0.3);
}
.ring-1 { width: 120px; height: 120px; animation: wh-rotate-rev 15s linear infinite; }
.ring-2 { width: 160px; height: 160px; animation: wh-rotate 25s linear infinite; }
.ring-3 { width: 200px; height: 200px; animation: wh-rotate-rev 30s linear infinite; }

/* 粒子 */
.wormhole-particles {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(2px 2px at 40px 60px, #667eea, transparent),
    radial-gradient(2px 2px at 20px 50px, #764ba2, transparent),
    radial-gradient(1px 1px at 90px 70px, #667eea, transparent),
    radial-gradient(1px 1px at 130px 80px, #764ba2, transparent),
    radial-gradient(2px 2px at 160px 30px, #667eea, transparent);
  background-repeat: repeat; background-size: 200px 200px;
  animation: wh-twinkle 3s linear infinite;
}

/* 虫洞提示文字 */
.wormhole-text { color: rgba(255,255,255,0.7); font-size: 14px; text-align: center; z-index: 20; pointer-events: none; position: absolute; }

/* ===== 虫洞状态 ===== */
/* 有消息 - 保留原有闪烁效果 */
.wormhole-container.has-message .wormhole {
  box-shadow: 0 0 100px rgba(102,126,234,0.8), inset 0 0 100px rgba(118,75,162,0.6);
  animation: wh-rotate 20s linear infinite, wh-message-glow 2s ease-in-out infinite !important;
}
.wormhole-container.has-message .wormhole-ring {
  border-color: rgba(102,126,234,0.6);
}
.wormhole-container.has-message .wormhole-core {
  box-shadow: 0 0 20px rgba(102,126,234,0.6), 0 0 30px rgba(0,0,0,0.8);
}
.wormhole-container.has-message .wormhole-particles {
  animation: wh-twinkle 1.5s linear infinite;
  opacity: 1;
}

/* 发送中（吸入动画状态） */
.wormhole-container.absorbing .wormhole {
  animation: wh-rotate 20s linear infinite, wh-pulse 1.5s ease-in-out !important;
  box-shadow: 0 0 80px rgba(102,126,234,0.6), inset 0 0 80px rgba(118,75,162,0.4);
}

/* 能量耗尽 */
.wormhole-container.depleted { cursor: default; }
.wormhole-container.depleted .wormhole {
  box-shadow: 0 0 30px rgba(255,71,87,0.3), inset 0 0 30px rgba(255,71,87,0.2);
  animation: wh-rotate 20s linear infinite, wh-depleted-pulse 3s ease-in-out infinite !important;
}

/* ===== 浮动消息（被虫洞吸入） ===== */
.floating-message {
  position: absolute;
  bottom: -30px; left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.9);
  color: #1a1a2e;
  padding: 8px 14px; border-radius: 20px;
  font-size: 0.85rem; max-width: 180px;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 0 20px rgba(102,126,234,0.5);
  animation: wh-float-to-wormhole 1.5s ease-in forwards;
  z-index: 5;
}

/* ===== 能量球（发送时爆发） ===== */
.energy-ball {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #667eea 50%, #764ba2 100%);
  box-shadow: 0 0 20px #667eea, 0 0 40px #764ba2, 0 0 60px rgba(102,126,234,0.5);
  animation: wh-energy-pulse 1s ease-out forwards;
  z-index: 10;
}
.energy-core {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px #fff;
  animation: wh-core-pulse 0.3s ease-out infinite alternate;
}

/* ===== 关键帧 ===== */
@keyframes wh-rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes wh-rotate-rev { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
@keyframes wh-twinkle { from { opacity: 0.3; } to { opacity: 0.8; } }

@keyframes wh-pulse {
  0% { box-shadow: 0 0 50px rgba(102,126,234,0.3), inset 0 0 50px rgba(118,75,162,0.2); }
  50% { box-shadow: 0 0 100px rgba(102,126,234,0.6), inset 0 0 100px rgba(118,75,162,0.4); }
  100% { box-shadow: 0 0 50px rgba(102,126,234,0.3), inset 0 0 50px rgba(118,75,162,0.2); }
}

@keyframes wh-message-glow {
  0% { box-shadow: 0 0 50px rgba(102,126,234,0.3), inset 0 0 50px rgba(118,75,162,0.2); }
  50% { box-shadow: 0 0 120px rgba(102,126,234,0.8), inset 0 0 120px rgba(118,75,162,0.6); }
  100% { box-shadow: 0 0 50px rgba(102,126,234,0.3), inset 0 0 50px rgba(118,75,162,0.2); }
}

@keyframes wh-float-to-wormhole {
  0% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-130px) scale(0.2); opacity: 0; }
}

@keyframes wh-energy-pulse {
  0% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0); opacity: 0; }
}

@keyframes wh-core-pulse { from { opacity: 0.5; } to { opacity: 1; } }

@keyframes wh-depleted-pulse {
  0% { box-shadow: 0 0 30px rgba(255,71,87,0.2), inset 0 0 30px rgba(255,71,87,0.1); }
  50% { box-shadow: 0 0 50px rgba(255,71,87,0.4), inset 0 0 50px rgba(255,71,87,0.2); }
  100% { box-shadow: 0 0 30px rgba(255,71,87,0.2), inset 0 0 30px rgba(255,71,87,0.1); }
}

.wormhole-hint { margin-top: 16px; color: var(--text-secondary); font-size: 14px; text-align: center; }

/* 能量条 */
.energy-bar { margin-top: 12px; width: 80%; max-width: 260px; }
.energy-bar-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.energy-bar-track { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; }
.energy-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.energy-bar-fill.low { background: var(--danger); }

/* 消息输入 */
.msg-input-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding-bottom: 15vh;
}
.msg-input-box {
  width: 90%; max-width: 360px; padding: 24px 20px;
  background: #1a1a2e; border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
}
.msg-input-box h3 { font-size: 16px; margin-bottom: 12px; }
.msg-input-box textarea {
  width: 100%; padding: 12px; border-radius: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: 14px; resize: none; height: 80px; outline: none;
}

/* 聊天弹窗 - 微信风格 */
.chat-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 0;
}
.chat-box {
  width: 100%; max-width: 400px; height: 50vh; max-height: 50vh;
  background: #1a1a2e; display: flex; flex-direction: column;
  border-radius: 16px;
}
.chat-header {
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.chat-close-btn {
  background: none; border: none; color: var(--text-secondary);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  border-radius: 50%; transition: background 0.2s;
}
.chat-close-btn:active { background: rgba(255,255,255,0.1); }
.chat-title { font-size: 16px; color: var(--primary); flex: 1; text-align: center; }
.chat-reply-info { font-size: 12px; color: var(--text-secondary); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

/* 聊天气泡 - 对方靠左，我方靠右 */
.chat-msg {
  display: flex; max-width: 85%;
}
.chat-msg-other {
  align-self: flex-start;
}
.chat-msg-self {
  align-self: flex-end;
}
.chat-bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.6; word-break: break-word;
  position: relative;
}
.chat-msg-other .chat-bubble {
  background: rgba(255,255,255,0.12); color: var(--text);
  border-radius: 4px 12px 12px 12px;
}
.chat-msg-self .chat-bubble {
  background: var(--primary); color: #fff;
  border-radius: 12px 4px 12px 12px;
}
.chat-sender {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 4px;
}

.chat-footer {
  padding: 12px 16px;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,0.1);
}
.chat-input-row {
  display: flex; gap: 10px; align-items: center;
}
.chat-input {
  flex: 1; padding: 10px 14px; border-radius: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: 14px; outline: none;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input::placeholder { color: rgba(255,255,255,0.3); }
.chat-send-btn {
  padding: 10px 18px; border-radius: 8px; border: none;
  background: var(--primary); color: #fff; font-size: 14px;
  cursor: pointer; transition: background 0.2s;
}
.chat-send-btn:active { background: var(--primary-dark); }
.energy-bar-full { margin-top: 8px; width: 100%; }
.energy-bar-segments { margin-top: 8px; display: flex; gap: 4px; }
.energy-segment { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); transition: background 0.3s; }
.energy-segment.active { background: var(--primary); }
.energy-segment.active.low { background: var(--danger); }
.energy-bar-full .energy-bar-track { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.energy-bar-full .energy-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; width: 100%; }
.energy-bar-full .energy-bar-fill.low { background: var(--danger); }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* 状态提示 */
.status-msg {
  margin-top: 20px; padding: 16px; border-radius: 8px;
  background: var(--bg-card); text-align: center;
  font-size: 14px; color: var(--text-secondary);
}

/* 管理后台 */
.manage-page { min-height: 100vh; padding: 20px; }
.manage-nav { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.manage-card {
  background: var(--bg-card); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 16px; margin-bottom: 12px;
}
.manage-card .meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.manage-card .content { font-size: 14px; line-height: 1.6; }
.manage-card .actions { display: flex; gap: 8px; margin-top: 12px; }

/* ==================== PWA 安装引导 ==================== */
.install-btn {
  display: block;
  margin: 20px auto 30px;
  opacity: 0.7;
  font-size: 13px;
}
.install-btn:active { opacity: 1; }

.ios-guide-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 9999;
  display: flex; justify-content: center; align-items: center;
}
.ios-guide-box {
  background: var(--bg-dark);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 16px;
  padding: 28px 24px;
  width: 85%; max-width: 320px;
  text-align: center;
}
.ios-guide-box h3 { color: var(--primary); margin-bottom: 16px; font-size: 18px; }
.ios-guide-box p { color: var(--text); font-size: 14px; line-height: 1.6; margin-bottom: 10px; }