:root {
  --accent: #318AFF;
  --accent-dark: #2174E1;
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(0,0,0,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); }
#map { position: absolute; inset: 0; }

/* ---------- floating search (Apple Maps style) ---------- */
.search-wrap {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 10px;
  z-index: 20; max-width: 430px; margin: 0 auto;
}
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.95); backdrop-filter: blur(12px);
  border-radius: 16px; padding: 8px 10px; box-shadow: var(--shadow);
}
.search-bar .logo { width: 32px; height: 32px; border-radius: 8px; }
.search-bar input {
  flex: 1; border: 0; background: transparent; font: inherit; font-size: 15px;
  outline: none; min-width: 0;
}
.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: #e8eef7; color: var(--accent); font-weight: 700; font-size: 12px;
  overflow: hidden; flex-shrink: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.avatar-btn img {
  width: 32px; height: 32px; object-fit: cover; border-radius: 50%;
  display: block; flex: none;
}
.search-results {
  margin-top: 6px; background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.search-results .item {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.search-results .item:last-child { border-bottom: 0; }
.search-results .item:hover { background: #f1f5f9; }
.search-results .item .sub { font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.mode-switch {
  display: flex; background: rgba(255,255,255,.95); backdrop-filter: blur(12px);
  border-radius: 999px; padding: 3px; box-shadow: var(--shadow);
}
.mode-switch button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.mode-switch button.active { background: var(--accent); color: #fff; }
.chip {
  border: 0; background: rgba(255,255,255,.95); backdrop-filter: blur(12px);
  border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow);
}
.chip.night { background: #1e293b; color: #fff; }

/* ---------- route banner ---------- */
.route-banner {
  position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.97); backdrop-filter: blur(12px);
  border-radius: 16px; padding: 10px 40px 10px 16px; box-shadow: var(--shadow);
  max-width: 92vw;
}
.route-info { display: flex; flex-direction: column; font-size: 14px; }
.route-info .muted { font-size: 11.5px; }
.route-toggle { display: flex; background: #f1f5f9; border-radius: 999px; padding: 3px; }
.route-toggle button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.route-toggle button.active { background: var(--accent); color: #fff; }
.route-banner .sheet-close { top: 8px; right: 8px; }

/* ---------- legend ---------- */
.legend {
  position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 12px; z-index: 10;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-radius: var(--radius); padding: 9px 12px; box-shadow: var(--shadow);
  font-size: 11.5px; display: flex; flex-direction: column; gap: 4px;
}
.legend .sw { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }

/* ---------- bottom sheet ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 30px rgba(0,0,0,.18);
  padding: 6px 18px calc(16px + env(safe-area-inset-bottom));
  max-height: 70vh; overflow-y: auto;
}
@media (min-width: 700px) {
  .sheet { left: auto; right: 16px; bottom: 16px; width: 380px; border-radius: 18px; max-height: 75vh; }
  .sheet.floating {
    right: auto; bottom: auto; width: 360px; max-height: 60vh;
  }
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 6px auto 2px; }
.sheet-close {
  position: absolute; top: 10px; right: 10px; border: 0; background: #f1f5f9;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
.sheet h2 { font-size: 18px; margin: 10px 0 4px; padding-right: 36px; }
.sheet #btn-directions { margin-top: 8px; }
.sheet-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; }
.sheet-meta .lvl { font-weight: 700; }
.lvl-safe { color: #1e9e57; } .lvl-caution { color: #d8860b; }
.lvl-risk { color: var(--danger); } .lvl-nodata { color: #69a878; }

/* ---------- comments ---------- */
.comments h3 { font-size: 14px; margin: 14px 0 10px; }
.comments-list { display: flex; flex-direction: column; gap: 12px; }
.comment { display: flex; gap: 10px; font-size: 14px; }
.comment .ava {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.comment .bubble {
  background: #f3f5f8; border-radius: 4px 16px 16px 16px; padding: 9px 13px;
  flex: 1; min-width: 0;
}
.comment .head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; flex-wrap: wrap; }
.comment .who { font-weight: 700; font-size: 13px; }
.comment .when { color: var(--muted); font-size: 11px; }
.comment .stars-inline { color: #f59e0b; font-size: 12px; letter-spacing: 1px; }
.comment .body { line-height: 1.45; overflow-wrap: anywhere; }
.comment.hidden-c .bubble { opacity: .55; background: #fef2f2; }
.comment .mod-row { margin-top: 7px; display: flex; gap: 8px; }
.comment .mod-row button {
  font-size: 11.5px; border: 0; background: #e8edf3; color: var(--text);
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 600;
}
.comment .mod-row button:hover { background: #dbe3ec; }
#comment-form textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px; font: inherit; font-size: 13.5px; resize: vertical; margin-top: 10px;
}
.form-row { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
.form-row .err { flex: 1; }
.rating-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 10px; }
.stars { display: flex; gap: 2px; cursor: pointer; font-size: 20px; color: #d1d5db; user-select: none; }
.stars span.on { color: #f59e0b; }

/* ---------- google reviews block ---------- */
.g-btn {
  margin-top: 10px; width: 100%; border: 1px solid var(--border); background: #fff;
  border-radius: 10px; padding: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.g-btn:hover { background: #f1f5f9; }
.g-head { display: flex; gap: 10px; align-items: baseline; margin: 12px 0 8px; font-size: 14px; }
.g-rating { font-weight: 700; }
.g-attr { margin-left: auto; font-size: 11px; color: var(--muted); }
.g-photos { display: flex; gap: 6px; margin-bottom: 10px; }
.g-photos img {
  width: 33%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; cursor: zoom-in;
}
.g-review { background: #f3f5f8; border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; font-size: 13px; }
.g-review .head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.g-review .who { font-weight: 700; font-size: 12.5px; }
.g-review .when { color: var(--muted); font-size: 11px; }
.g-review .body { line-height: 1.4; }

/* ---------- buttons / forms ---------- */
button.primary {
  border: 0; background: var(--accent); color: #fff; font-weight: 600;
  border-radius: 999px; padding: 8px 20px; font-size: 14px; cursor: pointer;
}
button.primary:hover { background: var(--accent-dark); }
button.primary.wide { width: 100%; padding: 11px; }
.err { color: var(--danger); font-size: 12.5px; margin: 4px 0; min-height: 1em; }
.ok { color: #15803d; font-size: 12.5px; margin: 4px 0; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
a { color: var(--accent-dark); }

/* ---------- modals ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  position: relative; background: #fff; border-radius: 18px; box-shadow: var(--shadow);
  width: 100%; max-width: 360px; padding: 22px;
}
.modal-wide { max-width: 560px; max-height: 80vh; overflow-y: auto; }
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.modal input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font: inherit; font-size: 14px; margin-bottom: 10px;
}
.admin-list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- profile ---------- */
.avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.avatar-big { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.file-btn {
  display: inline-block; border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 4px;
}
.profile-h { font-size: 13px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; margin-bottom: 0; }
.profile-actions { display: flex; gap: 10px; margin-top: 18px; }
.profile-actions button {
  flex: 1; border: 1px solid var(--border); background: #fff; border-radius: 10px;
  padding: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.comment .ava { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }

[hidden] { display: none !important; }
