@font-face { font-family: 'Archivo'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/archivo-500.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/archivo-600.woff2') format('woff2'); }

:root {
  --bg: #FFFFFF; /* 상단 바, 입력 영역, 로그인/설정 화면 */
  --chat-bg: #F6F6F7; /* 대화 영역 바탕 */
  --ink: #1F1F1F;
  --ink-sub: #6B6B6B;
  --ink-faint: #8C8C8C;
  --apollo-card: #FFFFFF;
  --apollo-card-shadow: 0 1px 2px rgba(31, 31, 31, 0.05), 0 6px 20px rgba(31, 31, 31, 0.05);
  --me: #FF7A3D; /* 내 메시지 말풍선 */
  --approval: #FFF4EE;
  --approval-btn: #FF7A3D;
  --approval-label: #C2562A;
  --approval-time: #A07A66;
  --code: #F6F6F7; /* 아폴로 카드 안의 코드 바탕 */
  --approval-code: #FFFFFF; /* 승인 카드 안의 명령 칸 */
  --accent: #A3471E; /* 링크, 오류 문구 */
  --ember: #FF7A3D;
  --sans: 'Archivo', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --body: 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* 상태 표시줄 아래가 흐려 보이지 않도록: 문서는 스크롤하지 않고, 스크롤은 대화 목록 상자 안에서만 일어난다.
   바탕은 단색 흰색(반투명, backdrop-filter 없음). 노치 영역은 상단 바 안의 padding-top 으로 같은 흰색을 채운다. */
html, body { margin: 0; padding: 0; height: 100%; background: #FFFFFF; overflow: hidden; overscroll-behavior: none; }
body {
  height: 100dvh; color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.55; font-weight: 400;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { display: inline-block; flex: none; line-height: 0; }
.icon svg { width: 100%; height: 100%; display: block; }

.wordmark { margin: 0; font-family: var(--sans); font-weight: 600; letter-spacing: 0.18em; color: var(--ink); }
.wordmark-sm { font-size: 15px; line-height: 1; }
.wordmark-lg { font-size: 26px; line-height: 1.2; letter-spacing: 0.24em; margin-right: -0.24em; }

.btn-top { min-height: 44px; min-width: 44px; padding: 0 20px 0 12px; font-size: 14px; color: var(--ink-sub); }
.btn-primary { height: 52px; width: 100%; background: var(--ember); color: #FFFFFF; font-size: 16px; font-weight: 600; border-radius: 12px; }
.btn-row { min-height: 52px; width: 100%; padding: 0; text-align: left; font-size: 15px; color: var(--ink); }
.btn-row:disabled { color: var(--ink-faint); cursor: default; }
.link { min-height: 44px; font-size: 13px; color: var(--ink-sub); align-self: center; }
.note { margin: 0; font-size: 13px; color: var(--ink-faint); text-align: center; }
.error { margin: 0; font-size: 13px; color: var(--accent); text-align: center; }

.update-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: env(safe-area-inset-top) 16px 0; min-height: calc(44px + env(safe-area-inset-top));
  background: var(--ink); color: #FFFFFF; font-size: 13px;
}
.update-bar .btn-top { color: #FFFFFF; text-decoration: underline; padding: 0 8px; }

/* 로그인 / 등록 */
.login { position: fixed; inset: 0; display: flex; flex-direction: column; background: #FFFFFF; }
.login-top { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: env(safe-area-inset-top) 20px 0; }
.login-top .icon { margin-bottom: 4px; }
.tagline { margin: 0; font-size: 14px; color: var(--ink-faint); }
.login-bottom { display: flex; flex-direction: column; gap: 12px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); }

/* 공통 앱 틀: 화면에 고정, 상단 바 / 대화 목록 / 입력 영역 */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; background: #FFFFFF; }
.topbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; background: #FFFFFF;
  height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  position: relative; z-index: 3; transition: box-shadow 200ms ease;
}
/* 대화 목록이 맨 위가 아닐 때만 상단 바 아래에 그림자(맨 위로 돌아오면 사라짐) */
.topbar.scrolled { box-shadow: 0 1px 0 rgba(31, 31, 31, 0.04), 0 8px 24px rgba(31, 31, 31, 0.05); }
@media (prefers-reduced-motion: reduce) { .topbar { transition: none; } }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .icon { width: 22px; height: 22px; }
.offline-bar { flex: none; padding: 8px 20px; background: var(--chat-bg); font-size: 13px; color: var(--ink-sub); }

/* 대화 목록: 바탕 #F6F6F7, 좌우 16px, 메시지 간격 18px */
.timeline {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: var(--chat-bg);
  display: flex; flex-direction: column; gap: 18px; padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}
.row { display: flex; flex-direction: column; max-width: min(86vw, 100%); align-self: flex-start; }
.row.me { max-width: min(80vw, 100%); align-self: flex-end; align-items: flex-end; }
/* 같은 사람이 연달아 보낸 메시지는 간격 8px(목록 간격 18px - 10px)로 붙이고 라벨은 생략한다 */
.row.cont { margin-top: -10px; }
.label { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-family: var(--sans); font-weight: 500; font-size: 11px; letter-spacing: 0.12em; color: var(--ink-faint); }
.label .icon { width: 14px; height: 14px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* 아폴로 메시지: 라벨(해 아이콘 + APOLLO · 시각)은 카드 밖 위쪽, 본문 전체를 흰 카드에 담는다(그림자만, 선 없음) */
.row:not(.me) > .text { padding: 14px 16px; background: var(--apollo-card); border-radius: 16px 16px 16px 4px; box-shadow: var(--apollo-card-shadow); }
.row.me .text { padding: 10px 14px; background: var(--me); color: #FFFFFF; border-radius: 16px 16px 4px 16px; }

/* 아폴로 답변의 마크다운 */
.md-text { white-space: normal; }
.md > * { margin: 0; }
.md > * + * { margin-top: 10px; }
.md strong { font-weight: 700; }
.md h3.md-h { font-size: 16px; font-weight: 700; line-height: 1.5; }
.md ul, .md ol { padding-left: 18px; }
.md li + li { margin-top: 4px; }
.md li > ul, .md li > ol { margin-top: 4px; }
.md code { padding: 0 4px; background: var(--code); border-radius: 4px; font-family: var(--mono); font-size: 0.92em; }
.md pre { padding: 10px 12px; background: var(--code); border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; font-family: var(--mono); font-size: 13px; line-height: 1.5; white-space: pre; }
.md pre code { padding: 0; background: none; border-radius: 0; font-size: inherit; }
.md a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }

/* 승인 카드: #FFF4EE 면, 16px 모서리, 그림자 없음. 명령 칸은 흰색 */
.approval { align-self: stretch; max-width: 360px; padding: 14px 16px 6px; background: var(--approval); border-radius: 16px; }
.approval-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.approval-title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--approval-label); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ember); flex: none; }
.remaining { font-family: var(--sans); font-weight: 500; font-size: 11px; color: var(--approval-time); }
.cmd { margin: 0; padding: 10px 12px; background: var(--approval-code); border-radius: 8px; font-family: var(--mono); font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cwd { margin: 8px 0 0; font-size: 12px; color: var(--approval-time); overflow-wrap: anywhere; }
.approval-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; min-height: 52px; margin-top: 4px; }
.approval-foot .deny { min-height: 44px; padding: 0 12px; font-size: 14px; color: var(--ink-sub); }
.approval-foot .allow { height: 40px; padding: 0 18px; font-size: 14px; font-weight: 600; color: #FFFFFF; background: var(--approval-btn); border-radius: 20px; }
.approval-foot button:disabled { opacity: 0.4; cursor: default; }
.approval-state { font-size: 13px; color: var(--approval-time); }

/* 답변 작성 중: 후광 두 겹이 천천히 숨 쉬듯 */
.thinking { display: flex; align-items: center; gap: 8px; align-self: flex-start; font-size: 13px; color: var(--ink-faint); }
.thinking .icon { width: 14px; height: 14px; }
.thinking .halo-outer, .thinking .halo-inner { transform-box: fill-box; transform-origin: center; animation: breathe 2.4s ease-in-out infinite; }
.thinking .halo-inner { animation-delay: 0.3s; }
@keyframes breathe { 0%, 100% { transform: scale(0.9); opacity: 0.6; } 50% { transform: scale(1.1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .thinking .halo-outer, .thinking .halo-inner { animation: none; } }

.empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.empty .icon { width: 72px; height: 72px; }
.empty p { margin: 0; font-size: 15px; color: var(--ink-sub); }

/* 입력 영역: 흰 띠 + 위쪽 그림자(선 없음), 입력칸 #F6F6F7(22px), 오른쪽 44px 원형 주황 보내기 버튼 */
.send-error { flex: none; padding: 8px 20px; background: var(--chat-bg); color: var(--accent); font-size: 13px; }
.composer {
  flex: none; position: relative; z-index: 2; display: flex; align-items: flex-end; gap: 8px; background: #FFFFFF;
  box-shadow: 0 -1px 0 rgba(31, 31, 31, 0.04), 0 -8px 24px rgba(31, 31, 31, 0.05);
  padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: var(--chat-bg); color: var(--ink); box-shadow: none;
  font-family: var(--body); font-size: 16px; line-height: 1.5; border-radius: 22px; padding: 10px 18px; min-height: 44px; max-height: calc(1.5em * 5 + 20px); overflow-y: auto;
}
.send { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--ember); color: #FFFFFF; }
.send svg { width: 22px; height: 22px; display: block; }
.send:disabled { opacity: 0.4; cursor: default; }

/* 설정: 글자 줄로 나열, 사이는 여백으로만 구분 */
.settings { flex: 1; min-height: 0; overflow-y: auto; padding: 12px max(20px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 8px; }
.settings .note { text-align: left; margin-top: -4px; }

/* 구글 콜백 등 서버가 만든 단순 페이지 */
body.plain { display: flex; align-items: center; justify-content: center; }
.plain-main { padding: 24px; text-align: center; }
.plain-msg { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
