/* ============================================================
   CONVOY — design system
   Sleek glass UI · accent-driven theming · GPU-only transitions
   ============================================================ */

:root {
  --accent: #4f8cff;
  --accent-rgb: 79, 140, 255;

  --bg: #0a0e15;
  --surface: rgba(17, 23, 33, .78);
  --surface-2: rgba(26, 34, 48, .65);
  --surface-solid: #141b27;
  --text: #e9eef6;
  --text-dim: #97a3b6;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --shadow: 0 12px 40px rgba(2, 6, 12, .55);
  --shadow-sm: 0 4px 18px rgba(2, 6, 12, .4);

  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;

  --radius: 18px;
  --radius-sm: 12px;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-disp: 'Space Grotesk', var(--font-body);

  --ease: cubic-bezier(.22, .85, .3, 1);
  --dur: 240ms;
}

[data-theme="light"] {
  --bg: #e9eef5;
  --surface: rgba(255, 255, 255, .82);
  --surface-2: rgba(244, 247, 252, .75);
  --surface-solid: #ffffff;
  --text: #17222f;
  --text-dim: #5d6b7e;
  --line: rgba(15, 30, 50, .09);
  --line-strong: rgba(15, 30, 50, .18);
  --shadow: 0 12px 36px rgba(30, 45, 70, .18);
  --shadow-sm: 0 4px 16px rgba(30, 45, 70, .12);
}

[data-anim="off"] *,
[data-anim="off"] *::before,
[data-anim="off"] *::after {
  transition-duration: 0ms !important;
  animation-duration: 0ms !important;
}

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

/* author display rules must not resurrect [hidden] elements */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

svg { display: block; }
button svg, .ctl svg, .search-icon svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

#map { position: absolute; inset: 0; }
#map canvas { outline: none; }

/* glass building block */
.glass {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

/* ============================== top bar ============================== */
#topbar {
  position: fixed;
  top: 14px; left: 16px; right: 16px;
  display: flex; align-items: center; gap: 12px;
  z-index: 8;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 9px;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  user-select: none;
}
.brand-logo { width: 26px; height: 26px; border-radius: 8px; }
.brand-name {
  font-family: var(--font-disp);
  font-weight: 700; font-size: 14px; letter-spacing: .14em;
}

.searchwrap {
  position: relative;
  flex: 1;
  max-width: 540px;
  margin: 0 auto;
}
.search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}
.search-icon svg { width: 17px; height: 17px; }
#search-input {
  width: 100%;
  height: 44px;
  padding: 0 42px 0 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  color: var(--text);
  font: 500 14px var(--font-body);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
#search-input::placeholder { color: var(--text-dim); }
#search-input:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), .65);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18), var(--shadow-sm);
}
.search-clear {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
}
.search-clear:hover { color: var(--text); background: var(--surface-2); }
.search-clear svg { width: 14px; height: 14px; }

.search-results {
  position: absolute;
  top: calc(100% + 8px); left: 0; right: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.sr-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 120ms var(--ease);
}
.sr-item:hover { background: rgba(var(--accent-rgb), .12); }
.sr-item + .sr-item { border-top: 1px solid var(--line); }
.sr-pin { font-size: 14px; }
.sr-text { display: flex; flex-direction: column; min-width: 0; }
.sr-text b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-text i { font-style: normal; font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-loading { padding: 13px 16px; color: var(--text-dim); font-size: 13px; }

.avatar-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 20px;
  display: grid; place-items: center;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.avatar-btn:hover { transform: translateY(-2px); border-color: rgba(var(--accent-rgb), .6); }
.avatar-btn:active { transform: scale(.94); }

/* ============================== status chips ============================== */
.chips {
  position: fixed;
  top: 72px; left: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 5;
}
.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.chip:hover { transform: translateX(2px); }
.chip-off { opacity: .45; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-live { background: var(--good); box-shadow: 0 0 0 0 rgba(52, 211, 153, .7); animation: livePulse 2.2s infinite; }
.dot-global { background: var(--warn); }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ============================== map controls ============================== */
.map-controls {
  position: fixed;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 5;
}
.ctl-group {
  display: flex; flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.ctl-group .ctl { border: 0; border-radius: 0; box-shadow: none; }
.ctl-group .ctl + .ctl { border-top: 1px solid var(--line); }
.ctl {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.ctl:hover { transform: scale(1.06); border-color: var(--line-strong); }
.ctl:active { transform: scale(.93); }
.ctl-accent { color: #fff; background: var(--accent); border-color: transparent; }
#compass-svg circle { stroke: currentColor; opacity: .5; }
#compass-needle { transform-origin: 12px 12px; transition: transform 80ms linear; }

/* ============================== dock ============================== */
#dock {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 4px;
  padding: 7px;
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 9;
}
.dock-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 76px;
  padding: 8px 12px 7px;
  border-radius: 17px;
  color: var(--text-dim);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.dock-btn svg { width: 21px; height: 21px; }
.dock-btn span { font-size: 10.5px; font-weight: 600; letter-spacing: .03em; }
.dock-btn:hover { color: var(--text); transform: translateY(-2px); }
.dock-btn:active { transform: scale(.95); }
.dock-btn.active {
  color: var(--accent);
  background: rgba(var(--accent-rgb), .13);
}
.dock-badge {
  position: absolute;
  top: 4px; right: 10px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: 700 10px/16px var(--font-body);
  font-style: normal;
  text-align: center;
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), .5);
}

/* ============================== panels ============================== */
.panel {
  position: fixed;
  top: 72px; right: 16px;
  bottom: 92px;
  width: 392px;
  max-width: calc(100vw - 32px);
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 7;
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition: transform 300ms var(--ease), opacity 300ms var(--ease);
  will-change: transform;
}
.panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.panel-titles { flex: 1; min-width: 0; }
.panel-head h2 {
  font-family: var(--font-disp);
  font-size: 17px; font-weight: 700; letter-spacing: .01em;
}
.panel-sub { font-size: 11.5px; color: var(--text-dim); font-weight: 500; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.panel-body-flush { padding: 0; gap: 0; }

.panel-body::-webkit-scrollbar, .chat-log::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb, .chat-log::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
  background-clip: padding-box;
  border: 2px solid transparent;
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  color: var(--text-dim);
  transition: background 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm svg { width: 13px; height: 13px; }
.icon-btn-accent { color: #fff; background: var(--accent); border-radius: 12px; }
.icon-btn-accent:hover { background: var(--accent); filter: brightness(1.12); color: #fff; }

/* ============================== buttons ============================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px;
  padding: 0 18px;
  border-radius: 13px;
  font: 600 13.5px var(--font-body);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform 160ms var(--ease), filter 160ms var(--ease),
              background 160ms var(--ease), border-color 160ms var(--ease), opacity 160ms var(--ease);
}
.btn:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0)) , var(--accent);
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), .35);
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; }
.btn-small { height: 33px; padding: 0 13px; border-radius: 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-lg { height: 48px; font-size: 15px; border-radius: 15px; }
.btn-danger-text { color: var(--bad); }
.btn-end {
  height: 38px; padding: 0 16px; border-radius: 12px;
  font-weight: 700; color: #fff;
  background: var(--bad);
  border: 0;
}
.btn-end:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-end:active { transform: scale(.96); }

/* ============================== rows / users ============================== */
.row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease);
}
.row:hover { transform: translateY(-1px); border-color: var(--line-strong); }

.u-ava {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  font-size: 18px;
  border-radius: 13px;
  background: var(--surface);
  border: 2px solid var(--paint, var(--accent));
  cursor: pointer;
}
.u-ava-sm { width: 32px; height: 32px; font-size: 15px; border-radius: 10px; }
.u-info { flex: 1; min-width: 0; }
.u-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-handle { color: var(--text-dim); font-weight: 500; font-size: 12px; }
.u-car { font-size: 12px; color: var(--text-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paint-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  vertical-align: -1px;
  margin: 0 1px;
}
.u-side { text-align: right; flex: none; }
.u-dist { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.u-status { font-size: 10.5px; color: var(--text-dim); font-weight: 600; letter-spacing: .03em; }
.u-status.in-convoy { color: var(--accent); }

/* ============================== convoy panel ============================== */
.convoy-hero { padding: 18px 18px 6px; display: flex; flex-direction: column; gap: 14px; }
.convoy-hero-art { font-size: 44px; text-align: center; margin-top: 8px; }
.convoy-hero h3 { font-family: var(--font-disp); font-size: 19px; text-align: center; }
.convoy-hero p { color: var(--text-dim); font-size: 13px; text-align: center; line-height: 1.5; margin-top: -6px; }
.emoji-row { display: flex; gap: 6px; }

.hint-card {
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(var(--accent-rgb), .08);
  border: 1px dashed rgba(var(--accent-rgb), .35);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.45;
}

.convoy-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.convoy-flag {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 13px;
  background: rgba(var(--accent-rgb), .14);
  border: 1px solid rgba(var(--accent-rgb), .4);
}
.convoy-names { flex: 1; min-width: 0; }
.convoy-name { font-family: var(--font-disp); font-weight: 700; font-size: 15px; }
.convoy-count { font-size: 11.5px; color: var(--text-dim); }

.convoy-members {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  border-bottom: 1px solid var(--line);
  max-height: 220px;
  overflow-y: auto;
  flex: none;
}
.member-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.member-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.member-info b { font-size: 13px; }
.member-dist { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  animation: msgIn 260ms var(--ease);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg-me {
  align-self: flex-end;
  color: #fff;
  background: var(--accent);
  border-bottom-right-radius: 5px;
}
.msg-them {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.msg-from { display: block; font-size: 10.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg-sys {
  align-self: center;
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  padding: 2px 6px;
}
.chat-form {
  display: flex; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  flex: none;
}
.chat-form .input { flex: 1; }

/* ============================== forms ============================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim);
}
.input {
  height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: 500 13.5px var(--font-body);
  width: 100%;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.input:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), .65);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .15);
}
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}
.select option { background: var(--surface-solid); color: var(--text); }

.handle-wrap { position: relative; }
.handle-wrap > span {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim); font-weight: 600;
}
.handle-wrap .input { padding-left: 28px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 84px 1fr 1fr; gap: 10px; }
.grid2 .field, .grid3 .field { min-width: 0; }

.section-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
  margin-top: 6px;
}

.segmented {
  display: flex;
  padding: 3px;
  gap: 3px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.seg-btn {
  flex: 1;
  height: 32px;
  border-radius: 9px;
  font: 600 12.5px var(--font-body);
  color: var(--text-dim);
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}
.seg-btn:active { transform: scale(.96); }
.seg-btn.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 3px 10px rgba(var(--accent-rgb), .4);
}

.toggle {
  width: 46px; height: 27px; flex: none;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  position: relative;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.toggle .knob {
  position: absolute;
  top: 2.5px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 220ms var(--ease), background 220ms var(--ease);
}
.toggle.on { background: rgba(var(--accent-rgb), .25); border-color: var(--accent); }
.toggle.on .knob { transform: translateX(19px); background: var(--accent); }

.setting-row {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 0;
}
.setting-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.setting-text b { font-size: 13.5px; font-weight: 600; }
.setting-text span { font-size: 11.5px; color: var(--text-dim); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  position: relative;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.swatch:hover { transform: scale(1.12); }
.swatch:active { transform: scale(.95); }
.swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .35);
}
.swatch-custom {
  display: grid; place-items: center;
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
}
.swatch-custom span { font-size: 16px; font-weight: 600; color: var(--text-dim); pointer-events: none; }
.swatch-custom input {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
}

.emoji-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 17px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease);
}
.emoji-btn:hover { transform: scale(1.12); }
.emoji-btn.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), .16);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .25);
}

/* ============================== profile ============================== */
.profile-preview {
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), .16), rgba(var(--accent-rgb), .03));
  border: 1px solid rgba(var(--accent-rgb), .3);
}
.pp-car { flex: none; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.pp-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pp-name { font-family: var(--font-disp); font-weight: 700; font-size: 17px; }
.pp-handle { font-size: 12px; color: var(--text-dim); }
.pp-carline { font-size: 13px; font-weight: 600; margin-top: 4px; }
.pp-paint { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.profile-actions { display: flex; gap: 10px; margin-top: 4px; }

.about {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
}
.about a { color: var(--text-dim); }

/* ============================== ETA / trip card ============================== */
.eta-card {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translate(-50%, 16px);
  opacity: 0;
  width: min(560px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 6;
  transition: transform 320ms var(--ease), opacity 320ms var(--ease);
}
.eta-card.show { transform: translate(-50%, 0); opacity: 1; }
.eta-main { flex: 1; min-width: 0; }
.eta-dest {
  font-family: var(--font-disp);
  font-weight: 700; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eta-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; font-variant-numeric: tabular-nums; }
.eta-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.progress {
  margin-top: 9px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(var(--accent-rgb), .65));
  transition: width 300ms linear;
}
.speed-chips {
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.speed-chip {
  padding: 5px 9px;
  border-radius: 8px;
  font: 700 11.5px var(--font-body);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.speed-chip.active { background: var(--accent); color: #fff; }

/* ============================== toasts ============================== */
#toasts {
  position: fixed;
  top: 76px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 11;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500;
  opacity: 0;
  transform: translateY(-10px) scale(.96);
  transition: transform 300ms var(--ease), opacity 300ms var(--ease);
  max-width: min(480px, calc(100vw - 40px));
}
.toast.in { opacity: 1; transform: none; }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.toast-info .toast-dot { background: var(--accent); }
.toast-success .toast-dot { background: var(--good); }
.toast-warn .toast-dot { background: var(--warn); }
.toast-invite { pointer-events: auto; flex-wrap: wrap; border-radius: 18px; }
.toast-actions { display: flex; gap: 8px; margin-left: 4px; }

/* ============================== onboarding modal ============================== */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 12;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(5, 8, 14, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 320ms var(--ease);
  overflow-y: auto;
}
.modal-backdrop.show { opacity: 1; }
.modal-backdrop.closing { opacity: 0; pointer-events: none; }
.modal-card {
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 26px 26px 22px;
  border-radius: 24px;
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 15px;
  transform: translateY(14px) scale(.98);
  transition: transform 380ms var(--ease);
}
.modal-backdrop.show .modal-card { transform: none; }
.ob-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 4px; }
.ob-head .brand-logo { width: 52px; height: 52px; border-radius: 15px; }
.ob-head h1 {
  font-family: var(--font-disp);
  font-size: 26px; letter-spacing: .18em; font-weight: 700;
}
.ob-head p { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; max-width: 320px; }
.pledge {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 13px;
  background: rgba(var(--accent-rgb), .08);
  border: 1px solid rgba(var(--accent-rgb), .3);
  font-size: 12.5px; line-height: 1.5;
  cursor: pointer;
}
.pledge input { margin-top: 2px; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.ob-note { text-align: center; font-size: 11px; color: var(--text-dim); line-height: 1.5; }

/* ============================== auth screen ============================== */
.modal-card .btn-block + .btn-block { margin-top: -4px; }
.auth-or {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim); font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  margin: 2px 0;
}
.auth-or::before, .auth-or::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.auth-head2 {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 2px;
}
.auth-back {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  color: var(--text-dim);
  transition: background 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
}
.auth-back:hover { background: var(--surface-2); color: var(--text); }
.auth-back:active { transform: scale(.92); }
.auth-back svg { width: 19px; height: 19px; }
.auth-title { font-family: var(--font-disp); font-size: 19px; font-weight: 700; }
.auth-err {
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .4);
  color: var(--bad);
  font-size: 12.5px; font-weight: 500;
}
.auth-switch { text-align: center; font-size: 12.5px; color: var(--text-dim); }
.auth-link {
  color: var(--accent); font-weight: 600; font-size: 12.5px;
  padding: 0; text-decoration: underline; text-underline-offset: 2px;
}
.auth-link:hover { filter: brightness(1.15); }

/* account section in settings */
.account-section { display: flex; flex-direction: column; gap: 10px; }
.account-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.account-info { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.account-info b { font-size: 13.5px; }
.account-info span { font-size: 11.5px; color: var(--text-dim); }

/* ============================== map markers ==============================
   NOTE: never set `position` on marker roots — it must stay maplibre's
   `.maplibregl-marker { position:absolute }` or every car renders offset. */
.m-car { cursor: pointer; }
.m-car .m-body {
  position: relative;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .45));
  transition: transform 160ms var(--ease);
}
.m-car:hover .m-body { transform: scale(1.15); }
.m-ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}
.m-player .m-ring {
  opacity: 1;
  border: 2px solid rgba(var(--accent-rgb), .85);
  animation: ringPulse 2.6s var(--ease) infinite;
}
@keyframes ringPulse {
  0% { transform: scale(.82); opacity: .9; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}
.m-member .m-ring {
  opacity: 1;
  border: 2.5px solid var(--accent);
  inset: -7px;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), .65);
}

.m-dest-pin svg { width: 38px; height: 38px; filter: drop-shadow(0 4px 7px rgba(0, 0, 0, .4)); }
.m-dest-pulse {
  position: absolute;
  left: 50%; bottom: -4px;
  width: 26px; height: 10px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(var(--accent-rgb), .45);
  animation: destPulse 2s var(--ease) infinite;
}
@keyframes destPulse {
  0%, 100% { transform: translateX(-50%) scale(.7); opacity: .8; }
  50% { transform: translateX(-50%) scale(1.3); opacity: .25; }
}

/* ============================== maplibre overrides ============================== */
.maplibregl-popup { z-index: 6; }
.maplibregl-popup-content {
  background: transparent;
  padding: 0;
  box-shadow: none;
  border-radius: var(--radius-sm);
}
.maplibregl-popup-tip { display: none; }

.pop-card {
  width: 270px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--font-body);
  display: flex; flex-direction: column; gap: 10px;
  animation: popIn 240ms var(--ease);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.pop-head { display: flex; align-items: center; gap: 10px; }
.pop-id { min-width: 0; }
.pop-car {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  line-height: 1.4;
}
.pop-car-svg { flex: none; }
.pop-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.tag-live { color: var(--good); border-color: rgba(52, 211, 153, .35); }
.tag-delayed { color: var(--warn); border-color: rgba(251, 191, 36, .35); }
.pop-actions { display: flex; gap: 8px; }
.pop-actions .btn { flex: 1; }

.pop-prompt { width: 235px; }
.prompt-label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 13.5px;
}
.prompt-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.maplibregl-ctrl-attrib {
  background: var(--surface) !important;
  backdrop-filter: blur(10px);
  border-radius: 8px;
  font-size: 10px !important;
  color: var(--text-dim) !important;
}
.maplibregl-ctrl-attrib a { color: var(--text-dim) !important; }
.maplibregl-ctrl-bottom-left { z-index: 4; }

/* ============================== responsive ============================== */
@media (max-width: 760px) {
  .brand-name { display: none; }
  .brand { padding: 8px 9px; }
  #topbar { top: 10px; left: 10px; right: 10px; gap: 8px; }
  .chips { top: 66px; left: 10px; flex-direction: row; }
  .chip span:last-child { font-size: 10.5px; }

  .map-controls { right: 10px; top: auto; bottom: 180px; transform: none; }

  .panel {
    top: auto;
    left: 10px; right: 10px; bottom: 86px;
    width: auto;
    max-height: min(560px, calc(100vh - 170px));
    height: auto;
    min-height: 320px;
    transform: translateY(calc(100% + 110px));
  }
  .panel.open { transform: translateY(0); }

  #dock {
    bottom: 10px;
    left: 10px; right: 10px;
    transform: none;
    justify-content: space-between;
  }
  .dock-btn { min-width: 0; flex: 1; padding: 8px 4px 7px; }

  .eta-card { bottom: 90px; flex-wrap: wrap; }
  .grid3 { grid-template-columns: 76px 1fr 1fr; }
}
