:root {
  --primary: #007aff;
  --primary-soft: #e5f0ff;
  --accent: #ff3b30;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --border-soft: #e5e5ea;
  --text-main: #1c1c1e;
  --text-muted: #3e3e3f;
  --radius-lg: 18px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* HEADER */
header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo img {
  display: block;
  max-width: 250px;
  height: auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text-title {
  font-size: 17px;
  font-weight: 600;
}

.brand-text-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Fascia istruzioni header (desktop) */
.header-steps {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--text-main);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-step {
  max-width: 220px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.step-number {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #000000;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.header-step-text {
  display: flex;
  flex-direction: column;
}

.header-step-main {
  font-size: 13px;
  font-weight: 600;
}

.header-step-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* LAYOUT */
main {
  flex: 1 0 auto;
  display: flex;
  min-height: 0;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 340px;
  max-width: 100%;
  border-right: 1px solid var(--border-soft);
  background: #ffffff;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-area {
  flex: 1;
  padding: 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
}

/* CONTROLLI SIDEBAR */
#controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
}

.info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: #f5f5f7;
  color: var(--text-muted);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.info-btn:hover {
  background: #e5e5ea;
}

.info-box {
  display: none;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f5f5f7;
  border: 1px solid #e5e5ea;
  font-size: 11px;
  color: var(--text-muted);
}

.info-box.visible {
  display: block;
}

.file-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 8px 6px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: #fdfdfd;
}

.file-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.label-track {
  font-weight: 600;
  font-size: 11px;
}
.label-track1 {
  color: #0a84ff;
}
.label-track2 {
  color: #ff3b30;
}

input[type="file"] {
  font-size: 11px;
  color: var(--text-muted);
}

.nick-input {
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  color: var(--text-main);
}

.nick-input::placeholder {
  color: var(--text-muted);
}

.slider-group {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  padding: 8px 8px 6px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: #fdfdfd;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.slider-group label {
  font-weight: 600;
  font-size: 12px;
}

input[type="range"] {
  width: 100%;
  cursor: pointer;
}

.fine-tune {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-top: 4px;
}

.fine-tune button {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  color: var(--text-main);
  cursor: pointer;
  font-size: 11px;
}
.fine-tune button:hover {
  border-color: var(--primary);
}

.fine-tune-info {
  opacity: 0.7;
  margin-left: 2px;
}

.mode-select {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  padding: 8px 8px 6px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: #fdfdfd;
}

.mode-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.mode-select label {
  font-weight: 600;
  font-size: 12px;
}

select {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  color: var(--text-main);
  font-size: 12px;
}

#currentTime {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

#playPause {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  background: #0a84ff;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(0, 122, 255, 0.35);
}
#playPause:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.chart-link-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-main);
}
.chart-link-btn:hover {
  border-color: var(--primary);
}

#status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* MAPPA */
#map {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 300px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

/* MODAL GRAFICO */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f2f2f7;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #2a2a2b;
  padding: 0 4px;
}

.modal-chart-wrapper {
  flex: 1;
  min-height: 220px;
}

#paceChart {
  width: 100% !important;
  height: 100% !important;
}

#chartMessage {
  font-size: 13px;
  color: red;
  margin-top: 4px;
}

/* FOOTER */
footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-soft);
  padding: 8px 24px;
  font-size: 14px;
  color: var(--text-muted);
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Footer donations */
.footer-donations {
  display: flex;
  gap: 8px;
  align-items: center;
}

.donation-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5f5f7;
  border: 1px solid #e5e5ea;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.donation-btn img {
  display: block;
  max-height: 28px;
  width: auto;
}

.donation-btn:hover {
  background: #e5e5ea;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Tablet: layout a colonna */
@media (max-width: 900px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-steps {
    justify-content: flex-start;
    flex-direction: column;
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }

  .map-area {
    padding: 12px;
  }
}

/* --- Mobile: layout semplificato (max 700px) --- */
@media (max-width: 700px) {
  /* header compatto: solo logo, niente step 1-2-3 */
  header {
    padding: 8px 12px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
  }

  .header-steps {
    display: none;
  }

  /* sidebar a tutta larghezza sopra la mappa */
  .sidebar {
    width: 100%;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid #e5e5ea;
  }

  .map-area {
    padding: 8px 10px 12px;
  }

  /* blocco "Tracce GPS" più staccato e chiaro */
  .file-group {
    margin-bottom: 10px;
  }

  /* evidenzia solo l’inizio segmento */
  #controls > .slider-group:first-of-type {
    border-color: #c7d7ff;
    background: #f6f8ff;
  }

  /* NASCONDI: fine segmento, modalità tempo, bottone grafico */
  .slider-group--end,
  .mode-select {
    display: none;
  }

  .chart-link-btn {
    display: none;
  }

  /* testi più leggibili */
  .section-title,
  .slider-group label {
    font-size: 14px;
  }

  input[type="file"] {
    font-size: 13px;
  }

  .nick-input {
    font-size: 13px;
    padding: 6px 8px;
  }

  /* slider più touch-friendly */
  input[type="range"] {
    height: 24px;
  }

  /* bottoni più grandi da toccare */
  .fine-tune button,
  #playPause,
  .info-btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  .info-btn {
    width: 22px;
    height: 22px;
  }

  /* Play quasi full-width */
  .actions-row {
    flex-wrap: nowrap;
  }

  #playPause {
    flex: 1;
    justify-content: center;
  }

  /* mappa più protagonista */
  #map {
    min-height: 55vh;
  }

  /* footer a colonna con donazioni e link sotto */
  footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 14px;
  }

  .footer-links {
    order: 2;
  }

  .footer-donations {
    order: 3;
  }
}
@media (max-width: 700px) {
  /* Nascondo fine segmento */
  .slider-group--end:nth-of-type(2) {
    display: none;
  }

  /* Nascondo selettore modalità avanzamento */
  .mode-select {
    display: none;
  }

  /* Nascondo il bottone grafico se vuoi tenerlo solo su desktop */
  .chart-link-btn {
    display: none;
  }
}

/* --- Modern file input button --- */

input[type="file"] {
  font-size: 13px;
  color: var(--text-main);
}

/* Chrome / Edge / Opera */
input[type="file"]::-webkit-file-upload-button {
  background: #0a84ff;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 10px rgba(0,122,255,0.25);
  transition: background 0.2s ease, transform 0.1s ease;
}

/* Hover */
input[type="file"]::-webkit-file-upload-button:hover {
  background: #006be6;
  transform: translateY(-1px);
}

/* Firefox */
input[type="file"]::file-selector-button {
  background: #0a84ff;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 10px rgba(0,122,255,0.25);
  transition: background 0.2s ease, transform 0.1s ease;
}

/* Hover Firefox */
input[type="file"]::file-selector-button:hover {
  background: #006be6;
  transform: translateY(-1px);
}

/* --- PLAY BUTTON LARGE + GREEN --- */
#playPause {
  width: 100%;
  background: #28a745; /* verde moderno */
  color: white;
  font-size: 1.4rem;
  padding: 14px 0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  transition: background 0.2s, transform 0.15s;
}

#playPause:hover {
  background: #23963f;
}

#playPause:active {
  transform: scale(0.97);
}

#playPause[disabled] {
  background: #9cccab;
  cursor: not-allowed;
  transform: none;
}

.mode-warning {
  font-size: 11px;
  color: #095307;
  margin-top: 4px;
}
.timestamp-modal .modal-body {
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.modal-btn {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid #e5e5ea;
}

.modal-btn-primary {
  background: #0a84ff;
  color: #fff;
  border-color: #0a84ff;
}

.modal-btn-secondary {
  background: #f5f5f7;
  color: #1c1c1e;
}

.ts-ok {
  color: #16a34a;        /* verde */
  font-weight: 600;
}

.ts-missing {
  color: #dc2626;        /* rosso */
  font-weight: 600;
}


