:root {
  --green-900: #1b3a2b;
  --green-700: #2f6b46;
  --green-500: #3f9463;
  --green-100: #e7f3ec;
  --amber-500: #c98a1d;
  --red-400: #c85a4a;
  --gray-100: #f5f6f4;
  --gray-300: #dcdfd9;
  --gray-600: #6b7268;
  --gray-900: #23261f;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gray-100);
  color: var(--gray-900);
}

.topbar {
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  color: white;
  padding: 28px 24px 22px;
}

.topbar h1 { margin: 0 0 6px; font-size: 22px; }
.subtitle { margin: 0; opacity: 0.85; font-size: 14px; }

main {
  max-width: 960px;
  margin: -20px auto 40px;
  padding: 0 16px;
}

.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.tab-btn {
  border: none;
  background: rgba(255,255,255,0.6);
  color: var(--gray-600);
  padding: 10px 18px;
  border-radius: 10px 10px 0 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: white;
  color: var(--green-900);
}

.tab-panel.hidden { display: none; }

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

.address-row input[type="text"] {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.address-row input[disabled] {
  background: var(--gray-100);
  color: var(--gray-600);
}

.address-search-btn {
  border: 1px solid var(--green-700);
  background: white;
  color: var(--green-700);
  border-radius: 8px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.address-search-btn:disabled {
  border-color: var(--gray-300);
  color: var(--gray-300);
  cursor: not-allowed;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
}

.date-group select {
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.trip-summary {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 14px;
  display: flex;
  gap: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.trip-summary .stat-label {
  font-size: 12px;
  color: var(--gray-600);
}

.trip-summary .stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--green-900);
}

.day-card {
  background: white;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.day-card.warning {
  border: 1px solid var(--amber-500);
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.day-title { font-weight: 700; font-size: 14px; }

.day-route {
  font-size: 14px;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.day-metrics {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--gray-600);
}

.warning-badge {
  background: #fdecea;
  color: var(--red-400);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.search-panel {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover { border-color: var(--green-500); }

.chip.active {
  background: var(--green-700);
  border-color: var(--green-700);
  color: white;
}

.date-group {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.date-group input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
}

.search-btn {
  background: var(--green-700);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  height: 38px;
}

.search-btn:hover { background: var(--green-900); }
.search-btn:disabled { background: var(--gray-300); cursor: not-allowed; }

.status-line {
  margin: 18px 4px 10px;
  font-size: 13px;
  color: var(--gray-600);
  min-height: 18px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* display:grid가 .hidden을 덮지 않도록 명시적으로 지정 */
.results-grid.hidden { display: none; }

.facility-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.facility-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.facility-name { font-size: 15px; font-weight: 700; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  width: fit-content;
}

.badge.available { background: var(--green-100); color: var(--green-700); }
.badge.unavailable { background: #f2ede3; color: var(--amber-500); }
.badge.error { background: #f7e9e7; color: var(--red-400); }

.type-tag {
  font-size: 12px;
  color: var(--gray-600);
}

.empty-state, .error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-600);
  font-size: 14px;
}

.error-state { color: var(--red-400); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 20, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: white;
  border-radius: 14px;
  max-width: 440px;
  width: 100%;
  padding: 24px;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-600);
  line-height: 1;
}

.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .type-tag { margin-bottom: 14px; display: block; }

.photo-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.theme-tag {
  background: var(--green-100);
  color: var(--green-700);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.card-summary {
  font-size: 12.5px;
  color: var(--gray-600);
  line-height: 1.45;
  margin-top: 2px;
}

.summary-box {
  background: var(--gray-100);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 4px 0 10px;
}

.summary-box p {
  margin: 0 0 5px;
  font-size: 13.5px;
  line-height: 1.5;
}

.summary-box p:last-of-type { margin-bottom: 0; }

.summary-src {
  display: block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--gray-600);
}

.view-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.view-toggle.hidden { display: none; }

.view-btn {
  border: 1px solid var(--gray-300);
  background: white;
  color: var(--gray-600);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.view-btn.active {
  background: var(--green-700);
  border-color: var(--green-700);
  color: white;
}

.map-wrap {
  background: white;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 14px;
}

.map-wrap.hidden { display: none; }

.map-canvas {
  width: 100%;
  height: 460px;
  border-radius: 8px;
  z-index: 0;
}

.map-note {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.5;
}

/* 지도 마커: 예약 가능 여부에 따라 색을 구분한다 */
.pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin span {
  transform: rotate(45deg);
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.pin.available { background: var(--green-500); }
.pin.unavailable { background: var(--amber-500); }
.pin.error { background: var(--red-400); }
.pin.start { background: #2f5fbf; }
.pin.stop { background: var(--green-700); }

.leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
.popup-name { font-weight: 700; display: block; margin-bottom: 3px; }
.popup-meta { color: var(--gray-600); font-size: 12px; }
.popup-btn {
  display: inline-block;
  margin-top: 7px;
  background: var(--green-700);
  color: white;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.mini-map {
  width: 100%;
  height: 180px;
  border-radius: 8px;
  margin: 4px 0 10px;
  z-index: 0;
}

.facts-box {
  background: var(--gray-100);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0 4px;
}

.facts-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--green-900);
}

.fact-row {
  display: flex;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-300);
}

.fact-row:last-of-type { border-bottom: none; }
.fact-row span:first-child { color: var(--gray-600); flex: 0 0 72px; }
.fact-row span:last-child { flex: 1; word-break: keep-all; }

.chat-theme-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 13px;
}

.ai-chat-panel {
  background: white;
  border-radius: 12px;
  padding: 16px 18px;
  margin-top: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.ai-chat-header {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.ai-chat-badge {
  background: var(--green-100);
  color: var(--green-700);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.ai-chat-desc {
  font-size: 12px;
  color: var(--gray-600);
  margin: 0 0 12px;
}

.ai-chat-messages {
  max-height: 360px;
  min-height: 60px;
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.ai-chat-messages:empty::before {
  content: '아직 대화가 없습니다. 궁금한 걸 물어보세요!';
  color: var(--gray-600);
  font-size: 13px;
}

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

.ai-chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
}

.mini-card-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.mini-card {
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  background: white;
}

.mini-card b { display: block; font-size: 13px; }

.chat-modal {
  max-width: 440px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.chat-header {
  font-weight: 700;
  font-size: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-300);
  margin-bottom: 12px;
}

.chat-messages {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
  min-height: 120px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}

.chat-bubble.bot {
  background: var(--green-100);
  color: var(--green-900);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  background: var(--green-700);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble .stop-name {
  font-weight: 700;
  display: block;
  margin-bottom: 3px;
}

.chat-pref-step {
  border-top: 1px solid var(--gray-300);
  padding-top: 12px;
  margin-top: 8px;
}

.chat-pref-label {
  font-size: 13px;
  color: var(--gray-600);
  margin: 0 0 8px;
}

.chat-confirm-btn {
  width: 100%;
  margin-top: 10px;
  height: 40px;
}

.chat-hidden { display: none; }

.postcode-modal {
  max-width: 500px;
  padding: 40px 16px 16px;
}

#postcodeLayer {
  width: 100%;
  height: 460px;
}

.photo-row img {
  width: 33.33%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--gray-100);
}

.modal-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-300);
  font-size: 14px;
}

.modal-row span:first-child { color: var(--gray-600); }

.deep-link-btn {
  display: block;
  text-align: center;
  margin-top: 18px;
  background: var(--green-700);
  color: white;
  text-decoration: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}

.deep-link-btn:hover { background: var(--green-900); }

.disclaimer {
  margin-top: 14px;
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.5;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--green-700);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* 날씨 표시 */
.weather-slot {
  display: inline-block;
  min-width: 1.2em;
}
.weather {
  margin-right: 0.3em;
  cursor: help;
}
.weather-none {
  margin-right: 0.3em;
  color: #9aa0a6;
  cursor: help;
}
