/* WeFlock MVP4 — clean, mobile-first */

:root {
  --bg: #f3efe6;
  --bg-accent: #e7f0ec;
  --ink: #1c2a26;
  --muted: #5c6b66;
  --brand: #0f766e;
  --brand-deep: #0b5a54;
  --surface: rgba(255, 252, 246, 0.92);
  --line: rgba(28, 42, 38, 0.12);
  --danger: #b42318;
  --ok: #157a3a;
  --warn: #a15c00;
  --shadow: 0 18px 40px rgba(28, 42, 38, 0.08);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9ebe4 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e2c8 0%, transparent 50%),
    var(--bg);
}

body {
  line-height: 1.45;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 0.75rem;
}

.lede {
  color: var(--muted);
  max-width: 28ch;
  font-size: 1.05rem;
}

.brand-lockup,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  flex-shrink: 0;
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.brand-logo.sm {
  width: 40px;
  height: 40px;
}

.brand-mark {
  margin: 0 0 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--brand);
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

.hint,
.muted,
.footer-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.screen {
  min-height: 100dvh;
}

.screen[hidden] {
  display: none !important;
}

/* Auth */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 440px;
  margin: 0 auto;
}

.brand-block {
  animation: rise 0.55s ease both;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  animation: rise 0.65s ease 0.05s both;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  background: rgba(15, 118, 110, 0.08);
  border-radius: 12px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 0.65rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.stack {
  display: grid;
  gap: 0.85rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--brand);
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  font-size: 1.15rem;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-deep);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-sm {
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 9px;
}

/* App chrome */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.75);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.tour-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.code-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0;
}

#lblTourCode,
#mTourCode {
  font-size: 1.35rem;
  letter-spacing: 0.14em;
  color: var(--brand-deep);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  font-weight: 600;
  color: var(--muted);
}

.stat.warn {
  border-color: #f0c36a;
  background: #fff7ed;
}

.stat span {
  display: block;
  font-family: var(--display);
  font-size: 1.8rem;
  color: var(--ink);
  line-height: 1.1;
}

.sos-banner,
.straggler-banner {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  font-size: 1.02rem;
  line-height: 1.4;
}

.sos-banner {
  background: #fee2e2;
  border: 2px solid #ef4444;
  color: #7f1d1d;
  animation: pulseSos 1.2s ease infinite;
}

.straggler-banner {
  background: #fef9c3;
  border: 1px solid #eab308;
  color: #713f12;
}

.sos-banner p,
.straggler-banner p {
  margin: 0.25rem 0 0;
  font-weight: 600;
}

.sos-panel {
  border: 2px solid rgba(220, 38, 38, 0.25);
}

#sosBtn,
#imHereBtn {
  width: 100%;
  margin-top: 0.35rem;
}

.btn-success {
  background: var(--ok);
  color: #fff;
}

.btn-success:hover {
  filter: brightness(0.95);
}

.badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.badge-sos {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-here {
  background: #d9f5e3;
  color: #157a3a;
}

.badge-away {
  background: #fef9c3;
  color: #a16207;
}

.guide-marker-wrap {
  background: transparent;
  border: 0;
}

.guide-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.55);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  font-family: "DM Sans", system-ui, sans-serif;
}

#enableGuideGpsBtn,
#enableMemberGpsBtn {
  margin: 0.35rem 0 0.65rem;
}

@keyframes pulseSos {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

.grid-2 {
  display: grid;
  gap: 1rem;
}

@media (min-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.person {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.person:last-child {
  border-bottom: 0;
}

.person .muted {
  display: block;
  font-size: 0.82rem;
  font-weight: 400;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.empty {
  color: var(--muted);
  padding: 0.5rem 0;
  list-style: none;
}

.map-panel .map {
  height: min(420px, 55vh);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-top: 0.5rem;
  background: #dce8e4;
}

.status-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #e8e4d9;
}

.status-pending {
  background: #fff1d6;
  color: var(--warn);
}

.status-active {
  background: #d9f5e3;
  color: var(--ok);
}

.gps-box {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.06);
  border: 1px solid rgba(15, 118, 110, 0.12);
  overflow: visible;
}

.gps-label {
  font-weight: 700;
  margin: 0.2rem 0 0.6rem;
}

.gps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 0.65rem;
  margin: 0;
}

.gps-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.gps-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.3;
  color: var(--ink);
}

.map-hint {
  margin-top: 0.15rem;
}

.meet-status,
.meet-status-panel {
  margin-top: 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: #fff7ed;
  border: 1px solid #fdba74;
}

.meet-status p,
.meet-status-panel p {
  margin: 0.25rem 0;
}

.btn-lg {
  padding: 1.05rem 1.2rem;
  font-size: 1.12rem;
  min-height: 3.25rem;
}

.join-or {
  text-align: center;
  margin: 1.1rem 0 0.85rem;
}

.scanner-box {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.75rem;
}

#qrReader {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #111;
}

#qrReader video {
  width: 100% !important;
}

.nav-hud {
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: 14px;
  background: #1c2a26;
  color: #fff;
  text-align: center;
}

.nav-dir {
  margin: 0;
  font-family: var(--display);
  font-size: 2.4rem;
  line-height: 1.1;
}

.nav-dist {
  margin: 0.35rem 0 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.nav-walk,
.nav-note {
  margin: 0.25rem 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.05rem;
}

.nav-hud.arrived {
  background: var(--ok);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(28, 42, 38, 0.55);
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  width: min(380px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
  display: grid;
  gap: 0.65rem;
  justify-items: center;
}

#qrCanvas {
  width: 240px;
  height: 240px;
  border-radius: 12px;
  background: #fff;
  padding: 0.5rem;
  border: 1px solid var(--line);
}

.qr-image {
  width: 240px;
  height: 240px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 0.5rem;
  border: 1px solid var(--line);
}

.camera-help {
  margin-top: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.15);
  font-size: 0.98rem;
  line-height: 1.4;
}

.alert-banner {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: #fff1d6;
  border: 1px solid #f0c36a;
  color: #7a4a00;
  font-size: 1.02rem;
  line-height: 1.45;
  font-weight: 600;
}

.invite-list .person strong {
  font-size: 1.02rem;
}

#navigateMeetBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 0.65rem;
}

#startNavBtn {
  width: 100%;
  margin-top: 0.65rem;
}

#stopNavBtn {
  width: 100%;
  margin-top: 0.5rem;
}

#scanQrBtn {
  width: 100%;
}

#memberTourPanel {
  display: grid;
  gap: 1rem;
}

#memberTourPanel[hidden] {
  display: none !important;
}

.map.picking {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

/* Toasts */
#toastHost {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: grid;
  gap: 0.5rem;
  width: min(320px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  background: #1c2a26;
  color: #fff;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(-8px);
  transition: 0.2s ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: var(--ok);
}

.toast-error {
  background: var(--danger);
}

.toast-info {
  background: var(--brand-deep);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .person {
    flex-direction: column;
    align-items: flex-start;
  }
}
