:root {
  --bg: #0f1419;
  --panel: #1a2029;
  --panel-2: #232c38;
  --line: #2e3947;
  --text: #e6edf3;
  --muted: #93a1b0;
  --primary: #f5a623;
  --primary-d: #d98c11;
  --accent: #3fb950;
  --danger: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* Top bar */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.brand span { color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-label { color: var(--muted); font-size: 13px; }

/* Layout */
.layout { display: flex; height: calc(100vh - 56px); }
.sidebar {
  width: 360px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg);
  border-right: 1px solid var(--line);
}
#map { flex: 1; height: 100%; background: #0b0e12; }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.panel h2 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0 0 10px; }
.pill { background: var(--panel-2); border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--muted); }

.field { margin-bottom: 12px; }
.field > label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* Buttons */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--line); }
.btn-primary { background: var(--primary); color: #1a1205; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; display: block; margin-top: 8px; }

.status { font-size: 12px; color: var(--muted); margin: 8px 0 0; min-height: 16px; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* Brand checkboxes */
.brand-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.brand-item {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 9px; cursor: pointer; font-size: 13px;
}
.brand-item input { accent-color: var(--primary); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.list li:last-child { margin-bottom: 0; }
.list .li-title { font-weight: 600; }
.list .li-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.li-actions { display: flex; gap: 6px; margin-top: 8px; }
.li-actions .btn { padding: 5px 10px; font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; font-style: italic; }

.feed li .li-sub { color: var(--text); margin-top: 4px; font-style: normal; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.badge.found { background: rgba(63,185,80,0.18); color: var(--accent); }
.badge.left { background: rgba(245,166,35,0.18); color: var(--primary); }
.badge.visited { background: rgba(147,161,176,0.18); color: var(--muted); }

/* Drawer */
.drawer {
  position: fixed; top: 56px; right: 0; bottom: 0; width: 380px;
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 16px; overflow-y: auto; z-index: 1000;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-head p { margin: 3px 0 0; font-size: 13px; }
.note-form { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 14px 0; }
.note-form h4, .notes-list h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.note-form input, .note-form textarea { margin-bottom: 8px; }
.seg { display: flex; gap: 6px; margin-bottom: 8px; }
.seg-btn { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 7px 4px; cursor: pointer; font-size: 12px; font-weight: 600; }
.seg-btn.active { border-color: var(--primary); color: var(--text); background: rgba(245,166,35,0.12); }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.check input { accent-color: var(--primary); }
.note-author { font-size: 12px; color: var(--muted); }
.note-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.note-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: 340px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; background: transparent; border: none; border-bottom: 2px solid var(--line); color: var(--muted); padding: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 8px; width: 100%; text-align: center; }
.link-btn:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Legal / content pages */
.legal { max-width: 720px; margin: 0 auto; padding: 28px 20px 60px; line-height: 1.6; }
.legal h1 { font-size: 26px; margin: 0 0 4px; }
.legal h2 { font-size: 17px; margin: 26px 0 8px; color: var(--primary); }
.legal p, .legal li { color: var(--text); }
.legal ul { padding-left: 20px; }
.legal a { color: var(--primary); }
.legal .small { font-size: 12px; margin-top: 28px; }

/* Centered single-card page (password reset) */
.center-page { display: flex; justify-content: center; padding: 48px 16px; }
.center-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 360px; max-width: 92vw; }
.center-card h2 { margin: 0 0 16px; }

/* Footer */
.site-footer { text-align: center; padding: 12px; color: var(--muted); font-size: 12px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Route -> maps navigation */
.route-nav { margin: 4px 0 10px; }
.nav-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }
.nav-hint:empty { display: none; }
.nav-alts { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.nav-alts a { color: var(--primary); text-decoration: none; }
.nav-alts a:hover { text-decoration: underline; }

/* Leaflet popup tweaks */
.leaflet-popup-content { font-size: 13px; }
.store-pin-label { font-weight: 600; }

/* ---------------- Mobile ---------------- */
@media (max-width: 760px) {
  body { font-size: 15px; }

  .topbar { height: 52px; padding: 0 12px; }
  .brand { font-size: 16px; }
  .topbar-right { gap: 8px; }
  .user-label { display: none; }
  .topbar .btn { padding: 7px 10px; }

  /* Stack the map on top, controls scroll with the page underneath. */
  .layout { flex-direction: column; height: auto; }
  #map { width: 100%; height: 48vh; min-height: 280px; order: -1; }
  .sidebar {
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: none;
    border-top: 1px solid var(--line);
  }

  /* Bigger tap targets on touch. */
  .btn { padding: 11px 14px; }
  input[type="text"], input[type="email"], input[type="password"], textarea { padding: 11px; font-size: 16px; }
  .brand-list { grid-template-columns: 1fr 1fr; }
  .li-actions { flex-wrap: wrap; }
  .li-actions .btn { flex: 1; min-width: 92px; }

  /* Notes drawer becomes a bottom sheet. */
  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 82vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
  }

  .modal-card { width: 92vw; max-width: 360px; }
}

@media (max-width: 400px) {
  .brand-list { grid-template-columns: 1fr; }
}
