/* ===== 基础变量与重置 ===== */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: #1a1a3e;
  --bg-hover: #222250;
  --text-primary: #e8e8f0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-purple: #a78bfa;
  --accent-cyan: #67e8f9;
  --accent-pink: #f472b6;
  --accent-green: #34d399;
  --accent-orange: #fb923c;
  --border-color: #2d2d5a;
  --shadow-glow: 0 0 20px rgba(167, 139, 250, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* ===== 页面切换 ===== */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* ===== 启动页 ===== */
#splash-screen {
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.splash-content {
  text-align: center;
  animation: fadeInUp 0.8s ease-out;
}

.logo {
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
}

.logo-svg {
  width: 100%;
  height: 100%;
  animation: pulse 2s ease-in-out infinite;
}

.app-title {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: 4px;
}

.app-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--bg-card);
  border-radius: 3px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 3px;
  animation: loading 2s ease-in-out forwards;
}

@keyframes loading {
  0% { width: 0%; }
  100% { width: 100%; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* ===== 头部 ===== */
.app-header {
  padding: 12px 16px;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto;
}

.logo-small {
  width: 32px;
  height: 32px;
}

.logo-svg-small {
  width: 100%;
  height: 100%;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: 80px;
  -webkit-overflow-scrolling: touch;
}

/* ===== 监测面板 ===== */
.monitor-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.monitor-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  transition: all 0.3s;
}

.status-indicator.recording {
  background: var(--accent-pink);
  animation: blink 1s ease-in-out infinite;
}

.status-indicator.detecting {
  background: var(--accent-orange);
  animation: blink 0.5s ease-in-out infinite;
}

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

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.visualizer-container {
  position: relative;
  width: 100%;
  height: 120px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}

#audio-visualizer {
  width: 100%;
  height: 100%;
}

.visualizer-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.recording-time {
  font-size: 24px;
  font-weight: 300;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}

.monitor-controls {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.btn-monitor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 32px;
  border: none;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: var(--shadow-glow);
}

.btn-monitor:active {
  transform: scale(0.95);
}

.btn-monitor.stop {
  background: linear-gradient(135deg, var(--accent-pink), #ef4444);
}

.btn-monitor.hidden {
  display: none;
}

.btn-icon-inner {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-inner svg {
  width: 32px;
  height: 32px;
}

.btn-label {
  font-size: 14px;
  font-weight: 500;
}

.monitor-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.info-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.sensitivity-slider {
  flex: 1;
  max-width: 200px;
  margin-left: 16px;
}

.sensitivity-slider input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-secondary);
  border-radius: 2px;
  outline: none;
}

.sensitivity-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  cursor: pointer;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.3);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.info-item select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

/* ===== 录音列表 ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.recordings-count {
  font-size: 13px;
  color: var(--text-muted);
}

.recordings-section {
  margin-bottom: 20px;
}

.recordings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 4px;
}

.empty-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.recording-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.recording-item:active {
  background: var(--bg-hover);
  transform: scale(0.98);
}

.recording-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.recording-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.recording-info {
  flex: 1;
  min-width: 0;
}

.recording-time {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.recording-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.recording-duration {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ===== 统计 ===== */
.stats-section {
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  border: 1px solid var(--border-color);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-color);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item span {
  font-size: 11px;
}

.nav-item.active {
  color: var(--accent-purple);
}

.nav-item.active svg {
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.4));
}

/* ===== 详情页 ===== */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.detail-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.btn-back {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-back svg {
  width: 20px;
  height: 20px;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-waveform {
  width: 100%;
  height: 150px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}

#detail-waveform {
  width: 100%;
  height: 100%;
}

.detail-info {
  text-align: center;
  margin-bottom: 16px;
}

.detail-time {
  font-size: 32px;
  font-weight: 300;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.detail-date {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.detail-duration {
  font-size: 13px;
  color: var(--accent-cyan);
}

.detail-tags {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  background: rgba(167, 139, 250, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.tag.snore {
  background: rgba(251, 146, 60, 0.15);
  color: var(--accent-orange);
  border-color: rgba(251, 146, 60, 0.3);
}

.tag.talk {
  background: rgba(244, 114, 182, 0.15);
  color: var(--accent-pink);
  border-color: rgba(244, 114, 182, 0.3);
}

/* ===== 播放控制 ===== */
.playback-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.btn-play {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
  transition: all 0.2s;
}

.btn-play:active {
  transform: scale(0.95);
}

.btn-play svg {
  width: 24px;
  height: 24px;
}

.playback-progress {
  flex: 1;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 2px;
  transition: width 0.1s linear;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== 备注 ===== */
.detail-note {
  margin-bottom: 20px;
}

.detail-note label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.detail-note textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.detail-note textarea::placeholder {
  color: var(--text-muted);
}

.detail-note textarea:focus {
  border-color: var(--accent-purple);
}

/* ===== 设置页 ===== */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.settings-group {
  margin-bottom: 24px;
}

.settings-group h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.setting-item span {
  font-size: 14px;
  color: var(--text-primary);
}

.setting-item select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.setting-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.setting-btn:hover {
  background: var(--bg-hover);
}

.setting-btn.danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.about-info {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
}

.about-info p {
  margin-bottom: 4px;
  font-size: 14px;
}

.about-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== Toast提示 ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius-xl);
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 工具类 ===== */
.hidden {
  display: none !important;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

/* ===== 响应式 ===== */
@media (min-width: 600px) {
  #app {
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
  }
  
  .bottom-nav {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}
