:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-hover: #222240;
  --bg-surface: #16162a;
  --primary: #4361ee;
  --primary-light: #5a7bff;
  --accent: #2ec4b6;
  --danger: #ef476f;
  --text: #edf2f4;
  --text-dim: #8d99ae;
  --text-muted: #555e70;
  --border: #2a2a44;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.view { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 20px; font-weight: 700; }
.subtitle { color: var(--text-dim); font-size: 13px; }

/* Recordings list */
.recordings-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 100px;
}

.recording-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  border: 1px solid var(--border);
}
.recording-card:hover { background: var(--bg-hover); }
.recording-card:active { transform: scale(0.99); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.card-date { font-size: 12px; color: var(--text-muted); }
.card-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-done { background: rgba(46,196,182,0.15); color: var(--accent); }
.status-processing { background: rgba(67,97,238,0.15); color: var(--primary-light); }
.status-failed { background: rgba(239,71,111,0.15); color: var(--danger); }
.status-uploaded { background: rgba(141,153,174,0.15); color: var(--text-dim); }

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-preview {
  font-size: 13px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.card-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.card-duration {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* FAB buttons */
.fab-group {
  position: absolute;
  bottom: 24px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}
.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  color: white;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.fab-upload { background: var(--primary); }
.fab-record { background: var(--danger); }

/* Recording Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.record-panel {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px;
  width: 320px;
  text-align: center;
}
.record-panel h2 { margin-bottom: 20px; font-size: 18px; }

.record-viz {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 12px;
}
.viz-bar {
  width: 4px;
  background: var(--primary);
  border-radius: 2px;
  transition: height 0.1s;
}

.record-timer {
  font-size: 36px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-bottom: 24px;
}

.record-controls { margin-bottom: 24px; }
.btn-round {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 28px;
}

.record-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-retry, .btn-retry-card { background: var(--primary); color: white; margin-top: 12px; }
.btn-retry:hover, .btn-retry-card:hover { background: var(--primary-light); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

/* Detail View */
.detail-topbar {
  gap: 8px;
}
.detail-header-info {
  flex: 1;
  min-width: 0;
}
.detail-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-date {
  font-size: 12px;
  color: var(--text-muted);
}

/* Player */
.player-bar {
  background: var(--bg-surface);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-time {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}
.speed-select {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Speaker Filter */
.speaker-filter {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--bg);
}
.speaker-tag {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.speaker-tag.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Transcript */
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 100px;
}

.segment {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid var(--border);
}
.segment:hover { background: var(--bg-card); }
.segment.active {
  background: rgba(67,97,238,0.08);
}

.segment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.segment-speaker {
  font-size: 12px;
  font-weight: 700;
}
.segment-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.segment-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* Empty & Loading states */
.empty-state, .loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Processing indicator on cards */
.processing-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.processing-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  animation: indeterminate 1.5s ease-in-out infinite;
  width: 40%;
}
@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Responsive */
@media (min-width: 600px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
