/* EventLabs · 白灰主色 · 黑白辅助 · 网页 + 移动端双适配 */
:root {
  --bg: #f5f5f5;
  --bg-card: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --accent: #1a1a1a;
  --accent-hover: #000000;
  --accent-soft: rgba(0, 0, 0, 0.06);
  --user-bubble: #1a1a1a;
  --assistant-bubble: #ebebeb;
  --error: #c62828;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-height: 60px;
  --input-min-height: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-card: #242424;
    --border: #333333;
    --text: #f0f0f0;
    --text-secondary: #9e9e9e;
    --accent: #f0f0f0;
    --accent-hover: #ffffff;
    --accent-soft: rgba(255, 255, 255, 0.08);
    --user-bubble: #3a3a3a;
    --assistant-bubble: #2e2e2e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  max-height: 100dvh;
  max-height: 100vh;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-card);
  overflow: hidden;
}

/* ========== 网页版（桌面）全屏 ========== */
@media (min-width: 769px) {
  .app {
    max-width: none;
    width: 100%;
    min-height: 100vh;
  }

  .header-inner {
    padding: 0 2rem;
  }

  .main {
    padding: 2rem;
    padding-bottom: 2rem;
  }

  .welcome {
    min-height: 50vh;
    padding: 3rem 0;
  }

  .welcome-content {
    max-width: 28rem;
  }

  .welcome h2 {
    font-size: 2rem;
  }

  .welcome p {
    font-size: 1rem;
  }

  .quick-actions {
    gap: 0.75rem;
  }

  .chip {
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
  }

  .message-bubble {
    max-width: 75%;
    padding: 1rem 1.25rem;
  }

  .header-controls {
    gap: 0.75rem;
  }

  .voice-picker {
    gap: 0.75rem;
    padding: 0.5rem 1rem;
  }

  .voice-picker select {
    min-width: 12rem;
  }

  .settings-panel {
    max-width: 560px;
  }

  .stability-control {
    padding-left: 1rem;
  }

  .stability-control input[type="range"] {
    width: 100px;
  }

  .input-area {
    padding: 1.25rem 2rem;
    padding-bottom: calc(1.25rem + var(--safe-bottom));
    width: 100%;
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
  }

  .input-wrap {
    padding: 0.75rem 1.25rem;
    width: 100%;
    max-width: 100%;
    border-radius: 40px;
  }

  .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
  }
}

/* ========== 通用：Header ========== */
.header {
  flex-shrink: 0;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

/* ========== 通用：Main（固定区域，仅在输入框上方滚动） ========== */
.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1.25rem;
  padding-bottom: 1.5rem;
}

.welcome {
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

.welcome-content {
  text-align: center;
  max-width: 26rem;
}

.welcome h2 {
  margin: 0 0 0.75rem;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  color: var(--text);
}

.welcome p {
  margin: 0 0 1.75rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  justify-content: center;
}

.chip {
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.chip:hover,
.chip:focus-visible {
  background: var(--accent-soft);
  border-color: var(--text-secondary);
  color: var(--text);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.chip:active {
  transform: scale(0.98);
}

/* ========== 通用：Messages ========== */
.messages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.messages[hidden] {
  display: none;
}

/* 有对话内容时隐藏欢迎区（标题、说明、示例按钮） */
.main:has(.messages .message) .welcome {
  display: none !important;
}

.message {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  max-width: 100%;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.message.user .message-avatar {
  background: var(--user-bubble);
  color: var(--bg-card);
}

.message.assistant .message-avatar {
  background: var(--assistant-bubble);
  color: var(--text-secondary);
}

.message-bubble {
  max-width: 85%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  line-height: 1.6;
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  color: var(--bg-card);
  border-bottom-right-radius: 6px;
  position: relative;
  padding-right: 2.5rem;
}

.message.assistant .message-bubble {
  background: var(--assistant-bubble);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.message.message--error .message-bubble {
  color: var(--error);
}

/* 重新发送按钮 */
.message-resend {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, transform 0.1s;
  outline: none;
}

.message.user .message-bubble:hover .message-resend {
  opacity: 1;
}

.message-resend:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.message-resend:active {
  transform: scale(0.95);
}

.message-resend svg {
  width: 16px;
  height: 16px;
}

/* 生成中动画 */
.message--generating .message-bubble {
  padding: 1rem 1.25rem;
}

.generating-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.generating-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: generating-bounce 0.6s ease-in-out infinite both;
}

.generating-dots span:nth-child(1) { animation-delay: 0s; }
.generating-dots span:nth-child(2) { animation-delay: 0.15s; }
.generating-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes generating-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; }
  40% { transform: scale(1); opacity: 1; }
}

.message-audio {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.message-audio audio {
  flex: 1;
  min-width: 0;
  height: 40px;
  max-width: 100%;
}

.message-audio .playing-badge {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ========== 通用：Header controls（标题栏右上角） ========== */
.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.voice-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.voice-picker label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.voice-picker select {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 0.25rem 0;
  min-width: 11rem;
  cursor: pointer;
  outline: none;
}

.voice-picker select:focus {
  color: var(--accent);
}

.settings-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  outline: none;
}

.settings-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

.settings-btn:active {
  transform: scale(0.96);
}

.settings-btn svg {
  width: 18px;
  height: 18px;
}

/* ========== 通用：Settings Modal（设置面板） ========== */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}

.settings-modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.settings-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.settings-panel {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s;
  overflow: hidden;
}

.settings-modal.show .settings-panel {
  transform: scale(1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.settings-close {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  outline: none;
}

.settings-close:hover {
  background: var(--bg);
  color: var(--text);
}

.settings-close svg {
  width: 20px;
  height: 20px;
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.setting-label label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.setting-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 3rem;
  text-align: right;
}

.setting-item input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

.setting-item input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.setting-item input[type="range"]::-moz-range-thumb:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

.setting-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.settings-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.settings-reset {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  outline: none;
}

.settings-reset:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* ========== 通用：Input area（固定在底部，内容不进入此区域） ========== */
.input-area {
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
  background: var(--bg-card);
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 32px;
  min-height: var(--input-min-height);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.input-wrap textarea {
  flex: 1;
  min-height: 22px;
  max-height: 200px;
  padding: 0.5rem 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  resize: none;
  outline: none;
}

.input-wrap textarea::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  margin: 0.625rem 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ========== 通用：Toast ========== */
.toast {
  position: fixed;
  bottom: calc(var(--input-min-height) + 3.5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg-card);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
  max-width: 90vw;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--error);
  color: #fff;
}

/* ========== 移动端 ========== */
@media (max-width: 768px) {
  .app {
    box-shadow: none;
  }

  .main {
    padding: 1rem;
    padding-bottom: 1rem;
  }

  .voice-picker {
    padding: 0.25rem 0.5rem;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  .voice-picker select {
    min-width: 0;
    max-width: 140px;
    font-size: 0.8125rem;
  }

  .header-controls {
    gap: 0.375rem;
  }

  .settings-btn {
    width: 32px;
    height: 32px;
  }

  .settings-btn svg {
    width: 16px;
    height: 16px;
  }

  .settings-panel {
    width: 95%;
    max-height: 90vh;
    border-radius: var(--radius-md);
  }

  .settings-header {
    padding: 1rem 1.25rem;
  }

  .settings-header h2 {
    font-size: 1.125rem;
  }

  .settings-content {
    padding: 1.25rem;
    gap: 1.5rem;
  }

  .settings-footer {
    padding: 0.875rem 1.25rem;
  }

  .message-bubble {
    max-width: 88%;
  }

  .message.user .message-bubble {
    padding-right: 2.25rem;
  }

  .message-resend {
    width: 26px;
    height: 26px;
    top: 0.375rem;
    right: 0.375rem;
    opacity: 0.7;
  }

  .message.user .message-bubble:active .message-resend,
  .message.user .message-bubble:focus-within .message-resend {
    opacity: 1;
  }

  .input-area {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + var(--safe-bottom));
  }

  .input-wrap {
    width: 100%;
  }

  .welcome h2 {
    font-size: 1.5rem;
  }

  .welcome p {
    font-size: 0.875rem;
  }
}
