:root {
  --primary: #ff6b35;
  --primary-light: #fff3ee;
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e9ecef;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --area-dongtan: #ff6b35;
  --area-yongin: #4caf82;
  --area-suwon: #5b8def;
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
}

.app { display: flex; flex-direction: column; height: 100dvh; }

/* 헤더 */
.header { background: var(--primary); color: white; padding: 10px 20px; flex-shrink: 0; }
.header-inner { max-width: 1300px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.header-logo {
  width: 52px; height: 52px; object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25)) brightness(1.05);
}
.header h1 { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.subtitle { font-size: 0.8rem; opacity: 0.85; }

/* 지역 필터 */
.area-filter {
  display: flex; gap: 8px; padding: 10px 20px;
  background: white; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.area-btn {
  padding: 5px 16px; border: 1.5px solid var(--border); border-radius: 20px;
  background: white; color: var(--text-muted); cursor: pointer;
  font-size: 0.88rem; font-weight: 500; transition: all 0.15s;
}
.area-btn.active[data-area="전체"], .area-btn:hover { background: var(--primary); border-color: var(--primary); color: white; }
.area-btn.active[data-area="동탄"] { background: var(--area-dongtan); border-color: var(--area-dongtan); color: white; }
.area-btn.active[data-area="용인"] { background: var(--area-yongin); border-color: var(--area-yongin); color: white; }
.area-btn.active[data-area="수원"] { background: var(--area-suwon); border-color: var(--area-suwon); color: white; }

/* 모델 선택 */
.model-selector {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
}
.model-selector label { font-size: 0.9rem; }
.model-selector select {
  padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 16px;
  background: white; color: var(--text); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236c757d'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  padding-right: 24px;
}
.model-selector select:focus { border-color: var(--primary); }

/* 메인 레이아웃 */
.main {
  display: flex; flex: 1; overflow: hidden;
  max-width: 1300px; width: 100%; margin: 0 auto;
  padding: 14px 16px; gap: 14px;
}

/* 채팅 섹션 */
.chat-section {
  flex: 1; display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; min-width: 0;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}

/* 버블 메시지 */
.message { display: flex; max-width: 78%; }
.message.user { margin-left: auto; flex-direction: row-reverse; }
.message.assistant { margin-right: auto; }
.message.wide { max-width: 100%; }

.message-content {
  padding: 11px 15px; border-radius: 18px;
  line-height: 1.65; font-size: 0.93rem;
  white-space: pre-wrap; word-break: keep-all;
}
.message.user .message-content {
  background: var(--primary); color: white; border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
  background: var(--primary-light); color: var(--text); border-bottom-left-radius: 4px;
}

/* 타이핑 인디케이터 */
.typing-indicator { display: flex; gap: 4px; padding: 14px 16px; align-items: center; }
.typing-indicator span {
  width: 7px; height: 7px; background: var(--primary); border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── 추천 카드 래퍼 ── */
.cards-wrapper {
  display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 100%;
}
.cards-label {
  font-size: 0.8rem; color: var(--text-muted); font-weight: 600;
  padding: 0 2px; letter-spacing: 0.03em;
}
.cards-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}

/* 맛집 추천 카드 */
.rest-card {
  background: white; border: 1.5px solid var(--border); border-radius: 14px;
  width: 210px; flex-shrink: 0; overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: default;
}
.rest-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.13); }

/* 카드 이미지 영역 */
.rest-card .card-img {
  width: 100%; height: 110px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fff8f4 0%, #fff3ea 100%);
  border-bottom: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.rest-card .card-img img {
  width: 100px; height: 100px; object-fit: contain;
  filter: drop-shadow(2px 3px 4px rgba(0,0,0,0.12));
}
.rest-card .card-img .area-badge {
  position: absolute; top: 8px; left: 8px;
}

/* 카드 내용 */
.rest-card .card-body { padding: 12px 14px; }

.rest-card .area-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; color: white; margin-bottom: 8px;
}
.area-badge.dongtan { background: var(--area-dongtan); }
.area-badge.yongin  { background: var(--area-yongin); }
.area-badge.suwon   { background: var(--area-suwon); }

.rest-card .card-name { font-size: 0.97rem; font-weight: 700; margin-bottom: 5px; line-height: 1.3; }
.rest-card .card-cuisine {
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px;
}
.rest-card .card-price {
  font-size: 0.82rem; font-weight: 600; color: var(--primary); margin-bottom: 8px;
}
.rest-card .card-meta {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 0.76rem; color: var(--text-muted); line-height: 1.5;
}
.rest-card .card-tip {
  margin-top: 10px; padding: 8px 10px;
  background: var(--primary-light); border-radius: 8px;
  font-size: 0.75rem; color: #c0440a; line-height: 1.5;
}
.rest-card .card-tag {
  margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px;
}
.rest-card .tag {
  font-size: 0.7rem; padding: 2px 7px; border-radius: 8px;
  background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
}

/* ── 타임라인 일정 ── */
.timeline-wrapper {
  display: flex; flex-direction: column; gap: 0; width: 100%;
  padding: 4px 0;
}
.timeline-summary {
  font-size: 0.83rem; color: var(--text-muted); line-height: 1.6;
  padding: 10px 12px; background: var(--bg); border-radius: 8px;
  margin-bottom: 14px;
}
.timeline-item {
  display: flex; gap: 0; position: relative;
}
.timeline-left {
  display: flex; flex-direction: column; align-items: center;
  width: 60px; flex-shrink: 0;
}
.timeline-time {
  font-size: 0.78rem; font-weight: 700; color: var(--primary);
  background: var(--primary-light); border: 2px solid var(--primary);
  border-radius: 20px; padding: 3px 8px; white-space: nowrap; z-index: 1;
}
.timeline-line {
  width: 2px; background: linear-gradient(to bottom, var(--primary), var(--border));
  flex: 1; margin-top: 4px; min-height: 20px;
}
.timeline-item:last-child .timeline-line { display: none; }

.timeline-card {
  flex: 1; background: white; border: 1.5px solid var(--border);
  border-radius: 14px; padding: 14px 16px; margin: 0 0 16px 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
}
.timeline-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.timeline-card .tl-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.timeline-card .tl-img {
  width: 56px; height: 56px; object-fit: contain; flex-shrink: 0;
  background: linear-gradient(135deg, #fff8f4, #fff0e8);
  border-radius: 10px; padding: 4px;
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.1));
}
.timeline-card .tl-name { font-size: 0.97rem; font-weight: 700; }
.timeline-card .tl-meta {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.7;
}
.timeline-card .tl-duration {
  margin-top: 8px; font-size: 0.76rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.timeline-card .tl-note {
  margin-top: 8px; padding: 7px 10px;
  background: var(--primary-light); border-radius: 8px;
  font-size: 0.76rem; color: #c0440a; line-height: 1.5;
}

/* 추천 질문 */
.suggestions {
  padding: 10px 14px; display: flex; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.suggestion-btn {
  padding: 5px 12px; border: 1.5px solid var(--primary); border-radius: 20px;
  background: white; color: var(--primary); cursor: pointer;
  font-size: 0.8rem; font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.suggestion-btn:hover { background: var(--primary); color: white; }

/* 입력 영역 */
.input-area {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border); align-items: flex-end;
}
#messageInput {
  flex: 1; padding: 9px 14px; border: 1.5px solid var(--border);
  border-radius: 22px; resize: none; font-size: 0.93rem; font-family: inherit;
  outline: none; max-height: 120px; line-height: 1.5; transition: border-color 0.15s;
}
#messageInput:focus { border-color: var(--primary); }
.send-btn {
  padding: 9px 18px; background: var(--primary); color: white;
  border: none; border-radius: 22px; cursor: pointer;
  font-size: 0.88rem; font-weight: 600; flex-shrink: 0; transition: opacity 0.15s;
}
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn:hover:not(:disabled) { opacity: 0.88; }

/* 오른쪽 패널 (일정) */
.schedule-panel {
  width: 360px; flex-shrink: 0; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.schedule-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.schedule-panel-header h2 { font-size: 0.97rem; font-weight: 700; }
.close-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-muted); }
.schedule-panel-body { flex: 1; overflow-y: auto; padding: 16px; }

/* 반응형 */
@media (max-width: 900px) {
  .schedule-panel { display: none !important; }
  .rest-card { width: 180px; }
}
@media (max-width: 600px) {
  .main { padding: 8px; gap: 0; }
  .message { max-width: 92%; }
  .rest-card { width: 100%; }
}
