/* ===== 声波工作台 样式 ===== */

:root {
  --background: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --foreground: #e8e9ed;
  --muted: #8b8f9a;
  --primary: #e87040;
  --primary-hover: #d4603a;
  --primary-glow: rgba(232, 112, 64, 0.4);
  --border: #2a2e3a;
  --danger: #e5534b;
  --speaker-1: #4a90d9;
  --speaker-2: #7b68ee;
  --speaker-3: #50c878;
  --speaker-4: #daa520;
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a3e4a;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--foreground);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px;
}
.btn-ghost:hover {
  color: var(--foreground);
  background: var(--surface);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  color: var(--foreground);
  background: var(--surface);
}
.icon-btn.danger:hover {
  color: var(--danger);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.link-btn:hover {
  text-decoration: underline;
}

/* ===== 登录注册 ===== */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232, 112, 64, 0.1);
  border-radius: 50%;
  color: var(--primary);
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(42, 46, 58, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}
.form-group input:focus {
  border-color: var(--primary);
}
.form-group input::placeholder {
  color: #555a68;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.auth-switch {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.auth-switch a {
  color: var(--primary);
  text-decoration: none;
}
.auth-switch a:hover {
  text-decoration: underline;
}

/* ===== 主应用布局 ===== */
.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 15px;
}
.brand-icon {
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.header-username {
  font-size: 13px;
  color: var(--muted);
  margin-right: 8px;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 96px;
}

.view-header {
  margin-bottom: 24px;
}
.view-header h1 {
  font-size: 24px;
  font-weight: 600;
}
.view-desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ===== 录音面板 ===== */
.recorder-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(229, 83, 75, 0.1);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.recorder-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.elapsed-time {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500;
  min-width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.record-btn-wrapper {
  position: relative;
}

.record-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.record-btn:hover {
  transform: scale(1.05);
  background: var(--primary-hover);
}
.record-btn:active {
  transform: scale(0.95);
}
.record-btn.recording {
  background: var(--danger);
  animation: record-pulse 2s ease-in-out infinite;
}
.record-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}

@keyframes record-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 var(--primary-glow);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(232, 112, 64, 0);
  }
}

.level-indicator {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
  min-width: 40px;
}
.level-indicator span {
  display: block;
  width: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.08s ease;
}
.level-indicator span:nth-child(1) { height: 8px; }
.level-indicator span:nth-child(2) { height: 13px; }
.level-indicator span:nth-child(3) { height: 18px; }
.level-indicator span:nth-child(4) { height: 23px; }
.level-indicator span:nth-child(5) { height: 28px; }
.level-indicator.active span {
  background: var(--primary);
}
.level-indicator.active span:nth-child(n+4) {
  background: var(--danger);
}

.recorder-hint {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
}

/* ===== 转写面板 ===== */
.transcript-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.transcript-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.segments-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.segment {
  display: flex;
  gap: 12px;
  animation: segment-in 150ms ease-out;
}

@keyframes segment-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.segment-bar {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 4px;
}

.segment-speaker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.segment-text {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.7;
  color: rgba(232, 233, 237, 0.9);
  word-break: break-word;
}

.recognizing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 使用说明 ===== */
.tips-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.tips-panel h3 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}
.tips-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tips-panel li {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  line-height: 1.6;
}
.tips-panel li::before {
  content: '·';
  color: var(--primary);
  font-weight: 700;
}
.tips-panel .link-btn {
  margin-top: 12px;
}

/* ===== 语音输入辅助 ===== */
.ime-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.ime-toggle input {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.ime-toggle:hover {
  color: rgba(232, 233, 237, 0.85);
}

.ime-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.ime-tip {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 10px;
}
.ime-tip kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  color: rgba(232, 233, 237, 0.9);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
}
#ime-input {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(232, 233, 237, 0.92);
  font-family: inherit;
}
#ime-input:focus {
  outline: none;
  border-color: var(--primary);
}
#ime-input::placeholder {
  color: var(--muted);
}

/* ===== 录音列表 ===== */
.recordings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recording-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.recording-item:hover {
  background: var(--surface-hover);
}

.recording-info {
  flex: 1;
  min-width: 0;
}
.recording-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recording-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.status-completed {
  background: rgba(80, 200, 120, 0.1);
  color: var(--speaker-3);
}
.status-processing, .status-recording {
  background: rgba(232, 112, 64, 0.1);
  color: var(--primary);
}
.status-error {
  background: rgba(229, 83, 75, 0.1);
  color: var(--danger);
}

.recording-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.empty-state svg {
  color: rgba(139, 143, 154, 0.4);
  margin-bottom: 12px;
}
.empty-state p {
  font-size: 14px;
  color: var(--muted);
}
.empty-state .sub {
  font-size: 12px;
  color: rgba(139, 143, 154, 0.7);
  margin-top: 4px;
}

.loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  color: var(--muted);
  font-size: 14px;
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}
.modal-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  animation: toast-in 0.2s ease;
}
.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .app-main {
    padding: 16px 16px 100px;
  }

  .header-username {
    display: none;
  }

  .recorder-controls {
    gap: 16px;
  }

  .elapsed-time {
    font-size: 22px;
    min-width: 60px;
  }

  .record-btn {
    width: 56px;
    height: 56px;
  }

  .view-header h1 {
    font-size: 20px;
  }

  .history-header {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-card {
    padding: 24px;
  }

  .recording-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 20px 16px 24px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.footer-link:hover {
  color: var(--foreground);
  border-color: var(--primary);
  background: var(--surface);
}

/* ===== 详情弹窗音频播放器 ===== */
.detail-audio-wrap {
  padding: 12px 24px 0;
}
.detail-audio-wrap audio {
  width: 100%;
  height: 36px;
  border-radius: var(--radius);
  outline: none;
}

/* ===== 含音频徽章 ===== */
.audio-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  background: rgba(74, 144, 217, 0.12);
  color: var(--speaker-1, #4a90d9);
}
