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

html {
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f8f8f8;
  color: #1a1a1a;
  height: 100dvh;
  height: -webkit-fill-available;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

/* ── Map ── */
#map {
  flex: 1;
  position: relative;
  min-height: 0;
  width: 100%;
}

/* Fix MapLibre canvas orientation on iOS WebView */
.maplibregl-canvas {
  transform: none !important;
  left: 0 !important;
  top: 0 !important;
}
.maplibregl-canvas-container {
  width: 100% !important;
  height: 100% !important;
}

/* ── Top bar ── */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 100;
  /* Extra top padding for Dynamic Island / notch */
  padding: max(56px, calc(env(safe-area-inset-top) + 8px)) 12px 8px;
  pointer-events: none;
}

#search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: all;
}

#search-box {
  flex: 1;
  background: rgba(255, 255, 255, 0.96);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.search-icon {
  font-size: 14px;
  flex-shrink: 0;
  color: rgba(0, 0, 0, 0.35);
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #1a1a1a;
  font-size: 14px;
  font-family: inherit;
  height: 100%;
}
#search-input::placeholder { color: rgba(0, 0, 0, 0.3); }

#search-clear {
  background: none;
  border: none;
  color: rgba(0, 0, 0, 0.3);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  display: none;
  flex-shrink: 0;
}

.icon-btn {
  width: 44px; height: 44px;
  background: rgba(255, 255, 255, 0.96);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; color: #333;
  flex-shrink: 0;
  transition: background 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.icon-btn:active { background: rgba(0, 0, 0, 0.06); }

.lang-pills { display: flex; gap: 4px; }

.lang-pill {
  background: rgba(255, 255, 255, 0.96);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.lang-pill.active {
  background: rgba(52, 152, 219, 0.15);
  border-color: #3498db;
  color: #1a6fa8;
}

/* ── Weather strip ── */
#weather-strip {
  position: absolute;
  top: calc(max(56px, env(safe-area-inset-top)) + 58px);
  left: 12px; right: 12px;
  z-index: 99;
  background: rgba(255, 255, 255, 0.96);
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 8px 14px;
  display: none;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
#weather-strip.show { display: flex; }

#wx-icon { font-size: 20px; flex-shrink: 0; }

.wx-middle { flex: 1; min-width: 0; }

#wx-text { font-size: 12px; color: rgba(0, 0, 0, 0.6); }
#wx-temp { font-size: 13px; font-weight: 500; color: #1a1a1a; flex-shrink: 0; }

#wx-rain-bar {
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
#wx-rain-fill {
  height: 100%;
  border-radius: 2px;
  background: #3498db;
  width: 0%;
  transition: width 0.4s;
}

/* ── Toast ── */
#toast {
  position: absolute;
  top: calc(max(56px, env(safe-area-inset-top)) + 58px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.97);
  border: 0.5px solid rgba(243, 156, 18, 0.6);
  color: #c47d0a;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}
#toast.show { opacity: 1; }
#toast.info    { border-color: rgba(52, 152, 219, 0.6); color: #1a6fa8; }
#toast.success { border-color: rgba(39, 174, 96, 0.6);  color: #1a7a45; }

/* ── Bottom sheet ── */
#bottom-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  height: var(--sheet-height, 25vh);
  min-height: 110px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#sheet-handle {
  width: 44px; height: 5px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  margin: 10px auto 4px;
  flex-shrink: 0;
  cursor: ns-resize;
  touch-action: none;
}
#sheet-handle:hover { background: rgba(0,0,0,0.28); }

#sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  flex-shrink: 0;
}
#sheet-title { font-size: 15px; font-weight: 500; color: #1a1a1a; }
#sheet-count {
  font-size: 12px; color: rgba(0, 0, 0, 0.4);
  background: rgba(0, 0, 0, 0.06);
  padding: 3px 10px; border-radius: 8px;
}

/* ── Filter chips ── */
#filter-row {
  display: flex;
  gap: 6px;
  padding: 0 14px 10px;
  overflow-x: auto;
  flex-shrink: 0;
}
#filter-row::-webkit-scrollbar { display: none; }

.chip {
  background: #f4f4f4;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.chip.active {
  background: rgba(243, 156, 18, 0.12);
  border-color: rgba(243, 156, 18, 0.5);
  color: #c47d0a;
}

/* ── Terrace list ── */
#terrace-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 10px 16px;
}
#terrace-list::-webkit-scrollbar { width: 2px; }
#terrace-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 1px;
}

#empty-state {
  text-align: center;
  padding: 24px 16px;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.3);
  line-height: 1.7;
}

.t-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  border: 0.5px solid transparent;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.t-row:hover    { background: rgba(0, 0, 0, 0.03); }
.t-row.selected { background: rgba(243, 156, 18, 0.07); border-color: rgba(243, 156, 18, 0.3); }

.t-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.t-icon.sunny   { background: rgba(243, 156, 18, 0.15); }
.t-icon.leaving { background: rgba(230, 126, 34, 0.12); }
.t-icon.shade   { background: rgba(0, 0, 0, 0.05); }
.t-icon.rainy   { background: rgba(52, 152, 219, 0.1); }
.t-icon.shadow  { background: rgba(100, 100, 160, 0.1); }

.t-info  { flex: 1; min-width: 0; }
.t-name  { font-size: 14px; font-weight: 500; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta  { font-size: 12px; color: rgba(0, 0, 0, 0.38); margin-top: 3px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.meta-dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(0, 0, 0, 0.2); flex-shrink: 0; }

.t-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

.sun-badge { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 7px; }
.sun-badge.sunny   { background: rgba(243, 156, 18, 0.15); color: #b57300; }
.sun-badge.leaving { background: rgba(230, 126, 34, 0.15); color: #a0500a; }
.sun-badge.shade   { background: rgba(0, 0, 0, 0.06);      color: rgba(0, 0, 0, 0.4); }
.sun-badge.rainy   { background: rgba(52, 152, 219, 0.12);  color: #1a6fa8; }
.sun-badge.shadow  { background: rgba(100, 100, 160, 0.12); color: #4a4a8a; }

.t-dist { font-size: 11px; color: rgba(0, 0, 0, 0.28); }

/* ── Info panel ── */
#info-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 20px 20px 0 0;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  padding-bottom: 24px;
  z-index: 150;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 80vh;
  overflow-y: auto;
}
#info-panel.open { transform: translateY(0); }

#info-handle {
  width: 36px; height: 3px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 2px;
  margin: 10px auto 0;
}

#info-close {
  position: absolute;
  top: 12px; right: 16px;
  width: 28px; height: 28px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; color: rgba(0, 0, 0, 0.5);
}

#info-body { padding: 14px 18px 0; }

#info-header-row {
  display: flex; align-items: center;
  gap: 12px; margin-bottom: 14px;
}

#info-icon {
  width: 50px; height: 50px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px; flex-shrink: 0;
}
#info-icon.sunny   { background: rgba(243, 156, 18, 0.15); }
#info-icon.leaving { background: rgba(230, 126, 34, 0.15); }
#info-icon.shade   { background: rgba(0, 0, 0, 0.06); }
#info-icon.rainy   { background: rgba(52, 152, 219, 0.1); }
#info-icon.shadow  { background: rgba(100, 100, 160, 0.1); }

#info-name     { font-size: 17px; font-weight: 500; color: #1a1a1a; }
#info-subtitle { font-size: 13px; color: rgba(0, 0, 0, 0.45); margin-top: 3px; }

#info-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.istat { background: #f6f6f6; border-radius: 12px; padding: 10px 12px; }
.istat-label { font-size: 11px; color: rgba(0, 0, 0, 0.35); margin-bottom: 4px; }
.istat-val   { font-size: 14px; font-weight: 500; color: #1a1a1a; }
.istat-val.sunny   { color: #b57300; }
.istat-val.leaving { color: #a0500a; }
.istat-val.shade   { color: rgba(0, 0, 0, 0.4); }
.istat-val.rainy   { color: #1a6fa8; }
.istat-val.shadow  { color: #4a4a8a; }

#info-weather-row {
  background: #f0f4f8;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: none;
  align-items: center;
}
#info-weather-row.show { display: flex; }
#iw-icon { font-size: 18px; flex-shrink: 0; margin-right: 8px; }
#iw-desc { font-size: 12px; color: rgba(0, 0, 0, 0.55); flex: 1; }
#iw-temp { font-size: 13px; font-weight: 500; color: #1a1a1a; }

#sun-bar-wrap { margin-bottom: 14px; }
#sun-bar-label { font-size: 12px; color: rgba(0, 0, 0, 0.4); margin-bottom: 6px; }
#sun-bar { height: 6px; background: rgba(0, 0, 0, 0.08); border-radius: 3px; overflow: hidden; }
#sun-fill { height: 100%; border-radius: 3px; width: 0%; background: #f39c12; transition: width 0.4s, background 0.4s; }

#monitor-btn {
  width: 100%; padding: 13px;
  border: none; border-radius: 14px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  background: #f39c12; color: #fff;
}
#monitor-btn:active { transform: scale(0.98); }
#monitor-btn.on {
  background: rgba(243, 156, 18, 0.1);
  color: #b57300;
  border: 0.5px solid rgba(243, 156, 18, 0.5);
}

/* ── Drink price list ── */
#price-section {
  margin-top: 14px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  padding-top: 14px;
}
.price-section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.price-section-title { font-size: 14px; font-weight: 500; color: #1a1a1a; }

#add-drink-btn {
  font-size: 12px; color: #1a6fa8;
  background: none;
  border: 0.5px solid rgba(52, 152, 219, 0.4);
  border-radius: 8px;
  padding: 4px 10px; cursor: pointer;
}

.price-row {
  display: flex; align-items: center;
  gap: 10px; padding: 8px 0;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
}
.price-row:last-child { border-bottom: none; }

.price-drink-name  { flex: 1; font-size: 13px; color: #1a1a1a; }
.price-val         { font-size: 15px; font-weight: 500; color: #1a1a1a; min-width: 52px; text-align: right; }
.price-val.unknown { color: rgba(0, 0, 0, 0.25); font-size: 12px; font-weight: 400; }
.price-edit-btn    { width: 28px; height: 28px; background: #f4f4f4; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.price-updated     { font-size: 10px; color: rgba(0, 0, 0, 0.3); margin-top: 1px; }

/* ── Price edit modal ── */
#price-modal {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 300; display: none;
  align-items: flex-end;
}
#price-modal.show { display: flex; }

#price-modal-box {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 36px;
  width: 100%;
}
#price-modal-title { font-size: 15px; font-weight: 500; margin-bottom: 14px; color: #1a1a1a; }
#price-modal-drink { font-size: 13px; color: rgba(0, 0, 0, 0.5); margin-bottom: 14px; }
#price-modal-input {
  width: 100%;
  border: 0.5px solid rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 12px 14px; font-size: 16px;
  outline: none; color: #1a1a1a; margin-bottom: 12px;
}
#price-modal-input:focus { border-color: #3498db; }

#price-modal-btns { display: flex; gap: 8px; }
.pm-btn    { flex: 1; padding: 13px; border: none; border-radius: 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.pm-cancel { background: #f4f4f4; color: rgba(0, 0, 0, 0.5); }
.pm-save   { background: #f39c12; color: #fff; }

/* ── Map markers ── */
.cmarker {
  width: 36px; height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.cmarker:hover  { transform: rotate(-45deg) scale(1.18); }
.cmarker.sunny  { background: #f39c12; }
.cmarker.leaving { background: #e67e22; }
.cmarker.shade  { background: #7f8c8d; }
.cmarker.rainy  { background: #2980b9; }
.cmarker.shadow { background: #6c6c9a; }
.cmarker-inner  { transform: rotate(45deg); font-size: 14px; }
