*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:         #0e0c09;
  --surface:    #1b1813;
  --surface-2:  #252019;
  --border:     #3a3325;
  --text:       #f0e8d5;
  --text-muted: #8a7d63;
  --accent:     #e8870a;
  --accent-dim: #c4720a;
  --gold:       #f0c040;
  --danger:     #e05555;
  --success:    #5cb87a;
  --radius:     10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Layout ── */

.app-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 96px;
  flex: 1;
}

/* ── Header ── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 100vw;
}

.app-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

.auth-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.auth-btn:hover {
  border-color: var(--accent);
  background: rgba(232,135,10,0.12);
}

.auth-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Sections ── */

.section {
  margin-top: 24px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Location Bar ── */

.location-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.location-bar:hover {
  border-color: var(--accent);
}

.location-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.location-text {
  flex: 1;
  min-width: 0;
}

.location-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-address {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-chevron {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
}

/* ── Picker header + view toggle ── */

.picker-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.picker-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.picker-header-top .section-label {
  margin-bottom: 0;
}

/* ── Distance slider ── */

.distance-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.distance-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.distance-row input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  outline: none;
}

.distance-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  min-width: 38px;
  text-align: right;
  flex-shrink: 0;
}

.view-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.toggle-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ── Map container ── */

#mapContainer {
  height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-search-btn {
  margin-top: 8px;
  font-size: 13px;
  padding: 10px;
}

/* Leaflet dark-mode overrides */
.leaflet-container {
  background: #1a1a1a;
  font-family: var(--font);
}

.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
  background: var(--surface);
}

.leaflet-popup-content {
  margin: 10px 14px;
}

.map-popup-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.map-popup-addr {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.map-popup-btn {
  display: block;
  width: 100%;
  padding: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-attribution {
  background: rgba(17,17,17,0.8) !important;
  color: var(--text-muted) !important;
}

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

/* ── Bar List (picker) ── */

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.bar-item:hover,
.bar-item.selected {
  border-color: var(--accent);
  background: var(--surface-2);
}

.bar-item-name {
  font-size: 14px;
  font-weight: 600;
}

.bar-item-addr {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Price Cards ── */

.price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.price-card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.price-card-avg {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.price-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Submit Form ── */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.drink-block {
  margin-bottom: 18px;
}

.drink-block:last-of-type {
  margin-bottom: 0;
}

.drink-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-wrap {
  flex: 1;
  position: relative;
}

.input-prefix {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

input[type="number"],
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 10px 10px 24px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="email"],
input[type="password"] {
  padding-left: 12px;
}

input:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: var(--text-muted);
}

/* hide number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { display: none; }
input[type="number"] { -moz-appearance: textfield; }

.input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

/* ── Buttons ── */

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-align: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  letter-spacing: 0.3px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dim);
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.submit-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

.submit-note a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

/* ── History List ── */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-drink {
  font-size: 13px;
  font-weight: 600;
}

.history-size {
  font-size: 11px;
  color: var(--text-muted);
}

.history-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}

.history-time {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

/* ── Auth Modal ── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-width: 480px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal .input-wrap {
  margin-bottom: 10px;
}

.modal-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
}

.modal-toggle a {
  color: var(--accent);
  cursor: pointer;
}

.modal-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 8px;
  min-height: 18px;
}

/* ── Toasts ── */

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 448px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  animation: slide-up 0.25s ease;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading / Empty States ── */

.state-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Divider ── */

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── Logged in user chip ── */

.user-chip {
  font-size: 12px;
  color: var(--text-muted);
}
