:root {
  --sm-bg: #080a10;
  --sm-surface: rgba(16, 19, 29, 0.92);
  --sm-surface-2: rgba(24, 29, 44, 0.95);
  --sm-border: rgba(255, 255, 255, 0.1);
  --sm-text: #f3f5fa;
  --sm-muted: rgba(243, 245, 250, 0.62);
  --sm-accent: #38bdf8;
  --sm-accent-2: #818cf8;
  --sm-ok: #34d399;
  --sm-warn: #fbbf24;
  --sm-err: #f87171;
}

* { box-sizing: border-box; }

html, body.sm-app {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--sm-bg);
  color: var(--sm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

.sm-topbar {
  height: 58px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(11, 14, 23, 0.96);
  border-bottom: 1px solid var(--sm-border);
  position: relative;
  z-index: 30;
}

.sm-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.sm-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--sm-border);
  color: var(--sm-muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
}

.sm-back:hover { color: #fff; border-color: rgba(255,255,255,0.25); }

.sm-brand-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.sm-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sm-ok);
  box-shadow: 0 0 10px var(--sm-ok);
}

.sm-sub {
  font-size: 0.78rem;
  color: var(--sm-muted);
}

.sm-top-pills {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.sm-top-pills::-webkit-scrollbar { display: none; }

.sm-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.36rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--sm-border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  color: var(--sm-text);
  white-space: nowrap;
}

.sm-pill-btn {
  cursor: pointer;
}

.sm-pill-btn.is-on {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(52, 211, 153, 0.14);
  color: var(--sm-ok);
}

.sm-pill-accent {
  cursor: pointer;
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.16);
  font-weight: 600;
}

/* —— Split Layout —— */
.sm-shell {
  display: grid;
  grid-template-columns: 1fr 430px;
  height: calc(100vh - 58px);
  width: 100%;
}

.sm-map-pane {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0d1220;
}

#showmeMap {
  width: 100%;
  height: 100%;
  background: #0d1220;
}

.sm-map-overlay-top {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 500;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.sm-style-switch {
  display: inline-flex;
  background: rgba(10, 13, 22, 0.9);
  border: 1px solid var(--sm-border);
  border-radius: 999px;
  padding: 2px;
  backdrop-filter: blur(8px);
}

.sm-style-btn {
  border: 0;
  background: transparent;
  color: var(--sm-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  cursor: pointer;
}

.sm-style-btn.active {
  background: var(--sm-accent);
  color: #06101a;
}

.sm-locate-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--sm-border);
  background: rgba(10, 13, 22, 0.9);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.sm-map-hint {
  position: absolute;
  left: 50%;
  bottom: 0.9rem;
  transform: translateX(-50%);
  z-index: 500;
  background: rgba(10, 13, 22, 0.88);
  border: 1px solid var(--sm-border);
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font-size: 0.77rem;
  color: var(--sm-text);
  white-space: nowrap;
  max-width: calc(100% - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Leaflet overrides (single subtle attribution, no overlapping controls) */
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(8, 10, 16, 0.72) !important;
  color: rgba(255, 255, 255, 0.55) !important;
}
.leaflet-control-attribution a { color: rgba(56, 189, 248, 0.85) !important; }

/* Custom Bounty Pins on Map */
.sm-pin-marker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
  border: 1.5px solid #fff;
}
.sm-pin-marker.is-open {
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #fff;
}
.sm-pin-marker.is-fulfilled {
  background: #065f46;
  color: #a7f3d0;
  border-color: #34d399;
}

/* —— Right Control Panel —— */
.sm-panel {
  background: var(--sm-surface);
  border-left: 1px solid var(--sm-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sm-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--sm-border);
  background: rgba(11, 14, 23, 0.9);
}

.sm-tab {
  min-height: 46px;
  border: 0;
  background: transparent;
  color: var(--sm-muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-bottom: 2px solid transparent;
}

.sm-tab.active {
  color: var(--sm-accent);
  border-bottom-color: var(--sm-accent);
  background: rgba(56, 189, 248, 0.06);
}

.sm-tab-body {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
}

.sm-tab-body.active {
  display: block;
}

.sm-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.sm-feed {
  display: grid;
  gap: 0.7rem;
}

.sm-pin-card {
  background: var(--sm-surface-2);
  border: 1px solid var(--sm-border);
  border-radius: 14px;
  padding: 0.85rem;
  cursor: pointer;
  transition: border-color 0.16s, transform 0.15s;
}

.sm-pin-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

.sm-pin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.sm-bounty-tag {
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--sm-accent);
}

.sm-bounty-tag.is-fulfilled {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--sm-ok);
}

.sm-pin-prompt {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #fff;
}

.sm-pin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  font-size: 0.76rem;
  color: var(--sm-muted);
  margin-bottom: 0.65rem;
}

.sm-in-range {
  color: var(--sm-ok);
  font-weight: 700;
}

.sm-card-box {
  background: var(--sm-surface-2);
  border: 1px solid var(--sm-border);
  border-radius: 14px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
}

.sm-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sm-muted);
  margin-bottom: 0.3rem;
}

.sm-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.sm-mini-link {
  border: 0;
  background: transparent;
  color: var(--sm-accent);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.sm-mini-note { font-size: 0.75rem; color: var(--sm-accent); }

.sm-coord-readout {
  padding: 0.48rem 0.65rem;
  border-radius: 9px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  font-size: 0.78rem;
  color: #bae6fd;
  margin-bottom: 0.55rem;
}

.sm-input, .sm-select, .sm-textarea {
  width: 100%;
  padding: 0.56rem 0.7rem;
  border-radius: 9px;
  border: 1px solid var(--sm-border);
  background: #0c101b;
  color: #fff;
  font-size: 0.86rem;
}

.sm-input:focus, .sm-select:focus, .sm-textarea:focus {
  outline: none;
  border-color: var(--sm-accent);
}

.sm-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.sm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.sm-chip {
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--sm-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--sm-text);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.sm-chip.active {
  background: var(--sm-accent);
  border-color: var(--sm-accent);
  color: #06101a;
}

.sm-split-hint {
  margin-top: 0.45rem;
  font-size: 0.76rem;
  color: var(--sm-ok);
}

.sm-drop-actions {
  display: grid;
  gap: 0.5rem;
}

.sm-btn-primary {
  width: 100%;
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.65);
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
}

.sm-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.sm-btn-secondary {
  width: 100%;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--sm-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--sm-text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  text-decoration: none;
}

.sm-wallet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.sm-stat-tile {
  background: var(--sm-surface-2);
  border: 1px solid var(--sm-border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}

.sm-stat-tile span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sm-muted);
}

.sm-stat-tile strong {
  font-size: 1.2rem;
  color: #fff;
}

.sm-subtabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.sm-subtab {
  padding: 0.42rem 0.3rem;
  border-radius: 8px;
  border: 1px solid var(--sm-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--sm-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.sm-subtab.active {
  border-color: var(--sm-accent);
  background: rgba(56, 189, 248, 0.14);
  color: #fff;
}

.sm-history-list {
  display: grid;
  gap: 0.45rem;
}

.sm-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
}

/* —— Modals —— */
.sm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(4, 6, 12, 0.84);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.sm-modal.active { display: flex; }

.sm-modal-box {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: #101421;
  border: 1px solid var(--sm-border);
  border-radius: 18px;
  padding: 1.25rem;
  position: relative;
}

.sm-modal-wide { max-width: 680px; }

.sm-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--sm-border);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.sm-modal-title { margin: 0 2rem 0.35rem 0; font-size: 1.2rem; }
.sm-modal-sub { margin: 0 0 0.85rem; color: var(--sm-muted); font-size: 0.88rem; }

.sm-camera-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.sm-camera-rules span {
  font-size: 0.74rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #bae6fd;
}

.sm-demo-toggle {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  margin-bottom: 0.75rem;
}

.sm-hud-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.sm-hud-row > div {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sm-border);
}

.sm-hud-row span { display: block; font-size: 0.7rem; color: var(--sm-muted); }
.sm-hud-row strong { font-size: 0.86rem; color: #fff; }

.sm-video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #05070c;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--sm-border);
  margin-bottom: 0.75rem;
}

#liveCameraPreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sm-timer-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
}

.sm-status-msg {
  font-size: 0.84rem;
  color: var(--sm-accent);
  min-height: 1.2rem;
  margin-bottom: 0.65rem;
}

.sm-proof-media {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--sm-border);
  margin-bottom: 0.85rem;
  background: #06080f;
}

.sm-proof-table {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.sm-proof-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.78rem;
}

.sm-proof-row span { color: var(--sm-muted); flex: 0 0 auto; }
.sm-proof-row code { color: #93c5fd; overflow-wrap: anywhere; word-break: normal; text-align: right; }

.sm-toast {
  position: fixed;
  bottom: 1.1rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  z-index: 3000;
  background: #0f172a;
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.55);
  border-radius: 999px;
  padding: 0.55rem 1.05rem;
  font-size: 0.84rem;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.2s;
}

.sm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .sm-topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 0.45rem 0.65rem;
    gap: 0.35rem;
  }

  .sm-top-pills {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.3rem;
  }

  .sm-pill {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }

  .sm-sub { display: none; }

  .sm-map-hint { display: none; }

  .sm-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 46vh 1fr;
    height: auto;
    min-height: calc(100vh - 96px);
  }

  .sm-map-pane { height: 46vh; }

  .sm-panel {
    border-left: 0;
    border-top: 1px solid var(--sm-border);
    height: auto;
    min-height: 460px;
  }

  .sm-two-col { grid-template-columns: 1fr; }
}
