:root {
  --bg: #0B1D26;
  --surface: #102B38;
  --surface-2: #16384A;
  --line: #1F4859;
  --text: #EAF4F4;
  --text-muted: #7FA8B3;
  --accent: #FF6B35;       /* safety orange – primární akce */
  --accent-press: #E0552A;
  --teal: #2EC4B6;         /* voda */
  --amber: #FFB000;        /* aktualizovat */
  --grey: #5C6B73;         /* offline */
  --danger: #E5484D;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", "Cascadia Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px; /* místo pro spodní navigaci */
}

/* ---------- Horní lišta + stavová tečka ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-pill[data-state="online"] { color: var(--teal); border-color: rgba(46,196,182,0.4); }
.status-pill[data-state="aktualizovat"] {
  color: var(--amber);
  border-color: rgba(255,176,0,0.4);
  cursor: pointer;
}
.status-pill[data-state="offline"] { color: var(--grey); }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.status-pill[data-state="aktualizovat"] .status-dot {
  animation: pulse 1.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .status-pill[data-state="aktualizovat"] .status-dot { animation: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

/* ---------- Obrazovky ---------- */
.screen { display: none; padding: 4px 16px 16px; flex: 1; }
.screen.active { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Aktivní jízda banner ---------- */
.run-banner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
}
.run-banner strong { color: var(--text); font-family: var(--sans); }

/* ---------- Tlačítka akcí (Parkuju / Start / Spot / Konec) ---------- */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 22px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  min-height: 96px;
}
.action-btn svg { width: 28px; height: 28px; }
.action-btn:disabled { opacity: 0.35; }
.action-btn:not(:disabled):active { transform: scale(0.97); }

.action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1A0E08;
}
.action-btn.primary:not(:disabled):active { background: var(--accent-press); }

.action-btn.danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

/* full-width tlačítko (Parkuju nahoře) */
.action-btn.wide { grid-column: 1 / -1; flex-direction: row; justify-content: center; min-height: 64px; }

/* ---------- Sekce / karty ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin: 0 0 10px; }

.section-label { font-size: 12px; color: var(--text-muted); margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.4px; }

.kv { font-family: var(--mono); font-size: 13px; color: var(--text); }
.kv .muted { color: var(--text-muted); }

select, input[type="text"], input[type="number"], input[type="url"], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: var(--sans);
}
label { font-size: 13px; color: var(--text-muted); display: block; margin: 12px 0 6px; }
label:first-child { margin-top: 0; }

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.primary { background: var(--accent); color: #1A0E08; border-color: var(--accent); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- Seznam jízd / úseků ---------- */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item .title { font-weight: 600; font-size: 14px; }
.list-item .meta { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-muted); }
.badge.synced { color: var(--teal); border-color: rgba(46,196,182,0.4); }
.badge.pending { color: var(--amber); border-color: rgba(255,176,0,0.4); }

.empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px 0; }

/* ---------- Mapa pro kreslení trasy ---------- */
#routeMap { width: 100%; height: 260px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }

/* ---------- Modal (Spot detaily) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 20px 16px 28px;
  width: 100%;
  max-width: 480px;
}
.modal h3 { margin: 0 0 4px; }
.modal .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; font-family: var(--mono); }

/* ---------- Spodní navigace ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.bottomnav button {
  flex: 1; background: none; border: none; color: var(--text-muted);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bottomnav button.active { color: var(--accent); }
.bottomnav svg { width: 20px; height: 20px; }

.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 60;
  opacity: 0; transition: opacity 0.2s ease;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; }
