:root {
  /* Race-spec identity — asphalt ground, ignition orange, cool steel neutrals. */
  --bg: #0a0b0d;
  --bg-2: #131519;
  --panel: #131519;
  --panel-2: #1b1e24;
  --line: #2a2f37;
  --line-2: #363c45;
  --text: #eef0f3;
  --muted: #8b909b;
  --faint: #5c616b;
  --accent: #ff5a1f;
  --accent-2: #ff8a3d;
  --accent-soft: rgba(255, 90, 31, 0.15);
  --hazard: #ffc400;
  --green: #25d07a;
  --red: #ff3b3b;
  --mine: linear-gradient(150deg, #ff5a1f, #ff8a3d);
  --shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --chamfer: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  --chamfer-sm: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

* { box-sizing: border-box; }

/* Line icons (SVG sprite) */
.ic { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic.filled { fill: currentColor; stroke: none; }
html, body { height: 100%; }
/* Disable pinch-zoom of the app itself (looks broken in the WebView); Leaflet
   maps set their own touch-action so map gestures still work. */
html { touch-action: pan-x pan-y; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -8%, rgba(255, 90, 31, .14) 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 8%, rgba(90, 120, 160, .07) 0%, transparent 55%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px),
    var(--bg);
  height: 100vh;
  overflow: hidden;
}
.hidden { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  border: 0;
  clip-path: var(--chamfer-sm);
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .045em;
  cursor: pointer;
  color: #140b06;
  transition: transform .06s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--mine); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-2); }
.btn-block { width: 100%; }
.btn-icon { padding: 10px 13px; line-height: 1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Auth screen ─────────────────────────────────────────────────── */
#auth {
  position: fixed; inset: 0;
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  background:
    radial-gradient(900px 620px at 82% -10%, rgba(255,90,31,.16), transparent 60%),
    radial-gradient(700px 520px at 4% 18%, rgba(74,163,255,.05), transparent 55%),
    var(--bg);
  overflow: auto;
}
.auth-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
  padding: clamp(28px, 5vw, 76px);
  border-right: 1px solid var(--line);
}
.auth-hazard {
  position: absolute; top: 44px; right: -34px; width: 240px; height: 18px;
  transform: rotate(-8deg); opacity: .5; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, var(--accent) 0 12px, transparent 12px 26px);
}
.plate-lg {
  align-self: flex-start; background: var(--panel); border: 1px solid var(--line);
  clip-path: var(--chamfer); padding: 12px 20px;
}
.wm { font-size: clamp(28px, 3.6vw, 44px); font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: -.01em; color: var(--text); }
.wm-slash { color: var(--accent); }
.auth-h1 {
  font-size: clamp(30px, 4.6vw, 52px); line-height: .98; font-weight: 900; font-style: italic;
  text-transform: uppercase; letter-spacing: -.01em; margin: 6px 0 0; color: var(--text);
}
.auth-h1 em { color: var(--accent); font-style: italic; }
.auth-lede { color: var(--muted); font-size: clamp(14px, 1.5vw, 16px); max-width: 46ch; margin: 0; line-height: 1.5; }
.auth-specs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.aspec {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text); background: var(--panel); border: 1px solid var(--line);
  padding: 7px 12px; clip-path: var(--chamfer-sm);
}
.auth-panel { display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 380px; max-width: 100%;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  clip-path: var(--chamfer);
  padding: 30px 26px;
  box-shadow: var(--shadow);
}
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; clip-path: var(--chamfer-sm); border: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 10px; clip-path: var(--chamfer-sm); font-weight: 700; cursor: pointer; font-size: 13px;
}
.tab.active { background: var(--panel-2); color: var(--text); }

/* auth field icons + chamfered inputs */
.field-wrap { position: relative; display: block; }
.fic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.auth-card .field-wrap input { padding-left: 38px; clip-path: var(--chamfer-sm); }
.auth-card .btn-block { clip-path: var(--chamfer-sm); }

@media (max-width: 860px) {
  #auth { grid-template-columns: 1fr; }
  .auth-hero { border-right: 0; border-bottom: 1px solid var(--line); min-height: 38vh; }
}

.fields { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
input, textarea, select {
  box-sizing: border-box; /* keep padding+border inside width:100% (date inputs overflowed) */
}
input {
  background: var(--bg);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  width: 100%;
  min-width: 0;
  outline: none;
  transition: border .15s ease, box-shadow .15s ease;
}
/* iOS renders date/time inputs with an intrinsic (too-wide) size — normalise. */
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
}
input::placeholder { color: var(--faint); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-err { color: var(--red); min-height: 1.2em; font-size: 13px; text-align: center; margin: 14px 0 0; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--hairline, rgba(255,255,255,.12)); }
#google-btn { display: flex; justify-content: center; min-height: 40px; }

/* ── App shell ───────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; }

/* Sidebar */
#sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
}
.side-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; padding: 4px 8px 14px; }
.side-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 6px 8px; font-weight: 700; }

.rooms { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rooms li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--muted);
  transition: background .12s ease, color .12s ease;
}
.rooms li:hover { background: var(--panel); color: var(--text); }
.rooms li.active { background: var(--accent-soft); color: var(--text); }
.rooms li.active .room-ava { outline: 2px solid var(--accent); }
.room-ava {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
}
.room-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.create-room { display: flex; gap: 6px; margin-top: 10px; }
.create-room input { padding: 9px 11px; }

.side-footer { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; }
.me-info { flex: 1; min-width: 0; }
.me-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.conn-status.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn-status.offline .dot { background: var(--red); }

/* Avatar */
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
}

/* Chat */
#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-header {
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(18, 22, 28, .6); backdrop-filter: blur(6px);
}
.ch-title { font-weight: 700; font-size: 17px; }
.ch-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.messages { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-emoji { font-size: 46px; margin-bottom: 8px; }

/* Message row */
.msg { display: flex; gap: 11px; padding: 4px 0; position: relative; }
.msg.mine { flex-direction: row-reverse; }
.msg .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; margin-top: 2px; }
.msg-main { max-width: 68%; display: flex; flex-direction: column; }
.msg.mine .msg-main { align-items: flex-end; }
.msg-head { font-size: 12px; color: var(--muted); margin: 0 4px 3px; display: flex; gap: 8px; align-items: baseline; }
.msg-head .who { font-weight: 700; color: var(--text); }
.msg-head .time { color: var(--faint); font-size: 11px; }

.reply-quote {
  border-left: 3px solid var(--accent); background: var(--panel);
  padding: 4px 10px; margin: 0 2px 4px; border-radius: 0 8px 8px 0;
  font-size: 12px; color: var(--muted); max-width: 100%;
}
.reply-quote b { color: var(--accent-2); }

.bubble {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 9px 13px; border-radius: 14px; border-top-left-radius: 4px;
  word-break: break-word; white-space: pre-wrap;
}
.msg.mine .bubble { background: var(--mine); border: 0; color: #fff; border-radius: 14px; border-top-right-radius: 4px; }
.msg.mine .bubble a { color: #fff; text-decoration: underline; }
.bubble a { color: var(--accent-2); }
.bubble .edited { font-size: 11px; opacity: .7; margin-left: 4px; }
.msg.deleted .bubble { font-style: italic; color: var(--muted); background: transparent; border: 1px dashed var(--line-2); }

/* Reaction chips */
.reactions { display: flex; gap: 5px; margin: 5px 2px 0; flex-wrap: wrap; }
.msg.mine .reactions { justify-content: flex-end; }
.chip {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px;
  padding: 2px 9px; font-size: 13px; cursor: pointer; display: flex; gap: 4px; align-items: center;
  transition: border .12s ease, background .12s ease;
}
.chip:hover { background: var(--panel-2); }
.chip.mine { border-color: var(--accent); background: var(--accent-soft); }
.chip .count { color: var(--muted); font-size: 12px; }

/* Hover action bar */
.msg-actions {
  position: absolute; top: -14px;
  display: none; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 5;
}
.msg:not(.mine) .msg-actions { left: 46px; }
.msg.mine .msg-actions { right: 46px; }
.msg:hover .msg-actions { display: flex; }
.act {
  border: 0; background: transparent; cursor: pointer; font-size: 16px;
  padding: 4px 6px; border-radius: 8px; line-height: 1;
}
.act:hover { background: var(--line); }
.act.small { font-size: 13px; }

/* Inline edit */
.edit-box { display: flex; flex-direction: column; gap: 6px; }
.edit-box input { padding: 8px 11px; }
.edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.edit-actions .btn { padding: 5px 12px; font-size: 13px; }

/* Composer */
.composer { padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.reply-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-left: 3px solid var(--accent);
  padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; color: var(--muted);
}
.reply-bar .x { cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.reply-bar .x:hover { background: var(--line); color: var(--text); }
.composer-row { display: flex; gap: 10px; align-items: center; }
.composer-row input { padding: 13px 16px; border-radius: 14px; }
.btn-send { width: 48px; height: 48px; border-radius: 14px; font-size: 18px; display: grid; place-items: center; flex-shrink: 0; }

/* Ride simulator */
.ride-open { margin-bottom: 12px; text-align: left; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card {
  width: 440px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-x { border: 0; background: var(--panel-2); color: var(--text); width: 32px; height: 32px; border-radius: 9px; cursor: pointer; font-size: 15px; }
.modal-x:hover { background: var(--line); }

.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.metric { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px; text-align: center; }
.m-val { font-size: 24px; font-weight: 800; background: var(--mine); -webkit-background-clip: text; background-clip: text; color: transparent; }
.m-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }

.track-wrap { margin-bottom: 16px; }
#ride-canvas { width: 100%; height: 200px; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.track-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.track-legend .sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.sw-real { background: #4aa3ff; }
.sw-stored { background: var(--accent); }

.ride-controls { display: flex; gap: 10px; }
.ride-controls .btn { flex: 1; }
.ride-status { font-size: 13px; color: var(--muted); margin: 12px 0; text-align: center; }
.ride-extra { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.hint { font-size: 12px; color: var(--faint); margin: 4px 0 10px; }
.zone-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.zone-row { display: flex; align-items: center; justify-content: space-between; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; font-size: 13px; }
.zone-row .del { cursor: pointer; color: var(--red); padding: 2px 6px; border-radius: 6px; }
.zone-row .del:hover { background: var(--line); }

/* ── App shell: top nav + views ──────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; width: 100%; }

#topnav {
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px; height: 58px; flex-shrink: 0;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.nav-brand { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.nav-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.nav-tab:hover { background: var(--panel); color: var(--text); }
.nav-tab.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-user-info { min-width: 0; }
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }

#views { flex: 1; overflow: hidden; position: relative; }
.view { display: none; height: 100%; overflow-y: auto; }
.view.active { display: block; }
.view.chat-view.active { display: flex; }

/* ── Feed ─────────────────────────────────────────────────────────── */
#view-feed { display: none; }
#view-feed.active { display: block; max-width: 640px; margin: 0 auto; padding: 22px; }
.feed-col { min-width: 0; }
.composer-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 18px; }
.composer-card textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: 14px; resize: vertical; outline: none;
}
.composer-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }

.feed-list { display: flex; flex-direction: column; gap: 14px; }
.feed-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.fc-head { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.fc-head .who { font-weight: 700; }
.fc-head .time { font-size: 12px; color: var(--faint); }
.fc-body { white-space: pre-wrap; word-break: break-word; margin-bottom: 12px; }
.fc-body a { color: var(--accent-2); }
.fc-img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; background: var(--panel-2); clip-path: var(--chamfer-sm); margin: 4px 0 12px; box-shadow: inset 0 0 0 1px var(--line); display: block; cursor: zoom-in; }
.img-preview { position: relative; margin: 10px 0 4px; display: inline-block; }
.img-preview img { max-height: 130px; clip-path: var(--chamfer-sm); display: block; box-shadow: inset 0 0 0 1px var(--line); }
.img-preview .rm { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.65); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 12px; }
.img-preview .rm:hover { background: var(--red); }
input[type="file"] { padding: 8px; font-family: inherit; color: var(--muted); cursor: pointer; }

/* Photo avatars */
img.avatar, .avatar.ava-img { object-fit: cover; padding: 0; }

/* Feed filter + profile edit */
.feed-filter { display: flex; gap: 6px; margin-bottom: 16px; }
.ff { border: 0; background: var(--panel-2); color: var(--muted); padding: 8px 16px; clip-path: var(--chamfer-sm); cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
.ff.on { background: var(--accent); color: #140b06; }
.pedit { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.pedit-row { display: flex; gap: 8px; }
.fc-actions { display: flex; gap: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.like-btn { display: flex; align-items: center; gap: 6px; background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; padding: 4px 8px; border-radius: 8px; }
.like-btn:hover { background: var(--panel-2); }
.like-btn.liked { color: var(--accent); }

.feed-rail .rail-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; position: sticky; top: 0; }
.rail-title { font-weight: 700; margin-bottom: 10px; }
.friend-results { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.friend-row { display: flex; align-items: center; gap: 10px; }
.friend-row .f-name { flex: 1; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row .btn { padding: 5px 11px; font-size: 13px; }

/* ── Chat view (sidebar + chat, inside a view) ───────────────────── */
.chat-view #sidebar { height: 100%; }
.chat-view #chat { height: 100%; }

/* ── Map view ─────────────────────────────────────────────────────── */
#map-full { width: 100%; height: 100%; }
.ride-map { width: 100%; height: 220px; border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--line); }
.leaflet-container { background: #0a0d11; }

/* ── Marketplace ──────────────────────────────────────────────────── */
.market-wrap { max-width: 1000px; margin: 0 auto; padding: 22px; }
.market-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.market-toolbar h2 { margin: 0; }
.market-tools { display: flex; gap: 8px; align-items: center; }
.market-tools input { width: 220px; }
.market-tools select, .field select {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none;
}
.field textarea {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical; outline: none;
}
.field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.listing { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.listing .l-img { height: 150px; background: var(--bg-2); display: grid; place-items: center; font-size: 40px; overflow: hidden; }
.listing .l-img img { width: 100%; height: 100%; object-fit: cover; }
.listing .l-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.listing .l-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 700; }
.listing .l-title { font-weight: 700; line-height: 1.3; }
.listing .l-price { font-size: 20px; font-weight: 800; color: var(--accent-2); }
.listing .l-desc { font-size: 13px; color: var(--muted); }
.listing .l-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--faint); }
.listing.sold { opacity: .7; }
.badge-sold { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.l-owner-actions { display: flex; gap: 6px; }
.l-owner-actions button { border: 0; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 12px; padding: 4px 8px; border-radius: 7px; }
.l-owner-actions button:hover { background: var(--line); }

/* ── Events ───────────────────────────────────────────────────────── */
.events-wrap { max-width: 900px; margin: 0 auto; padding: 22px; }
.events-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.events-toolbar h2 { margin: 0; }
.events-tools { display: flex; gap: 8px; align-items: center; }
.events-map { width: 100%; height: 300px; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 12px; }
.events-list { display: flex; flex-direction: column; gap: 12px; }
.event-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.ev-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ev-title { font-weight: 700; font-size: 16px; }
.ev-dist { font-size: 12px; color: var(--accent-2); font-weight: 700; white-space: nowrap; }
.ev-time { color: var(--muted); font-size: 13px; margin: 4px 0; }
.ev-desc { font-size: 14px; color: var(--muted); margin-bottom: 10px; white-space: pre-wrap; }
.ev-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rsvp-group { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 3px; }
.rsvp-group button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px 11px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.rsvp-group button.on { background: var(--accent); color: #fff; }
.ev-count { font-size: 13px; color: var(--muted); }
.ev-spacer { flex: 1; }

/* ── Garage ───────────────────────────────────────────────────────── */
.garage-wrap { max-width: 820px; margin: 0 auto; padding: 22px; }
.garage-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.garage-head h2 { margin: 0; }
.bikes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 22px; }
.bike-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; transition: border .12s ease; }
.bike-card:hover { border-color: var(--line-2); }
.bike-card.active { border-color: var(--accent); background: var(--accent-soft); }
.bike-emoji { font-size: 28px; }
.bike-img { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; display: block; box-shadow: inset 0 0 0 1px var(--line); }
.bike-card .bike-emoji { position: relative; }
.bike-card .bike-emoji:has(.bike-img) { font-size: 0; }
.bike-photo-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: rgba(11,12,14,.7); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.bike-photo-btn:hover { background: var(--accent); color: #140b06; }
.bike-photo-btn.busy { opacity: .5; pointer-events: none; }
.bike-photo-btn .ic { width: 15px; height: 15px; }
.bike-name { font-weight: 700; font-size: 16px; margin: 6px 0 2px; }
.bike-year { font-size: 13px; color: var(--muted); }
.bike-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.badge-primary { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.bike-actions { margin-left: auto; display: flex; gap: 6px; }
.bike-actions button { border: 0; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 12px; padding: 4px 8px; border-radius: 7px; }
.bike-actions button:hover { background: var(--line); }

.maint-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.maint-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.maint-head h3 { margin: 0; font-size: 16px; }
.logs-list { display: flex; flex-direction: column; gap: 8px; }
.log-row { display: flex; align-items: center; gap: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.log-date { font-size: 12px; color: var(--muted); width: 92px; flex-shrink: 0; }
.log-main { flex: 1; }
.log-kind { font-weight: 600; }
.log-meta { font-size: 12px; color: var(--faint); }
.log-cost { font-weight: 700; color: var(--accent-2); white-space: nowrap; }
.log-del { cursor: pointer; color: var(--red); padding: 2px 6px; border-radius: 6px; }
.log-del:hover { background: var(--line); }

/* ── Placeholder ("soon") views ──────────────────────────────────── */
.soon { max-width: 520px; margin: 8vh auto; text-align: center; padding: 22px; }
.soon-emoji { font-size: 52px; margin-bottom: 10px; }
.soon h2 { margin: 0 0 10px; }
.soon p { color: var(--muted); }
.soon code { background: var(--panel); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ── Rides view ───────────────────────────────────────────────────── */
#view-rides { padding: 22px; max-width: 800px; margin: 0 auto; }
.rides-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.rides-head h2 { margin: 0; }
.rides-map { width: 100%; height: 300px; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 12px; }
.ride-card { cursor: pointer; }
.ride-card:hover { border-color: var(--line-2); }
.ride-card.active { border-color: var(--accent); background: var(--accent-soft); }
.rides-list { display: flex; flex-direction: column; gap: 10px; }
.ride-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; gap: 18px; align-items: center; }
.ride-card .r-main { flex: 1; }
.ride-card .r-dist { font-size: 20px; font-weight: 800; color: var(--accent-2); }
.ride-card .r-meta { font-size: 13px; color: var(--muted); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid var(--bg-2); }
::-webkit-scrollbar-thumb:hover { background: #3d4757; }

@media (max-width: 720px) {
  #sidebar { width: 220px; }
  .msg-main { max-width: 82%; }
}

/* ═══════════════════════════════════════════════════════════════════
   RACE-SPEC SKIN (Stage 1) — global identity over the existing layout.
   Chamfered "number-plate" surfaces, uppercase display, mono telemetry.
   ═══════════════════════════════════════════════════════════════════ */

/* Chamfered large surfaces */
.auth-card, .composer-card, .feed-card, .rail-card, .listing,
.event-card, .bike-card, .ride-card, .maint-panel, .modal-card {
  clip-path: var(--chamfer);
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: inset 0 0 0 1px var(--line);
}
.ride-card.active, .bike-card.active { box-shadow: inset 0 0 0 1.5px var(--accent) !important; background: var(--accent-soft); }
.ride-card:hover, .bike-card:hover, .listing:hover { box-shadow: inset 0 0 0 1px var(--line-2); }

/* Chamfered small surfaces */
input, select, textarea, .nav-tab, .badge, .badge-sold, .badge-primary,
.chip, .avatar, .room-ava, .av, .metric, .log-row, .zone-row, .l-img,
.pillrow, .rsvp-group, .tabs, .stat, .friend-row .btn {
  clip-path: var(--chamfer-sm);
  border-radius: 0 !important;
}

/* Top nav — hazard edge + race pills */
#topnav { border-bottom: 2px solid var(--accent); }
.nav-brand { text-transform: uppercase; font-style: italic; letter-spacing: -.01em; }
.nav-tab { text-transform: uppercase; letter-spacing: .045em; font-weight: 800; font-size: 13px; }
.nav-tab.active { background: var(--accent); color: #140b06; }

/* Auth */
.brand-name { font-style: italic; text-transform: uppercase; }
.brand-tag { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
.tab { text-transform: uppercase; letter-spacing: .04em; }
.tab.active { background: var(--accent); color: #140b06; }

/* Section headings → display */
.garage-head h2, .market-toolbar h2, .events-toolbar h2, .rides-head h2,
.rail-title, .maint-head h3, .modal-head h3 {
  text-transform: uppercase; font-style: italic; font-weight: 900; letter-spacing: -.01em;
}

/* Telemetry / data → monospace, tabular */
.fc-head .time, .r-dist, .l-price, .ev-dist, .ev-time, .log-date, .log-cost,
.m-val, .conn-status, .side-section-title, .l-cat, .badge,
.badge-sold, .badge-primary {
  font-family: var(--mono);
}
.r-dist, .l-price, .m-val, .ev-dist, .log-cost { font-variant-numeric: tabular-nums; }
.badge, .badge-sold, .badge-primary, .l-cat { text-transform: uppercase; letter-spacing: .1em; }

/* Pills read dark-on-ignition when active */
.rsvp-group button.on { color: #140b06; }

/* Chat: race plate avatars + squared active room */
.rooms li.active { box-shadow: inset 0 0 0 1px var(--accent); }
.msg.mine .bubble { border-top-right-radius: 4px; }

/* ═══ Social depth: clickable users, profile, comments, likers ═════ */
.uname { color: var(--accent-2); cursor: pointer; font-weight: 700; }
.uname:hover { text-decoration: underline; }

/* Profile modal */
.profile-hd { display: flex; gap: 16px; align-items: center; margin-bottom: 6px; }
.profile-hd .avatar { width: 64px; height: 64px; font-size: 24px; }
.profile-name { font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 22px; letter-spacing: -.01em; }
.profile-counts { display: flex; gap: 22px; margin: 14px 0; }
.profile-counts .pc b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 800; }
.profile-counts .pc span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.profile-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.profile-posts { display: flex; flex-direction: column; gap: 10px; max-height: 42vh; overflow-y: auto; }
.profile-posts .feed-card { padding: 12px; }

/* User list rows */
.ulist { display: flex; flex-direction: column; gap: 8px; }
.urow { display: flex; align-items: center; gap: 11px; }
.urow .u-n { flex: 1; font-weight: 700; cursor: pointer; }
.urow .u-n:hover { color: var(--accent-2); }

/* Comments */
.fc-comments { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 11px; }
.comment { display: flex; gap: 9px; }
.comment .c-main { flex: 1; background: var(--panel-2); padding: 8px 12px; clip-path: var(--chamfer-sm); }
.comment .c-top { font-size: 13px; }
.comment .c-time { color: var(--faint); font-family: var(--mono); font-size: 11px; margin-left: 7px; }
.comment .c-body { font-size: 13.5px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; gap: 8px; }
.comment-form input { flex: 1; }
.cmt-empty { color: var(--faint); font-size: 13px; }

.fc-actions button { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px 9px; clip-path: var(--chamfer-sm); }
.fc-actions button:hover { background: var(--panel-2); color: var(--text); }
.fc-actions .like-btn.liked { color: var(--accent); }
.fc-actions .likers-btn { margin-left: auto; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

/* ═══ Direct messages (Üzenetek) ═══════════════════════════════════ */
.view.dm-view.active { display: flex; }
#dm-sidebar { width: 280px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--line); padding: 16px 12px; overflow-y: auto; }
#dm-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dm-convos { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.dm-convos li { display: flex; gap: 10px; align-items: center; padding: 9px 10px; clip-path: var(--chamfer-sm); cursor: pointer; }
.dm-convos li:hover { background: var(--panel); }
.dm-convos li.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.dm-convos .dc-main { flex: 1; min-width: 0; }
.dm-convos .dc-name { font-weight: 700; font-size: 14px; }
.dm-convos .dc-last { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dm-header { padding: 14px 22px; border-bottom: 1px solid var(--line); font-weight: 700; }
#dm-messages { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; }
.dm-msg { max-width: 70%; display: flex; flex-direction: column; }
.dm-msg.mine { align-self: flex-end; align-items: flex-end; }
.dm-msg .b { background: var(--panel-2); padding: 9px 13px; clip-path: var(--chamfer-sm); box-shadow: inset 0 0 0 1px var(--line); word-break: break-word; white-space: pre-wrap; }
.dm-msg.mine .b { background: var(--mine); color: #140b06; box-shadow: none; }
.dm-msg .t { font-size: 11px; color: var(--faint); font-family: var(--mono); margin: 2px 4px 0; }

/* ═══ Full profile page ════════════════════════════════════════════ */
#profile-view { max-width: 740px; margin: 0 auto; padding-bottom: 30px; }
.pf-cover { height: 180px; }
.pf-head { display: flex; align-items: flex-end; gap: 18px; padding: 0 22px; margin-top: -46px; flex-wrap: wrap; }
.pf-avatar .avatar { width: 100px; height: 100px; font-size: 36px; box-shadow: 0 0 0 4px var(--bg); }
.pf-avatar .avatar.ava-img { box-shadow: 0 0 0 4px var(--bg); }
.pf-idblock { flex: 1; min-width: 180px; padding-bottom: 4px; }
.pf-name { font-weight: 900; font-style: italic; text-transform: uppercase; font-size: 26px; letter-spacing: -.02em; }
.pf-stats { display: flex; gap: 18px; margin-top: 6px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pf-stat b { color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pf-stat.linkish { cursor: pointer; }
.pf-stat.linkish:hover { color: var(--accent-2); }
.pf-actions { display: flex; gap: 8px; padding-bottom: 6px; }
.pf-tabs { display: flex; gap: 4px; padding: 16px 22px 0; border-bottom: 1px solid var(--line); margin-top: 16px; }
.pf-tab { border: 0; background: transparent; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.pf-tab:hover { color: var(--text); }
.pf-tab.on { color: var(--text); border-bottom-color: var(--accent); }
#pf-content { padding: 18px 22px; }
.pf-feed { display: flex; flex-direction: column; gap: 14px; }
.pf-rides { display: flex; flex-direction: column; gap: 10px; }
.pf-edit { max-width: 440px; }

/* ═══ Top-nav global search ════════════════════════════════════════ */
.nav-search { position: relative; flex-shrink: 1; min-width: 130px; max-width: 250px; }
.nav-search input { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-2); padding: 9px 12px; }
.nav-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow); clip-path: var(--chamfer-sm); z-index: 60; max-height: 340px; overflow-y: auto; }
.nav-result { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; }
.nav-result:hover { background: var(--panel-2); }
.nav-result .avatar { width: 30px; height: 30px; font-size: 12px; }
.nav-result .nr-name { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-result .btn { margin-left: auto; padding: 4px 11px; font-size: 12px; }
.nav-head { padding: 9px 11px 6px; font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.nav-empty { padding: 11px; color: var(--muted); font-size: 13px; }

@media (max-width: 780px) { .nav-search { display: none; } }

/* Search icon inside the nav search box */
.nav-q-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.nav-search input { padding-left: 34px; }
/* Icon rhythm in buttons/labels */
.btn .ic { margin-right: 1px; }
.like-btn .heart .ic.filled { color: var(--accent); }
.ev-time .ic, .np-txt .ic { color: var(--faint); }

/* ═══ Responsive (mobile) ══════════════════════════════════════════ */
@media (max-width: 680px) {
  /* Messages: stack conversation list on top, thread below */
  .view.msg-view.active { flex-direction: column; }
  #msg-sidebar { width: 100%; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  /* Modals fill the screen comfortably */
  .modal { padding: 10px; }
  .modal-card { width: 100%; padding: 18px; }
  .notif-panel { width: min(92vw, 360px); }
  .user-menu { width: 200px; }
  /* Tighter section paddings */
  #view-feed.active, #view-rides, .market-wrap, .events-wrap, .garage-wrap { padding-left: 14px; padding-right: 14px; }
  .pf-name { font-size: 22px; }
  .pf-avatar .avatar { width: 84px; height: 84px; font-size: 30px; }
  /* Toolbars wrap */
  .market-toolbar, .events-toolbar, .section-head, .he-head, .rides-head, .garage-head { flex-wrap: wrap; gap: 10px; }
  .market-tools { flex-wrap: wrap; }
  .market-tools input { width: 100%; }
}
@media (max-width: 420px) {
  #topbar { gap: 8px; padding: 0 12px; }
  .tb-brand { font-size: 16px; }
}

/* ═══ Unified Messages view (rooms + DMs) ══════════════════════════ */
.view.msg-view.active { display: flex; }
#msg-sidebar { width: 288px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--line); padding: 16px 12px; overflow-y: auto; display: flex; flex-direction: column; }
#msg-sidebar .rooms { margin-bottom: 6px; }
#thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#thread .pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#thread .pane.hidden { display: none; }

/* ═══ Home: upcoming rides strip ═══════════════════════════════════ */
.home-events { margin-bottom: 20px; }
.he-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.he-head h3 { margin: 0; text-transform: uppercase; font-style: italic; font-weight: 900; letter-spacing: -.01em; font-size: 16px; }
.he-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.he-strip .event-card { min-width: 300px; max-width: 340px; flex-shrink: 0; }
.he-strip > .hint { padding: 10px 2px; }

/* Event-create modal map */
.event-map { width: 100%; height: 210px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px; }

/* ═══ Útvonaltervező (profi navi) ══════════════════════════════════ */
.view.planner-view.active { display: flex; }
.planner-panel { width: 360px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--line); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; }
.planner-panel .section-head { margin-bottom: 12px; }
#planner-map { flex: 1; min-width: 0; }

.pl-field { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pl-dot.start { background: var(--green); }
.pl-dot.end { background: var(--red); }
.pl-field input { flex: 1; }
.pl-here { border: 0; background: var(--panel-2); color: var(--text); width: 38px; height: 38px; clip-path: var(--chamfer-sm); cursor: pointer; flex-shrink: 0; display: grid; place-items: center; }
.pl-here:hover { background: var(--line); color: var(--accent-2); }
.pl-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow); clip-path: var(--chamfer-sm); z-index: 30; max-height: 260px; overflow-y: auto; }
.pl-result { padding: 9px 11px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pl-result:hover { background: var(--panel-2); }

.pl-modes { display: flex; gap: 6px; margin: 4px 0 12px; }
.pl-mode { flex: 1; border: 0; background: var(--panel-2); color: var(--muted); padding: 9px; clip-path: var(--chamfer-sm); cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: 12px; }
.pl-mode.on { background: var(--accent); color: #140b06; }
.pl-clear { border: 0; background: var(--panel-2); color: var(--muted); width: 38px; clip-path: var(--chamfer-sm); cursor: pointer; display: grid; place-items: center; }
.pl-clear:hover { background: var(--line); color: var(--red); }

.pl-summary { padding: 4px 2px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.pl-sum-main { font-family: var(--mono); font-size: 15px; }
.pl-sum-main b { font-size: 20px; color: var(--accent-2); }
.pl-sum-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

.pl-steps { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.pl-step { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 8px; cursor: pointer; }
.pl-step:hover { background: var(--panel); }
.pl-arrow { font-size: 18px; width: 22px; text-align: center; color: var(--accent-2); flex-shrink: 0; }
.pl-step-text { flex: 1; font-size: 13px; }
.pl-step-dist { font-family: var(--mono); font-size: 12px; color: var(--muted); flex-shrink: 0; }

@media (max-width: 780px) {
  .view.planner-view.active { flex-direction: column; }
  .planner-panel { width: 100%; max-height: 46vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #planner-map { min-height: 300px; }
}
.he-actions { display: flex; gap: 8px; }

/* ═══ App shell: top bar + left rail ═══════════════════════════════ */
#topbar { display: flex; align-items: center; gap: 16px; height: 58px; flex-shrink: 0; padding: 0 18px; background: var(--bg-2); border-bottom: 2px solid var(--accent); position: relative; z-index: 45; }
.tb-brand { font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: -.01em; font-size: 18px; display: flex; align-items: center; gap: 8px; cursor: pointer; flex-shrink: 0; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tb-icon { position: relative; background: var(--panel-2); border: 0; color: var(--text); width: 40px; height: 40px; clip-path: var(--chamfer-sm); cursor: pointer; font-size: 17px; }
.tb-icon:hover { background: var(--line); }
.tb-user { display: flex; align-items: center; gap: 9px; background: var(--panel-2); border: 0; color: var(--text); padding: 5px 12px 5px 6px; clip-path: var(--chamfer-sm); cursor: pointer; }
.tb-user:hover { background: var(--line); }
.tb-user .me-name { font-weight: 700; font-size: 14px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-dot { display: inline-flex; }
.conn-dot .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: block; }
.conn-dot.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn-dot.offline .dot { background: var(--red); }
.badge { position: absolute; top: -4px; right: -4px; background: var(--accent); color: #140b06; font-size: 10px; font-weight: 800; min-width: 16px; height: 16px; border-radius: 9px; display: grid; place-items: center; padding: 0 3px; }

#shell { flex: 1; display: flex; min-height: 0; }
#railnav { width: 190px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.rail-item { position: relative; display: flex; align-items: center; gap: 12px; background: transparent; border: 0; color: var(--muted); padding: 11px 12px; clip-path: var(--chamfer-sm); cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: 13px; text-align: left; }
.rail-item .ri-ic { font-size: 18px; width: 20px; text-align: center; }
.rail-item:hover { background: var(--panel); color: var(--text); }
.rail-item.active { background: var(--accent-soft); color: var(--accent-2); box-shadow: inset 3px 0 0 var(--accent); }
.rail-item .badge { position: static; margin-left: auto; }
#views { flex: 1; overflow: hidden; position: relative; }

/* Notifications panel */
.notif-wrap, .user-wrap { position: relative; }
.notif-panel { position: absolute; top: calc(100% + 8px); right: 0; width: 330px; max-height: 72vh; overflow-y: auto; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow); clip-path: var(--chamfer); z-index: 60; }
.np-head { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); padding: 12px 14px 8px; }
.np-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 14px; cursor: pointer; }
.np-item:hover { background: var(--panel-2); }
.np-item.unread { background: var(--accent-soft); }
.np-txt { font-size: 13px; }
.np-time { font-size: 11px; color: var(--faint); font-family: var(--mono); margin-top: 2px; }

/* User menu */
.user-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 190px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow); clip-path: var(--chamfer-sm); z-index: 60; padding: 4px; }
.um-item { padding: 10px 12px; clip-path: var(--chamfer-sm); cursor: pointer; font-weight: 600; font-size: 14px; }
.um-item:hover { background: var(--panel-2); }

/* Unread badge in message lists */
.unread-dot { margin-left: auto; background: var(--accent); color: #140b06; font-size: 10px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 10px; display: grid; place-items: center; padding: 0 4px; flex-shrink: 0; }

/* Section header (events etc.) */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin: 0; text-transform: uppercase; font-style: italic; font-weight: 900; letter-spacing: -.01em; }

/* Mobile: rail → bottom icon bar */
@media (max-width: 820px) {
  #railnav { position: fixed; bottom: 0; left: 0; right: 0; width: auto; height: 60px; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 6px; z-index: 50; justify-content: space-around; gap: 0; }
  .rail-item { flex-direction: column; gap: 2px; padding: 6px 4px; flex: 1; align-items: center; text-align: center; }
  .rail-item .ri-tx { font-size: 9px; letter-spacing: 0; }
  .rail-item.active { box-shadow: none; }
  #shell { padding-bottom: 0; }
  #views { padding-bottom: 60px; }
  .tb-user .me-name { display: none; }
  .nav-search { display: none; }
}

/* ═══ Stage 2 — HUD hero + header accents ═══════════════════════════ */

/* Ignition accent bar above each view heading */
.garage-head h2::before, .market-toolbar h2::before,
.events-toolbar h2::before, .rides-head h2::before {
  content: ""; display: block; width: 34px; height: 3px;
  background: var(--accent); margin-bottom: 9px; clip-path: var(--chamfer-sm);
}

/* Ride simulator → proper telemetry HUD: big current speed on top */
.metrics-grid { grid-template-columns: repeat(3, 1fr); }
.metric:first-child {
  grid-column: 1 / -1; text-align: center; padding: 18px 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.metric:first-child .m-val {
  font-size: 56px; line-height: 1; font-weight: 800;
}
.metric:first-child .m-lbl { font-size: 12px; letter-spacing: .22em; }

/* HUD-style current-value color pop on the ride modal */
#m-cur { background: var(--mine); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.ride-map, .events-map, .rides-map { clip-path: var(--chamfer); border: 0 !important; box-shadow: inset 0 0 0 1px var(--line); }
.ride-status { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }

/* ── Gamification: profile level + achievements ─────────────────────────── */
.pf-level { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.lvl-badge { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #0a0b0d; background: var(--accent); padding: 4px 10px; clip-path: var(--chamfer-sm); font-weight: 700; }
.xpbar { flex: 1; max-width: 260px; height: 10px; background: var(--bg); border: 1px solid var(--line); clip-path: var(--chamfer-sm); overflow: hidden; }
.xpbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--hazard)); }
.xp-num { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.pf-ach { display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.ach-head { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 4px 2px; }
.ach-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); clip-path: var(--chamfer-sm); }
.ach-item.locked { opacity: .45; }
.ach-ic { width: 38px; height: 38px; display: grid; place-items: center; background: var(--panel-2); clip-path: var(--chamfer-sm); color: var(--faint); }
.ach-item.on .ach-ic { background: var(--accent-soft); color: var(--hazard); }
.ach-ic .ic { width: 20px; height: 20px; }
.ach-tx { flex: 1; }
.ach-name { font-weight: 600; color: var(--text); }
.ach-desc { font-size: 13px; color: var(--muted); }
.ach-xp { font-family: var(--mono); font-weight: 700; color: var(--hazard); }

/* ── Leaderboard ────────────────────────────────────────────────────────── */
.lb-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.lb-seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); clip-path: var(--chamfer-sm); padding: 3px; }
.lb-seg button { border: 0; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; padding: 7px 14px; cursor: pointer; clip-path: var(--chamfer-sm); }
.lb-seg button.on { background: var(--accent); color: #0a0b0d; font-weight: 700; }
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); clip-path: var(--chamfer-sm); }
.lb-row.me { border-color: var(--accent); background: linear-gradient(100deg, var(--accent-soft), transparent); }
.lb-rank { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--muted); width: 26px; text-align: center; }
.lb-rank.top { color: var(--accent); }
.lb-main { flex: 1; display: flex; flex-direction: column; }
.lb-name { font-weight: 600; color: var(--text); cursor: pointer; }
.lb-sub { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.lb-val { font-family: var(--mono); font-weight: 700; color: var(--text); }

/* ── Event detail: route map + itinerary ────────────────────────────────── */
.modal-lg { max-width: 900px; width: 94vw; }
.evd-body { display: flex; gap: 16px; }
.evd-map { flex: 1; min-height: 420px; height: 60vh; clip-path: var(--chamfer); box-shadow: inset 0 0 0 1px var(--line); }
.evd-side { width: 320px; display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
.evd-itinerary { display: flex; flex-direction: column; gap: 8px; }
.evd-wp { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--panel); border: 1px solid var(--line); clip-path: var(--chamfer-sm); }
.evd-wp.mine { border-color: var(--accent); background: linear-gradient(100deg, var(--accent-soft), transparent); }
.wp-num { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; background: var(--accent); color: #0a0b0d; font-family: var(--mono); font-weight: 700; font-size: 12px; border-radius: 50%; }
.wp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wp-label { font-weight: 600; color: var(--text); }
.wp-eta { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.wp-eta .ic { width: 13px; height: 13px; }
.wp-cnt { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.wp-label-in, .wp-eta-in { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 6px 8px; font-size: 13px; border-radius: 6px; }
.wp-del { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; }
.wp-del .ic { width: 16px; height: 16px; }
.evd-hostbar { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.evd-editrow { display: flex; gap: 8px; }
.evd-editrow .btn { flex: 1; }
.wp-pin { width: 26px; height: 26px; display: grid; place-items: center; background: var(--accent); color: #0a0b0d; font-family: var(--mono); font-weight: 700; font-size: 13px; border-radius: 50%; border: 2px solid #0a0b0d; box-shadow: 0 0 0 1px var(--accent); }
.wp-pin.mine { background: var(--hazard); }
@media (max-width: 720px) { .evd-body { flex-direction: column; } .evd-side { width: auto; } .evd-map { height: 40vh; min-height: 260px; } }

/* Reaction icons (SVG, no emoji) — explicit colors so they read clearly */
.chip { display: inline-flex; align-items: center; gap: 5px; }
.act { color: var(--text); }
.act .ic { width: 19px; height: 19px; }
.chip .ic { width: 16px; height: 16px; color: var(--text); }
.chip.mine .ic { color: var(--accent); }
/* Tap-to-reveal the action bar on touch (mobile webview has no hover) */
.msg.open .msg-actions { display: flex; }

/* Inline chat images */
.msg-img { max-width: min(280px, 72%); max-height: 320px; margin-top: 3px; display: block; clip-path: var(--chamfer-sm); box-shadow: inset 0 0 0 1px var(--line); cursor: zoom-in; }
.msg.mine .msg-img { margin-left: auto; }

/* Icon-only round buttons: keep the glyph dead-centered */
.btn-send { padding: 0; }
.btn-send .ic { margin: 0; width: 20px; height: 20px; }

/* Back button in chat/DM headers — hidden on desktop, shown on mobile */
.thread-back { display: none; background: var(--panel-2); border: 0; color: var(--text);
  width: 38px; height: 38px; clip-path: var(--chamfer-sm); cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0; }
.thread-back .ic { width: 20px; height: 20px; transform: scaleX(-1); }
.thread-back:hover { background: var(--line); }

/* ═══════════════════════════════════════════════════════════════════
   PREMIUM MOBILE (≤820px) — genuine responsive layout. Works in any phone
   browser AND inside the native Közösség WebView. The section nav becomes a
   horizontal pill strip under a slim topbar (so it never fights a bottom
   bar), and Messages uses a real native list↔thread flow (full-screen list,
   tap a conversation → full-screen thread with a back button).
   App-only refinements (notch/home-indicator safe areas) live under
   html.rh-embedded further down.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 820px) {
  /* Slim topbar, drop desktop-only chrome */
  #topbar { height: auto; min-height: 52px; gap: 10px; flex-wrap: nowrap; padding: 8px 12px; }
  .tb-brand { font-size: 16px; }
  .nav-search { display: none; }
  .conn-dot { display: none; }
  .tb-right { gap: 8px; }
  .tb-icon { width: 42px; height: 42px; }
  .tb-user { padding: 6px 10px 6px 6px; }
  .tb-user .me-name { display: none; }
  #me-avatar { width: 34px; height: 34px; font-size: 14px; }

  /* Section nav → top horizontal scroll pills (overrides the old bottom bar) */
  #shell { flex-direction: column; min-height: 0; padding-bottom: 0; }
  #railnav {
    position: static; width: auto; height: auto; flex: 0 0 auto;
    flex-direction: row; gap: 7px; justify-content: flex-start;
    border-right: 0; border-top: 0; border-bottom: 1px solid var(--line);
    padding: 9px 12px; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; background: var(--bg-2); z-index: 40;
  }
  #railnav::-webkit-scrollbar { display: none; }
  .rail-item {
    flex: 0 0 auto; flex-direction: row; gap: 7px; align-items: center;
    padding: 9px 15px; font-size: 12px; letter-spacing: .04em; white-space: nowrap;
    background: var(--panel-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line);
  }
  .rail-item .ri-ic { width: 18px; font-size: 16px; text-align: center; }
  .rail-item .ri-tx { font-size: 12px; letter-spacing: .04em; }
  .rail-item.active { background: var(--accent); color: #140b06; box-shadow: none; }
  .rail-item .badge { position: static; margin-left: 4px; }
  #views { flex: 1; min-height: 0; padding-bottom: 0; }

  /* Native tap targets + iOS no-zoom inputs (≥16px avoids focus zoom) */
  .btn { padding: 12px 16px; }
  /* Icon-only buttons: re-assert 0 padding (the .btn rule above would offset
     the glyph) and hard-center via flex so the send/attach icons sit dead centre */
  .btn-send { padding: 0; width: 46px; height: 46px; display: inline-flex;
    align-items: center; justify-content: center; flex: 0 0 auto; }
  .btn-send .ic { margin: 0; display: block; }
  .btn-icon { padding: 0; width: 46px; height: 46px; display: inline-flex;
    align-items: center; justify-content: center; flex: 0 0 auto; }
  .btn-icon .ic { margin: 0; display: block; }
  input, textarea, select { font-size: 16px; }
  .rail-item, .btn, .tb-icon, .fc-actions button, .nav-tab, .thread-back { -webkit-tap-highlight-color: transparent; }

  /* Comfortable section paddings on a phone canvas */
  #view-feed.active, #view-rides, .market-wrap, .events-wrap,
  .garage-wrap { padding-left: 14px; padding-right: 14px; }
  .feed-col { max-width: 100%; }

  /* ── Messages: native list ↔ thread flow ────────────────────────── */
  .view.msg-view.active { display: flex; flex-direction: column; }
  #msg-sidebar { width: 100%; max-height: none; flex: 1; min-height: 0;
    border-right: 0; border-bottom: 0; padding: 12px; }
  #thread { display: none; }
  .msg-view.thread-open #msg-sidebar { display: none; }
  .msg-view.thread-open #thread { display: flex; flex: 1; width: 100%; min-width: 0; }
  .thread-back { display: inline-flex; }
  #chat-header, #dm-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
  #chat-header .ch-head-main, #dm-header .ch-title { flex: 1; min-width: 0; }
  #chat-header .ch-title, #dm-header .ch-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #messages, #dm-messages { padding: 14px; }
  .msg-main, .dm-msg { max-width: 86%; }
  /* Reactions/action bar reveal on TAP (.msg.open) — never always-on */
  .composer { padding: 10px 12px; }

  /* Toolbars & grids stack cleanly */
  .market-toolbar, .events-toolbar, .section-head, .he-head, .rides-head,
  .garage-head, .market-tools { flex-wrap: wrap; gap: 10px; }
  .market-tools input { width: 100%; }
  .modal { padding: 10px; }
  .modal-card { width: 100%; padding: 18px; }

  /* Dropdowns stay inside the frame — never bleed off-screen */
  .notif-panel { position: fixed; top: calc(env(safe-area-inset-top) + 56px);
    left: 8px; right: 8px; width: auto; max-height: 70vh; }
  .user-menu { position: fixed; top: calc(env(safe-area-inset-top) + 56px);
    right: 8px; left: auto; width: 220px; }

  /* Kill ALL horizontal scroll on mobile — nothing scrolls sideways */
  html, body { max-width: 100%; overflow-x: hidden; }
  .view { overflow-x: hidden; }
  img, video, canvas, .leaflet-container, table { max-width: 100%; }
  #profile-view, .pf-head, .pf-stats, .pf-content { max-width: 100%; }
  /* Cover is full-bleed on mobile; the inner sections carry their own padding. */
  #profile-view { padding-left: 0; padding-right: 0; }
  .pf-cover { width: 100%; }
  .pf-head { padding-left: 14px; padding-right: 14px; }
  .pf-tabs { padding-left: 14px; padding-right: 14px; }
  #pf-content { padding-left: 14px; padding-right: 14px; }
  /* Profile tabs scroll internally, not the page */
  .pf-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .pf-tabs::-webkit-scrollbar { display: none; }
  .pf-tab { flex: 0 0 auto; white-space: nowrap; }
}

/* ═══ Toasts (non-blocking notifications) ══════════════════════════ */
#toast-wrap {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px;
  z-index: 200; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: var(--panel); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent), var(--shadow);
  clip-path: var(--chamfer-sm); padding: 11px 16px; font-size: 14px; font-weight: 600;
  opacity: 0; transform: translateY(10px); transition: opacity .25s ease, transform .25s ease;
  word-break: break-word;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ═══ Boot splash — no login flash while a saved token is validated ═══ */
html.rh-authpending #auth { display: none !important; }
html.rh-authpending::before {
  content: ''; position: fixed; inset: 0; background: var(--bg); z-index: 9998;
}
html.rh-authpending::after {
  content: ''; position: fixed; top: 50%; left: 50%; width: 34px; height: 34px;
  margin: -17px 0 0 -17px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: rh-spin .8s linear infinite; z-index: 9999;
}
@keyframes rh-spin { to { transform: rotate(360deg); } }

/* ═══ App-only refinements when running inside the native WebView ═══ */
html.rh-embedded, html.rh-embedded body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.rh-embedded #app { height: 100vh; height: 100dvh; }
html.rh-embedded #topbar { padding-top: max(8px, env(safe-area-inset-top)); }
html.rh-embedded .view { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* ═══════════════════════════════════════════════════════════════════
   MESSAGES-ONLY (chromeless) — the native Üzenetek tab shows ONLY the chat.
   No topbar, no section nav, no other views: just conversations + thread,
   full-screen. Reuses the full-featured web chat (DM reactions/reply/edit/
   delete/image). Activated by <html class="rh-messages-only">.
   ═══════════════════════════════════════════════════════════════════ */
html.rh-messages-only, html.rh-messages-only body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.rh-messages-only #app { height: 100vh; height: 100dvh; }
html.rh-messages-only #topbar,
html.rh-messages-only #railnav { display: none !important; }
html.rh-messages-only #shell { flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); }
html.rh-messages-only #views { flex: 1; min-height: 0; }
/* Only the messages view is ever visible in this mode. */
html.rh-messages-only .view:not(.msg-view) { display: none !important; }
html.rh-messages-only .view.msg-view { display: flex; flex-direction: column; height: 100%; }
html.rh-messages-only .view { padding-bottom: env(safe-area-inset-bottom); }

/* Profile-only (chromeless) mode: native Profil tab shows just the web profile. */
html.rh-profile-only, html.rh-profile-only body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.rh-profile-only #app { height: 100vh; height: 100dvh; }
html.rh-profile-only #topbar,
html.rh-profile-only #railnav { display: none !important; }
html.rh-profile-only #shell { flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); }
html.rh-profile-only #views { flex: 1; min-height: 0; overflow-y: auto; }
html.rh-profile-only .view:not(#view-profile) { display: none !important; }
html.rh-profile-only #view-profile { display: block; padding-bottom: env(safe-area-inset-bottom); }

/* Section-only (chromeless) mode: native shell shows a single web section
   (events / market / garage) with no topbar/railnav. */
html.rh-section-only, html.rh-section-only body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.rh-section-only #app { height: 100vh; height: 100dvh; }
html.rh-section-only #topbar,
html.rh-section-only #railnav { display: none !important; }
html.rh-section-only #shell { flex-direction: column; min-height: 0; padding-top: env(safe-area-inset-top); }
html.rh-section-only #views { flex: 1; min-height: 0; overflow-y: auto; }
html.rh-section-only .view { padding-bottom: env(safe-area-inset-bottom); }

/* ── Famous route segments (KOM) ──────────────────────────────────────────── */
.lb-mode { max-width: 320px; margin: 0 0 14px; }
.seg-list { display: flex; flex-direction: column; gap: 10px; }
.seg-card {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; transition: border-color .12s, background .12s;
}
.seg-card:hover { border-color: #a855f7; background: var(--panel-2); }
.seg-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.seg-name { font-weight: 800; font-size: 15px; color: var(--text); letter-spacing: -.01em; }
.seg-sub { font-size: 12px; color: var(--muted); }
.seg-kom { font-size: 12px; color: #c084fc; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.seg-kom .ic { width: 13px; height: 13px; }
.seg-kom-empty { color: var(--muted); font-weight: 500; font-style: italic; }
.seg-chevron { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }

.segd-meta { margin-bottom: 12px; }
.segd-desc { font-size: 13px; color: var(--text); line-height: 1.5; }
.segd-stats { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.segd-mybest { color: #c084fc; font-weight: 700; }
.segd-warn {
  display: flex; align-items: center; gap: 7px; margin: 12px 0 0;
  font-size: 11px; color: var(--accent-2); background: var(--accent-soft);
  border-radius: 8px; padding: 8px 10px; line-height: 1.4;
}
.segd-warn .ic { width: 14px; height: 14px; flex-shrink: 0; }
.seg-lb { display: flex; flex-direction: column; gap: 6px; }
.seg-lb-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0 2px; }
#segc-map, #segd-map { min-height: 340px; }

/* ── Feed: post edit/delete + comment likes/replies/edit ───────────────────── */
.fc-menu { display: flex; gap: 4px; margin-left: auto; }
.fc-menu button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.fc-menu button:hover { color: var(--text); background: var(--panel-2); }
.fc-menu .fc-del:hover { color: var(--red); }
.fc-menu .ic { width: 15px; height: 15px; }
.edited-tag { color: var(--faint); font-style: italic; }
.fc-edit-box { margin: 4px 0 12px; }
.fc-edit-box textarea { width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--line-2); color: var(--text); border-radius: 10px; padding: 10px; font-size: 14px; resize: vertical; }
.fc-edit-actions { display: flex; gap: 8px; margin-top: 8px; }
.fc-edit-actions .btn { padding: 7px 14px; }

.c-actions { display: flex; align-items: center; gap: 14px; margin-top: 5px; }
.c-actions button { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; padding: 2px 0; display: inline-flex; align-items: center; gap: 4px; }
.c-actions button:hover { color: var(--text); }
.c-actions .c-like.liked { color: var(--accent); }
.c-actions .c-like .ic { width: 13px; height: 13px; }
.c-actions .c-del:hover { color: var(--red); }
.c-replies { margin-top: 8px; padding-left: 16px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.comment-reply { margin: 0; }
.reply-form { margin-top: 8px; }
.c-edit-input { width: 100%; box-sizing: border-box; }

/* ── Event create: geocoder stops builder ─────────────────────────────────── */
.ev-cover { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; display: block; cursor: zoom-in; }
.ev-search-wrap { position: relative; }
.ev-hits { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; max-height: 240px; overflow-y: auto; box-shadow: var(--shadow); }
.ev-hits.hidden { display: none; }
.ev-hit { padding: 10px 12px; font-size: 13px; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--line); }
.ev-hit:last-child { border-bottom: 0; }
.ev-hit:hover { background: var(--panel-2); color: var(--accent-2); }
.ev-stops { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.ev-stop { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.ev-stop .wp-num { flex-shrink: 0; }
.ev-stop-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ev-stop-ops { display: flex; align-items: center; gap: 2px; }
.ev-stop-ops button { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; font-size: 11px; }
.ev-stop-ops button:hover { color: var(--text); background: var(--panel-2); }
.ev-stop-ops .ev-rm:hover { color: var(--red); }
.ev-stop-ops .ic { width: 14px; height: 14px; }

/* ── Goers, mentions, galleries, misc ─────────────────────────────────────── */
.avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.ev-goers { display: flex; align-items: center; gap: -6px; margin-top: 8px; }
.ev-goers .avatar { margin-right: -6px; border: 2px solid var(--panel); }
.ev-goers-txt { margin-left: 12px; font-size: 12px; color: var(--muted); }

.mention { color: var(--accent-2); font-weight: 700; cursor: pointer; }
.mention:hover { text-decoration: underline; }
.mention-menu { position: fixed; z-index: 1200; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.mm-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 13px; color: var(--text); }
.mm-item:hover { background: var(--panel-2); }
.mm-item .avatar { flex-shrink: 0; }

.img-preview.hidden { display: none; }
.ip-thumb { position: relative; display: inline-block; margin: 6px 6px 0 0; }
.ip-thumb img { height: 88px; width: 88px; object-fit: cover; border-radius: 8px; display: block; box-shadow: inset 0 0 0 1px var(--line); }
.ip-thumb .rm { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.7); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.ip-thumb .rm:hover { background: var(--red); }

.fc-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 4px 0 12px; border-radius: 10px; overflow: hidden; }
.fc-gallery.n1 { grid-template-columns: 1fr; }
.fc-grid-img { height: 180px; width: 100%; object-fit: cover; margin: 0; border-radius: 0; max-height: none; background: var(--panel-2); }

.r-share { margin-left: auto; }

/* ── Image orientation (honour EXIF) + full-screen lightbox ────────────────── */
img { image-orientation: from-image; }
.pf-cover, .pf-avatar .avatar.ava-img { cursor: zoom-in; }
.l-img img { cursor: zoom-in; }
.img-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 16px);
  cursor: zoom-out;
}
.img-lightbox.hidden { display: none; }
.img-lightbox img {
  max-width: 96vw; max-height: 92vh;
  width: auto; height: auto; object-fit: contain;
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.img-lightbox-x {
  position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 14px;
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(20, 22, 26, 0.8); color: #fff; font-size: 24px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.img-lightbox-x:hover { background: rgba(40, 44, 50, 0.9); }
