/* =============================================
   CSS VARIABLES — LIGHT (default) + DARK
   ============================================= */
:root {
  --bg:        #f5f4f0;
  --bg2:       #eeedea;
  --surface:   #ffffff;
  --surface2:  #f0efe9;
  --border:    #e0ddd6;
  --text:      #1a1814;
  --text2:     #4a4740;
  --muted:     #9a9790;
  --accent:    #e8521a;
  --accent2:   #c43e08;
  --accent-bg: rgba(232,82,26,.1);
  --green:     #2a9d5c;
  --blue:      #2979c8;
  --yellow:    #d4860a;
  --red:       #d63031;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --nav-h:      64px;
  --header-h:   52px;
  --safe-b:     env(safe-area-inset-bottom, 0px);
  --safe-t:     env(safe-area-inset-top, 0px);
  --safe-l:     env(safe-area-inset-left, 0px);
  --safe-r:     env(safe-area-inset-right, 0px);
  --voice-bar-h: 0px;
}
[data-theme="dark"] {
  --bg:        #0f0f0d;
  --bg2:       #141410;
  --surface:   #1a1916;
  --surface2:  #222018;
  --border:    #2e2c26;
  --text:      #f0ede6;
  --text2:     #b0ada6;
  --muted:     #666460;
  --accent:    #e8521a;
  --accent2:   #ff7040;
  --accent-bg: rgba(232,82,26,.12);
  --green:     #2ecc71;
  --blue:      #3498db;
  --yellow:    #f39c12;
  --red:       #e74c3c;
  --shadow:    0 2px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow: hidden; }
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* =============================================
   LAYOUT
   ============================================= */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: 0;
}

/* Header */
#appHeader {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}
.logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.9rem;
  letter-spacing: 3px;
  color: var(--accent);
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.logo span { color: var(--text); }
.logo-version {
  font-family: 'DM Mono', monospace;
  font-size: .48rem;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--muted);
  line-height: 1.4;
}
.header-spacer { flex: 1; }
.header-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  letter-spacing: .5px;
  transition: color .2s, background .2s;
}
.header-btn:hover { color: var(--text); background: var(--surface2); }
.header-user-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 20px;
  transition: background .2s;
  max-width: 160px;
}
.header-user-btn:hover { background: var(--accent-bg); }
.header-user-btn .hub-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: var(--muted);
}
.header-user-btn .hub-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.header-user-btn .hub-name {
  font-family: 'DM Sans', sans-serif;
  font-size: .8rem;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main content area */
#mainContent {
  flex: 1;
  overflow: hidden;
  display: flex;
  position: relative;
}

/* Tab screens */
.tab-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.tab-screen.active { display: flex; }

/* Bottom nav (phone) */
#bottomNav {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  height: var(--nav-h);
  padding-bottom: var(--safe-b);
  flex-shrink: 0;
  z-index: 100;
  position: relative;
  transition: margin-bottom .2s;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 6px 2px;
  position: relative;
  transition: opacity .2s;
}
.nav-item:active { opacity: .7; }
.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  position: relative;
}
.nav-label {
  font-family: 'DM Mono', monospace;
  font-size: .48rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}
.nav-item.active .nav-label { color: var(--accent); }
.nav-item.active .nav-icon { filter: none; }

/* Record center button — pill shape */
.nav-item.nav-ride {
  flex: 0 0 auto;
  padding: 0 6px;
}
.nav-item.nav-ride .nav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--accent);
  border-radius: 26px;
  padding: 0 18px;
  height: 44px;
  margin-top: -14px;
  box-shadow: 0 4px 18px rgba(232,82,26,.5);
  transition: transform .15s, box-shadow .15s;
  white-space: nowrap;
}
.nav-item.nav-ride .ride-pill-icon {
  font-size: 1.1rem;
  line-height: 1;
}
.nav-item.nav-ride .ride-pill-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  letter-spacing: 2px;
  color: #fff;
  line-height: 1;
}
.nav-item.nav-ride:active .nav-icon-wrap {
  transform: scale(.93);
  box-shadow: 0 2px 10px rgba(232,82,26,.35);
}
.nav-item.nav-ride.recording .nav-icon-wrap {
  background: var(--green);
  box-shadow: 0 4px 18px rgba(76,175,80,.5);
  animation: ridePulse 2s ease-in-out infinite;
}
@keyframes ridePulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(76,175,80,.5); }
  50% { box-shadow: 0 4px 28px rgba(76,175,80,.8); }
}

/* Live badge */
.live-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--surface);
  display: none;
}
.live-badge.visible { display: block; }
/* badge needs a positioned parent inside the pill */
.nav-item.nav-ride .nav-icon-wrap { position: relative; }

/* Tablet side nav */
#sideNav {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 64px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 8px 0;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 30;
}
.side-item {
  width: 52px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 12px;
  cursor: pointer;
  border: none;
  background: none;
  position: relative;
  transition: background .15s;
}
.side-item:hover { background: var(--surface2); }
.side-item.nav-ride { background: none; width: auto; padding: 0 6px; }
.side-item.nav-ride:hover { background: none; }
.side-item.nav-ride.recording .nav-icon-wrap {
  background: var(--green) !important;
  box-shadow: 0 3px 14px rgba(76,175,80,.5) !important;
  animation: ridePulse 2s ease-in-out infinite;
}
.side-item.active { background: var(--accent-bg); }
.side-item.active .nav-label { color: var(--accent); }
.side-item.active .nav-icon { color: var(--accent); }
.side-item .nav-icon { font-size: 1.2rem; color: var(--muted); }
.side-item .nav-label { font-size: .42rem; color: var(--muted); }
.side-item.nav-record {
  background: var(--accent);
  margin: 4px 0;
}
.side-item.nav-record .nav-icon { color: #fff; font-size: 1.1rem; }
.side-item.nav-record:hover { background: var(--accent2); }

/* =============================================
   SCREEN INNER LAYOUT
   ============================================= */
.screen-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.screen-title {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0;
}
.screen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
}
.screen-body.no-pad { padding: 0; }
/* Pull-to-refresh */
.ptr-indicator {
  height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; background: var(--surface);
}
.ptr-spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%;
}
.ptr-indicator.ptr-loading .ptr-spinner { animation: ptrSpin .7s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* Sub-tabs */
.sub-tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  flex-shrink: 0;
  padding: 11px 16px;
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* =============================================
   COMMON COMPONENTS
   ============================================= */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  font-weight: 700;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary:active { transform: scale(.97); }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost {
  background: none;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); }
.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-sm { padding: 8px 14px; font-size: .78rem; min-height: 36px; }
.btn-full { width: 100%; }
.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: .85rem;
}
.btn-google:hover { background: var(--surface2); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--muted);
  font-size: .75rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.card-body { padding: 14px 16px; }

/* Form elements */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-label {
  font-family: 'DM Mono', monospace;
  font-size: .58rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.form-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .92rem;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* Toast */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 18px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--green); color: #fff; }
#toast.error { background: var(--red); color: #fff; }
#toast.warn { background: var(--accent); color: #fff; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 1300;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 16px; }

}
.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
@media (min-width: 600px) {
  .modal { border-radius: 16px; }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 10px;
  border-radius: 8px;
  transition: color .15s, background .15s;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px 24px; }
.modal-footer {
  padding: 12px 20px calc(12px + var(--safe-b));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 8px;
}
.empty-icon { font-size: 2.5rem; opacity: .4; }
.empty-title { font-weight: 700; color: var(--text2); }
.empty-sub { font-size: .82rem; color: var(--muted); }

/* =============================================
   AUTH SCREEN
   ============================================= */
#authScreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.8rem;
  letter-spacing: 5px;
  color: var(--accent);
  text-align: center;
  line-height: 1;
}
.auth-logo span { color: var(--text); }
.auth-sub {
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  letter-spacing: 3px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
  margin-top: 2px;
}
.auth-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.auth-error {
  background: rgba(214,48,49,.1);
  border: 1px solid rgba(214,48,49,.3);
  color: var(--red);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .8rem;
  margin-bottom: 12px;
  display: none;
}
.auth-success {
  background: rgba(42,157,92,.1);
  border: 1px solid rgba(42,157,92,.3);
  color: var(--green);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .8rem;
  margin-bottom: 12px;
  display: none;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.auth-link {
  color: var(--muted);
  font-size: .72rem;
  text-decoration: none;
  font-family: 'DM Mono', monospace;
  letter-spacing: .5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: color .15s;
}
.auth-link:hover { color: var(--accent); }

/* =============================================
   LIVE SCREEN
   ============================================= */
#liveScreen, #rideScreen { position: relative; overflow: hidden; }
#liveMap {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.live-overlay {
  position: fixed;
  z-index: 20;
  pointer-events: none;
}
@media (min-width: 768px) {
  .live-overlay {
    left: calc(64px + 12px) !important;
  }
  .live-bottom { right: 12px; }
  #liveRecenterBtn { left: calc(64px + 16px) !important; right: auto !important; }
  #liveRidersPanel { left: calc(64px + 12px) !important; }
}
.live-overlay > * { pointer-events: all; }
.live-top {
  top: calc(var(--safe-t) + var(--header-h) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.live-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 11px;
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  letter-spacing: 1px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow);
}
.live-dot-green {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }
.track-stat-val { font-family:'DM Mono',monospace; font-size:clamp(.78rem,4vw,1.5rem); color:var(--text); line-height:1; }
.track-stat-lbl { font-family:'DM Mono',monospace; font-size:clamp(.38rem,1.5vw,.52rem); color:var(--muted); text-transform:uppercase; margin-top:2px; }
@media (orientation: landscape) {
  .track-stat-val { font-size:clamp(.72rem,2.6vh,1.1rem); }
  .track-stat-lbl { font-size:clamp(.34rem,1vh,.45rem); margin-top:1px; }
  #trackBar {
    background: transparent !important;
    border-top-color: transparent !important;
    box-shadow: none !important;
    padding-top: 4px !important;
    padding-bottom: calc(4px + var(--safe-b)) !important;
  }
  #trackStatsRow { padding: 4px 6px; }
  .track-stat-cell {
    background: rgba(0,0,0,.45);
    border-radius: 10px;
    padding: 4px 10px;
  }
  .track-stat-cell .track-stat-val { color: #fff; }
  .track-stat-cell .track-stat-lbl { color: rgba(255,255,255,.65); }
  .track-stat-div { display: none; }
  /* Expanded panel (if opened in landscape) stays readable */
  #trackBarExpanded {
    background: var(--surface);
    border-radius: 14px;
    padding: 8px;
    margin-top: 4px;
  }
}
.live-bottom {
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  left: 12px;
  right: 12px;
}
@media (min-width: 768px) {
  .live-bottom {
    bottom: 12px;
  }
}
.riders-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow-lg);
}
.riders-panel-title {
  font-family: 'DM Mono', monospace;
  font-size: .55rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.rider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.rider-row:last-child { border-bottom: none; padding-bottom: 0; }
.rider-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.rider-info { flex: 1; min-width: 0; }
.rider-name { font-size: .82rem; font-weight: 700; color: var(--text); }
.rider-meta { font-family: 'DM Mono', monospace; font-size: .55rem; color: var(--muted); }
.rider-speed { font-family: 'DM Mono', monospace; font-size: .7rem; color: var(--text2); }

/* =============================================
   RECORD SCREEN
   ============================================= */
#recordScreen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 20px;
  gap: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#recordScreen.active { display: flex; }
.record-big-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  box-shadow: 0 6px 28px rgba(232,82,26,.4);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  margin: 16px auto 8px;
}
.record-big-btn:active { transform: scale(.93); box-shadow: 0 3px 14px rgba(232,82,26,.3); }
.record-hint {
  font-family: 'DM Mono', monospace;
  font-size: .58rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
}
.record-options { width: 100%; display: flex; flex-direction: column; gap: 0; }
.record-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.record-option:last-child { border-bottom: none; }
.record-option-label {
  font-size: .85rem;
  color: var(--text2);
}
.record-option-value {
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
}
.record-option-value.muted { color: var(--muted); }

/* =============================================
   LOGBOOK SCREEN
   ============================================= */
.ride-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s;
  box-shadow: var(--shadow);
}
.ride-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.12); }
.ride-card-map {
  height: 130px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  isolation: isolate;
}
.ride-card-body {
  padding: 11px 13px;
}
.ride-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 5px;
  gap: 8px;
}
.ride-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}
.ride-date {
  font-family: 'DM Mono', monospace;
  font-size: .6rem;
  color: var(--muted);
  flex-shrink: 0;
}
.ride-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.ride-stat {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  color: var(--muted);
}
.ride-stat strong {
  color: var(--accent);
  font-size: .82rem;
}
.ride-bike {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  color: var(--muted);
  margin-top: 5px;
}
.ride-visibility {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: 'DM Mono', monospace;
  font-size: .55rem;
  letter-spacing: .5px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 6px;
}

/* =============================================
   GROUPS SCREEN
   ============================================= */
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.group-card:hover { border-color: var(--accent); }
.group-avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent-bg);
  border: 1.5px solid rgba(232,82,26,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.group-info { flex: 1; min-width: 0; }
.group-name { font-size: .92rem; font-weight: 700; color: var(--text); }
.group-meta { font-family: 'DM Mono', monospace; font-size: .6rem; color: var(--muted); margin-top: 2px; }
.group-badge {
  font-family: 'DM Mono', monospace;
  font-size: .55rem;
  letter-spacing: .5px;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.badge-member { background: var(--accent-bg); color: var(--accent); }
.badge-admin { background: rgba(42,157,92,.1); color: var(--green); }
.badge-live { background: rgba(42,157,92,.15); color: var(--green); }

/* =============================================
   PROFILE SCREEN
   ============================================= */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent-bg);
  border: 2px solid rgba(232,82,26,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 10px;
}
.profile-name { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.profile-email { font-family: 'DM Mono', monospace; font-size: .65rem; color: var(--muted); margin-top: 2px; }
.profile-stats {
  display: flex;
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
  background: var(--surface2);
}
.profile-stat {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.profile-stat:last-child { border-right: none; }
.profile-stat-val { font-family: 'DM Mono', monospace; font-size: .95rem; color: var(--accent); font-weight: 500; }
.profile-stat-label { font-family: 'DM Mono', monospace; font-size: .5rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 2px; }

.menu-section { margin-bottom: 16px; }
.menu-section-title {
  font-family: 'DM Mono', monospace;
  font-size: .58rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
  margin-bottom: 6px;
}
.menu-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.menu-item {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  gap: 10px;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--surface2); }
.menu-item-icon { font-size: 1rem; width: 24px; text-align: center; flex-shrink: 0; }
.menu-item-label { flex: 1; font-size: .88rem; color: var(--text); }
.menu-item-value { font-family: 'DM Mono', monospace; font-size: .68rem; color: var(--muted); }
.menu-item-chevron { color: var(--muted); font-size: .8rem; }
.menu-item.danger .menu-item-label { color: var(--red); }
.menu-item.danger .menu-item-icon { color: var(--red); }

/* =============================================
   TABLET LAYOUT
   ============================================= */
@media (min-width: 768px) and (orientation: landscape) {
  #bottomNav { display: none; }
  #sideNav { display: flex; }
  #mainContent { flex-direction: row; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 16px; }
  #toast { bottom: 20px; }
}

/* =============================================
   MISC
   ============================================= */
.hidden { display: none !important; }
body.has-apk-banner #app { padding-top: 45px; }
.leaflet-container { background: var(--bg2) !important; }
[data-theme="light"] .leaflet-tile { filter: none; }
[data-theme="dark"] .leaflet-tile { filter: brightness(.85) saturate(.9); }

/* Make active ride zoom controls easier to tap without changing Leaflet behavior. */
#trackMapContainer .leaflet-control-zoom {
  margin: 10px;
}

#trackMapContainer .leaflet-control-zoom.leaflet-bar {
  background: transparent;
  border: none;
  box-shadow: none;
}

#trackMapContainer .leaflet-control-zoom a {
  width: 46px;
  height: 46px;
  line-height: 46px;
  font-size: 24px;
  background: #fff;
  border: none;
  border-radius: 10px;
}

#trackMapContainer .leaflet-control-zoom a + a {
  margin-top: 6px;
}

#trackMapContainer .leaflet-touch .leaflet-control-zoom a {
  width: 46px;
  height: 46px;
  line-height: 46px;
}
.maamet-attr {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 999;
  background: rgba(255,255,255,0.55);
  color: rgba(0,0,0,0.55);
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  padding: 2px 5px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1.4;
}
[data-theme="dark"] .maamet-attr {
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.55);
}


/* Onboarding tour */
#tourSpotlight {
  position: absolute;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.75);
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease;
  pointer-events: none;
}
#tourTooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 20px 16px;
  width: min(320px, calc(100vw - 32px));
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  transition: left .35s ease, top .35s ease;
}
#tourStep { font-size: 11px; color: var(--accent); font-family: 'DM Mono', monospace; letter-spacing: .08em; margin-bottom: 6px; text-transform: uppercase; }
#tourTitle { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 8px; font-family: 'DM Sans', sans-serif; }
#tourDesc { font-size: 14px; color: var(--text2); margin: 0 0 16px; line-height: 1.5; font-family: 'DM Sans', sans-serif; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-skip { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 6px 0; font-family: 'DM Sans', sans-serif; }
.tour-skip:hover { color: var(--text2); }
.tour-next { background: var(--accent, #e8521a); color: #fff; border: none; border-radius: 8px; padding: 8px 22px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.tour-next:hover { opacity: .88; }
