:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #334155;
  --fg: #f1f5f9;
  --fg-2: #cbd5e1;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin:0; padding:0; background:var(--bg); color:var(--fg); min-height:100vh; }
a { color: var(--accent); text-decoration:none; }
a:hover { text-decoration: underline; }

.app-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 20px; background:linear-gradient(180deg,#1e293b 0%,#0f172a 100%);
  border-bottom:1px solid var(--bg-3); position:sticky; top:0; z-index:10;
}
.brand { display:flex; gap:12px; align-items:center; }
.brand .logo { font-size:32px; }
.brand h1 { margin:0; font-size:18px; }
.brand p  { margin:2px 0 0; color:var(--fg-2); font-size:12px; }
.header-actions { display:flex; gap:8px; }

.layout {
  display:grid; grid-template-columns:1fr 420px; gap:16px; padding:16px;
  max-width:1400px; margin:0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.chat-panel {
  background:var(--bg-2); border-radius:var(--radius); padding:16px;
  box-shadow:var(--shadow); display:flex; flex-direction:column; min-height:70vh;
}
.messages { flex:1; overflow-y:auto; padding-right:4px; }
.msg { padding:12px 14px; border-radius:10px; margin-bottom:10px; line-height:1.55; }
.msg.user { background:var(--accent); color:#082f49; align-self:flex-end; max-width:85%; }
.msg.ai   { background:var(--bg-3); border-left:3px solid var(--accent); }
.msg.ai h2, .msg.ai h3 { margin:8px 0 6px; color:var(--accent); }
.msg.ai ul { margin:6px 0; padding-left:20px; }

/* v4: 진행 로그 누락 표시 */
.progress-log {
  background:var(--bg-3);
  border:1px solid rgba(56,189,248,.25);
  border-left:3px solid var(--accent);
  border-radius:10px;
  padding:10px 14px;
  margin:10px 0;
  max-height:220px;
  overflow-y:auto;
}
.progress-head { color:var(--accent); font-weight:600; margin-bottom:6px; font-size:13px; }
.progress-list  { list-style:none; padding-left:0; margin:0; }
.progress-item  {
  padding:4px 0; font-size:13px; color:var(--fg-2);
  border-bottom:1px dashed rgba(255,255,255,.06);
  animation: fade .25s ease;
}
.progress-item:last-child { border-bottom:0; }
@keyframes fade { from { opacity:0; transform:translateY(2px);} to { opacity:1; transform:none; } }

.composer { display:flex; flex-direction:column; gap:8px; margin-top:12px; }
.composer textarea {
  background:var(--bg); color:var(--fg); border:1px solid var(--bg-3);
  border-radius:8px; padding:10px; resize:vertical; min-height:70px; font-family:inherit;
}
.composer-actions { display:flex; gap:8px; }
.composer-actions select {
  background:var(--bg); color:var(--fg); border:1px solid var(--bg-3);
  border-radius:8px; padding:8px; flex:1;
}

/* 미크 버튼 */
.mic-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.btn-mic  { background:linear-gradient(180deg,#38bdf8 0%,#0ea5e9 100%); color:#082f49; border:none; padding:8px 14px; border-radius:8px; cursor:pointer; font-weight:600; }
.btn-mic:disabled { opacity:.5; cursor:not-allowed; }
.btn-mic-stop { background:linear-gradient(180deg,#f87171 0%,#dc2626 100%); color:#fff; border:none; padding:8px 14px; border-radius:8px; cursor:pointer; font-weight:600; animation: redPulse 1.2s infinite; }
@keyframes redPulse { 0%,100% { box-shadow:0 0 0 0 rgba(248,113,113,.6);} 50% { box-shadow:0 0 0 8px rgba(248,113,113,0);} }
.mic-hint { color:var(--fg-2); font-size:12px; }

.btn-primary  { background:var(--accent); color:#082f49; border:none; padding:10px 16px; border-radius:8px; cursor:pointer; font-weight:600; }
.btn-primary:disabled { opacity:.5; cursor:not-allowed; }
.btn-secondary { background:var(--bg-3); color:var(--fg); border:none; padding:8px 12px; border-radius:8px; cursor:pointer; font-size:13px; }

.sources-panel { background:var(--bg-2); border-radius:var(--radius); padding:12px; box-shadow:var(--shadow); min-height:70vh; }
.tabs { display:flex; gap:4px; margin-bottom:8px; }
.tab  { flex:1; background:var(--bg-3); color:var(--fg-2); border:none; padding:8px; border-radius:8px 8px 0 0; cursor:pointer; font-size:13px; }
.tab.active { background:var(--bg); color:var(--accent); border-bottom:2px solid var(--accent); }
.panel { display:none; }
.panel.active { display:block; }
.ref-card { background:var(--bg-3); border-radius:8px; padding:10px; margin-bottom:8px; border-left:3px solid var(--accent-2); font-size:13px; }
.ref-card h4 { margin:0 0 4px; font-size:14px; color:var(--accent); }
.ref-card .meta { color:var(--fg-2); font-size:11px; margin-bottom:4px; }
.ref-card .snippet { line-height:1.45; }
.ref-card .actions { display:flex; gap:6px; margin-top:6px; }
.ref-card .badge { background:var(--accent-2); color:#0f172a; padding:2px 6px; border-radius:4px; font-size:10px; }

.app-footer { text-align:center; padding:14px; color:var(--fg-2); font-size:11px; border-top:1px solid var(--bg-3); }
