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

:root {
  --spring: #f9a8d4;
  --spring-bg: linear-gradient(135deg, #fce4ec, #f48fb1);
  --summer: #86efac;
  --summer-bg: linear-gradient(135deg, #e8f5e9, #66bb6a);
  --autumn: #fdba74;
  --autumn-bg: linear-gradient(135deg, #fff3e0, #ef6c00);
  --winter: #93c5fd;
  --winter-bg: linear-gradient(135deg, #e3f2fd, #42a5f5);

  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --primary-light: #52b788;
  --accent: #f77f00;
  --bg: #f8fafb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 8px;
}

html { font-size: 16px; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
}

/* ===== Header ===== */
.header {
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; }
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.reset-btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.reset-btn:hover { background: rgba(255,255,255,0.25); }

/* ===== Main ===== */
.main { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }

/* ===== Steps ===== */
.step { animation: fadeIn 0.3s ease; }
.step.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.step-header { text-align: center; margin-bottom: 32px; }
.step-header h2 { font-size: 26px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.step-header p { color: var(--text-muted); font-size: 15px; }

/* ===== Season Grid ===== */
.season-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
}
@media (min-width: 600px) { .season-grid { grid-template-columns: repeat(4, 1fr); } }

.season-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.season-card:hover { transform: translateY(-4px); box-shadow: 0 8px 32px rgba(0,0,0,0.14); }
.season-card:active { transform: translateY(-1px); }

.season-card.spring { background: var(--spring-bg); }
.season-card.summer { background: var(--summer-bg); }
.season-card.autumn { background: var(--autumn-bg); }
.season-card.winter { background: var(--winter-bg); }

.season-emoji { font-size: 40px; }
.season-name { font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.season-sub { font-size: 11px; color: var(--text-muted); }
.season-desc { font-size: 12px; color: var(--primary-dark); font-weight: 500; }

/* ===== Difficulty Grid ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color 0.2s, color 0.2s;
}
.back-btn:hover { border-color: var(--primary); color: var(--primary); }
.back-btn.small { font-size: 12px; padding: 4px 10px; margin-bottom: 0; }

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
}
@media (max-width: 480px) { .difficulty-grid { grid-template-columns: 1fr; } }

.diff-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow);
}
.diff-card:hover { transform: translateY(-4px); box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.diff-card.beginner:hover { border-color: #16a34a; }
.diff-card.intermediate:hover { border-color: #ca8a04; }
.diff-card.advanced:hover { border-color: #dc2626; }

.diff-icon { font-size: 32px; }
.diff-name { font-size: 22px; font-weight: 700; }
.diff-card.beginner .diff-name { color: #16a34a; }
.diff-card.intermediate .diff-name { color: #ca8a04; }
.diff-card.advanced .diff-name { color: #dc2626; }
.diff-desc { font-size: 13px; color: var(--text-muted); text-align: center; line-height: 1.7; }

/* ===== Badge ===== */
.badge {
  display: inline-block;
  background: var(--primary-light);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  margin: 2px;
}

/* ===== Chat Layout ===== */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 860px) {
  .chat-layout { grid-template-columns: 1fr 420px; }
}

.chat-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 140px);
  min-height: 500px;
  overflow: hidden;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Message bubbles */
.message { display: flex; gap: 10px; align-items: flex-start; }
.message.user { flex-direction: row-reverse; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.message.assistant .avatar { background: var(--primary); }
.message.user .avatar { background: var(--accent); }

.bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.7;
}
.message.assistant .bubble {
  background: #f1f5f9;
  border-radius: 4px 18px 18px 18px;
}
.message.user .bubble {
  background: var(--primary);
  color: white;
  border-radius: 18px 4px 18px 18px;
}

/* Markdown inside bubbles */
.bubble h2, .bubble h3 { margin: 12px 0 6px; color: var(--primary-dark); font-size: 15px; }
.bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }
.bubble ul, .bubble ol { padding-left: 18px; margin: 6px 0; }
.bubble li { margin: 4px 0; }
.bubble strong { color: var(--primary-dark); }
.message.user .bubble strong { color: white; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.bubble p { margin: 6px 0; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble code { background: rgba(0,0,0,0.07); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* Typing indicator */
.typing-indicator .bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}
.dot {
  width: 8px; height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Itinerary action button */
.itinerary-btn {
  margin-top: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.15s;
  font-family: inherit;
}
.itinerary-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* ===== Chat Input ===== */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  background: var(--surface);
}
.quick-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.quick-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.quick-btn:hover { background: var(--primary-light); color: white; border-color: var(--primary-light); }

.input-row { display: flex; gap: 8px; align-items: flex-end; }
#chatInput {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
#chatInput:focus { border-color: var(--primary-light); }

.send-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
  white-space: nowrap;
}
.send-btn:hover { background: var(--primary-dark); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* ===== Itinerary Panel ===== */
.itinerary-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 140px);
  min-height: 400px;
  position: sticky;
  top: 80px;
}
.itinerary-panel.hidden { display: none; }

.itinerary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.itinerary-header h3 { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.close-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.close-btn:hover { background: var(--border); }

.itinerary-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 14px;
  line-height: 1.75;
}
.itinerary-content::-webkit-scrollbar { width: 4px; }
.itinerary-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.itinerary-content h2, .itinerary-content h3 { color: var(--primary-dark); margin: 14px 0 6px; font-size: 15px; }
.itinerary-content h2:first-child { margin-top: 0; }
.itinerary-content ul, .itinerary-content ol { padding-left: 18px; margin: 6px 0; }
.itinerary-content li { margin: 4px 0; }
.itinerary-content strong { color: var(--primary); }
.itinerary-content hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.itinerary-content p { margin: 6px 0; }

.itinerary-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.print-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s;
}
.print-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Loading Spinner ===== */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
.modal-box {
  position: relative;
  background: white;
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 480px;
  width: 90%;
  max-height: 80dvh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-box h3 { font-size: 18px; margin-bottom: 16px; color: var(--primary-dark); }
.mountain-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.mountain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8fafb;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.mountain-item:hover { border-color: var(--primary); background: #f0fdf4; }
.mountain-item-name { font-weight: 600; font-size: 15px; }
.mountain-item-info { font-size: 12px; color: var(--text-muted); }
.modal-close {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-muted);
  transition: border-color 0.15s;
}
.modal-close:hover { border-color: var(--text-muted); }

/* ===== Print styles ===== */
@media print {
  .header, .chat-panel, .itinerary-footer, .chat-meta { display: none !important; }
  .itinerary-panel {
    position: static;
    max-height: none;
    box-shadow: none;
    border: none;
  }
  .itinerary-content { overflow: visible; }
}

/* ===== Mobile adjustments ===== */
@media (max-width: 600px) {
  .main { padding: 16px 12px; }
  .step-header h2 { font-size: 20px; }
  .chat-panel { height: calc(100dvh - 120px); min-height: 400px; }
  .bubble { max-width: 90%; font-size: 13px; }
}
