:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #252540;
  --primary: #4ecca3;
  --primary-dark: #3ba882;
  --danger: #e74c3c;
  --text: #eaeaea;
  --text-muted: #8888a0;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ===== Login ===== */
#view-login {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
}

.login-card {
  width: 90%;
  max-width: 340px;
  text-align: center;
}

.login-logo { font-size: 64px; margin-bottom: 8px; }
.login-card h1 { font-size: 28px; font-weight: 600; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }

.login-card input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus { border-color: var(--primary); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #000;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:active { background: var(--primary-dark); }

.btn-secondary {
  padding: 10px 20px;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.btn-sm { padding: 8px 16px; font-size: 13px; width: auto; }

/* ===== Map View ===== */

#search-bar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  gap: 8px;
}

#input-search {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#btn-my-location {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

#map-container { flex: 1; width: 100%; }

.fab {
  position: absolute;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}
.fab:active { transform: scale(0.92); }

#btn-add {
  bottom: calc(24px + var(--safe-bottom));
  right: 20px;
  background: var(--primary);
  color: #000;
  font-weight: 700;
}

.fab-user {
  bottom: calc(24px + var(--safe-bottom));
  left: 20px;
  background: var(--surface);
  font-size: 20px !important;
}

/* ===== Bottom Sheet ===== */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}

.bottom-sheet.show {
  transform: translateY(0);
}

.sheet-handle {
  padding: 12px 0 8px;
  display: flex;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}

.handle-bar {
  width: 40px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
}

.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  overscroll-behavior: contain;
}

.sheet-header h2 { font-size: 20px; margin-bottom: 4px; }
.sheet-header .text-muted { margin-bottom: 8px; }

/* ===== Stars ===== */
.stars-display { display: flex; gap: 2px; margin: 4px 0; align-items: center; }
.stars-display .star { color: #ffc107; font-size: 18px; }
.stars-display .star.empty { color: var(--surface2); }
.stars-display .score-text { margin-left: 8px; font-size: 14px; color: var(--text-muted); }

.star-picker { display: flex; gap: 8px; margin: 8px 0; }
.star-picker .star {
  font-size: 32px;
  cursor: pointer;
  color: var(--surface2);
  transition: color 0.1s;
  user-select: none;
  -webkit-user-select: none;
}
.star-picker .star.active { color: #ffc107; }

/* ===== Photos ===== */
.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.photo-strip img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  scroll-snap-align: start;
  cursor: pointer;
}

/* ===== Sections ===== */
.section-title {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 8px;
  padding-top: 8px;
  border-top: 1px solid var(--surface2);
}

/* ===== Rating items ===== */
.rating-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.rating-item .rating-user { font-weight: 600; font-size: 14px; }
.rating-item .rating-comment { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.rating-item .rating-date { color: var(--text-muted); font-size: 11px; margin-top: 4px; }

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  margin-bottom: 8px;
}
textarea:focus { border-color: var(--primary); }

#sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--surface2);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
}

.modal-content h3 { margin-bottom: 16px; font-size: 18px; }

.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
.modal-content input:focus,
.modal-content textarea:focus { border-color: var(--primary); }

.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-lg { font-size: 18px; margin-bottom: 16px; }

/* ===== Gallery ===== */
.gallery-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.gallery-scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  width: 100%;
  height: 100%;
}

.gallery-scroll img {
  min-width: 100%;
  height: 100%;
  object-fit: contain;
  scroll-snap-align: center;
}

.gallery-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== AMap overrides ===== */
.amap-logo, .amap-copyright { display: none !important; }
.amap-info-content { background: var(--surface) !important; color: var(--text) !important; border: none !important; }

/* ===== Marker label ===== */
.marker-label {
  background: var(--surface);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transform: translateY(-8px);
}

/* ===== Loading indicator on map ===== */
.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  color: var(--text-muted);
  font-size: 14px;
}
