:root {
  color-scheme: light;
  --bg: #eef3f0;
  --bg-deep: #071312;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --panel-dark: rgba(7, 19, 18, 0.78);
  --ink: #0c1716;
  --muted: #60706d;
  --muted-strong: #3f4e4b;
  --line: rgba(255, 255, 255, 0.48);
  --line-dark: rgba(12, 23, 22, 0.12);
  --accent: #00a88e;
  --accent-dark: #087363;
  --accent-soft: rgba(0, 168, 142, 0.16);
  --warm: #ffb45c;
  --warn: #c46a19;
  --danger: #d63d3d;
  --offline: #777f85;
  --shadow: 0 22px 55px rgba(8, 31, 29, 0.18);
  --shadow-soft: 0 12px 30px rgba(8, 31, 29, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background:
    linear-gradient(135deg, rgba(0, 168, 142, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(255, 180, 92, 0.18), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main[role="main"] {
  min-height: 100svh;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.language-switcher {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1200;
}

.language-switcher select {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  padding: 0 34px 0 12px;
  color: white;
  background: rgba(7, 19, 18, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.home-shell,
.expired-panel {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.home-shell {
  background:
    linear-gradient(90deg, rgba(7, 19, 18, 0.88), rgba(7, 19, 18, 0.54) 38%, rgba(7, 19, 18, 0.14) 72%),
    linear-gradient(180deg, rgba(7, 19, 18, 0.14), rgba(7, 19, 18, 0.36)),
    url("/img/home-roadtrip-map.png") center / cover no-repeat;
  place-items: center start;
}

.home-panel,
.expired-panel {
  width: min(560px, 100%);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.home-panel {
  color: white;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.07)),
    rgba(7, 19, 18, 0.5);
  margin-left: clamp(0px, 4vw, 54px);
}

.eyebrow {
  color: #85f2df;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

.home-panel h1 {
  font-size: clamp(2.6rem, 11vw, 4.9rem);
  line-height: 0.92;
  margin-bottom: 18px;
  text-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
}

.lede {
  color: rgba(255, 255, 255, 0.78);
  font-size: 1.08rem;
  line-height: 1.58;
}

.home-panel .primary-action {
  margin-top: 8px;
}

.primary-action,
.secondary-action,
.ghost-action,
.map-actions button {
  min-height: 46px;
  border-radius: 14px;
  padding: 0 16px;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-action {
  background: linear-gradient(135deg, var(--accent), #14c8a7);
  color: white;
  box-shadow: 0 14px 28px rgba(0, 168, 142, 0.28);
}

.primary-action:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
}

.primary-action:active,
.secondary-action:active,
.ghost-action:active,
.map-actions button:active {
  transform: translateY(1px) scale(0.99);
}

.secondary-action,
.map-actions button {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.72);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.ghost-action {
  background: rgba(255, 255, 255, 0.16);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(16px);
}

.trip-app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(7, 19, 18, 0.98), rgba(14, 41, 38, 0.92) 56px, transparent 56px),
    linear-gradient(135deg, rgba(0, 168, 142, 0.13), transparent 42%),
    linear-gradient(315deg, rgba(255, 180, 92, 0.13), transparent 36%),
    var(--bg);
}

.trip-header {
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: white;
  background: rgba(7, 19, 18, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 900;
}

.brand {
  font-size: 1.12rem;
  font-weight: 800;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-pill {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.74rem;
  padding: 6px 9px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
}

.connection-pill.connected {
  color: #9ff5e4;
  border-color: rgba(111, 241, 213, 0.42);
  background: rgba(0, 168, 142, 0.14);
}

.connection-pill.disconnected {
  color: #ffd0d0;
  border-color: rgba(214, 61, 61, 0.42);
  background: rgba(214, 61, 61, 0.14);
}

.trip-layout {
  display: grid;
  grid-template-rows: minmax(360px, 54svh) auto;
  min-height: 0;
  width: 100%;
}

.map-section {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  background: #dce8dd;
  border-bottom: 1px solid rgba(8, 31, 29, 0.08);
  box-shadow: 0 16px 38px rgba(8, 31, 29, 0.14);
}

.trip-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.trip-map::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 410;
  background:
    linear-gradient(180deg, rgba(7, 19, 18, 0.24), transparent 20%, transparent 72%, rgba(7, 19, 18, 0.16)),
    linear-gradient(90deg, rgba(7, 19, 18, 0.08), transparent 22%, transparent 78%, rgba(7, 19, 18, 0.08));
}

.map-actions {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 500;
}

.map-actions button {
  flex: 1;
  padding: 0 10px;
}

.trip-sidebar {
  display: grid;
  gap: 10px;
  padding: 10px;
  width: 100%;
  min-width: 0;
}

.status-panel,
.participants-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.status-panel {
  margin-top: -28px;
  position: relative;
  z-index: 700;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.status-row strong {
  font-size: 1.02rem;
}

.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--offline);
  box-shadow: 0 0 0 5px rgba(119, 127, 133, 0.13);
}

.status-dot.active {
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft), 0 0 26px rgba(0, 168, 142, 0.5);
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.telemetry-grid div {
  border: 1px solid rgba(12, 23, 22, 0.08);
  border-radius: 15px;
  padding: 10px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.58);
}

.telemetry-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.telemetry-grid strong {
  display: block;
  margin-top: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.limitation {
  color: #8b4a12;
  margin: 12px 0 0;
  line-height: 1.45;
  font-size: 0.9rem;
  background: rgba(255, 180, 92, 0.16);
  border: 1px solid rgba(255, 180, 92, 0.2);
  border-radius: 14px;
  padding: 10px;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.button-row button {
  flex: 1;
}

button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  box-shadow: none;
}

.participants-panel h2 {
  font-size: 1.04rem;
  margin-bottom: 10px;
}

.participants-list {
  display: grid;
  gap: 8px;
}

.participant-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  border: 1px solid rgba(12, 23, 22, 0.08);
  border-radius: 16px;
  padding: 11px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.62);
}

.participant-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.participant-meta {
  color: var(--muted);
  font-size: 0.84rem;
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.activity {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-dark);
  background: rgba(0, 168, 142, 0.12);
  border-radius: 999px;
  padding: 4px 7px;
  align-self: start;
}

.activity.stale {
  color: var(--warn);
  background: rgba(255, 180, 92, 0.2);
}

.activity.offline {
  color: var(--offline);
  background: rgba(119, 127, 133, 0.14);
}

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  padding: 0;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

dialog::backdrop {
  background: rgba(7, 19, 18, 0.56);
}

dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

dialog h1 {
  font-size: 1.4rem;
  margin: 0;
}

label {
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(12, 23, 22, 0.12);
  border-radius: 14px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

input:focus {
  outline: 3px solid rgba(0, 168, 142, 0.2);
  border-color: rgba(0, 168, 142, 0.44);
}

.error-text {
  color: var(--danger);
  min-height: 1.2em;
  margin: 0;
}

.toast-message {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1000;
  background: rgba(7, 19, 18, 0.9);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
  transform: translateY(120%);
  transition: transform 160ms ease;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.toast-message.visible {
  transform: translateY(0);
}

.participant-marker {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #14c8a7);
  color: white;
  border: 3px solid white;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  font-weight: 800;
}

.participant-marker.stale {
  background: linear-gradient(135deg, var(--warn), var(--warm));
}

.participant-marker.offline {
  background: linear-gradient(135deg, var(--offline), #9aa0a6);
}

.destination-marker {
  width: 34px;
  height: 34px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 50% 6px;
  background: linear-gradient(135deg, #ff6b35, var(--warm));
  border: 3px solid white;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  transform: rotate(-45deg);
}

.destination-marker::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  box-shadow: inset 0 0 0 2px rgba(196, 106, 25, 0.22);
}

/* Critical Leaflet layout rules. These keep tiles clipped and positioned even
   if the external Leaflet stylesheet loads late on mobile networks. */
.leaflet-container {
  overflow: hidden;
  touch-action: none;
  background: #dce8dd;
  font-family: inherit;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  user-select: none;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
  float: left;
  clear: both;
}

.leaflet-control-zoom {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  overflow: hidden;
  margin: 10px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.leaflet-control-zoom a {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  border-bottom: 1px solid rgba(12, 23, 22, 0.1);
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0;
}

.leaflet-control-attribution {
  margin: 0;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.76);
  font-size: 0.68rem;
  backdrop-filter: blur(10px);
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  backdrop-filter: blur(16px);
}

@media (min-width: 900px) {
  .trip-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: 1fr;
    height: calc(100svh - 60px);
  }

  .map-section {
    min-height: 0;
  }

  .trip-sidebar {
    overflow: auto;
    align-content: start;
    padding: 14px;
  }

  .status-panel {
    margin-top: 0;
  }
}
