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

:root {
  --bg:       #0F1117;
  --card:     #21262D;
  --card2:    #2D333B;
  --orange:   #FF6B35;
  --green:    #3FB950;
  --blue:     #1F6FEB;
  --text:     #F0F6FC;
  --muted:    #8B949E;
  --border:   #30363D;
  --radius:   12px;
  --shadow:   0 4px 12px rgba(0,0,0,.35);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  overflow-x: hidden;
}

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

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.nav-logo span {
  font-size: 18px; font-weight: 700; color: var(--text);
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: color .15s;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active {
  color: var(--orange);
  border-bottom: 2px solid var(--orange);
  border-radius: 0;
}

.nav-right { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px;
  background: #2EA043;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  cursor: pointer;
}

/* Mobile app bar */
.mobile-appbar {
  display: none;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.mobile-status {
  font-size: 11px; color: var(--muted);
  text-align: right;
}

/* ── Page wrapper ───────────────────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }

/* ── Hero ───────────────────────────────────────────────────── */
.hero { margin-bottom: 28px; }
.hero h1 { font-size: 28px; font-weight: 700; }
.hero p  { color: var(--muted); margin-top: 4px; }

/* ── Control Bar ────────────────────────────────────────────── */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.mode-tabs {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.mode-tabs button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.mode-tabs button:hover { color: var(--text); }
.mode-tabs button.active {
  background: var(--orange);
  color: #fff;
  font-weight: 600;
}

.unit-toggle {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}
.unit-toggle button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 20px;
  transition: background .15s, color .15s;
}
.unit-toggle button.active {
  background: var(--orange);
  color: #fff;
}

/* ── Cards Grid ─────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform .15s;
}
.card:hover { transform: scale(1.01); }
.card.blue-border   { border-color: var(--blue);   }
.card.orange-border { border-color: var(--orange); }
.card.green-border  { border-color: var(--green);  }

.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-value {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.card-value.green { color: var(--green); }

.card-sub {
  font-size: 13px;
  color: var(--muted);
}

/* Quick buttons */
.quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-btn {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.quick-btn:hover { color: var(--text); border-color: var(--orange); }
.quick-btn.active {
  background: rgba(255,107,53,.15);
  border-color: var(--orange);
  color: var(--orange);
}

/* Number input */
.num-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
.num-input-wrap input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  width: 60px;
  text-align: center;
}
.num-input-wrap button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color .1s;
}
.num-input-wrap button:hover { color: var(--orange); }

/* Slider */
.slider-wrap { display: flex; flex-direction: column; gap: 6px; }
.slider-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--card2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(31,111,235,.3);
  transition: box-shadow .15s;
}
input[type=range]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 6px rgba(31,111,235,.25);
}

/* Pace +/- row */
.pace-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.pace-row .pace-display {
  flex: 1;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}
.pace-adj {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 20px;
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .1s, border-color .1s;
}
.pace-adj:hover { color: var(--orange); border-color: var(--orange); }

/* ── Splits Table ───────────────────────────────────────────── */
.splits-section { margin-bottom: 24px; }
.section-title {
  font-size: 14px; font-weight: 700;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.splits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.splits-table th {
  text-align: left;
  padding: 8px 14px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.splits-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(48,54,61,.5);
}
.splits-table tr:nth-child(even) td { background: rgba(33,38,45,.5); }
.splits-table tr:hover td { background: rgba(255,107,53,.05); }
.splits-table tr.finish-row td {
  background: rgba(63,185,80,.08);
  color: var(--green);
  font-weight: 700;
}
.splits-table tr.finish-row td:first-child { border-radius: 0; }
.splits-table tr.half-row td {
  background: rgba(31,111,235,.07);
  border-top: 1px dashed rgba(31,111,235,.3);
  border-bottom: 1px dashed rgba(31,111,235,.3);
}
.splits-table tr.half-row td:first-child strong { color: var(--blue); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-orange { background: rgba(255,107,53,.15); color: var(--orange); }
.badge-green  { background: rgba(63,185,80,.15);  color: var(--green); }
.badge-blue   { background: rgba(31,111,235,.15); color: var(--blue); }

/* ── Action Buttons ─────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .12s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn-outline { background: none; color: var(--text); border-color: var(--border); }

/* ── Bottom Nav (mobile) ────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 0 12px;
  justify-content: space-around;
  z-index: 100;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 12px;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--orange); }
.bottom-nav-item.active .dot {
  width: 4px; height: 4px;
  background: var(--orange);
  border-radius: 50%;
  margin-top: 2px;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .cards-grid { grid-template-columns: 1fr; }
  .card { flex-direction: column; }
}

@media (max-width: 640px) {
  .navbar { display: none; }
  .mobile-appbar { display: flex; }
  .bottom-nav { display: flex; }
  .page { padding: 16px 14px 90px; }
  .hero h1 { font-size: 22px; }
  .card-value { font-size: 38px; }
  .card-value.result-main { font-size: 48px; color: var(--green); }
  .mode-tabs { width: 100%; }
  .mode-tabs button { flex: 1; font-size: 12px; padding: 9px 8px; text-align: center; }
  .control-bar { flex-direction: column; align-items: stretch; }
  .action-bar .btn { flex: 1; justify-content: center; }
  .splits-table { font-size: 13px; }
  .splits-table td, .splits-table th { padding: 10px 10px; }
}

/* ── Mode visibility ────────────────────────────────────────── */
.mode-field { display: none; }
.mode-field.visible { display: block; }

/* ── Split Options Section ──────────────────────────────────── */
.split-options-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.split-opts-grid {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 28px 32px;
  align-items: start;
}

.split-opt-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.split-opt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Reusable small segmented tabs */
.seg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.seg-tabs button {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.seg-tabs button:hover { color: var(--text); border-color: var(--orange); }
.seg-tabs button.active {
  background: rgba(255,107,53,.18);
  border-color: var(--orange);
  color: var(--orange);
}

.split-type-desc {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  max-width: 260px;
}

.split-info-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.badge-slower { background: rgba(255,107,53,.13); color: var(--orange); }
.badge-faster { background: rgba(63,185,80,.13);  color: var(--green); }

/* Split row colours */
.splits-table tr.split-faster td { color: var(--green); }
.splits-table tr.split-slower td { color: var(--orange); }

@media (max-width: 900px) {
  .split-opts-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .split-opts-grid { grid-template-columns: 1fr; gap: 18px; }
  .split-options-section { padding: 16px; }
}

/* Custom distance input */
.dist-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 2px;
}
.dist-input-row input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 18px; font-weight: 700;
  width: 90px;
}
.dist-input-row span { color: var(--muted); font-size: 14px; }

/* Time input */
.time-inputs {
  display: flex;
  gap: 6px;
  align-items: center;
}
.time-seg {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.time-seg label { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.time-seg input {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 20px; font-weight: 700;
  width: 58px;
  text-align: center;
  padding: 6px 4px;
  outline: none;
}
.time-sep { font-size: 22px; font-weight: 700; color: var(--muted); margin-top: 14px; }
