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

/* 密码门禁 */
.gate {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a0a2e 50%, #2d1b4e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.gate-box {
  text-align: center;
  padding: 40px;
}

.gate-box h2 {
  font-size: 32px;
  color: #e4e4f0;
  margin-bottom: 8px;
}

.gate-hint {
  color: #8888aa;
  font-size: 14px;
  margin-bottom: 24px;
}

.gate-input {
  width: 240px;
  padding: 14px 18px;
  border: 1px solid #2d2d4a;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: #e4e4f0;
  font-size: 16px;
  text-align: center;
  font-family: inherit;
}

.gate-input:focus {
  outline: none;
  border-color: #e84393;
}

.gate-btn {
  display: block;
  width: 240px;
  margin: 16px auto 0;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: #e84393;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.gate-btn:disabled { opacity: 0.5; }

.gate-error {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

:root {
  --bg: #0f0f1a;
  --card: #1a1a2e;
  --card-light: #22223e;
  --border: #2d2d4a;
  --text: #e4e4f0;
  --text-dim: #8888aa;
  --accent: #6c5ce7;
  --accent-hover: #7d6ff0;
  --green: #00b894;
  --red: #e74c3c;
  --orange: #fdcb6e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 500px;
  margin: 0 auto;
  padding: 12px;
}

.hidden { display: none !important; }

/* 状态栏 */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.offline { background: #666; }
.dot.connecting { background: var(--orange); animation: pulse 1s infinite; }
.dot.online { background: var(--green); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#statusText { flex: 1; }
.timer { color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 28px 20px;
  text-align: center;
}

.card h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

/* 表单 */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.model-tabs, .mode-tabs {
  display: flex;
  gap: 8px;
}

.model-tab, .mode-tab {
  flex: 1;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-light);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.model-tab small {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.7;
}

.model-tab.active, .mode-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(108, 92, 231, 0.15);
}

#instructions {
  width: 100%;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-light);
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}

#instructions:focus {
  outline: none;
  border-color: var(--accent);
}

/* 通话按钮 */
.call-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--green);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.call-btn:hover { opacity: 0.9; }
.call-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 通话区 */
#callArea {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#videoWrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

#localVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像 */
}

#frameCanvas { display: none; }

/* 控制按钮 */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.ctrl-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 24px;
  background: var(--card-light);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn:hover { background: var(--accent); }
.ctrl-btn.danger { background: var(--red); }
.ctrl-btn.active { background: var(--accent); }

/* 转写区 */
.transcript {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  max-height: 50vh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
}

.transcript-placeholder {
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

.msg {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
}

.msg.user {
  background: var(--card-light);
  margin-left: auto;
  text-align: right;
}

.msg.ai {
  background: rgba(108, 92, 231, 0.15);
  border: 1px solid rgba(108, 92, 231, 0.3);
  margin-right: auto;
}

.msg .role {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.msg .text {
  word-break: break-word;
}

.msg.interim {
  opacity: 0.6;
  font-style: italic;
}

/* AI说话动画 */
.ai-speaking {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  animation: dots 1.4s infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* 错误提示 */
.error-banner {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: 12px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
}

/* 角色选择 */
.caller-tabs {
  display: flex;
  gap: 8px;
}

.caller-tab {
  flex: 1;
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-light);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.caller-tab .caller-emoji {
  font-size: 28px;
}

.caller-tab .caller-name {
  font-size: 15px;
  font-weight: 600;
}

.caller-tab small {
  font-size: 10px;
  opacity: 0.7;
}

.caller-tab.active {
  border-color: #e84393;
  color: var(--text);
  background: rgba(232, 67, 147, 0.12);
}

/* 通话中角色信息 */
.caller-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: var(--card);
  border-radius: 16px;
  font-size: 18px;
  font-weight: 600;
}

.caller-avatar {
  font-size: 28px;
}

/* 音色选择 */
.voice-select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-light);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.voice-select:focus {
  outline: none;
  border-color: #e84393;
}

/* 画画输入栏 */
.draw-bar {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--card);
  border-radius: 12px;
}

.draw-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-light);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.draw-bar input:focus {
  outline: none;
  border-color: #e84393;
}

.draw-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: #e84393;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

.draw-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 视频双窗口布局 */
.video-layout {
  display: flex;
  gap: 10px;
}

.tiantian-window {
  flex: 1;
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 100%);
}

.tiantian-window img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.sound-wave {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 4px;
  align-items: center;
  height: 32px;
}

.sound-wave.active { display: flex; }

.sound-wave span {
  width: 4px;
  height: 8px;
  background: #e84393;
  border-radius: 2px;
  animation: wave 0.6s ease-in-out infinite;
}

.sound-wave span:nth-child(2) { animation-delay: 0.1s; }
.sound-wave span:nth-child(3) { animation-delay: 0.2s; }
.sound-wave span:nth-child(4) { animation-delay: 0.3s; }
.sound-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 8px; opacity: 0.5; }
  50% { height: 28px; opacity: 1; }
}

.tiantian-label {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 12px;
}

.self-window {
  flex: 1;
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

.self-window video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.self-label {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 12px;
}

@media (max-width: 400px) {
  body { padding: 8px; }
  .card { padding: 20px 16px; }
  .model-tab { font-size: 12px; }
}
