:root {
  --bg: #f6f9ff;
  --grad-a: #cfe6ff;
  --grad-b: #e7f0ff;
  --ink: #1d2433;
  --muted: #5b6577;
  --accent: #2f6df6;
  --card: #ffffff;
  --chip: #eef3ff;
  --line: #e6ebf5;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  min-height: 100vh;
  min-height: 100svh;       /* 모바일: 주소창 보이는 상태 기준(아래 .hero 주석 참조) */
  overflow-x: hidden;       /* 가로 스크롤 방지(칩·원문 등 넓은 요소 대비) */
}

/* ── 히어로 (State A: 중앙 / State B: 상단 축소) ── */
.hero {
  background: radial-gradient(900px 420px at 50% -10%, var(--grad-a), var(--grad-b) 70%, var(--bg));
  display: flex;
  flex-direction: column;
  /* ⚠️ 모바일 100vh 함정: vh 는 '주소창이 접힌' 큰 높이라 실제 보이는 화면보다 커서
     ① 항상 세로 스크롤이 생기고 ② 수직중앙이 안 보이는 영역까지 포함해 계산돼 어긋난다.
     svh(small viewport height) = 주소창이 보이는 상태의 높이 = 넘치지 않는 안전값.
     vh 줄은 svh 미지원 구형 브라우저 폴백(뒤 선언이 이김). */
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 16px;
  transition: min-height .35s ease, padding .35s ease;
}
/* State A: 화면을 상/하 반으로 나눠 경계(=페이지 수직중앙)에 [브랜드 밑]이 오게.
   위 절반=브랜드(하단정렬) / 아래 절반=검색창(상단정렬). */
.hero-top { flex: 1 1 50%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.hero-bottom { flex: 1 1 50%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 28px; }

/* State B(검색 후): 컴팩트하게 위로 모음 */
body.searched .hero { min-height: auto; padding: 22px 16px 18px; }
body.searched .hero-top, body.searched .hero-bottom { flex: 0 0 auto; padding-top: 0; }

.brand { text-align: center; margin-bottom: 0; transition: margin .3s ease; }
body.searched .brand { margin-bottom: 14px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 22px; color: #fff; font-weight: 700; font-size: 34px;
  background: linear-gradient(145deg, #4b8bff, #6366f1);
  box-shadow: 0 12px 30px rgba(99,102,241,.36);
}
.brand h1 { font-size: 34px; margin: 16px 0 6px; font-weight: 700; }
.beta { font-size: 17px; color: var(--accent); font-style: italic; font-weight: 600; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
body.searched .tagline { display: none; }

/* ── 검색창 ── */
.search-box {
  display: flex; align-items: center; width: min(680px, 92vw);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(47,109,246,.12);
  padding: 6px 6px 6px 22px;
}
.search-box input {
  flex: 1; border: 0; outline: 0; font-size: 16px; background: transparent; color: var(--ink);
  padding: 12px 8px;
}
.search-box input::placeholder { color: #9aa3b5; }
.search-box button {
  border: 0; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; color: #fff; font-size: 20px;
  background: linear-gradient(145deg, #4b8bff, #2f6df6);
  box-shadow: 0 6px 16px rgba(47,109,246,.35);
}

/* ── 결과 ── */
.results { width: min(760px, 94vw); margin: 8px auto 60px; }
.results-head { margin: 6px 4px 16px; }
.results-q { display: block; font-size: 18px; font-weight: 600; }
.results-note { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.cards { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 18px 14px; box-shadow: 0 4px 16px rgba(29,36,51,.05);
  animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card .headline { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.card .score { float: right; font-size: 12px; color: var(--accent); font-weight: 600; }
.card .answer { margin: 0 0 10px; color: var(--ink); font-size: 14px; line-height: 1.7;
  padding: 10px 12px; background: #f3f7ff; border-left: 3px solid var(--accent); border-radius: 8px; }
.card .summary { margin: 0 0 12px; color: #36404f; font-size: 13px; line-height: 1.6; }
.card .sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip {
  font-size: 12px; color: #355; background: var(--chip); border: 1px solid #dde6fb;
  border-radius: 999px; padding: 3px 10px;
}
a.chip-link { text-decoration: none; color: var(--accent); }
a.chip-link:hover { background: #e2ecff; border-color: #c5d6fb; }

/* 한 상황 카드 안의 해석 요소(facet) 아코디언 */
.facets { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.facet { border: 1px solid var(--line); border-radius: 10px; background: #fcfdff; }
.facet > summary {
  cursor: pointer; list-style: none; padding: 9px 12px; display: flex; align-items: center;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::before { content: "›"; color: var(--accent); font-weight: 700; margin-right: 8px; transition: transform .2s ease; }
.facet[open] > summary::before { transform: rotate(90deg); }
.facet-type { font-size: 13px; font-weight: 600; color: var(--ink); }
.facet-body { padding: 0 12px 12px; }
.facet-body p { margin: 2px 0 8px; font-size: 14px; line-height: 1.65; color: #46506a; }

.facet .raw-wrap { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 6px; }
.facet .raw-wrap summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.card .raw { margin: 8px 0 0; font-size: 13px; white-space: pre-wrap;
  background: #fafbff; border-radius: 10px; padding: 10px; color: #4a5568; }

/* ②다중카드 생성 중 — 셔머 스켈레톤(사이트 톤) + 부드러운 caret. 출처·헤드라인은 확정. */
.sk-lines { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.sk-line { height: 11px; border-radius: 6px; width: 100%;
  background: linear-gradient(100deg, #eaf1ff 30%, #f7faff 50%, #eaf1ff 70%);
  background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; }
.sk-line.short { width: 58%; }
@keyframes shimmer { 0% { background-position: 150% 0; } 100% { background-position: -50% 0; } }
.card .stream-text { margin: 10px 0 0; font-size: 14px; line-height: 1.75;
  color: #46506a; white-space: pre-wrap; }
.card .stream-text::after { content: ""; display: inline-block; width: 2px; height: 1.05em;
  vertical-align: text-bottom; margin-left: 3px; border-radius: 2px; background: var(--accent);
  animation: caret 1.15s ease-in-out infinite; }
@keyframes caret { 0%, 100% { opacity: .12; } 50% { opacity: .5; } }

.status { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
/* 부드러운 '생각 중' — 딱딱한 점(···) 대신 은은한 호흡(opacity) 애니메이션. */
.status.thinking { animation: breathe 1.9s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

/* ── 모바일(≤480px) ──────────────────────────────────────────────
   목표: State A(검색 전)가 한 화면에 '스크롤 없이' 들어오고 수직중앙이 맞을 것.
   브랜드 블록이 데스크톱 크기 그대로면 작은 화면에서 반분할이 넘치므로 축소한다.
   ⚠️ .search-box input 의 font-size 는 16px 미만으로 내리지 말 것 — iOS Safari 가
      16px 미만 입력창에 포커스하면 페이지를 자동 확대(줌)한다. */
@media (max-width: 480px) {
  .hero { padding: 0 14px; }
  .hero-bottom { padding-top: 20px; }
  .logo { width: 56px; height: 56px; border-radius: 18px; font-size: 26px; }
  .brand h1 { font-size: 26px; margin: 12px 0 4px; }
  .beta { font-size: 14px; }
  .tagline { font-size: 13px; }

  .search-box { width: 100%; padding: 5px 5px 5px 16px; }
  .search-box button { width: 40px; height: 40px; font-size: 18px; }

  body.searched .hero { padding: 16px 14px 14px; }

  .results { width: 100%; padding: 0 12px; margin-bottom: 40px; }
  .card { padding: 15px 14px 12px; border-radius: 14px; }
  /* 관련도 배지: 좁은 화면에서 float 이 제목과 겹쳐 보이므로 제목 위 별도 줄로 */
  .card .headline { display: flex; flex-wrap: wrap-reverse; gap: 4px 8px; align-items: baseline; }
  .card .score { float: none; margin-left: auto; }
  .card .raw { font-size: 12px; max-height: 40vh; overflow-y: auto; }
  .facet-body p { font-size: 13px; }
}

/* 가로모드·낮은 화면(세로 여백 부족): 반분할을 포기하고 자연스럽게 위에서 흐르게 */
@media (max-height: 520px) {
  .hero { min-height: auto; padding-top: 24px; padding-bottom: 20px; }
  .hero-top, .hero-bottom { flex: 0 0 auto; }
  .hero-bottom { padding-top: 18px; }
}

/* 👍👎 피드백 바(RLHF 수집) — 카드 하단, 사이트 톤(둥근·연한) */
.feedback {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid #eef0f4;
}
.fb-label { font-size: 13px; color: #8a94a6; }
.fb-btn {
  border: 1px solid #dfe3ea; background: #fff; border-radius: 999px;
  padding: 4px 11px; cursor: pointer; font-size: 15px; line-height: 1;
  transition: transform .1s ease, background .12s, border-color .12s;
}
.fb-btn:hover { background: #f5f7fb; }
.fb-btn:active { transform: scale(.9); }
.fb-btn.chosen { border-color: #2f6df6; background: #eef3ff; }
.feedback.voted .fb-btn { cursor: default; opacity: .5; }
.feedback.voted .fb-btn.chosen { opacity: 1; }
