:root {
  color-scheme: dark;
  --bg: #070a10;
  --surface: #0e1420;
  --card: #141c2b;
  --border: rgba(120, 180, 255, 0.14);
  --text: #e8eef8;
  --muted: #8090a8;
  --accent: #3dffa8;
  --accent-2: #4cc9ff;
  --warn: #ffb454;
  --danger: #ff6b8a;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --display: "Orbitron", "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(61, 255, 168, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(76, 201, 255, 0.08), transparent 45%),
    var(--bg);
  line-height: 1.5;
}

code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.page {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  min-height: 100vh;
  align-items: start;
}

.panel h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: 0.02em;
  margin: 0.2rem 0 0.75rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}

.lede {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: 1.02rem;
}

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

.stat {
  background: linear-gradient(160deg, rgba(61, 255, 168, 0.1), var(--card));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.stat strong { font-size: 1.15rem; font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
}

.card h2 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.bullets {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.bullets li { margin: 0.35rem 0; }

.bullets code, .card code {
  color: var(--accent-2);
  background: rgba(76, 201, 255, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent-2); }
.btn.primary {
  background: var(--accent);
  color: #042016;
  border-color: transparent;
}

.hint {
  font-size: 0.8rem !important;
  margin-top: 0.25rem !important;
}

.stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 0.5rem;
  position: sticky;
  top: 1rem;
}

.phone { width: min(100%, 380px); }

.phone-bezel {
  background: linear-gradient(165deg, #1a2233, #0a0e16 55%);
  border: 2px solid rgba(150, 180, 220, 0.22);
  border-radius: 36px;
  padding: 10px 10px 14px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 30px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.phone-notch {
  width: 110px;
  height: 22px;
  background: #05070c;
  border-radius: 0 0 14px 14px;
  margin: 0 auto 4px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 2px 18px 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-icons { color: var(--muted); font-size: 0.68rem; }

.phone-screen {
  background: var(--bg);
  border-radius: 8px 8px 0 0;
  min-height: 540px;
  max-height: 580px;
  overflow: auto;
  border: 1px solid rgba(120, 180, 255, 0.08);
  border-bottom: none;
}

.phone-screen::-webkit-scrollbar { width: 4px; }
.phone-screen::-webkit-scrollbar-thumb {
  background: rgba(128, 144, 168, 0.35);
  border-radius: 4px;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border: 1px solid rgba(120, 180, 255, 0.08);
  border-top: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  padding: 6px 2px 10px;
}

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.58rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 1px;
  cursor: pointer;
  border-radius: 10px;
}

.nav-btn .nav-icon { font-size: 0.95rem; line-height: 1.2; }
.nav-btn.active {
  color: var(--accent);
  background: rgba(61, 255, 168, 0.1);
}

.phone-caption {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.85rem 0 0;
  letter-spacing: 0.04em;
}

/* In-phone */
.screen-pad { padding: 12px 14px 18px; }

.screen-eyebrow {
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 4px;
}

.screen-title {
  font-family: var(--display);
  font-size: 1.35rem;
  margin: 0 0 4px;
}

.screen-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0 0 12px;
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}

.chip {
  border-radius: 12px;
  border: 1px solid rgba(61, 255, 168, 0.22);
  background: linear-gradient(160deg, rgba(61, 255, 168, 0.12), var(--card));
  padding: 9px;
}

.chip.blue {
  border-color: rgba(76, 201, 255, 0.25);
  background: linear-gradient(160deg, rgba(76, 201, 255, 0.12), var(--card));
}

.chip.warn {
  border-color: rgba(255, 180, 84, 0.28);
  background: linear-gradient(160deg, rgba(255, 180, 84, 0.12), var(--card));
}

.chip-label {
  display: block;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.chip-value { font-size: 0.95rem; font-weight: 600; }

.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 8px;
}

.app-card h3 { margin: 0 0 6px; font-size: 0.88rem; }
.app-card p { margin: 0; color: var(--muted); font-size: 0.78rem; }

.status-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(61, 255, 168, 0.12);
  color: var(--accent);
  margin-bottom: 8px;
}

.status-pill.transit {
  background: rgba(255, 180, 84, 0.14);
  color: var(--warn);
}

.place-row, .trip-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 11px;
  margin-bottom: 7px;
}

.trip-row-stack {
  flex-direction: column;
  gap: 8px;
}

.trip-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.trip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.trip-dist { font-weight: 600; font-size: 0.85rem; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.mini-btn.warn {
  border-color: rgba(255, 180, 84, 0.45);
  color: var(--warn);
}

.tag-work {
  color: var(--accent);
  background: rgba(61, 255, 168, 0.12);
}

.tag-personal {
  color: var(--warn);
  background: rgba(255, 180, 84, 0.12);
}

.tag-live {
  color: var(--accent-2);
  background: rgba(76, 201, 255, 0.12);
}

.trip-editor h3 { margin-bottom: 8px; }

.trip-map-wrap {
  width: 100%;
  margin-top: 2px;
}

.trip-map-shell {
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a1018;
}

.trip-map {
  width: 100%;
  height: 100%;
}

.trip-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}

.trip-map-legend .leg-from { color: var(--accent); font-weight: 600; }
.trip-map-legend .leg-to { color: var(--accent-2); font-weight: 600; }

.trip-map-label {
  background: transparent !important;
  border: 0 !important;
}

.trip-map-label span {
  display: inline-block;
  background: rgba(7, 10, 16, 0.88);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.place-row strong, .trip-row strong {
  display: block;
  font-size: 0.86rem;
}

.meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.tag {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  background: rgba(76, 201, 255, 0.12);
  border-radius: 999px;
  padding: 3px 8px;
  text-transform: lowercase;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.form-grid {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.form-grid label {
  display: grid;
  gap: 3px;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-grid input, .form-grid select, .form-grid textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 10px;
  outline: none;
}

.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9px;
  padding: 7px 10px;
  cursor: pointer;
}

.mini-btn.primary {
  background: var(--accent);
  color: #042016;
  border-color: transparent;
}

.mini-btn.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 138, 0.35);
}

.mini-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.setting-row {
  padding: 7px 0;
  border-bottom: 1px solid rgba(120, 180, 255, 0.08);
}

.setting-row:last-child { border-bottom: 0; }

.setting-row .label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.setting-row .value { font-size: 0.85rem; }

.event-log {
  font-size: 0.72rem;
  color: var(--muted);
  max-height: 90px;
  overflow: auto;
}

.event-log div { margin: 2px 0; }

/* Map (Places) */
.places-layout {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.places-layout .screen-pad {
  flex: 0 0 auto;
}

.map-shell {
  position: relative;
  margin: 0 10px 8px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a1018;
  height: 280px;
  flex: 0 0 auto;
  z-index: 1;
}

.map-shell.expanded {
  height: 320px;
}

#places-map {
  width: 100%;
  height: 100%;
  background: #0a1018;
}

.map-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-toolbar .mini-btn {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  background: rgba(14, 20, 32, 0.92);
  backdrop-filter: blur(6px);
}

.map-hint {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 1000;
  max-width: calc(100% - 16px);
  background: rgba(7, 10, 16, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--muted);
  pointer-events: none;
}

.map-hint strong {
  color: var(--accent);
  font-weight: 600;
}

.pin-coords {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--accent-2);
}

/* Leaflet dark tweaks inside phone */
.leaflet-container {
  font-family: var(--font);
  background: #0a1018;
}

.leaflet-control-zoom a {
  background: rgba(14, 20, 32, 0.95) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-attribution {
  background: rgba(7, 10, 16, 0.75) !important;
  color: var(--muted) !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a { color: var(--accent-2) !important; }

.place-marker {
  background: var(--accent);
  border: 2px solid #042016;
  border-radius: 50%;
  width: 14px !important;
  height: 14px !important;
  margin-left: -7px !important;
  margin-top: -7px !important;
  box-shadow: 0 0 0 3px rgba(61, 255, 168, 0.25);
}

.draft-marker {
  background: var(--warn);
  border: 2px solid #2a1a00;
  border-radius: 50% 50% 50% 0;
  width: 18px !important;
  height: 18px !important;
  transform: rotate(-45deg);
  margin-left: -9px !important;
  margin-top: -18px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.user-marker {
  background: var(--accent-2);
  border: 3px solid #fff;
  border-radius: 50%;
  width: 16px !important;
  height: 16px !important;
  margin-left: -8px !important;
  margin-top: -8px !important;
  box-shadow: 0 0 0 4px rgba(76, 201, 255, 0.3);
}

/* Desktop: large map beside the phone when Places is active */
.page.has-map {
  max-width: 1400px;
  grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr) minmax(300px, 380px);
}

.desktop-map-panel {
  display: none;
  position: sticky;
  top: 1rem;
  align-self: start;
}

.page.has-map .desktop-map-panel {
  display: block;
}

.desktop-map-shell {
  position: relative;
  height: min(78vh, 720px);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a1018;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

#desktop-places-map {
  width: 100%;
  height: 100%;
}

.desktop-map-caption {
  margin: 0.65rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

@media (max-width: 1100px) {
  .page.has-map {
    grid-template-columns: minmax(280px, 1fr) minmax(300px, 380px);
  }
  .desktop-map-panel { display: none !important; }
}

@media (max-width: 880px) {
  .page {
    grid-template-columns: 1fr;
    padding: 1.25rem 1rem 2.5rem;
  }
  .page.has-map {
    grid-template-columns: 1fr;
  }
  .stage { position: static; order: -1; }
  .phone { width: min(100%, 360px); margin: 0 auto; }
  .map-shell { height: 260px; }
}
