@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ─────────────────────────────────── */
:root {
  --bg:           #FFFFFF;
  --bg-soft:      #F8FAFC;
  --bg-card:      #FFFFFF;
  --border:       #E2E8F0;
  --primary:      #0EA5E9;
  --primary-dark: #0284C7;
  --primary-bg:   #F0F9FF;
  --primary-ring: rgba(14, 165, 233, 0.2);
  --safe:         #059669;
  --safe-bg:      #ECFDF5;
  --safe-border:  #A7F3D0;
  --danger:       #DC2626;
  --danger-bg:    #FEF2F2;
  --danger-border:#FECACA;
  --warning:      #D97706;
  --warning-bg:   #FFFBEB;
  --warning-border:#FDE68A;
  --text:         #0F172A;
  --text-sub:     #475569;
  --text-muted:   #94A3B8;
  --font:         'Outfit', -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  --radius:       16px;
  --radius-sm:    10px;
  --radius-xs:    8px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 10px 24px rgba(0,0,0,0.1);
  --transition:   all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

/* ── App Shell ──────────────────────────────────────── */
#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.btn-language {
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--primary-dark);
  padding: 6px 10px;
  font-weight: 700;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
}

.btn-restart-home {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-restart-home:active { background: var(--border); }

.step-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Progress bar */
.progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.scan-progress-label {
    min-height: 1.2em;
    margin-top: 6px;
    color: #64748b;
    font-size: 12px;
    text-align: center;
}

/* ── Chat Thread ──────────────────────────────────────── */
#chat-thread {
  flex: 1;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.msg-row.bot { justify-content: flex-start; }
.msg-row.user { justify-content: flex-end; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: #fff;
}

.bubble {
  max-width: 80%;
  padding: 13px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-line;
  animation: bubble-in 0.25s ease both;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bubble.bot {
  background: var(--bg-soft);
  color: var(--text);
  border-bottom-left-radius: 6px;
}
.bubble.user {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 6px;
  font-weight: 600;
}
.bubble.wide {
  max-width: 100%;
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 18px;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 6px 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

/* Inline scan checklist (appears inside a bot bubble) */
.scan-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.scan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.scan-item.appear { opacity: 1; transform: translateY(0); }
.scan-dot { width: 7px; height: 7px; background: var(--primary); border-radius: 50%; flex-shrink: 0; }
.scan-item-text { font-size: 13.5px; color: var(--text); flex: 1; }
.scan-item-check { color: var(--safe); font-size: 15px; opacity: 0; transition: opacity 0.2s; }
.scan-item-check.show { opacity: 1; }

/* ── Composer (fixed bottom reply area) ───────────────── */
#composer {
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
}
#composer.hidden { display: none; }

.chip-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}
.chip-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.chip-option:active { transform: scale(0.99); }
.chip-option.selected { border-color: var(--primary); background: var(--primary-bg); }
.chip-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.chip-text { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.chip-check {
  width: 19px; height: 19px;
  border: 2px solid var(--border);
  border-radius: 5px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  transition: var(--transition);
}
.chip-option.selected .chip-check { background: var(--primary); border-color: var(--primary); color: #fff; }

.composer-actions { display: flex; flex-direction: column; gap: 8px; }

.composer-input-row { display: flex; gap: 8px; }
.composer-input-row input {
  flex: 1;
  height: 48px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: var(--transition);
}
.composer-input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  letter-spacing: -0.2px;
}
.btn-primary:disabled { background: #CBD5E1; cursor: not-allowed; }
.btn-primary:not(:disabled):active { transform: scale(0.98); }

.btn-secondary {
  width: 100%;
  height: 44px;
  background: transparent;
  color: var(--text-sub);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}
.btn-secondary:active { background: var(--bg-soft); }

.btn-safe { background: linear-gradient(135deg, #059669, #047857); }
.btn-danger { background: linear-gradient(135deg, #DC2626, #B91C1C); }

.btn-link-inline {
  display: inline-block;
  margin-top: 10px;
  color: var(--primary);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}

/* ── Report Card ─────────────────────────────────────── */
.report-header {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  border-radius: 16px;
  padding: 20px;
  margin: -2px -2px 16px;
  color: #fff;
}
.report-score-row { display: flex; align-items: center; gap: 16px; }
.score-ring-wrap { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.score-ring-wrap svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.score-ring-wrap .score-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
}
.report-meta h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.report-meta p { font-size: 12px; color: #94A3B8; }

.report-section { margin-bottom: 16px; }
.report-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.finding-card {
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.finding-card.danger { background: var(--danger-bg); border-color: var(--danger-border); }
.finding-card.warning { background: var(--warning-bg); border-color: var(--warning-border); }
.finding-card.safe { background: var(--safe-bg); border-color: var(--safe-border); }

.finding-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.finding-severity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.danger .finding-severity-dot { background: var(--danger); }
.warning .finding-severity-dot { background: var(--warning); }
.safe .finding-severity-dot { background: var(--safe); }
.finding-title { font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.4; flex: 1; }
.finding-detail { font-size: 13px; color: var(--text-sub); margin-bottom: 10px; line-height: 1.6; }
.finding-concern-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,0.06); padding: 3px 8px; border-radius: 6px;
  font-size: 11px; color: var(--text-sub); margin-bottom: 8px;
}
.finding-effects { display: flex; flex-direction: column; gap: 4px; }
.effect-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--safe); font-weight: 500; }
.effect-item::before { content: '✅'; font-size: 11px; }

.finding-not-found {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; background: var(--safe-bg); border: 1px solid var(--safe-border);
  border-radius: var(--radius-sm); margin-bottom: 10px;
}
.finding-not-found-icon { font-size: 18px; }
.finding-not-found-text { font-size: 13.5px; color: var(--safe); font-weight: 600; }

.report-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.report-note { text-align: center; font-size: 11.5px; color: var(--text-muted); line-height: 1.6; margin-top: 8px; }

/* ── Treatment ────────────────────────────────────────── */
.treatment-item {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.treatment-item-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.treatment-num {
  width: 28px; height: 28px; background: var(--primary); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.treatment-item-title { flex: 1; font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.4; }
.treatment-steps { display: flex; flex-direction: column; gap: 9px; padding-left: 38px; }
.treatment-step { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; color: var(--text-sub); line-height: 1.5; }
.treatment-step-num { font-size: 11.5px; font-weight: 700; color: var(--primary); width: 18px; flex-shrink: 0; padding-top: 2px; }

.treatment-done-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 12px; margin-left: 38px;
  padding: 8px 14px;
  background: var(--safe-bg); border: 1px solid var(--safe-border);
  border-radius: var(--radius-xs);
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--safe);
  cursor: pointer; transition: var(--transition);
}
.treatment-done-btn.completed { background: var(--safe); color: #fff; border-color: var(--safe); }

.treatment-locked {
  background: var(--bg);
  border: 1px dashed #CBD5E1;
  border-radius: var(--radius-xs);
  padding: 13px 14px;
  flex-direction: row;
  align-items: center;
  gap: 9px;
}
.lock-icon { font-size: 17px; }
.lock-text { font-size: 12.5px; color: #94A3B8; }

.shred-banner {
  background: linear-gradient(135deg, #1E293B, #0F172A);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  margin-top: 18px;
  color: #fff;
}
.shred-banner h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.shred-banner p { font-size: 12.5px; color: #94A3B8; margin-bottom: 16px; }

/* ── Payment Gate ─────────────────────────────────────── */
.payment-gate {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border: 1px solid #BAE6FD;
  border-radius: 16px;
  padding: 22px 18px;
  text-align: center;
  margin-top: 16px;
}
.payment-gate-icon { font-size: 40px; margin-bottom: 10px; }
.payment-gate h3 { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.payment-gate p { font-size: 13.5px; color: var(--text-sub); line-height: 1.6; margin-bottom: 18px; }
.payment-price { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 4px; letter-spacing: -1px; }
.payment-price-note { font-size: 11.5px; color: var(--text-muted); margin-bottom: 18px; }
.payment-features { display: flex; flex-direction: column; gap: 6px; text-align: left; margin-bottom: 18px; }
.payment-feature { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-sub); }
.payment-feature::before { content: '✅'; font-size: 12px; }

/* ── Loader ──────────────────────────────────────────── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
}
.loader-overlay.hidden { display: none; }
.spinner {
  width: 40px; height: 40px;
  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); } }
.loader-text { font-size: 14px; font-weight: 600; color: var(--text-sub); }

/* ── Misc ────────────────────────────────────────────── */
.hidden { display: none !important; }
.info-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 12.5px;
  color: var(--text-sub);
  line-height: 1.6;
  margin-top: 10px;
}
.info-box strong { color: var(--text); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 390px) {
  #chat-thread { padding: 16px 12px 12px; }
  .bubble { max-width: 86%; font-size: 14px; }
}
