/* ══════════════════════════════════════════════
   쿠폰24 챗봇 — Redesigned for visibility
   Color system:
     Primary:  #1e40af (deep blue) → #3b82f6 (bright blue)
     Accent:   #f97316 (orange) → #ea580c (deep orange)
     Success:  #16a34a (green)
     Danger:   #dc2626 (red)
     Surface:  #ffffff, #f8fafc, #f1f5f9
     Text:     #0f172a (heading), #334155 (body), #64748b (muted)
   ══════════════════════════════════════════════ */

* { box-sizing: border-box; margin: 0; padding: 0; word-break: keep-all; overflow-wrap: break-word; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 50%, #ede9fe 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px;
}

/* ── 앱 컨테이너 ── */
#app {
  display: flex; flex-direction: column;
  width: 100%; max-width: 640px; height: min(880px, calc(100dvh - 48px));
  background: #ffffff;
  border: none;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 20px 60px rgba(30, 64, 175, 0.15),
    0 4px 16px rgba(0, 0, 0, 0.08);
}

@media (max-width: 640px) {
  body { padding: 0; background: #ffffff; }
  #app {
    max-width: 100%; width: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .popular-section { display: none; }
    .msg { gap: 0; }
  #mobile-tags {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 12px;
    max-height: 80px; overflow: hidden;
    flex-shrink: 0;
    background: #f8fafc;
  }
  #mobile-tags:empty { display: none; }
  #mobile-tags .m-tag {
    padding: 5px 12px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    font-size: 12px; font-weight: 500; color: #475569;
    cursor: pointer; white-space: nowrap;
    font-family: inherit;
  }
  #mobile-tags .m-tag:active { background: #dbeafe; border-color: #93c5fd; }
  #mobile-tags.hidden { display: none; }
  .popular-toggle { padding-bottom: 3px; }
  .popular-grid { gap: 6px; }
  .pop-btn {
    flex: 0 0 120px;
    padding: 7px 9px;
    border-radius: 8px;
  }
  .pop-meta { margin-bottom: 2px; }
  .pop-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .pop-desc {
    font-size: 11px; margin-top: 1px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .badge-cat { font-size: 10px; padding: 1px 5px; }
  .popular-nav { width: 26px; height: 26px; }
  #input-row { padding: 7px 10px; }
}

/* ── PC 폰트 키움 ── */
@media (min-width: 641px) {
  .bubble { font-size: 17px; }
  .c-brand { font-size: 18px; }
  .c-name { font-size: 15px; }
  .c-value { font-size: 24px; }
  .c-code { font-size: 22px; letter-spacing: 0; padding: 12px 24px; }
  .c-hint { font-size: 13px; }
  .c-exp { font-size: 13px; }
  .c-btn { font-size: 14px; padding: 10px 16px; }
  .c-btn.link { font-size: 17px; padding: 14px 28px; }
  .pop-name { font-size: 16px; }
  .pop-desc { font-size: 14px; }
  .rec-name { font-size: 16px; }
  .rec-desc { font-size: 14px; }
  .mc-name { font-size: 17px; }
  .mc-stats { font-size: 14px; }
  #user-input { font-size: 17px; }
}

/* ══════════════════════════════════════
   헤더 — 그라디언트 블루
   ══════════════════════════════════════ */
#header {
  padding: 14px 18px;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  position: relative;
}
.h-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.h-icon svg { stroke: #ffffff; }
.h-icon svg circle { fill: #ffffff; }
.h-title {
  font-size: 19px; font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}
.h-sub { font-size: 13px; color: rgba(255, 255, 255, 0.75); margin-top: 1px; }
.h-reg-btn {
  margin-left: auto;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  color: #ffffff;
  cursor: pointer; white-space: nowrap; font-family: inherit;
  transition: all 0.2s;
}
.h-reg-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
}
.h-reg-btn:active { transform: translateY(0); }

/* ══════════════════════════════════════
   채팅 영역
   ══════════════════════════════════════ */
#messages {
  flex: 1; overflow-y: auto;
  padding: 16px; padding-bottom: 80px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
  background: #f8fafc;
  scrollbar-width: none; -ms-overflow-style: none;
}
#messages::-webkit-scrollbar { display: none; }

.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg.user { flex-direction: row-reverse; }


.bubble {
  max-width: 80%; padding: 12px 16px;
  border-radius: 18px 18px 18px 6px;
  font-size: 16px; line-height: 1.6;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.msg.user .bubble {
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.examples { margin-top: 6px; font-size: 13px; color: #94a3b8; }

/* ══════════════════════════════════════
   인기 쿠폰 섹션 + 모바일 태그 (데스크탑 숨김)
   ══════════════════════════════════════ */
@media (min-width: 641px) { #mobile-tags { display: none; } }
.popular-section {
  border-top: 1px solid #e2e8f0;
  padding: 10px 16px; background: #ffffff; flex-shrink: 0;
}
.popular-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 0 0 8px 0;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit;
}
.popular-label {
  font-size: 12px; font-weight: 700;
  color: #f97316;
  letter-spacing: 0;
  text-transform: uppercase;
}
.popular-toggle-text {
  font-size: 13px; font-weight: 500;
  color: #3b82f6;
  padding: 4px 10px;
  transition: color 0.15s;
}
.popular-toggle-text:hover { text-decoration: underline; }
.popular-section.collapsed .popular-toggle { padding-bottom: 0; }
.popular-section.collapsed .popular-grid-wrap { display: none; }

/* 좌우 네비 버튼 */
.popular-grid-wrap { position: relative; }
.popular-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  color: #334155;
  border: 1px solid #e2e8f0;
  cursor: pointer; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}
.popular-nav.prev { left: 4px; }
.popular-nav.next { right: 4px; }
.popular-nav:hover {
  background: #3b82f6; color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
  transform: translateY(-50%) scale(1.08);
}
.popular-nav:active { transform: translateY(-50%) scale(0.95); }
.popular-nav.disabled { opacity: 0; pointer-events: none; }

/* 가로 스크롤 그리드 */
.popular-grid {
  display: flex; gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  cursor: grab; user-select: none;
  padding: 2px 0;
}
.popular-grid::-webkit-scrollbar { display: none; }
.popular-grid.dragging { cursor: grabbing; }

.pop-btn {
  text-align: left; padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
  flex: 0 0 164px;
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
}
.pop-btn::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, #f97316, #ea580c);
  border-radius: 12px 0 0 12px;
  opacity: 0;
  transition: opacity 0.2s;
}
.pop-btn:hover {
  border-color: #f97316;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.12);
  transform: translateY(-2px);
}
.pop-btn:hover::before { opacity: 1; }
.pop-name {
  font-size: 15px; font-weight: 600;
  color: #0f172a;
}
.pop-desc {
  font-size: 13px; font-weight: 500;
  color: #f97316;
  margin-top: 3px;
}
.pop-meta { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.badge-cat {
  font-size: 11px; font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ══════════════════════════════════════
   입력창
   ══════════════════════════════════════ */
#input-row {
  display: flex; gap: 8px; padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff; flex-shrink: 0;
}
#user-input {
  flex: 1; padding: 12px 16px; font-size: 16px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#user-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  background: #ffffff;
}
#user-input::placeholder { color: #94a3b8; }
#send-btn {
  padding: 12px 20px; font-size: 15px; font-weight: 600;
  border-radius: 12px; border: none;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  cursor: pointer; font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
#send-btn:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}
#send-btn:active { transform: translateY(0); }

/* ══════════════════════════════════════
   발급 안내 헤더 + 오류 신고
   ══════════════════════════════════════ */
.issue-header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
.report-link {
  font-size: 12px; font-weight: 500;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
  transition: all 0.15s;
}
.report-link:hover { background: #fee2e2; border-color: #fca5a5; }
.report-link:disabled { opacity: 0.4; cursor: default; background: #fef2f2; }

/* ══════════════════════════════════════
   쿠폰 카드 — 핵심 비주얼
   ══════════════════════════════════════ */
.coupon-card {
  margin-top: 10px;
  background: linear-gradient(135deg, #fffbeb 0%, #fff7ed 100%);
  border: 2px solid #fed7aa;
  border-radius: 16px;
  padding: 18px; text-align: center;
  position: relative;
  overflow: hidden;
}
.coupon-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #f97316, #ea580c, #f59e0b);
}
.c-brand {
  font-size: 16px; font-weight: 700;
  color: #92400e;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.c-name {
  font-size: 14px; color: #78716c;
  margin-bottom: 6px;
}
.c-value {
  font-size: 22px; font-weight: 800;
  color: #ea580c;
  margin-bottom: 14px;
  line-height: 1.3;
}
.c-code {
  display: inline-block;
  font-family: 'Courier New', monospace;
  font-size: 18px; letter-spacing: 0; font-weight: 700;
  padding: 10px 22px;
  background: #ffffff;
  border: 2px dashed #f97316;
  border-radius: 10px;
  color: #ea580c;
  cursor: pointer; user-select: all;
  transition: all 0.2s;
}
.c-code:hover {
  background: #fff7ed;
  border-color: #ea580c;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15);
}
.c-image {
  display: block;
  max-width: 100%; max-height: 260px;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  cursor: pointer; background: #fff;
  object-fit: contain;
  transition: border-color 0.2s;
}
.c-image:hover { border-color: #f97316; }
.c-hint {
  font-size: 12px; color: #94a3b8;
  margin-top: 6px;
}
.c-exp {
  font-size: 12px; font-weight: 500;
  color: #78716c;
  margin-top: 12px;
  border-top: 1px solid #fed7aa;
  padding-top: 10px;
}
.c-actions {
  display: flex; gap: 8px;
  margin-top: 12px; justify-content: center;
}
.c-btn {
  font-size: 13px; padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff; color: #475569;
  cursor: pointer; font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.c-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.c-btn.report { color: #dc2626; border-color: #fecaca; }
.c-btn.report:hover { background: #fef2f2; }
.c-btn.link {
  color: #ffffff;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border: none;
  font-size: 15px;
  padding: 12px 24px;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(249, 115, 22, 0.3);
  transition: all 0.2s;
}
.c-btn.link:hover {
  background: linear-gradient(135deg, #ea580c, #dc2626);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.4);
  transform: translateY(-1px);
}
.c-btn:disabled {
  opacity: 0.35; cursor: not-allowed;
  color: #94a3b8 !important;
  border-color: #e2e8f0 !important;
  background: #f8fafc !important;
  box-shadow: none !important;
  transform: none !important;
}

/* ══════════════════════════════════════
   추천 목록
   ══════════════════════════════════════ */
.text-link {
  background: none; border: none;
  color: #3b82f6; font-size: 13px;
  cursor: pointer; text-decoration: underline;
  padding: 0; font-weight: 500;
}
.text-link:hover { color: #1d4ed8; }

.cat-group-label {
  margin-top: 12px; margin-bottom: 4px;
  font-size: 12px; font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cat-group-label:first-child { margin-top: 8px; }

.rec-list {
  margin-top: 6px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
}
.rec-item {
  padding: 10px 8px; border-radius: 12px;
  border: 1px solid #e2e8f0; background: #ffffff;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  transition: all 0.2s;
}
.rec-item:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}
.rec-name {
  font-size: 15px; font-weight: 600;
  color: #0f172a;
}
.rec-desc {
  font-size: 13px; font-weight: 500;
  color: #f97316;
  margin-top: 2px;
}

/* ══════════════════════════════════════
   타이핑 애니메이션
   ══════════════════════════════════════ */
.typing { display: flex; gap: 5px; align-items: center; padding: 8px 4px; }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #93c5fd; animation: blink 1.2s infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:0.3} 40%{opacity:1} }

/* ══════════════════════════════════════
   단계 입력
   ══════════════════════════════════════ */
.step-input { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.step-input .btn-row { display: flex; gap: 7px; justify-content: flex-end; }
.step-input button { align-self: flex-end; }
.step-input input {
  flex: 1; padding: 11px 14px; font-size: 16px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff; color: #0f172a;
  outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.step-input input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.step-input button {
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff; color: #334155;
  cursor: pointer; font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.step-input button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* ══════════════════════════════════════
   쿠폰 수정 폼
   ══════════════════════════════════════ */
.edit-form { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.edit-form label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; font-weight: 600; color: #64748b;
}
.edit-form input {
  padding: 9px 12px; font-size: 14px; border-radius: 8px;
  border: 1.5px solid #e2e8f0; background: #ffffff; color: #0f172a;
  outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.edit-form input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.edit-form-btns { display: flex; gap: 7px; margin-top: 4px; }

/* ══════════════════════════════════════
   내 쿠폰 현황
   ══════════════════════════════════════ */
.my-coupons { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.my-coupon-item {
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid #e2e8f0; background: #ffffff;
  transition: border-color 0.15s;
}
.my-coupon-item:hover { border-color: #cbd5e1; }
.mc-name {
  font-size: 16px; font-weight: 600;
  color: #0f172a;
  margin-bottom: 4px;
}
.mc-stats { font-size: 13px; color: #64748b; }
.mc-report { color: #dc2626; font-weight: 500; }
.mc-btns { display: flex; gap: 7px; margin-top: 10px; }
.mc-btn {
  font-size: 13px; padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff; color: #475569;
  cursor: pointer; font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.mc-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.mc-btn.del { color: #dc2626; border-color: #fecaca; }
.mc-btn.del:hover { background: #fef2f2; }

/* ══════════════════════════════════════
   카테고리 둘러보기
   ══════════════════════════════════════ */
.inline-action {
  display: inline-flex; align-items: center;
  margin-top: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1.5px solid #3b82f6;
  background: #eff6ff;
  font-size: 14px; font-weight: 600;
  color: #2563eb;
  cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.inline-action:hover {
  background: #3b82f6;
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(59, 130, 246, 0.25);
}

.cat-chip-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px;
  margin-top: 6px;
}
.cat-chip {
  padding: 10px 6px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  font-size: 13px; font-weight: 500;
  color: #334155;
  cursor: pointer; font-family: inherit;
  transition: all 0.15s;
  text-align: center;
}
.cat-chip:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #2563eb;
}
.cat-chip:active {
  background: #dbeafe;
  transform: scale(0.97);
}
