/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg: #0a0e17;
  --surface-1: #111827;
  --surface-2: #1a2332;
  --surface-3: #243044;
  --border: #2a3a50;
  --border-light: #334766;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #3b82f6;
  --accent-glow: #3b82f640;
  --accent-2: #8b5cf6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f97316;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --shadow-sm: 0 1px 3px #0004;
  --shadow-md: 0 4px 12px #0006;
  --shadow-lg: 0 8px 30px #0008;
  --transition: 180ms ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── App layout ────────────────────────────────────────────── */
html, body { height: 100%; }

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  overflow: hidden;
}

/* ── Controls (in bottom nav) ─────────────────────────────── */
#controls-panel {
  min-width: 0;
}

.top-controls-grid {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Profile selector */
.profile-selector {
  display: flex;
  gap: 0.375rem;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.profile-chip:hover {
  border-color: var(--border-light);
  background: var(--surface-3);
  color: var(--text);
  transform: none;
}
.profile-chip.active {
  border-color: var(--accent);
  background: var(--accent)18;
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* Transport controls */
.transport-controls {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.3;
}
.btn:hover {
  border-color: var(--border-light);
  background: var(--surface-3);
  color: var(--text);
  transform: none;
}

.btn-play {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  padding: 0;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 0 12px var(--accent-glow);
}
.btn-play:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-play.recording {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 12px #22c55e40;
}
.btn-play.recording:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-stop {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  padding: 0;
  font-size: 0.85rem;
}

.btn-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  padding: 0;
  font-size: 1rem;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

/* Spacer */
.spacer { flex: 1; }

/* ── Session indicator ─────────────────────────────────────── */
.session-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.session-indicator.active {
  color: var(--green);
  border-color: #22c55e40;
  background: #22c55e10;
}
.session-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}
.session-indicator.active .session-dot {
  animation: pulse-dot 1.5s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── BT badge (top bar) ───────────────────────────────────── */
.bt-badge {
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: default;
  line-height: 1;
  transition: background var(--transition);
}
.bt-badge-ok {
  background: #22c55e20;
}
.bt-badge-busy {
  animation: bt-pulse 1.2s ease infinite;
  background: #eab30820;
}
.bt-badge-off {
  background: #ef444420;
}
.bt-badge-sim {
  background: #3b82f620;
}

/* ── Mode tabs ─────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.2rem;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab:hover {
  color: var(--text-2);
  background: var(--surface-3);
  transform: none;
}
.tab.active {
  color: var(--text);
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 1px 4px var(--accent-glow);
}
.tab-icon {
  font-size: 0.9rem;
  line-height: 1;
}

/* ── Stage / main content ──────────────────────────────────── */
.stage-wrap {
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

/* ── Bottom nav (controls + tabs in one row) ──────────────── */
.bottom-nav {
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  z-index: 100;
}
.nav-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0.15rem 0;
  flex-shrink: 0;
}

.stage-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  min-height: 0;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

/* ── Mode panes ────────────────────────────────────────────── */
.mode-pane {
  display: none;
  height: 100%;
  min-height: 0;
}
.mode-pane.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ── Stats overlay (top) ───────────────────────────────────── */
.stats-overlay {
  z-index: 150;
  background: var(--surface-1)f0;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.4rem;
  flex-shrink: 0;
}

.metric-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  min-width: 0;
  gap: 0.15rem;
}
.metric-card.primary {
  background: linear-gradient(180deg, var(--surface-3) 0%, var(--surface-2) 100%);
  border-color: var(--border-light);
}

.metric-label {
  font-size: clamp(0.65rem, 1.2vw, 0.85rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  white-space: nowrap;
  line-height: 1.2;
}

.metric-value {
  font-size: clamp(1.3rem, 2.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.metric-value.accent { color: var(--accent); }
.metric-value.green { color: var(--green); }

.metric-divider {
  width: 1px;
  background: var(--border);
  margin: 0.4rem 0;
  flex-shrink: 0;
}

/* ── Settings panel ────────────────────────────────────────── */
.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #0008;
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-end;
}

.settings-drawer {
  width: min(24rem, 90vw);
  height: 100vh;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slide-in 200ms ease;
}
@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.settings-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── BT status card ───────────────────────────────────────── */
.bt-status-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.bt-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bt-status-indicator.bt-connected {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.bt-status-indicator.bt-connecting {
  background: var(--yellow);
  animation: bt-pulse 1.2s ease infinite;
}
.bt-status-indicator.bt-disconnected {
  background: var(--text-3);
}
@keyframes bt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.bt-status-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.bt-status-label {
  font-size: 0.85rem;
  font-weight: 600;
}
.bt-status-detail {
  font-size: 0.7rem;
  color: var(--text-3);
}
.bt-log {
  max-height: 80px;
  overflow-y: auto;
  font-size: 0.68rem;
  color: var(--text-3);
  padding: 0.3rem 0.5rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-family: monospace;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ── Form elements ─────────────────────────────────────────── */
select, input[type="text"], input[type="search"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  transition: border-color var(--transition);
  outline: none;
  width: 100%;
}
select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.8rem;
}

/* ── YouTube view ──────────────────────────────────────────── */
.yt-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.5rem;
  min-height: 0;
}

.yt-search-bar {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.4rem;
  flex-shrink: 0;
}
.yt-search-bar input {
  border: none;
  background: transparent;
  flex: 1;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
}
.yt-search-bar input:focus {
  box-shadow: none;
}
.yt-search-bar .btn {
  flex-shrink: 0;
}
.yt-divider {
  width: 1px;
  height: 1.4rem;
  background: var(--border-light);
  flex-shrink: 0;
}
.yt-results-wrap {
  display: none;
  flex-shrink: 0;
}
.yt-results-wrap.visible {
  display: block;
}
.yt-results {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.yt-results::-webkit-scrollbar { height: 6px; }
.yt-results::-webkit-scrollbar-track { background: transparent; }
.yt-results::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 999px; }
.yt-no-results {
  color: var(--text-3);
  font-size: 0.8rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}
.yt-load-more {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5.5rem;
  min-height: 100%;
  background: var(--surface-2);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms;
  padding: 0;
  font-family: inherit;
}
.yt-load-more:hover {
  background: var(--surface-3);
}
.yt-signin-btn {
  background: #c4302b !important;
  color: white !important;
  font-weight: 600;
  white-space: nowrap;
}
.yt-signout-btn {
  font-size: 0.7rem;
  opacity: 0.6;
}
.yt-playlists-btn {
  white-space: nowrap;
}
.yt-playlist-card .yt-thumb-playlist {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16/9;
  background: var(--surface-3);
}
.yt-playlist-card .yt-thumb-playlist img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.yt-thumb-icon {
  font-size: 1.8rem;
}
.yt-result-card {
  flex-shrink: 0;
  width: 11rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  padding: 0;
  transition: border-color 150ms, transform 100ms;
}
.yt-result-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.yt-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: var(--surface-3);
}
.yt-result-info {
  padding: 0.35rem 0.45rem;
}
.yt-result-title {
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-result-channel {
  font-size: 0.65rem;
  color: var(--text-3);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-main {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0.5rem;
}

.youtube-frame,
.youtube-frame iframe {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: #000;
}

/* ── YouTube Sidebar ─────────────────────────────────────── */
.yt-sidebar-toggle {
  flex-shrink: 0;
  width: 1.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  align-self: stretch;
  padding: 0;
}
.yt-sidebar-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
}
.yt-sidebar {
  width: 16rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: width 200ms ease, opacity 200ms ease;
}
.yt-sidebar.collapsed {
  width: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}
.yt-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.yt-sidebar-title {
  font-weight: 600;
  font-size: 0.8rem;
}
.yt-sidebar-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}
.yt-sidebar-loading, .yt-sidebar-empty {
  padding: 1rem 0.6rem;
  color: var(--text-3);
  font-size: 0.75rem;
  text-align: center;
}
.yt-sidebar-item-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.yt-sidebar-item-row .yt-sidebar-item { border-bottom: none; flex: 1; min-width: 0; }
.yt-sidebar-unsave, .yt-sidebar-rename {
  background: transparent; border: none; color: var(--text-3); cursor: pointer;
  padding: 0.25rem 0.3rem; font-size: 0.7rem; opacity: 0; transition: opacity 120ms;
}
.yt-sidebar-item-row:hover .yt-sidebar-unsave,
.yt-sidebar-item-row:hover .yt-sidebar-rename { opacity: 1; }
.yt-sidebar-unsave:hover { color: var(--danger, #ef4444); }
.yt-sidebar-rename:hover { color: var(--accent, #3b82f6); }
.yt-sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  transition: background 120ms;
}
.yt-sidebar-item:hover {
  background: var(--surface-2);
}
.yt-sidebar-thumb {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.25rem;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  font-size: 1rem;
}
.yt-sidebar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.yt-sidebar-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.yt-sidebar-item-title {
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yt-sidebar-item-count {
  font-size: 0.62rem;
  color: var(--text-3);
}
.yt-sidebar-back {
  display: block;
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.yt-sidebar-back:hover {
  background: var(--surface-2);
}
.yt-sidebar-section-title {
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.yt-sidebar-video {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.3rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  transition: background 120ms;
}
.yt-sidebar-video:hover {
  background: var(--surface-2);
}
.yt-sidebar-video-thumb {
  width: 3.5rem;
  height: 2rem;
  border-radius: 0.2rem;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-3);
}
.yt-sidebar-video-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.yt-sidebar-video-title {
  font-size: 0.68rem;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.yt-sidebar-video-channel {
  font-size: 0.6rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yt-sidebar-load-more {
  display: block;
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.yt-sidebar-load-more:hover {
  background: var(--surface-2);
}

/* ── Map view ──────────────────────────────────────────────── */
.map-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.5rem;
  min-height: 0;
}

.map-controls-bar {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.map-controls-bar input {
  flex: 1;
  min-width: 8rem;
}

.map-wrap {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.leaflet-map {
  width: 100%;
  height: 100%;
}

.map-footer {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}
.map-footer .metric-card {
  flex: 1;
}

.map-status {
  font-size: 0.7rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.map-status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--text-3);
}
.map-status-dot.ok { background: var(--green); }
.map-status-dot.loading { background: var(--yellow); animation: pulse-dot 1s ease infinite; }
.map-status-dot.error { background: var(--red); }

.map-pick-btn.active-pick {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent)12;
}

/* ── Game view ─────────────────────────────────────────────── */
.game-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  min-height: 0;
}

.game-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-md);
  background: #0b1520;
}

.game-hud {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  pointer-events: none;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(8,16,28,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #e4e8ee;
  white-space: nowrap;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.game-difficulty {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(8,16,28,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.25rem 0.35rem;
  pointer-events: auto;
  z-index: 5;
}
.game-difficulty .diff-label {
  font-size: 0.8rem;
  padding: 0 0.25rem;
}
.diff-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-3);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}
.diff-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.diff-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.hud-effort-bar {
  position: absolute;
  bottom: 0.75rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(8,16,28,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.effort-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #a0aab8;
  white-space: nowrap;
  min-width: 6rem;
}

.effort-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.effort-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 180ms ease, background 250ms ease;
  box-shadow: 0 0 6px rgba(255,255,255,0.15);
}

.effort-pct {
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 2.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #e4e8ee;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.badge.green { background: #22c55e18; border-color: #22c55e40; color: var(--green); }
.badge.yellow { background: #eab30818; border-color: #eab30840; color: var(--yellow); }
.badge.red { background: #ef444418; border-color: #ef444440; color: var(--red); }

/* ── History ───────────────────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 0.55rem 0.75rem;
  transition: background var(--transition);
}
.history-row:hover {
  background: var(--surface-3);
}

.history-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
}

.history-sub {
  font-size: 0.75rem;
  color: var(--text-3);
}

.history-group-header {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.6rem 0.25rem 0.2rem;
  border-bottom: 1px solid var(--border);
  margin-top: 0.3rem;
}
.history-group-header:first-child {
  margin-top: 0;
}
.history-group-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
}
.history-group-summary {
  font-size: 0.72rem;
  color: var(--text-3);
  white-space: nowrap;
}

.history-day-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.2rem;
  margin-top: 0.15rem;
  background: var(--surface-2)80;
  border-radius: var(--radius-sm);
}
.history-day-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
}
.history-day-summary {
  font-size: 0.68rem;
  color: var(--text-3);
  white-space: nowrap;
  flex: 1;
}
.history-day-export {
  font-size: 0.7rem !important;
  padding: 0.15rem 0.35rem !important;
}

.btn-delete-session {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease;
  flex-shrink: 0;
}
.history-row:hover .btn-delete-session {
  opacity: 0.6;
}
.btn-delete-session:hover {
  opacity: 1 !important;
  background: rgba(239,68,68,0.15);
}

/* ── Workout progress bar ──────────────────────────────────── */
.workout-progress {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.25rem;
  flex-shrink: 0;
}
.workout-progress-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  white-space: nowrap;
}
.workout-progress-track {
  flex: 1;
  height: 0.45rem;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.workout-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 300ms ease;
}
.workout-interval-text {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Ride detail overlay ──────────────────────────────────── */
.ride-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: #000a;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ride-detail-panel {
  width: min(56rem, 94vw);
  max-height: 90vh;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fade-in 200ms ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.ride-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ride-detail-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.ride-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.5rem;
}
.ride-chart-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 0.75rem;
}
.ride-chart-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-bottom: 0.4rem;
}
.ride-chart-canvas {
  width: 100%;
  height: 10rem;
}

/* ── User edit (inline in settings) ────────────────────────── */
.user-edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.user-edit-field label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}
.user-edit-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── Settings profile rows ────────────────────────────────── */
.settings-profile-row {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}
.settings-profile-row input {
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

/* ── Settings workout rows ────────────────────────────────── */
.settings-workout-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.settings-workout-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ── Workout editor modal ─────────────────────────────────── */
.workout-editor-panel {
  width: min(36rem, 94vw);
  max-height: 85vh;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: fade-in 200ms ease;
}
.wo-interval-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 50vh;
  overflow-y: auto;
}
.wo-interval-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.wo-interval-row input {
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
  text-align: center;
}
.wo-interval-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-3);
  min-width: 1.2rem;
  text-align: center;
}

/* ── Toast notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  z-index: 250;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms ease;
}
.toast-container.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast {
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(12px);
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast-warning {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.toast-caution {
  background: rgba(234, 179, 8, 0.2);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #fde68a;
}
.toast-success {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

/* ── Inline dropdown (top bar) ────────────────────────────── */
.top-dropdown {
  width: auto;
  min-width: 6rem;
  max-width: 12rem;
  font-size: 0.78rem;
  padding: 0.25rem 1.6rem 0.25rem 0.5rem;
  background-color: var(--surface-2);
}

/* ── Controls row (generic) ────────────────────────────────── */
.controls-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Shortcut legend ───────────────────────────────────────── */
.shortcut-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-3);
}
.shortcut-key {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.7rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.05rem 0.35rem;
  color: var(--text-2);
  text-align: center;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .bottom-nav { flex-wrap: wrap; }
  .stats-overlay {
    flex-wrap: wrap;
    height: auto;
    padding: 0.4rem 0.6rem;
  }
  .metric-card { min-width: calc(33% - 0.5rem); }
  .metric-divider { display: none; }
  .map-controls-bar { flex-direction: column; }
  .map-controls-bar input { min-width: 100%; }
  .yt-search-bar { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .bottom-nav { padding: 0.3rem 0.4rem; }
  .stats-overlay { padding: 0.3rem 0.4rem; }
}
