/* ============================================================
   PaceMaker -- main.css
   Aesthetic: Dark athletic / precision instrument
   Fonts: Barlow Condensed (display) + Inter (body)
   Palette: Deep navy, electric cyan, warm white, amber accent
   ============================================================ */

@import url('fonts.css');

/* -- CSS Variables ------------------------------------------- */
:root {
  --bg:         #0a0e1a;
  --bg2:        #111827;
  --bg3:        #1a2236;
  --card:       #141c2e;
  --card-hover: #1e2a42;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(0,212,255,0.25);
  --cyan:       #00d4ff;
  --cyan-dim:   rgba(0,212,255,0.15);
  --cyan-glow:  rgba(0,212,255,0.4);
  --amber:      #f5a623;
  --amber-dim:  rgba(245,166,35,0.15);
  --green:      #00e676;
  --red:        #ff5252;
  --text:       #e8edf5;
  --text-muted: #7a8ba8;
  --text-dim:   #4a5a72;
  --white:      #ffffff;
  --ff-display: 'Barlow Condensed', sans-serif;
  --ff-body:    'Barlow', sans-serif;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* -- Reset --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--ff-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--ff-body); }
input, select, textarea { font-family: var(--ff-body); }

/* -- Scrollbar ----------------------------------------------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

/* -- Layout --------------------------------------------------- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.page-content { padding-top: 80px; min-height: calc(100vh - 200px); }

/* -- Navbar --------------------------------------------------- */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(10,14,26,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: 68px;
  display: flex; align-items: center;
}
.navbar .container {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--ff-display); font-size: 1.6rem; font-weight: 800;
  letter-spacing: 0.05em; color: var(--white);
}
.navbar-brand .brand-icon {
  width: 36px; height: 36px; background: var(--cyan);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-size: 1.2rem; font-weight: 900;
}
.navbar-brand span.accent { color: var(--cyan); }
.navbar-nav {
  display: flex; align-items: center; gap: 8px; list-style: none;
}
.navbar-nav .nav-link {
  color: var(--text-muted); padding: 6px 14px; border-radius: 6px;
  font-size: 0.9rem; font-weight: 500; transition: var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.navbar-nav .nav-link:hover, .navbar-nav .nav-link.active {
  color: var(--text); background: var(--bg3); text-decoration: none;
}
.lang-selector {
  display: flex; gap: 4px;
}
.lang-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 4px 9px; border-radius: 5px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em;
  transition: var(--transition); text-transform: uppercase;
}
.lang-btn:hover, .lang-btn.active {
  background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan);
}
.nav-user {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 0.85rem;
}
.nav-user .user-avatar {
  width: 30px; height: 30px; background: var(--cyan-dim);
  border: 1px solid var(--cyan); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--cyan); font-size: 0.75rem; font-weight: 700;
}
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; padding: 4px; }
.hamburger span { display: block; width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: var(--transition); }

/* -- Hero Section --------------------------------------------- */
.hero {
  position: relative; overflow: hidden;
  padding: 80px 0 60px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg2) 50%, var(--bg3) 100%);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 70% 50%, rgba(0,212,255,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(245,166,35,0.04) 0%, transparent 50%);
}
.hero-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center;
  position: relative; z-index: 1;
}
.hero-eyebrow {
  font-family: var(--ff-display); font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.2em; color: var(--cyan); text-transform: uppercase;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.hero-eyebrow::before {
  content: ''; display: block; width: 24px; height: 2px; background: var(--cyan);
}
.hero-title {
  font-family: var(--ff-display); font-size: clamp(2.8rem, 5vw, 4.2rem);
  font-weight: 800; line-height: 1.0; letter-spacing: -0.01em;
  color: var(--white); margin-bottom: 20px;
}
.hero-title .line2 { color: var(--cyan); display: block; }
.hero-desc {
  font-size: 1.05rem; color: var(--text-muted); line-height: 1.75;
  max-width: 480px; margin-bottom: 32px;
}
.hero-stats {
  display: flex; gap: 32px;
}
.stat-item { }
.stat-num {
  font-family: var(--ff-display); font-size: 2rem; font-weight: 800;
  color: var(--white); line-height: 1;
}
.stat-num span { color: var(--cyan); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }

.hero-visual {
  display: flex; justify-content: center; align-items: center;
}
.hero-device {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  width: 100%; max-width: 340px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(0,212,255,0.06);
}
.device-header {
  font-family: var(--ff-display); font-size: 0.75rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.15em; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between;
}
.device-pace-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.device-pace-row:last-child { border-bottom: none; }
.dp-km { font-family: var(--ff-display); font-size: 1rem; color: var(--text-muted); font-weight: 600; }
.dp-pace { font-family: var(--ff-display); font-size: 1.4rem; font-weight: 700; color: var(--white); }
.dp-tag {
  font-size: 0.7rem; padding: 2px 7px; border-radius: 4px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.dp-tag.up   { background: rgba(255,82,82,0.15);  color: var(--red); }
.dp-tag.down { background: rgba(0,230,118,0.12);  color: var(--green); }
.dp-tag.flat { background: var(--cyan-dim); color: var(--cyan); }

/* -- Section Headers ------------------------------------------ */
.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 32px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-family: var(--ff-display); font-size: 1.8rem; font-weight: 700;
  color: var(--white); letter-spacing: 0.02em;
}
.section-title span { color: var(--cyan); }

/* -- Filters & Search ----------------------------------------- */
.races-controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 32px;
}
.search-wrap {
  position: relative; flex: 1; min-width: 220px;
}
.search-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
.search-input {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px 10px 42px;
  color: var(--text); font-size: 0.9rem; outline: none;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.search-input::placeholder { color: var(--text-dim); }

.filter-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-btn {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-muted); padding: 8px 14px; border-radius: var(--radius);
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0.03em;
  transition: var(--transition); white-space: nowrap;
}
.filter-btn:hover { background: var(--bg3); color: var(--text); }
.filter-btn.active { background: var(--cyan-dim); border-color: var(--cyan); color: var(--cyan); }


/* -- Race logo image ----------------------------------------- */
.race-logo-img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 16px;
  background: var(--bg3);
  transition: var(--transition);
}
.race-card:hover .race-logo-img {
  padding: 12px;
}

/* -- Races Grid ----------------------------------------------- */
.races-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* Accordion grouping by country */
.races-accordion {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.country-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  overflow: hidden;
}
.country-header {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--white);
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 1rem;
  text-align: left;
  transition: background .2s;
}
.country-header:hover {
  background: var(--card-hover);
}
.country-chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  font-size: .7rem;
  width: 18px;
  transition: transform .2s;
}
.country-name { flex: 1; }
.country-count {
  background: var(--cyan-dim);
  color: var(--cyan);
  font-size: .72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--ff-display);
  letter-spacing: .3pt;
}
.country-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}
.country-group.open .country-body { display: block; }
.country-group.open .country-header { background: var(--card-hover); }

.country-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding-top: 20px;
}

.race-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: var(--transition); cursor: pointer; position: relative;
  display: flex; flex-direction: column;
}
.race-card:hover {
  transform: translateY(-4px); border-color: var(--cyan-glow);
  box-shadow: 0 12px 40px rgba(0,212,255,0.12);
  background: var(--card-hover);
}
.race-card-image {
  height: 140px; background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.race-card-image .race-emoji {
  font-size: 3.5rem; line-height: 1; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}
.race-card-image::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(20,28,46,0.8) 100%);
}
.race-dist-badge {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  background: var(--bg); border: 1px solid var(--border2);
  color: var(--cyan); font-family: var(--ff-display); font-size: 0.75rem;
  font-weight: 700; padding: 3px 9px; border-radius: 5px;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.race-card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.race-name {
  font-family: var(--ff-display); font-size: 1.1rem; font-weight: 700;
  color: var(--white); margin-bottom: 6px; line-height: 1.2;
}
.race-meta {
  font-size: 0.8rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px;
}
.race-meta .dot { opacity: 0.3; }
.race-km {
  font-family: var(--ff-display); font-size: 1.5rem; font-weight: 800;
  color: var(--cyan); margin-top: auto;
}
.race-km small { font-size: 0.85rem; font-weight: 400; color: var(--text-muted); }
.card-footer-btn {
  width: 100%; margin-top: 12px; padding: 9px;
  background: transparent; border: 1px solid var(--border2);
  color: var(--cyan); border-radius: var(--radius); font-size: 0.85rem; font-weight: 600;
  transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px;
}
.card-footer-btn:hover { background: var(--cyan-dim); }

.no-races {
  grid-column: 1/-1; text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-family: var(--ff-display); font-size: 1.1rem;
}

/* -- Buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 24px; border-radius: var(--radius); font-size: 0.9rem;
  font-weight: 600; border: none; transition: var(--transition); white-space: nowrap;
}
.btn-primary {
  background: var(--cyan); color: var(--bg); 
}
.btn-primary:hover { background: #33ddff; box-shadow: 0 4px 20px var(--cyan-glow); transform: translateY(-1px); }
.btn-secondary {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); border-color: var(--text-muted); }
.btn-ghost {
  background: transparent; color: var(--cyan); border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--cyan-dim); }
.btn-danger {
  background: rgba(255,82,82,0.1); color: var(--red); border: 1px solid rgba(255,82,82,0.3);
}
.btn-danger:hover { background: rgba(255,82,82,0.2); }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* -- Forms ---------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  margin-bottom: 6px; letter-spacing: 0.05em; text-transform: uppercase;
}
.form-control {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 14px;
  color: var(--text); font-size: 0.95rem; outline: none; transition: var(--transition);
}
.form-control:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.form-control::placeholder { color: var(--text-dim); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a8ba8' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
.form-error { font-size: 0.8rem; color: var(--red); margin-top: 6px; }
.form-success { font-size: 0.9rem; color: var(--green); padding: 10px 14px; background: rgba(0,230,118,0.08); border: 1px solid rgba(0,230,118,0.2); border-radius: var(--radius); margin-bottom: 16px; }

/* -- Modal ---------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 440px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px); transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 24px 24px 0; display: flex; align-items: center; justify-content: space-between;
}
.modal-title {
  font-family: var(--ff-display); font-size: 1.5rem; font-weight: 700; color: var(--white);
}
.modal-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.5rem;
  line-height: 1; transition: color var(--transition); padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.modal-tab {
  flex: 1; padding: 10px; background: none; border: none;
  color: var(--text-muted); font-size: 0.9rem; font-weight: 600;
  border-bottom: 2px solid transparent; transition: var(--transition);
  margin-bottom: -1px;
}
.modal-tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.modal-footer-link {
  text-align: center; margin-top: 16px;
  font-size: 0.85rem; color: var(--text-muted);
}
.modal-footer-link a { color: var(--cyan); }

/* -- Pace Calculator Page ------------------------------------- */
.calc-page { padding: 40px 0 60px; }
.calc-header {
  margin-bottom: 40px;
}
.calc-back { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; display: inline-block; }
.calc-back:hover { color: var(--cyan); text-decoration: none; }
.calc-title {
  font-family: var(--ff-display); font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800; color: var(--white); letter-spacing: 0.02em;
}
.calc-title .accent { color: var(--cyan); }

.calc-grid { display: grid; grid-template-columns: 360px 1fr; gap: 32px; align-items: start; }
.calc-panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; position: sticky; top: 88px;
}
.calc-panel-title {
  font-family: var(--ff-display); font-size: 1.1rem; font-weight: 700;
  color: var(--white); margin-bottom: 20px; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.time-input-wrap { position: relative; }
.time-input {
  font-family: var(--ff-display); font-size: 2rem; font-weight: 700;
  letter-spacing: 0.1em; text-align: center; color: var(--cyan);
}
.time-input::placeholder { color: var(--text-dim); font-size: 1.5rem; }
.calc-btn {
  width: 100%; margin-top: 8px; padding: 14px;
  background: var(--cyan); color: var(--bg);
  border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 700;
  font-family: var(--ff-display); letter-spacing: 0.08em; text-transform: uppercase;
  transition: var(--transition);
}
.calc-btn:hover:not(:disabled) { background: #33ddff; box-shadow: 0 6px 24px var(--cyan-glow); transform: translateY(-1px); }

.base-pace-card {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 16px; margin-top: 20px;
  text-align: center;
}
.base-pace-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.base-pace-value {
  font-family: var(--ff-display); font-size: 2.5rem; font-weight: 800; color: var(--cyan);
  line-height: 1.1;
}
.base-pace-unit { font-size: 0.8rem; color: var(--text-muted); }

/* Elevation summary */
.elev-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px;
}
.elev-box {
  background: var(--bg3); border-radius: var(--radius); padding: 12px; text-align: center;
}
.elev-box-val {
  font-family: var(--ff-display); font-size: 1.3rem; font-weight: 700;
}
.elev-box-val.pos { color: var(--red); }
.elev-box-val.neg { color: var(--green); }
.elev-box-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* Results table */
.results-panel {}
.results-title {
  font-family: var(--ff-display); font-size: 1.4rem; font-weight: 700;
  color: var(--white); margin-bottom: 20px; display: flex; align-items: center; gap: 10px;
}
.results-count {
  background: var(--cyan-dim); color: var(--cyan);
  font-size: 0.75rem; padding: 2px 9px; border-radius: 20px;
}

/* Chart mini */
.profile-chart-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 24px;
}
.profile-chart-title {
  font-family: var(--ff-display); font-size: 0.85rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 16px;
}
#elevationChart { width: 100%; }

.km-table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.km-table {
  width: 100%; border-collapse: collapse;
}
.km-table thead { background: var(--bg3); }
.km-table th {
  padding: 12px 16px; text-align: left;
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; white-space: nowrap;
}
.km-table td { padding: 12px 16px; border-top: 1px solid var(--border); }
.km-table tr:hover td { background: var(--bg3); }
.km-num {
  font-family: var(--ff-display); font-size: 1rem; font-weight: 700; color: var(--text-muted);
}
.km-pace {
  font-family: var(--ff-display); font-size: 1.3rem; font-weight: 800; color: var(--white);
}
.km-elev {
  font-family: var(--ff-display); font-size: 0.95rem; font-weight: 600;
}
.km-elev.up { color: var(--red); }
.km-elev.down { color: var(--green); }
.km-elev.flat { color: var(--text-muted); }
.km-type {
  font-size: 0.72rem; padding: 3px 8px; border-radius: 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.km-type.up   { background: rgba(255,82,82,0.12);  color: var(--red); }
.km-type.down { background: rgba(0,230,118,0.1);   color: var(--green); }
.km-type.flat { background: var(--cyan-dim); color: var(--cyan); }
.km-alt { font-size: 0.85rem; color: var(--text-muted); font-family: var(--ff-display); }

/* Pace bar */
.pace-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.pace-bar-bg { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.pace-bar-fill { height: 100%; border-radius: 2px; background: var(--cyan); transition: width 0.4s; }

/* Empty / loading states */
.results-empty {
  padding: 80px 20px; text-align: center;
  color: var(--text-muted);
}
.results-empty .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.results-empty p { font-size: 0.95rem; }
.loading-spinner {
  width: 36px; height: 36px; margin: 0 auto 16px;
  border: 3px solid var(--border); border-top-color: var(--cyan);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -- Footer --------------------------------------------------- */
footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 24px 0; text-align: center;
  font-size: 0.83rem; color: var(--text-dim);
}

/* -- Toast ---------------------------------------------------- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 0.88rem; color: var(--text);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
  animation: slideUp 0.3s ease; pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--cyan); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* -- Responsive ----------------------------------------------- */
@media (max-width: 1100px) {
  .races-grid { grid-template-columns: repeat(3, 1fr); }
  .country-grid { grid-template-columns: repeat(3, 1fr); }
  .calc-grid { grid-template-columns: 300px 1fr; }
}
@media (max-width: 900px) {
  .races-grid { grid-template-columns: repeat(2, 1fr); }
  .country-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero-visual { display: none; }
  .calc-grid { grid-template-columns: 1fr; }
  .calc-panel { position: static; }
}
@media (max-width: 640px) {
  .races-grid { grid-template-columns: 1fr; }
  .country-grid { grid-template-columns: 1fr; }
  .navbar-nav { display: none; }
  .navbar-nav.open { 
    display: flex; flex-direction: column; position: fixed;
    top: 68px; left: 0; right: 0; background: var(--bg2);
    padding: 20px; border-bottom: 1px solid var(--border); z-index: 999;
  }
  .hamburger { display: flex; }
  .lang-selector { order: -1; }
  .elev-summary { grid-template-columns: 1fr 1fr; }
  .km-table th:nth-child(4), .km-table td:nth-child(4) { display: none; }
}
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero { padding: 40px 0; }
  .calc-panel { padding: 20px; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* -- Language flag dropdown ---------------------------------- */
.lang-dropdown { position: relative; }
.lang-drop-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px; cursor: pointer;
  font-size: 1.1rem; display: flex; align-items: center; gap: 4px;
  color: var(--text-muted); transition: var(--transition);
}
.lang-drop-btn:hover { border-color: var(--cyan); background: var(--cyan-dim); }
.lang-drop-arrow { font-size: .6rem; color: var(--text-dim); }
.lang-drop-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 140px; z-index: 500;
  box-shadow: var(--shadow); overflow: hidden;
}
.lang-drop-menu.open { display: block; }
.lang-drop-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 14px; background: none; border: none;
  color: var(--text-muted); font-size: .88rem; cursor: pointer;
  transition: var(--transition); text-align: left;
}
.lang-drop-item:hover, .lang-drop-item.active {
  background: var(--cyan-dim); color: var(--cyan);
}
.lang-drop-item.active { font-weight: 600; }
body.theme-light .lang-drop-btn { border-color: rgba(0,0,0,0.15); color: #4a5568; }
body.theme-light .lang-drop-btn:hover { border-color: var(--cyan); }
body.theme-light .lang-drop-menu { background: #fff; border-color: rgba(0,0,0,0.1); box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
body.theme-light .lang-drop-item { color: #4a5568; }
body.theme-light .lang-drop-item:hover, body.theme-light .lang-drop-item.active { background: var(--cyan-dim); color: var(--cyan); }

/* ============================================================
   AD SLOTS & INTERSTITIAL
   ============================================================ */
.ad-slot {
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .75rem;
  letter-spacing: .4pt;
  text-transform: uppercase;
  overflow: hidden;
  position: relative;
}
.ad-slot.ad-slot-card {
  /* Same size as a race card so it fits the grid */
  min-height: 280px;
  grid-column: span 1;
}
.ad-slot.ad-slot-sidebar {
  min-height: 250px;
  width: 100%;
}
.ad-slot.ad-slot-banner {
  min-height: 90px;
  width: 100%;
  margin: 16px 0;
}
.ad-slot ins.adsbygoogle {
  display: block !important;
  width: 100%;
  height: 100%;
}
.ad-slot::before {
  content: attr(data-label);
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: .58rem;
  color: var(--text-dim);
  letter-spacing: .5pt;
  opacity: .6;
  z-index: 1;
}
.ad-slot:empty::after,
.ad-slot.ad-slot-placeholder::after {
  content: "Anuncio";
  font-weight: 600;
  color: var(--text-muted);
}

/* Interstitial modal */
.interstitial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.interstitial-overlay.open { display: flex; }
.interstitial-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  position: relative;
  text-align: center;
}
.interstitial-title {
  font-family: var(--ff-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 8px;
}
.interstitial-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.interstitial-ad {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 250px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .8rem;
  overflow: hidden;
}
.interstitial-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
.interstitial-countdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-muted);
}
.interstitial-countdown .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border-radius: 50%;
  font-weight: 700;
}
.interstitial-skip-btn {
  background: var(--cyan);
  color: #0f172a;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
}
.interstitial-skip-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* Disabled "coming soon" export buttons */
.btn-coming-soon {
  position: relative;
  opacity: .65;
  cursor: not-allowed !important;
}
.btn-coming-soon::after {
  content: attr(data-coming);
  position: absolute;
  top: -7px;
  right: -7px;
  font-size: .58rem;
  background: var(--amber);
  color: #1a1a1a;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: .3pt;
}

/* ============================================================
   TOGGLE SWITCH (used by weather, settings)
   ============================================================ */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: .25s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: .25s;
}
.switch input:checked + .switch-slider {
  background: var(--cyan-dim);
  border-color: var(--cyan);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
  background: var(--cyan);
}
