:root {
  --bg: #0f172a;
  --bg-elevated: #182339;
  --card: #1c2942;
  --border: #2a3a5c;
  --text: #eef2f9;
  --text-dim: #93a3c1;
  --accent: #d67a2f;
  --accent-2: #e8973f;
  --ok: #35c97a;
  --danger: #e5484d;
  --tabbar-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; overflow: hidden; }
button, input, select { font-family: inherit; }
a { color: var(--accent-2); }

#app {
  display: flex; flex-direction: column;
  height: 100%; width: 100%;
}

/* ---------- Top status bar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-top)) 14px 8px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#topbar .title { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
#sync-indicator { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
#sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); transition: background .3s; }
#sync-dot.live { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
#sync-dot.offline { background: var(--danger); }

/* ---------- Views ---------- */
#views { position: relative; flex: 1; min-height: 0; }
.view {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.view.active { display: flex; }

/* ---------- Map view ---------- */
#view-map { padding: 0; }
#map { flex: 1; width: 100%; height: 100%; background: #0b1220; }

.floating-card {
  position: absolute; left: 10px; right: 10px; top: 10px;
  background: rgba(24,35,57,.94);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  z-index: 500;
  backdrop-filter: blur(6px);
}
#nearest-station-card { display: flex; align-items: center; gap: 10px; }
#nearest-station-card .icon { font-size: 22px; }
#nearest-station-card .info { flex: 1; min-width: 0; }
#nearest-station-card .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
#nearest-station-card .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nearest-station-card .dist { font-size: 13px; color: var(--accent-2); font-weight: 700; white-space: nowrap; }

#map-controls {
  position: absolute; right: 10px; bottom: 14px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.round-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-size: 19px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
.round-btn:active { transform: scale(0.94); }

#stats-pill {
  position: absolute; left: 10px; bottom: 14px; z-index: 500;
  background: rgba(24,35,57,.94); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px;
  display: flex; gap: 14px; font-size: 12px; box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
#stats-pill .stat { display: flex; flex-direction: column; align-items: center; }
#stats-pill .stat b { font-size: 14px; color: var(--accent-2); }

#category-panel {
  position: absolute; right: 10px; bottom: 70px; z-index: 501;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; display: none; flex-direction: column; gap: 6px;
  min-width: 190px; box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
#category-panel.open { display: flex; }

/* Checkbox minta: label > input (rejtett) + i (ikon) + em (címke, az ikon után) */
.cat-check {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; padding: 7px 8px; border-radius: 10px;
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.cat-check:active { background: rgba(255,255,255,.05); }
.cat-check input {
  position: absolute; opacity: 0;
  top: 0; left: 0; width: 100%; height: 100%; margin: 0;
  cursor: pointer;
}
.cat-check i {
  width: 18px; flex-shrink: 0; text-align: center; font-size: 15px;
  color: var(--text-dim); transition: color .15s;
}
.cat-check em {
  font-style: normal; color: var(--text-dim); transition: color .15s;
}
.cat-check input:checked + i { color: var(--accent-2); }
.cat-check input:checked ~ em { color: var(--text); font-weight: 600; }
.cat-check input:focus-visible ~ em { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }

/* Leaflet marker tweaks */
.rt-emoji-icon { font-size: 22px; line-height: 1; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.rt-user-marker { width: 26px; height: 26px; }
.rt-user-dot { width: 16px; height: 16px; border-radius: 50%; background: #3b9eff; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(59,158,255,.35); position: absolute; top: 5px; left: 5px; }
.rt-user-cone {
  position: absolute; top: -8px; left: 5px; width: 0; height: 0;
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-bottom: 14px solid rgba(59,158,255,.85);
  transform-origin: 8px 22px;
}
.rt-team-marker {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.rt-team-marker span { transform: rotate(45deg); font-size: 11px; font-weight: 700; color: #fff; }

/* ---------- POI view ---------- */
#view-poi { padding: 10px 0 0; }
#poi-filter-bar { display: flex; gap: 8px; padding: 0 12px 10px; overflow-x: auto; flex-shrink: 0; }
.chip {
  flex-shrink: 0; padding: 7px 13px; border-radius: 999px; font-size: 13px;
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #1a0f04; font-weight: 700; }

#poi-list { flex: 1; overflow-y: auto; padding: 0 12px 90px; -webkit-overflow-scrolling: touch; }
.poi-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px;
}
.poi-row .icon { font-size: 24px; width: 34px; text-align: center; flex-shrink: 0; }
.poi-row .body { flex: 1; min-width: 0; }
.poi-row .name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poi-row .sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poi-row .dist { font-size: 13px; color: var(--accent-2); font-weight: 700; flex-shrink: 0; }
.poi-row .visited-badge { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #06210f; display: none; align-items: center; justify-content: center; font-size: 13px; font-weight: 900; }
.poi-row.visited .visited-badge { display: flex; }
.poi-row.visited .name { color: var(--text-dim); }
#poi-empty { text-align: center; color: var(--text-dim); padding: 40px 20px; font-size: 14px; }

/* POI detail sheet */
#poi-detail {
  position: absolute; left: 0; right: 0; bottom: 0; top: 8%;
  background: var(--bg-elevated); border-radius: 20px 20px 0 0;
  transform: translateY(100%); transition: transform .28s ease;
  z-index: 900; display: flex; flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0,0,0,.5);
}
#poi-detail.open { transform: translateY(0); }
#poi-detail-scroll { overflow-y: auto; padding: 16px 18px calc(24px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }
#poi-detail-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 10px auto 4px; flex-shrink: 0; }
#poi-detail-image { width: 100%; height: 160px; border-radius: var(--radius); background: linear-gradient(135deg, #223154, #182339); display: flex; align-items: center; justify-content: center; font-size: 52px; margin-bottom: 14px; overflow: hidden; }
#poi-detail-image img { width: 100%; height: 100%; object-fit: cover; }
#poi-detail h2 { margin: 0 0 4px; font-size: 20px; }
#poi-detail .cat-label { font-size: 12px; color: var(--accent-2); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 12px; }
.detail-row { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.detail-row .k { color: var(--text-dim); width: 92px; flex-shrink: 0; }
.detail-row .v { flex: 1; }
.detail-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: none; border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px; justify-content: center; flex: 1; min-width: 120px;
}
.btn-primary { background: var(--accent); color: #1a0f04; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ok { background: var(--ok); color: #06210f; }
.btn:active { transform: scale(.97); }
#poi-detail-close { position: absolute; top: 14px; right: 14px; background: var(--card); border: 1px solid var(--border); color: var(--text); width: 32px; height: 32px; border-radius: 50%; font-size: 16px; z-index: 2; }
#detail-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .28s; z-index: 890; }
#detail-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- Team view ---------- */
#view-team { padding: 12px 0 0; }
#team-cards { display: flex; gap: 10px; padding: 0 12px 12px; overflow-x: auto; flex-shrink: 0; }
.team-card {
  flex-shrink: 0; width: 150px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.team-card .avatar { width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 15px; }
.team-card .name { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-card .dist { font-size: 17px; font-weight: 800; color: var(--accent-2); }
.team-card .dir { font-size: 12px; color: var(--text-dim); margin-top: 2px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.team-card .dir .arrow { display: inline-block; font-size: 14px; }
.team-card.offline { opacity: .45; }
#team-empty { padding: 0 14px 10px; color: var(--text-dim); font-size: 13px; }
#team-map { flex: 1; width: 100%; min-height: 0; }

/* ---------- Settings view ---------- */
#view-settings { overflow-y: auto; padding: 16px 16px calc(30px + var(--safe-bottom)); }
.settings-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.settings-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input[type=text] {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 15px;
}
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; }
.swatch.selected { border-color: #fff; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); }
.settings-row:first-child { border-top: none; }
.settings-row .lbl { font-size: 14px; }
.settings-row .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked ~ .thumb { transform: translateX(20px); }
.stat-big { display: flex; gap: 14px; }
.stat-big .box { flex: 1; background: var(--bg-elevated); border-radius: 12px; padding: 14px; text-align: center; }
.stat-big .box .n { font-size: 24px; font-weight: 800; color: var(--accent-2); }
.stat-big .box .l { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.btn-full { width: 100%; }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 10px; }
.app-version { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 6px; }

/* ---------- Tabbar ---------- */
#tabbar {
  display: flex; flex-shrink: 0; background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; padding: 6px 0 0;
}
.tab-btn .ic { font-size: 21px; }
.tab-btn.active { color: var(--accent-2); }
.tab-btn .badge { position: absolute; margin-left: 14px; margin-top: -18px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 800; border-radius: 999px; min-width: 15px; height: 15px; display: none; align-items: center; justify-content: center; padding: 0 3px; }
.tab-btn .badge.show { display: flex; }

/* ---------- Idle / "lazítunk" toast ---------- */
#idle-toast {
  position: absolute; left: 14px; right: 14px; top: calc(10px + var(--safe-top));
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0f04; border-radius: var(--radius); padding: 13px 16px;
  display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px;
  transform: translateY(-140%); transition: transform .35s ease;
  z-index: 1000; box-shadow: 0 8px 22px rgba(0,0,0,.4);
}
#idle-toast.show { transform: translateY(0); }
#idle-toast > span:first-child { font-size: 18px; }
#idle-toast .close { margin-left: auto; background: rgba(0,0,0,.15); border: none; width: 26px; height: 26px; border-radius: 50%; color: #1a0f04; font-size: 14px; flex-shrink: 0; }

/* ---------- First run modal ---------- */
#onboarding {
  position: fixed; inset: 0; background: var(--bg); z-index: 2000;
  display: flex; flex-direction: column; justify-content: center; padding: 26px;
}
#onboarding.hidden { display: none; }
#onboarding h1 { font-size: 24px; margin-bottom: 6px; }
#onboarding p { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }

/* ---------- Toast (generic small) ---------- */
#mini-toast {
  position: absolute; left: 50%; bottom: calc(var(--tabbar-h) + 16px);
  transform: translate(-50%, 12px); background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: 999px; font-size: 13px;
  opacity: 0; transition: opacity .25s, transform .25s; z-index: 1500; pointer-events: none;
  white-space: nowrap;
}
#mini-toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 0; height: 0; }
