/* Aurora — 라이트 배경 + 리퀴드 글래스 (오로라 얼굴은 그대로) */
:root {
  --ink: #161a2e; --ink2: #5d637c; --ink3: #8a90a8;
  --glass-a: rgba(255, 255, 255, .74); --glass-b: rgba(255, 255, 255, .34);
  --rim: rgba(255, 255, 255, .85);
  --shadow: 0 10px 34px rgba(46, 56, 120, .13);
  --ai: linear-gradient(135deg, #ff8fd8, #ffb27a 30%, #7fe3c4 55%, #7fa6ff 78%, #b48cff);
  --spring: cubic-bezier(.34, 1.56, .64, 1); --spring-soft: cubic-bezier(.25, 1.18, .5, 1); --out: cubic-bezier(.22, 1, .36, 1);
  --font: -apple-system, 'SF Pro Display', 'SF Pro Text', 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #f5f7fd; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { display: flex; flex-direction: column; position: relative; overflow: hidden; }
/* 유리가 비춰 볼 부드러운 색 번짐 배경 */
body::before { content: ''; position: fixed; inset: -20%; z-index: -1; pointer-events: none; animation: drift 20s ease-in-out infinite alternate;
  background: radial-gradient(38vmax 38vmax at 16% 12%, rgba(255, 168, 214, .58), transparent 70%), radial-gradient(42vmax 42vmax at 90% 16%, rgba(146, 188, 255, .58), transparent 70%),
              radial-gradient(46vmax 46vmax at 74% 94%, rgba(196, 168, 255, .52), transparent 70%), radial-gradient(36vmax 36vmax at 8% 90%, rgba(158, 240, 214, .48), transparent 70%); }
@keyframes drift { to { transform: translate3d(2.5%, -2%, 0) scale(1.07); } }

/* ---------- 리퀴드 글래스 공통 ---------- */
#bubble, #ubub, #form, #gear, button, dialog, #log div, .info {
  background: linear-gradient(160deg, var(--glass-a), var(--glass-b));
  -webkit-backdrop-filter: blur(22px) saturate(185%); backdrop-filter: blur(22px) saturate(185%);
  border: 1px solid var(--rim);
  box-shadow: var(--shadow), inset 0 1.5px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(255, 255, 255, .35), inset 1.5px 0 0 rgba(255, 255, 255, .5), inset -1.5px 0 0 rgba(255, 255, 255, .25);
}
/* 윗부분의 빛 반사(스페큘러) */
#bubble::before, #ubub::before, #form::before, #gear::before, button::before, dialog::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(110% 70% at 22% -8%, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0) 58%); opacity: .75; }

main { flex: 1; display: flex; flex-direction: column; align-items: center; min-height: 0; padding: 64px 16px 0; position: relative; }
#stage { order: 1; position: relative; display: flex; flex-direction: column; align-items: center; flex: none; }
#face { width: min(58vw, 330px); height: auto; aspect-ratio: 1; flex: none; filter: drop-shadow(0 16px 30px rgba(140, 112, 255, .30)); }

/* 사용자가 말하거나 입력한 글: 얼굴 바로 아래에 살짝 내려앉는 유리 풍선 */
#ubub { position: relative; order: 1; width: max-content; z-index: 3; margin: -2px 0 2px; padding: 12px 20px; border-radius: 28px; max-width: min(88vw, 540px); font-size: 17px; line-height: 1.45; text-align: center; word-break: break-word; max-height: 24vh; overflow: auto;
  background: linear-gradient(150deg, rgba(168, 190, 255, .78), rgba(214, 176, 255, .58) 60%, rgba(255, 190, 228, .52));
  animation: pop .5s cubic-bezier(.2, 1.1, .3, 1.2) both; transition: opacity .8s, transform .8s; }
#ubub:empty { display: none; }
#ubub.fade { opacity: 0; transform: translateY(-6px) scale(.97); }
#ubub.typing::after { content: ''; display: inline-block; width: 2px; height: 1.05em; margin-left: 3px; vertical-align: text-bottom; background: var(--ink); border-radius: 1px; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }

/* 오로라의 답변 */
#bubble { order: 2; position: relative; margin: 6px 0 10px; padding: 14px 22px; border-radius: 28px; max-width: min(92vw, 600px); text-align: center; font-size: 16.5px; line-height: 1.55; white-space: pre-wrap; max-height: 32vh; overflow: auto; }
#log { order: 4; width: min(92vw, 600px); flex: 1; overflow: auto; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0 10px; font-size: 12.5px; color: var(--ink2); }
#log div { position: relative; padding: 6px 14px; border-radius: 999px; max-width: 100%; word-break: break-all; animation: pop .35s ease both; }

/* 입력 바: 둥근 유리 캡슐 + 포커스/생각 중일 때 애플 인텔리전스 빛 */
#form { position: relative; display: flex; align-items: center; gap: 8px; margin: 0 auto calc(16px + env(safe-area-inset-bottom)); padding: 6px 6px 6px 8px; width: min(92vw, 640px); border-radius: 999px; }
#form::after { content: ''; position: absolute; inset: -4px; padding: 4px; border-radius: inherit; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .5s; filter: blur(5px);
  background: conic-gradient(from var(--a, 0deg), #ff8fd8, #ffb27a, #fff08a, #7fe3c4, #7fa6ff, #b48cff, #ff8fd8); animation: glowSpin 5s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); mask-composite: exclude; }
#form:focus-within::after { opacity: .55; }
body.busy #form::after { opacity: 1; animation-duration: 1.5s; }
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes glowSpin { to { --a: 360deg; } }
#input { flex: 1; min-width: 0; padding: 11px 14px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16.5px; outline: none; position: relative; z-index: 1; }
#input::placeholder { color: var(--ink3); }

/* ---------- 버튼: 리퀴드 글래스 ---------- */
button { position: relative; font: inherit; font-weight: 600; font-size: 14.5px; color: var(--ink); padding: 10px 18px; border-radius: 999px; cursor: pointer; overflow: hidden;
  transition: transform .3s cubic-bezier(.2, 1, .3, 1.5), box-shadow .2s, filter .2s; }
button:hover { filter: brightness(1.03) saturate(1.1); }
button:active { transform: scale(.94); }
button.primary { color: #fff; text-shadow: 0 1px 3px rgba(70, 40, 170, .4); border-color: rgba(255, 255, 255, .65);
  background: linear-gradient(140deg, rgba(255, 130, 214, .9), rgba(150, 140, 255, .9) 55%, rgba(110, 170, 255, .9)); }
button.send { width: 46px; height: 46px; padding: 0; display: grid; place-items: center; flex: none; z-index: 1; }
#gear { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; z-index: 5; color: var(--ink2); border-radius: 50%; }
#gear svg, button.send svg { position: relative; }

/* ---------- 설정 시트 ---------- */
dialog { position: fixed; border: 0; border-radius: 34px; padding: 22px 22px 18px; width: min(92vw, 460px); max-height: 88vh; overflow: auto; color: var(--ink);
  background: linear-gradient(160deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .56)); -webkit-backdrop-filter: blur(36px) saturate(190%); backdrop-filter: blur(36px) saturate(190%);
  box-shadow: 0 30px 80px rgba(46, 56, 120, .28), inset 0 1.5px 0 rgba(255, 255, 255, .95); animation: pop .4s cubic-bezier(.2, 1.1, .3, 1.15) both; }
dialog::backdrop { background: rgba(222, 230, 252, .42); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
dialog h3 { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; position: relative; }
label { display: block; margin: 12px 0; font-size: 13px; font-weight: 600; color: var(--ink2); position: relative; }
label input:not([type=checkbox]), label select { display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border-radius: 16px; font: inherit; font-size: 15px; font-weight: 500; color: var(--ink); outline: none;
  background: rgba(255, 255, 255, .6); border: 1px solid rgba(255, 255, 255, .95); box-shadow: inset 0 2px 7px rgba(46, 56, 120, .09), 0 1px 0 rgba(255, 255, 255, .8); transition: box-shadow .2s, background .2s; }
label input:not([type=checkbox]):focus, label select:focus { background: rgba(255, 255, 255, .85); box-shadow: inset 0 2px 7px rgba(46, 56, 120, .06), 0 0 0 3px rgba(150, 130, 255, .32); }
input[type=checkbox] { accent-color: #8c7bff; width: 18px; height: 18px; }
.row { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.warn { font-size: 12.5px; color: #b8530c; margin: 4px 0; }
.hint { font-size: 12.5px; color: var(--ink3); margin: 4px 0; line-height: 1.5; }
menu { display: flex; gap: 10px; justify-content: flex-end; padding: 0; margin: 18px 0 0; }
menu button { padding: 11px 22px; }
.acts { margin: 14px 0; font-size: 13.5px; color: var(--ink2); line-height: 1.9; }
.acts b { font-weight: 700; color: var(--ink); }
.acts button { margin: 6px 6px 0 0; padding: 8px 14px; font-size: 13px; }
.info { position: relative; white-space: pre-wrap; word-break: break-all; font-size: 12px; font-weight: 500; line-height: 1.55; border-radius: 18px; padding: 10px 14px; margin: 8px 0; color: #2f3b6e; user-select: text; text-align: left; }
.info:empty { display: none; }
[data-only=web], [data-only=web].row { display: none; }
select option { color: #161a2e; background: #fff; }

@supports (transition-timing-function: linear(0, 1)) {
  :root { --spring: linear(0, 0.02, 0.075, 0.156, 0.255, 0.365, 0.478, 0.591, 0.699, 0.798, 0.886, 0.963, 1.026, 1.076, 1.114, 1.14, 1.156, 1.163, 1.162, 1.154, 1.143, 1.127, 1.11, 1.092, 1.073, 1.055, 1.038, 1.023, 1.01, 0.999, 0.99, 0.983, 0.978, 0.975, 0.974, 0.973, 0.974, 0.976, 0.978, 0.981, 0.984, 0.987, 0.99, 0.993, 1); --spring-soft: linear(0, 0.01, 0.037, 0.077, 0.127, 0.184, 0.246, 0.31, 0.376, 0.441, 0.504, 0.565, 0.622, 0.676, 0.726, 0.772, 0.813, 0.85, 0.883, 0.912, 0.937, 0.959, 0.977, 0.993, 1.005, 1.015, 1.023, 1.029, 1.033, 1.036, 1.038, 1.038, 1.038, 1.037, 1.036, 1.034, 1.032, 1.029, 1.027, 1.024, 1.022, 1.019, 1.017, 1.015, 1); }
}

/* ================= 쫀득한 모션 ================= */
button { transition: transform .7s var(--spring), box-shadow .3s, filter .3s; }
button:hover { transform: translateY(-1px) scale(1.02); }
button:active { transform: scale(.9, .84); transition-duration: .12s; transition-timing-function: var(--out); }
#gear { transition: transform .8s var(--spring), box-shadow .3s; }
#gear:hover { transform: rotate(35deg) scale(1.06); }
#gear:active { transform: rotate(90deg) scale(.86); transition-duration: .12s; }
#form { transition: transform .8s var(--spring), box-shadow .3s; }
#form:focus-within { transform: scale(1.012, 1.03); }
button.send { transition: transform .7s var(--spring); }
#form:focus-within button.send { transform: scale(1.06); }

@keyframes jelly { 0% { transform: scale(.78, 1.18); } 22% { transform: scale(1.14, .88); } 44% { transform: scale(.94, 1.07); } 64% { transform: scale(1.04, .97); } 82% { transform: scale(.99, 1.01); } 100% { transform: none; } }
@keyframes land { 0% { transform: scale(1.06, .86); } 30% { transform: scale(.96, 1.06); } 58% { transform: scale(1.02, .98); } 100% { transform: none; } }
@keyframes puff { 0% { opacity: 0; transform: translateY(18px) scale(.7, .5); } 38% { opacity: 1; transform: translateY(-5px) scale(1.1, .9); } 62% { transform: translateY(1px) scale(.96, 1.05); } 82% { transform: scale(1.02, .99); } 100% { opacity: 1; transform: none; } }
.jelly { animation: jelly .75s var(--out) both; transform-origin: 50% 70%; }
#bubble.jelly { animation-name: puff; animation-duration: .85s; }
#log div { animation: puff .7s var(--out) both; }

#ubub { animation: none; transition: opacity .7s, transform .7s var(--out), filter .7s; opacity: 0; }
#ubub.in { opacity: 1; }
#ubub.fade { opacity: 0; transform: translateY(8px) scale(.96); filter: blur(4px); }
#ubub.typing { opacity: 1; }
/* 보내면 풍선이 위에서 살짝 내려와 자리를 잡는다 (스프링) */
#ubub.drop-in { animation: dropIn .75s var(--spring) both; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-16px) scale(.94, .9); } 55% { opacity: 1; } to { opacity: 1; transform: none; } }

dialog { animation: sheetIn .8s var(--spring) both; transform-origin: 50% 60%; }
dialog.closing { animation: sheetOut .28s cubic-bezier(.5, 0, .75, 0) both; }
dialog::backdrop { animation: aIn .4s ease both; }
@keyframes sheetIn { from { opacity: 0; transform: translateY(40px) scale(.84, .8); } to { opacity: 1; transform: none; } }
@keyframes sheetOut { to { opacity: 0; transform: translateY(24px) scale(.94, .9); } }
@keyframes aIn { from { opacity: 0; } to { opacity: 1; } }

#stage::before, #stage::after { content: ''; position: absolute; left: 50%; top: 52%; width: 56%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; pointer-events: none; opacity: 0; z-index: -1;
  border: 2px solid rgba(255, 255, 255, .9); background: radial-gradient(circle, rgba(190, 160, 255, .18), rgba(255, 170, 220, .06) 60%, transparent 70%); box-shadow: 0 0 40px rgba(170, 140, 255, .35); }
body.listening #stage::before { animation: ripple 2.2s var(--out) infinite; }
body.listening #stage::after { animation: ripple 2.2s var(--out) .9s infinite; }
@keyframes ripple { 0% { opacity: .9; transform: scale(.7); } 100% { opacity: 0; transform: scale(1.85); } }
body.listening #form::after { opacity: 1; animation-duration: 2.4s; }
body.listening #form { transform: scale(calc(1.01 + var(--lvl, 0) * .03), calc(1.02 + var(--lvl, 0) * .08)); }
#face { cursor: pointer; transition: filter .4s; }
#face:active { filter: drop-shadow(0 16px 30px rgba(140, 112, 255, .5)) brightness(1.04); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* 검색 출처 칩 */
#sources { order: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: min(92vw, 600px); margin: 0 0 8px; }
#sources:empty { display: none; }
#sources .src { position: relative; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--ink2); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: linear-gradient(160deg, var(--glass-a), var(--glass-b)); -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%); border: 1px solid var(--rim);
  box-shadow: 0 6px 18px rgba(46, 56, 120, .10), inset 0 1.5px 0 rgba(255, 255, 255, .95); transition: transform .5s var(--spring), color .2s; }
#sources .src:hover { transform: translateY(-2px) scale(1.03); color: var(--ink); }
#sources .src:active { transform: scale(.94); }
