/* Flock — light, friendly, beige. Imports zlef tokens.css for type/space/radius
   scale only; colours are a bespoke light palette (DA dark theme overridden by
   explicit product direction: light theme, beige touch colour). */
:root {
  --paper:     #f6efe2;
  --paper-2:   #efe6d4;
  --surface:   #fffdf8;
  --surface-2: #fbf6ec;
  --ink:       #2c2620;
  --ink-soft:  #6f6557;
  --ink-faint: #9a9080;
  --line:      rgba(60,48,30,.13);
  --line-2:    rgba(60,48,30,.22);

  --beige:      #c9a86a; /* touch colour */
  --beige-deep: #a9844c;
  --beige-soft: #ead8b6;
  --beige-wash: #f1e6cf;
  --on-beige:   #2a2114;

  --danger: #c2566a;
  --ok: #5aa85a;

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 26px;
  --sh-1: 0 1px 2px rgba(60,40,15,.08);
  --sh-2: 0 8px 26px rgba(70,50,20,.13);
  --sh-3: 0 18px 50px rgba(70,50,20,.20);
  --font: var(--zl-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fbf4e6 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #f3e9d6 0%, transparent 55%),
    var(--paper);
  font-size: 16.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; font-size: 16px; }

/* ── topbar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(246,239,226,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(140deg, var(--beige), var(--beige-deep));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4), var(--sh-1);
  position: relative;
}
.brand-mark::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(169,132,76,.5);
}
.brand-name { font-weight: 750; font-size: 21px; letter-spacing: -.02em; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; font-size: 20px;
  color: var(--ink); box-shadow: var(--sh-1); transition: transform .15s, box-shadow .2s, background .2s;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.ghost { background: rgba(255,255,255,.7); }
.avatar-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--beige); box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }

/* ── views ──────────────────────────────────────────────────────────── */
.view { max-width: 920px; margin: 0 auto; padding: clamp(16px, 4vw, 36px) clamp(16px, 4vw, 40px) 80px; animation: rise .4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.hero { padding: clamp(18px, 5vw, 48px) 0 clamp(10px, 3vw, 24px); }
.hero-title { font-size: clamp(32px, 6vw, 52px); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 780; }
.hero-blurb { font-size: clamp(16px, 2.2vw, 19px); color: var(--ink-soft); max-width: 620px; margin: 0; }

.panel { margin-top: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-faint); margin: 0; font-weight: 700; }

.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.group-card {
  position: relative; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-lg); padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--sh-1); transition: transform .16s, box-shadow .22s, border-color .2s;
}
.group-card:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--line-2); }
.gc-name { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.gc-meta { color: var(--ink-soft); font-size: 14.5px; }
.gc-code { margin-top: 6px; font-family: var(--zl-font-mono, monospace); font-size: 13px; letter-spacing: .18em; color: var(--beige-deep); background: var(--beige-wash); align-self: flex-start; padding: 3px 9px; border-radius: 6px; }
.gc-badge { position: absolute; top: 14px; right: 16px; color: var(--beige-deep); font-size: 16px; }
.skeleton-card { height: 104px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-2), #fff7ea, var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty-note { color: var(--ink-soft); grid-column: 1/-1; padding: 8px 2px; }

.forms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 26px; }
.mini-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--sh-1); }
.mini-card h3 { margin: 0 0 12px; font-size: 16px; }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; min-width: 0; }
input, .code-input {
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-md); padding: 11px 13px; outline: none; transition: border-color .18s, box-shadow .18s, background .2s;
}
input:focus { border-color: var(--beige-deep); box-shadow: 0 0 0 3px rgba(201,168,106,.25); background: #fff; }
.code-input { text-transform: uppercase; letter-spacing: .22em; font-family: var(--zl-font-mono, monospace); }

.btn {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  border-radius: var(--r-md); padding: 11px 18px; font-weight: 650; font-size: 15.5px;
  transition: transform .14s, box-shadow .2s, background .2s, border-color .2s; box-shadow: var(--sh-1);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: linear-gradient(160deg, var(--beige), var(--beige-deep)); color: var(--on-beige); border-color: transparent; font-weight: 720; }
.btn.primary:hover { box-shadow: 0 10px 26px rgba(169,132,76,.4); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--danger); border-color: rgba(194,86,106,.4); }
.btn.full { width: 100%; }

.devices-hint { margin-top: 34px; color: var(--ink-faint); font-size: 14.5px; text-align: center; border-top: 1px dashed var(--line-2); padding-top: 22px; }

/* ── MAP VIEW ───────────────────────────────────────────────────────── */
.map-view { position: fixed; inset: 0; z-index: 40; }
#map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }

.glass {
  background: rgba(255,253,248,.86);
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid rgba(255,255,255,.6); box-shadow: var(--sh-2);
}

.map-top {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 5;
  display: flex; align-items: center; gap: 10px; border-radius: var(--r-lg); padding: 8px 10px;
}
.map-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.mt-name { font-weight: 720; font-size: 18px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-sub { font-size: 13px; color: var(--ink-soft); display: flex; gap: 5px; align-items: center; }
.live { display: inline-flex; align-items: center; gap: 5px; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.live.on { color: var(--ok); } .live.on::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(90,168,90,.2); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(90,168,90,0); } }

.style-switch { position: absolute; top: calc(70px + env(safe-area-inset-top)); left: 12px; z-index: 5; display: flex; gap: 2px; border-radius: var(--r-md); padding: 4px; }
.style-switch button { border: none; background: transparent; color: var(--ink-soft); padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 14px; transition: background .2s, color .2s; }
.style-switch button.active { background: var(--beige); color: var(--on-beige); box-shadow: var(--sh-1); }

.fab { position: absolute; z-index: 5; width: 46px; height: 46px; border-radius: 14px; border: none; display: grid; place-items: center; font-size: 20px; color: var(--ink); transition: transform .14s, box-shadow .2s; }
.fab:active { transform: scale(.93); }
.fab.fit { right: 12px; bottom: calc(150px + env(safe-area-inset-bottom)); }
.fab.locate { right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); }
.loc-ico { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--beige-deep); position: relative; }
.loc-ico::after { content: ''; position: absolute; inset: 0; margin: auto; width: 5px; height: 5px; border-radius: 50%; background: var(--beige-deep); }
.fab.locate.locating .loc-ico { display: none; }
.loc-spin { display: none; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--beige-wash); border-top-color: var(--beige-deep); animation: spin .8s linear infinite; }
.fab.locate.locating .loc-spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.members-dock { position: absolute; left: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 5; width: min(320px, 72vw); border-radius: var(--r-lg); overflow: hidden; }
.dock-handle { width: 100%; border: none; background: transparent; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font-weight: 650; color: var(--ink); font-size: 15px; }
.dock-count { background: var(--beige-wash); color: var(--beige-deep); border-radius: 999px; padding: 1px 9px; font-size: 13px; font-weight: 700; }
.dock-list { max-height: 0; overflow-y: auto; transition: max-height .3s ease; }
.members-dock.open .dock-list { max-height: min(46vh, 360px); border-top: 1px solid var(--line); }
.member-row { width: 100%; border: none; background: transparent; display: flex; align-items: center; gap: 11px; padding: 11px 16px; text-align: left; transition: background .15s; }
.member-row:hover { background: var(--beige-wash); }
.mr-dot { width: 13px; height: 13px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.mr-info { display: flex; flex-direction: column; min-width: 0; }
.mr-name { font-weight: 640; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-sub { font-size: 13px; color: var(--ink-soft); }

.share-bar { position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.share-btn { pointer-events: auto; display: inline-flex; align-items: center; gap: 10px; padding: 15px 26px; border-radius: 999px; font-size: 16.5px; font-weight: 700;
  background: linear-gradient(160deg, var(--beige), var(--beige-deep)); color: var(--on-beige); border: none; box-shadow: 0 10px 30px rgba(169,132,76,.45); }
.share-btn .share-ico { width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.4); }
.share-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-2); }
.share-btn.on .share-ico { background: var(--ok); box-shadow: 0 0 0 3px rgba(90,168,90,.3); animation: pulse 1.6s infinite; }
.share-btn.locating .share-ico { background: var(--beige-deep); animation: pulse 1s infinite; }
.speed-readout { pointer-events: none; background: rgba(44,38,32,.82); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }

/* ── discreet name labels above the 3D avatars (DOM markers) ─────────── */
.avatar-label {
  --c: #c08a3e;
  display: inline-flex; align-items: center; gap: 4px; width: max-content; max-width: 180px;
  padding: 2px 9px; border-radius: 999px; cursor: pointer;
  background: rgba(255,253,248,.78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 7px rgba(40,30,10,.18); border: 1px solid rgba(255,255,255,.7);
  font-size: 12.5px; font-weight: 620; color: var(--ink); white-space: nowrap;
  transform-origin: bottom center; transition: transform .14s, box-shadow .2s; user-select: none;
}
.avatar-label::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.6); }
.avatar-label .al-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-label .al-act { display: none; font-size: 12px; }
.avatar-label .al-act.on { display: inline; }
.avatar-label:hover { transform: translateY(-1px) scale(1.05); box-shadow: 0 5px 14px rgba(40,30,10,.26); }
.avatar-label.is-self { background: var(--beige); color: var(--on-beige); border-color: transparent; }
.avatar-label.is-self::before { background: #fff; }
.avatar-label.stale { opacity: .5; }
.avatar-label.not-sharing { opacity: .42; }

/* ── avatar detail sheet (on tap) ────────────────────────────────────── */
.detail-sheet {
  position: absolute; left: 12px; right: 12px; bottom: calc(152px + env(safe-area-inset-bottom));
  z-index: 8; max-width: 420px; margin: 0 auto; border-radius: var(--r-xl);
  padding: 16px 18px 18px; animation: slideUp .26s cubic-bezier(.2,.8,.2,1);
}
.ds-close { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--surface-2); color: var(--ink-soft); font-size: 15px; display: grid; place-items: center; }
.ds-head { display: flex; align-items: center; gap: 14px; }
.ds-avatar { width: 64px; height: 64px; border-radius: 16px; flex: none; background: linear-gradient(180deg, #fbf3e3, #efe1c8) center/86% no-repeat; box-shadow: inset 0 0 0 2px var(--c, var(--beige-soft)); }
.ds-id { min-width: 0; }
.ds-id h3 { margin: 0 0 3px; font-size: 19px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-status { font-size: 14px; color: var(--ink-soft); }
.ds-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 0; }
.ds-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; color: var(--ink); }
.ds-chip .k { color: var(--ink-faint); font-weight: 500; }
.ds-actions { margin-top: 14px; display: flex; gap: 8px; }
.ds-actions .btn { flex: 1; }

/* ── modals ─────────────────────────────────────────────────────────── */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; background: rgba(40,30,15,.34); backdrop-filter: blur(3px); animation: fade .2s; }
@media (min-width: 640px) { .modal-wrap { place-items: center; } }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--sh-3); max-height: 92vh; display: flex; flex-direction: column; animation: slideUp .28s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 640px) { .modal { border-radius: var(--r-xl); } }
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.modal-head h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.modal-body { padding: 8px 20px 18px; overflow-y: auto; }
.modal-body.center { text-align: center; }
.modal-foot { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.lbl { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); font-weight: 700; margin: 16px 0 8px; }
.modal-body input { width: 100%; }

.seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px; }
.seg button { flex: 1; border: none; background: transparent; color: var(--ink-soft); padding: 9px; border-radius: 9px; font-weight: 600; font-size: 14px; transition: background .2s, color .2s; }
.seg button.active { background: var(--beige); color: var(--on-beige); box-shadow: var(--sh-1); }

.car-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; transition: opacity .2s; }
.car-styles.dim { opacity: .4; pointer-events: none; }
.car-styles button { border: 1px solid var(--line-2); background: var(--surface-2); border-radius: 10px; padding: 9px; font-size: 13.5px; font-weight: 600; color: var(--ink); transition: border-color .18s, background .18s; }
.car-styles button.active { border-color: var(--beige-deep); background: var(--beige-wash); }

.color-row { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; box-shadow: var(--sh-1); transition: transform .15s; }
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--ink); transform: scale(1.12); }

.custom-box { margin-top: 20px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: 16px; background: var(--surface-2); }
.cb-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.badge.soft { background: var(--beige-wash); color: var(--beige-deep); font-size: 11px; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.cb-hint { color: var(--ink-soft); font-size: 14px; margin: 8px 0 12px; }
.cb-state { color: var(--beige-deep); font-size: 13.5px; margin: 10px 0 0; font-weight: 600; }

.preview-stage { margin-top: 18px; border-radius: var(--r-lg); overflow: hidden; background: linear-gradient(180deg, #fbf3e3, #f0e4cc); border: 1px solid var(--line); }
#avatarPreview { width: 100%; height: 170px; display: block; }

.code-big { font-family: var(--zl-font-mono, monospace); font-size: 38px; letter-spacing: .3em; font-weight: 700; color: var(--beige-deep); margin: 14px 0 18px; padding-left: .3em; }
.invite-link input { width: 100%; text-align: center; font-size: 14px; }
.invite-actions { margin-top: 14px; }
.muted { color: var(--ink-soft); }
.modal-body hr { border: none; border-top: 1px solid var(--line); margin: 22px 0 16px; }

/* ── toast ──────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(120px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(12px); z-index: 80; background: rgba(44,38,32,.94); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14.5px; font-weight: 600; box-shadow: var(--sh-2); opacity: 0; transition: opacity .25s, transform .25s; max-width: 88vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── responsive ─────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .forms { grid-template-columns: 1fr; }
  .brand-name { font-size: 20px; }
}
@media (min-width: 1000px) {
  .members-dock { width: 320px; }
}

/* maplibre controls tinted to match */
.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: var(--sh-2) !important; border: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button { width: 38px !important; height: 38px !important; }
