:root{
  --ink:#0B0F1E;
  --panel:rgba(17,22,42,.62);
  --panel-border:rgba(148,163,255,.16);
  --muted:#94A3B8;
  --text:#E7EAFB;
  --accent:#7C6CFF;
  --accent-2:#33D6D6;
  --live:#FF5D6C;
  --good:#33D6A0;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  background:
    radial-gradient(1100px 700px at 50% -10%, #241B4D 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 100%, #0E2A3A 0%, transparent 55%),
    var(--ink);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Apple SD Gothic Neo",sans-serif;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

/* ── 상단바 ── */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:18px 24px;
  z-index:2;
}
.brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  width:36px; height:36px;
  border-radius:11px;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  display:flex; align-items:center; justify-content:center;
  font-weight:800; color:#0B0F1E; font-size:1.1rem;
  box-shadow:0 6px 20px rgba(124,108,255,.35);
}
.brand-text{ display:flex; flex-direction:column; line-height:1.25; }
.brand-text strong{ font-size:.95rem; letter-spacing:.01em; }
.brand-text small{ color:var(--muted); font-size:.72rem; }

.badge{
  display:flex; align-items:center; gap:8px;
  background:var(--panel);
  border:1px solid var(--panel-border);
  padding:7px 13px;
  border-radius:999px;
  font-size:.78rem;
  color:var(--muted);
  backdrop-filter:blur(10px);
}
.dot-led{
  width:8px;height:8px;border-radius:50%;
  background:var(--muted);
  transition:background .25s ease, box-shadow .25s ease;
}
.badge.online .dot-led{ background:var(--good); box-shadow:0 0 8px rgba(51,214,160,.7); }
.badge.offline .dot-led{ background:var(--live); box-shadow:0 0 8px rgba(255,93,108,.7); }

/* ── 무대: 좌측 아바타 / 우측 대화창 ── */
.stage{
  position:relative;
  flex:1;
  display:flex;
  flex-direction:row;
  align-items:stretch;
  gap:20px;
  padding:0 20px 20px;
  min-height:0;
}
.avatar-col{
  position:relative;
  flex:1 1 55%;
  min-width:0;
  border-radius:24px;
  overflow:hidden;
  background:rgba(255,255,255,.02);
}
#avatar{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
}
#avatar canvas{ display:block; }
#avatarLoading{
  position:absolute;
  top:50%; left:50%;
  transform:translate(-50%,-50%);
  color:var(--muted);
  font-size:.85rem;
  z-index:1;
  pointer-events:none;
}
#avatarLoading.hidden{ display:none; }

/* ── 아바타 선택기 (좌상단 오버레이) ── */
.avatar-picker{
  position:absolute;
  left:14px; top:14px;
  display:flex;
  gap:8px;
  z-index:2;
  max-width:calc(100% - 28px);
  flex-wrap:wrap;
}
.avatar-chip{
  display:flex;
  align-items:center;
  gap:7px;
  padding:6px 12px 6px 7px;
  border-radius:999px;
  border:1px solid var(--panel-border);
  background:rgba(17,22,42,.55);
  backdrop-filter:blur(8px);
  color:var(--text);
  font-size:.78rem;
  font-weight:600;
  cursor:pointer;
  transition:background .18s ease, border-color .18s ease, transform .12s ease;
}
.avatar-chip:hover{ background:rgba(124,108,255,.24); }
.avatar-chip:active{ transform:scale(.96); }
.avatar-chip .chip-face{
  width:26px; height:26px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:1rem;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
}
.avatar-chip.active{
  border-color:rgba(124,108,255,.75);
  background:rgba(124,108,255,.3);
  box-shadow:0 0 0 3px rgba(124,108,255,.14);
}
.avatar-chip[disabled]{ opacity:.5; cursor:default; }

/* ── 확대/축소 컨트롤 (아바타 우하단 오버레이) ── */
.zoom-ctrl{
  position:absolute;
  right:14px; bottom:14px;
  display:flex;
  flex-direction:column;
  gap:8px;
  z-index:2;
}
.zoom-btn{
  width:38px; height:38px;
  border-radius:12px;
  border:1px solid var(--panel-border);
  background:rgba(17,22,42,.55);
  backdrop-filter:blur(8px);
  color:var(--text);
  font-size:1.25rem;
  font-weight:600;
  line-height:1;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:background .2s ease, transform .12s ease;
}
.zoom-btn:hover{ background:rgba(124,108,255,.28); }
.zoom-btn:active{ transform:scale(.92); }

/* ── 대화 패널 ── */
.panel{
  position:relative;
  z-index:1;
  flex:0 0 min(380px,40vw);
  background:var(--panel);
  border:1px solid var(--panel-border);
  border-radius:24px;
  backdrop-filter:blur(18px);
  box-shadow:0 20px 60px rgba(0,0,0,.35);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  min-height:0;
}

.transcript{
  flex:1;
  min-height:64px;
  overflow-y:auto;
  padding:18px 18px 8px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.transcript::-webkit-scrollbar{ width:6px; }
.transcript::-webkit-scrollbar-thumb{ background:rgba(148,163,255,.25); border-radius:3px; }

.msg{ display:flex; }
.msg p{
  max-width:82%;
  padding:10px 14px;
  border-radius:16px;
  font-size:.88rem;
  line-height:1.45;
  white-space:pre-wrap;
}
.msg.assistant{ justify-content:flex-start; }
.msg.assistant p{
  background:rgba(124,108,255,.14);
  border:1px solid rgba(124,108,255,.22);
  border-bottom-left-radius:4px;
}
.msg.user{ justify-content:flex-end; }
.msg.user p{
  background:linear-gradient(135deg,var(--accent),#5A4BD9);
  color:#fff;
  border-bottom-right-radius:4px;
}
.msg.error p{
  background:rgba(255,93,108,.14);
  border:1px solid rgba(255,93,108,.3);
  color:#FFC9CE;
}

/* ── 입력 바 ── */
.composer{
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 16px;
  border-top:1px solid var(--panel-border);
}
.lang-btn{
  flex:0 0 auto;
  width:40px; height:40px;
  border-radius:50%;
  border:1px solid var(--panel-border);
  background:rgba(255,255,255,.05);
  color:var(--muted);
  font-size:.7rem;
  font-weight:700;
  letter-spacing:.02em;
  cursor:pointer;
  transition:background .2s ease, color .2s ease;
}
.lang-btn:hover{ background:rgba(255,255,255,.1); color:var(--text); }

.search-btn{
  flex:0 0 auto;
  width:40px; height:40px;
  border-radius:50%;
  border:1px solid var(--panel-border);
  background:rgba(255,255,255,.05);
  font-size:1rem;
  line-height:1;
  cursor:pointer;
  filter:grayscale(.65) opacity(.7);
  transition:background .2s ease, filter .2s ease, box-shadow .2s ease;
}
.search-btn:hover{ background:rgba(255,255,255,.1); }
/* 켜짐: 색이 살아나고 은은한 청록 글로우로 "지금 검색 모드"임을 명확히 표시 */
.search-btn.active{
  background:rgba(51,214,214,.16);
  border-color:rgba(51,214,214,.5);
  filter:none;
  box-shadow:0 0 0 3px rgba(51,214,214,.12);
}

.mic-btn{
  flex:0 0 auto;
  width:44px; height:44px;
  border-radius:50%;
  border:none;
  background:rgba(255,255,255,.06);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  transition:transform .15s ease, background .2s ease, box-shadow .2s ease;
}
.mic-btn:hover{ background:rgba(255,255,255,.12); }
.mic-btn:active{ transform:scale(.94); }
.mic-icon{
  font-size:1.15rem;
  line-height:1;
  filter:grayscale(.15);
  transition:transform .2s ease, filter .2s ease;
}
.mic-btn.listening{ background:rgba(255,93,108,.14); animation:ring 1.6s ease-out infinite; }
.mic-btn.listening .mic-icon{ filter:none; animation:pulse 1.1s ease-in-out infinite; }

#textInput{
  flex:1;
  background:rgba(255,255,255,.05);
  border:1px solid var(--panel-border);
  border-radius:999px;
  padding:11px 16px;
  color:var(--text);
  font-size:.88rem;
  outline:none;
  transition:border-color .15s ease;
}
#textInput::placeholder{ color:var(--muted); }
#textInput:focus{ border-color:var(--accent); }

.send-btn{
  flex:0 0 auto;
  width:44px; height:44px;
  border-radius:50%;
  border:none;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  color:#0B0F1E;
  font-size:1rem;
  cursor:pointer;
  transition:transform .15s ease, opacity .15s ease;
}
.send-btn:hover{ transform:scale(1.06); }
.send-btn:active{ transform:scale(.94); }
.send-btn:disabled{ opacity:.4; cursor:default; transform:none; }

/* ── 목소리 선택 바 ── */
.voicebar{
  display:flex;
  align-items:center;
  gap:8px;
  padding:0 16px 6px;
  font-size:.78rem;
  color:var(--muted);
}
.voicebar label{ flex:0 0 auto; }
#voiceSelect{
  flex:1 1 auto;
  min-width:0;
  background:rgba(30,36,66,.92);
  border:1px solid var(--panel-border);
  border-radius:10px;
  padding:6px 10px;
  color:var(--text);
  font-size:.8rem;
  outline:none;
  cursor:pointer;
}
#voiceSelect:focus{ border-color:var(--accent); }
/* 드롭다운 펼침 목록: OS 기본은 흰 배경이라 흰 글자가 안 보임 → 어두운 배경+흰 글자 강제 */
#voiceSelect option{
  background:#1E2442;
  color:#E7EAFB;
}
.voice-preview-btn{
  flex:0 0 auto;
  border:1px solid var(--panel-border);
  background:rgba(255,255,255,.05);
  border-radius:10px;
  padding:6px 11px;
  color:var(--text);
  font-size:.76rem;
  cursor:pointer;
  transition:background .18s ease;
}
.voice-preview-btn:hover{ background:rgba(124,108,255,.24); }
.voice-preview-btn:disabled{ opacity:.5; cursor:default; }

#status{
  text-align:center;
  color:var(--muted);
  font-size:.76rem;
  padding:0 0 14px;
}

/* ── 하단 예제 프롬프트 바 (일렬, 가로 스크롤) ── */
.examples{
  display:flex;
  gap:9px;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  padding:2px 20px 4px;
  z-index:2;
}
.example-chip{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:8px 14px;
  border-radius:999px;
  border:1px solid var(--panel-border);
  background:rgba(255,255,255,.045);
  color:var(--text);
  font-size:.8rem;
  white-space:nowrap;
  cursor:pointer;
  transition:background .18s ease, border-color .18s ease, transform .12s ease;
}
.example-chip:hover{ background:rgba(124,108,255,.22); border-color:rgba(124,108,255,.5); }
.example-chip:active{ transform:scale(.96); }
.example-chip .ex-emoji{ font-size:1rem; }
.example-chip .ex-tag{
  font-size:.62rem;
  color:var(--accent-2);
  border:1px solid rgba(51,214,214,.35);
  border-radius:6px;
  padding:1px 5px;
}
@media (max-width:720px){
  .examples{ flex-wrap:nowrap; overflow-x:auto; justify-content:flex-start; }
  .examples::-webkit-scrollbar{ height:0; }
}

.foot{
  text-align:center;
  color:rgba(148,163,255,.35);
  font-size:.72rem;
  padding:8px 0 14px;
  z-index:2;
}

@keyframes pulse{
  0%,100%{ transform:scale(1); }
  50%{ transform:scale(1.22); }
}
@keyframes ring{
  0%{ box-shadow:0 0 0 0 rgba(255,93,108,.35); }
  70%{ box-shadow:0 0 0 18px rgba(255,93,108,0); }
  100%{ box-shadow:0 0 0 0 rgba(255,93,108,0); }
}

@media (prefers-reduced-motion: reduce){
  .mic-btn.listening, .mic-btn.listening .mic-dot{ animation:none; }
}

@media (max-width:720px){
  .stage{ flex-direction:column; }
  .avatar-col{ flex:1 1 42%; }
  .panel{ flex:1 1 58%; }
  .transcript{ max-height:none; }
}
