:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --card: #222c37;
  --accent: #5728b4;     /* primary: purple */
  --accent-ink: #ffffff; /* text on purple (dark accent → white) */
  --climb: #5728b4;      /* climb highlight */
  --accent2: #2dd4bf;
  --text: #e7edf3;
  --muted: #93a1b0;
  --line: #2c3947;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; height: 100vh;
}
header { padding: 0; height: 76px; border-bottom: 1px solid var(--line); display: flex; align-items: stretch; }
/* Logo: a full-height purple square with the white "Stiip" name centred inside */
.logo-mark {
  flex: 0 0 auto; height: 100%; aspect-ratio: 1; background: var(--accent);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  text-decoration: none; color: inherit;
}
.logo-mark h1 {
  margin: 0; font-family: 'Sriracha', cursive; font-weight: 400; font-size: 20px; color: #fff;
  transform: rotate(-10deg); /* tilt up like a climb */
}
header .tag { align-self: center; margin: 0; padding: 0 20px; color: var(--muted); font-size: 13px; }
.settings { position: relative; margin-left: auto; align-self: center; margin-right: 14px; }
.cog {
  display: flex; align-items: center; justify-content: center; padding: 7px;
  background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s, transform .3s ease;
}
.cog:hover { color: var(--text); background: #0d1217; }
.cog[aria-expanded="true"] { color: var(--accent); transform: rotate(60deg); }
.cog svg { width: 20px; height: 20px; }
.settings-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1300; min-width: 160px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
.settings-menu.hidden { display: none; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 8px 6px; }
.lang-opt {
  display: block; width: 100%; text-align: left; padding: 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); font-size: 14px; cursor: pointer;
}
.lang-opt:hover { background: #0d1217; }
.lang-opt.active { background: rgba(87, 40, 180, .35); font-weight: 700; }

main { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }

.powered { flex: 0 0 auto; height: 28px; display: flex; align-items: center; justify-content: center;
  border-top: 1px solid var(--line); background: var(--panel); }
.powered a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  text-decoration: none; font-size: 12px; letter-spacing: .02em; }
.powered a:hover { color: var(--text); }
.powered img { height: 14px; width: auto; display: block; opacity: .85; }
.powered a:hover img { opacity: 1; }

.panel { padding: 16px; overflow-y: auto; border-right: 1px solid var(--line); }

.find-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.find-label { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.tabs {
  position: relative; display: flex; flex: 1;
  background: #0d1217; padding: 4px; border-radius: 10px; border: 1px solid var(--line);
}
/* Sliding highlight behind the active tab */
.tab-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 2);
  background: var(--accent); border-radius: 7px;
  box-shadow: 0 2px 8px rgba(87, 40, 180, 0.45);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
.tabs[data-mode="climbs"] .tab-thumb { transform: translateX(100%); }
.tab {
  position: relative; z-index: 1; flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer;
  transition: color .2s;
}
.tab.active { color: var(--accent-ink); }
.tab:not(.active):hover { color: var(--text); }
.tab svg { width: 16px; height: 16px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
form .row { display: flex; gap: 10px; }
form .row label { flex: 1; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
label.check input { width: auto; margin: 0; accent-color: var(--accent); }
input, select {
  width: 100%; margin-top: 4px; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #0d1217; color: var(--text); font-size: 14px;
}
button#go, button#find {
  width: 100%; padding: 11px; margin-top: 4px; border: 0; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; cursor: pointer;
}
button#go:disabled, button#find:disabled { opacity: .6; cursor: progress; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.via-chip {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 7px 10px; border-radius: 8px; font-size: 13px;
  background: rgba(87, 40, 180, 0.15); border: 1px solid var(--climb); color: var(--text);
}
.via-chip b { color: var(--climb); }
.via-chip button { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.via-chip button:hover { color: var(--text); }

.status { margin: 14px 0; font-size: 13px; min-height: 18px; }
.status.err { color: #ff8a8a; }
.status.ok { color: var(--accent2); }

.loop-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px; margin-bottom: 12px; cursor: pointer; transition: border-color .15s;
}
.loop-card:hover { border-color: var(--muted); }
.loop-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.loop-card .top { display: flex; align-items: baseline; justify-content: space-between; }
.loop-card .dplus { font-size: 22px; font-weight: 800; color: var(--accent); }
.loop-card .dplus small { font-size: 12px; font-weight: 600; color: var(--muted); }
.loop-card .swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: middle; margin-right: 6px; }
.loop-card .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.loop-card .actions { display: flex; gap: 8px; margin-top: 10px; }
.loop-card .actions a, .loop-card .actions button {
  flex: 1; text-align: center; text-decoration: none; padding: 7px; border-radius: 7px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: #0d1217; color: var(--text); cursor: pointer;
}
.loop-card .actions .gpx { background: var(--accent2); color: #06302b; border: 0; }

/* Map click-info popup */
.map-info { font-size: 13px; color: #1a1a1a; min-width: 150px; }
.map-info b { display: block; margin-bottom: 8px; }
.map-info .popup-start {
  width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
}
.map-info .popup-start:hover { filter: brightness(1.1); }

/* Climb direction arrow (▲ points north; rotated to the uphill bearing) */
.climb-arrow { background: none; border: 0; }
.climb-arrow .arr {
  color: var(--climb); font-size: 20px; line-height: 22px; text-align: center;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff; font-weight: 900;
}

.mapwrap { position: relative; display: flex; flex-direction: column; min-height: 0; }

/* Loading overlay — covers the map and blocks clicks while working */
.loading {
  position: absolute; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: rgba(15, 20, 25, 0.55); color: var(--text); font-weight: 600;
}
.loading.hidden { display: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid rgba(87, 40, 180, 0.3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results appear one by one */
.loop-card { animation: fadeUp .28s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.load-more {
  width: 100%; padding: 10px; margin-top: 2px; border: 1px dashed var(--line);
  border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer;
}
.load-more:hover { color: var(--text); border-color: var(--muted); }
#map { flex: 1; background: #0d1217; }
#profile-wrap { height: 190px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); }
.hidden { display: none; }

@media (max-width: 760px) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 60vh; }
}
