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

:root {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-input: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.08);
  --warning: #ca8a04;
  --warning-soft: rgba(202, 138, 4, 0.08);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html {
  height: 100%;
  height: 100dvh;
}

body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  will-change: opacity, transform;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + var(--safe-top));
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  min-height: calc(3.25rem + var(--safe-top));
  flex-shrink: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.topbar-actions {
  display: flex;
  gap: 0.125rem;
}

/* ── Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.padded {
  padding: 1.25rem 1rem;
  padding-left: calc(1rem + var(--safe-left));
  padding-right: calc(1rem + var(--safe-right));
}
.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

/* ── Bottom Bar ── */
.bottom-bar {
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  padding-left: calc(1rem + var(--safe-left));
  padding-right: calc(1rem + var(--safe-right));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  min-height: 48px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}
.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.2);
}
.btn-warning {
  background: var(--warning);
  color: #fff;
  box-shadow: 0 1px 3px rgba(202, 138, 4, 0.2);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.2);
}
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-large {
  width: 100%;
  padding: 1rem;
  min-height: 54px;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  -webkit-appearance: none;
  flex-shrink: 0;
}
.btn-icon-inline {
  margin-right: 0.35rem;
  font-size: 0.9em;
}
.btn-icon:active {
  background: var(--bg-hover);
  color: var(--text);
}

/* ── Inputs ── */
.input {
  display: block;
  width: 100%;
  padding: 0.875rem 1rem;
  min-height: 48px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
.input-small { width: 5rem; display: inline-block; margin-bottom: 0; min-height: 40px; }

.field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Checkbox label ── */
.field-label-check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.75rem 0;
}
.field-label-check input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ── Track List ── */
#track-list {
  padding: 0.75rem;
  padding-left: calc(0.75rem + var(--safe-left));
  padding-right: calc(0.75rem + var(--safe-right));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
.track-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
  min-height: 72px;
  cursor: pointer;
}
.track-item:hover {
  box-shadow: var(--shadow-md);
  background: var(--bg-input);
}
.track-item:active {
  transform: scale(0.985);
  background: var(--bg-hover);
}
.track-item-main { flex: 1; min-width: 0; }
.track-item-name {
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  color: var(--text);
}
.track-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  line-height: 1.3;
}
.track-item-surfaces {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}
.track-item .btn-delete {
  color: var(--text-muted);
  font-size: 1.1rem;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
.track-item .btn-delete:hover {
  opacity: 1;
  color: var(--danger);
}

.surface-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-transform: capitalize;
  letter-spacing: 0.03em;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 2rem;
  font-size: 0.95rem;
  line-height: 1.6;
  min-height: 60%;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  grid-column: 1 / -1;
}

.badge {
  background: var(--bg-input);
  padding: 0.2rem 0.65rem;
  border-radius: 6px;
  font-size: 0.75rem;
  text-transform: capitalize;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── GPS Warmup ── */
.warmup-accuracy {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.3rem;
  margin-bottom: 2.5rem;
  padding: 1rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 320px;
  justify-content: center;
}
.warmup-accuracy strong {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ── Accuracy Dot ── */
.accuracy-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.accuracy-dot.green { background: #16a34a; box-shadow: 0 0 6px rgba(22, 163, 74, 0.4); }
.accuracy-dot.yellow { background: #ca8a04; box-shadow: 0 0 6px rgba(202, 138, 4, 0.4); }
.accuracy-dot.red { background: #dc2626; box-shadow: 0 0 6px rgba(220, 38, 38, 0.4); }
.accuracy-dot.gray { background: #94a3b8; }

/* ── Recording Screen ── */
.rec-topbar {
  justify-content: space-between;
  padding: 0.625rem 1rem;
  padding-top: calc(0.625rem + var(--safe-top));
  min-height: calc(3rem + var(--safe-top));
  gap: 0.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.rec-status {
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rec-status.recording { color: #dc2626; }
.rec-status.paused { color: var(--warning); }
.rec-timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  animation: pulse 1.2s ease infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.gps-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.gps-info-text {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.rec-map {
  flex: 1 1 40%;
  min-height: 160px;
  max-height: 50%;
  border-bottom: 1px solid var(--border);
}

/* ── Stats Row ── */
.stats-row {
  display: flex;
  padding: 0.75rem 0.5rem;
  padding-left: calc(0.5rem + var(--safe-left));
  padding-right: calc(0.5rem + var(--safe-right));
  gap: 0.125rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stat {
  flex: 1;
  text-align: center;
  padding: 0.25rem 0;
}
.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--text);
}
.stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 0.15rem;
}

/* ── Surface Section ── */
.surface-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0.625rem 0.75rem;
  padding-left: calc(0.75rem + var(--safe-left));
  padding-right: calc(0.75rem + var(--safe-right));
  background: var(--bg);
}
.current-surface {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
#current-surface-label {
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: capitalize;
  flex: 1;
}
.surface-dur {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ── Surface Grid ── */
.surface-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  width: 100%;
}
.surface-btn {
  position: relative;
  min-height: 52px;
  border: 2px solid color-mix(in srgb, var(--surface-color) 50%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-color) 6%, var(--bg-elevated));
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: capitalize;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  -webkit-appearance: none;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.surface-btn:active { transform: scale(0.95); }
.surface-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}
.surface-btn.active {
  background: var(--surface-color);
  color: #fff;
  border-color: var(--surface-color);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--surface-color) 30%, transparent);
}
.surface-btn.confirming {
  border-color: var(--surface-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface-color) 25%, transparent);
  animation: confirmFlash 0.4s ease infinite alternate;
}
@keyframes confirmFlash {
  from { background: color-mix(in srgb, var(--surface-color) 6%, var(--bg-elevated)); }
  to { background: color-mix(in srgb, var(--surface-color) 20%, var(--bg-elevated)); }
}
.surface-btn-label {
  line-height: 1.2;
}
.confirm-hint {
  position: absolute;
  bottom: 1px;
  left: 0;
  right: 0;
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: none;
  font-weight: 500;
}

/* Category step: 3 cols */
.surface-grid-categories {
  grid-template-columns: repeat(3, 1fr);
}
/* Surface step: 2 cols (back + surfaces) */
.surface-grid-surfaces {
  grid-template-columns: repeat(2, 1fr);
}
.surface-btn-back {
  grid-column: 1 / -1;
  min-height: 40px !important;
  font-size: 0.8rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  opacity: 0.7;
}
.surface-btn-back i {
  font-size: 0.75rem;
}

/* Warmup surface grid: wider layout */
#warmup-surface-grid {
  max-width: 400px;
}
#warmup-surface-grid .surface-btn {
  min-height: 56px;
  font-size: 0.85rem;
}

/* ── Recording Bottom ── */
.rec-bottom {
  display: flex;
  gap: 0.75rem;
  padding-left: calc(1rem + var(--safe-left));
  padding-right: calc(1rem + var(--safe-right));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}
.rec-bottom .btn {
  flex: 1;
  min-height: 52px;
  font-size: 1rem;
}

/* ── Dialog ── */
.dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
}
.dialog {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.dialog h2 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.dialog p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
}
.dialog-actions {
  display: flex;
  gap: 0.75rem;
}
.dialog-actions .btn {
  flex: 1;
  min-height: 48px;
}

/* ── Summary ── */
.summary-map {
  height: 220px;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.summary-item {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--text);
}
.summary-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.summary-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.segments-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}
.segments-table th {
  text-align: left;
  padding: 0.6rem 0.5rem;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border-strong);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.segments-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
}
.summary-actions .btn { width: 100%; }

/* ── Settings ── */
#screen-settings .content {
  padding-bottom: calc(2rem + var(--safe-bottom));
}
.settings-group {
  margin-bottom: 1.75rem;
}
.settings-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Offline Maps ── */
.offline-map {
  height: 280px;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.offline-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  align-items: center;
}
.offline-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tile-estimate {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.6rem 0;
  font-variant-numeric: tabular-nums;
}

/* ── Cached Regions ── */
.cached-regions-section {
  margin-top: 1.5rem;
}
.cached-region {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.5rem;
}
.cached-region-info {
  flex: 1;
  min-width: 0;
}
.cached-region-area {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--text);
}
.cached-region-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.cached-region .btn-delete {
  color: var(--text-muted);
  font-size: 1.1rem;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
.cached-region .btn-delete:hover {
  opacity: 1;
  color: var(--danger);
}
.cached-regions-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

/* ── Tile Progress ── */
.tile-progress {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.3s ease;
  border-radius: 3px;
}

/* ── Leaflet overrides ── */
.leaflet-container {
  background: var(--bg) !important;
  font-family: inherit !important;
}
.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
}
.recenter-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  color: var(--primary);
  box-shadow: var(--shadow-md);
  transition: background 0.15s;
}
.recenter-btn:active {
  background: var(--bg-hover);
}

/* ── Landscape / taller screens ── */
@media (min-height: 700px) {
  .rec-map {
    flex: 1 1 45%;
  }
  .surface-btn {
    min-height: 56px;
    font-size: 0.8rem;
  }
}

/* ── Very small screens (SE, etc) ── */
@media (max-height: 600px) {
  .rec-map {
    flex: 1 1 30%;
    min-height: 120px;
  }
  .stats-row {
    padding: 0.4rem 0.5rem;
  }
  .stat-value {
    font-size: 0.95rem;
  }
  .surface-btn {
    min-height: 44px;
    font-size: 0.7rem;
  }
  .current-surface {
    margin-bottom: 0.35rem;
    padding: 0.3rem 0.75rem;
  }
  #current-surface-label {
    font-size: 1rem;
  }
}

/* ── Tablet ── */
@media (min-width: 600px) {
  .padded {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
  }
  #track-list {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding: 1rem;
  }
  .bottom-bar {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
  }
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .surface-grid {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }
  .dialog { max-width: 400px; }
}

/* ── Desktop ── */
@media (min-width: 900px) {
  .padded {
    max-width: 760px;
  }
  #track-list {
    max-width: 760px;
  }
  .bottom-bar {
    max-width: 760px;
  }
  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .summary-map {
    height: 300px;
  }
  .offline-map {
    height: 400px;
  }
}
