/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f12;
  --bg2: #13161b;
  --bg3: #1a1e25;
  --bg4: #222730;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --accent: #7c6af7;
  --accent2: #a08fff;
  --accent-dim: rgba(124,106,247,0.15);
  --text: #e8eaf0;
  --text2: #9298a8;
  --text3: #5c6272;
  --danger: #e55a5a;
  --danger-dim: rgba(229,90,90,0.12);
  --success: #4caf82;
  --warn: #e09838;
  --font: 'Noto Sans KR', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-w: 280px;
  --transition: 0.2s ease;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── UTILS ── */
.hidden { display: none !important; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
}
.modal-header {
  padding: 2.5rem 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(124,106,247,0.08) 0%, transparent 100%);
}
.modal-icon {
  font-size: 32px;
  color: var(--accent2);
  margin-bottom: 0.8rem;
  display: block;
}
.modal-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.modal-sub {
  color: var(--text2);
  font-size: 13.5px;
  line-height: 1.7;
}
.modal-body {
  padding: 1.8rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.input-row input, input[type="text"], input[type="password"], textarea {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
.input-row input:focus, textarea:focus {
  border-color: var(--accent);
}
.icon-btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text2);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border2); }

/* Checkbox */
.save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  user-select: none;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
  width: 17px; height: 17px;
  border: 1.5px solid var(--border2);
  border-radius: 5px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.checkbox-label input:checked ~ .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-label input:checked ~ .checkbox-custom::after {
  content: '';
  display: block;
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(40deg) translateY(-1px);
}
.save-hint {
  font-size: 11.5px;
  color: var(--text3);
}
.error-msg {
  color: var(--danger);
  font-size: 12.5px;
  background: var(--danger-dim);
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
}
.primary-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  padding: 0.75rem;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  letter-spacing: -0.2px;
}
.primary-btn:hover { background: var(--accent2); transform: translateY(-1px); }
.modal-footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--text3);
}
.modal-footer-note a { color: var(--accent2); text-decoration: none; }
.modal-footer-note a:hover { text-decoration: underline; }

/* ── APP LAYOUT ── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
}
.sidebar.collapsed { width: 0; min-width: 0; }

/* ★ 데스크톱 사이드바 접기/펼치기 탭 — main 영역 왼쪽 가장자리에 고정 */
.sidebar-collapse-tab {
  display: flex;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  width: 18px;
  height: 52px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: background var(--transition), color var(--transition), opacity var(--transition);
  opacity: 0.5;
  padding: 0;
}
.sidebar-collapse-tab:hover { background: var(--bg4); color: var(--accent2); opacity: 1; }
/* collapsed 상태엔 화살표 반전 */
.sidebar.collapsed ~ .sidebar-collapse-tab svg,
.app.sidebar-collapsed .sidebar-collapse-tab svg { transform: rotate(180deg); }

/* 모바일에선 탭 숨김 */
@media (max-width: 700px) { .sidebar-collapse-tab { display: none; } }

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.1rem 0.8rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  user-select: none;
}
.logo-text { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text2);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg3); color: var(--text); }

.section-title {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  padding: 0.9rem 1.1rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.badge {
  background: var(--accent-dim);
  color: var(--accent2);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* Drop Zone */
.drop-zone {
  margin: 0 0.9rem;
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  flex-shrink: 0;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-icon { color: var(--text3); margin-bottom: 0.5rem; }
.drop-text { font-size: 13px; color: var(--text2); margin-bottom: 0.4rem; }
.upload-label {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent2);
  padding: 0.3rem 0.9rem;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid rgba(124,106,247,0.25);
}
.upload-label:hover { background: rgba(124,106,247,0.25); }
.drop-hint { font-size: 11px; color: var(--text3); margin-top: 0.4rem; }

/* Doc List */
.doc-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0.6rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.doc-list::-webkit-scrollbar { width: 4px; }
.doc-list::-webkit-scrollbar-track { background: transparent; }
.doc-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.empty-hint {
  font-size: 12.5px;
  color: var(--text3);
  text-align: center;
  padding: 1rem;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}
.doc-item:hover { background: var(--bg3); }
.doc-item.selected {
  background: var(--accent-dim);
  border-color: rgba(124,106,247,0.2);
}
.doc-checkbox {
  width: 15px; height: 15px;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  background: var(--bg3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.doc-item.selected .doc-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}
.doc-item.selected .doc-checkbox::after {
  content: '';
  display: block;
  width: 4px; height: 7px;
  border: 1.5px solid white;
  border-top: none; border-left: none;
  transform: rotate(40deg) translateY(-1px);
}
.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.doc-meta { font-size: 11px; color: var(--text3); }
.doc-del {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 3px;
  border-radius: 5px;
  display: flex; align-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.doc-del:hover { color: var(--danger); background: var(--danger-dim); }

/* Sidebar Bottom */
.sidebar-bottom {
  padding: 0.7rem 0.8rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  background: var(--bg2);
}
.danger-btn {
  background: var(--danger-dim);
  border: 1px solid rgba(229,90,90,0.2);
  border-radius: var(--radius);
  color: var(--danger);
  padding: 0.5rem;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.danger-btn:hover { background: rgba(229,90,90,0.2); }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text2);
  padding: 0.5rem;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.ghost-btn:hover { background: var(--bg3); color: var(--text); }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  gap: 1rem;
  flex-shrink: 0;
}
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text2);
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* RAG Toggle */
.rag-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 30px;
  padding: 0.3rem 0.9rem 0.3rem 0.5rem;
}
.toggle-label { display: flex; align-items: center; cursor: pointer; }
.toggle-label input { display: none; }
.toggle-track {
  width: 34px; height: 18px;
  background: var(--bg4);
  border-radius: 9px;
  position: relative;
  transition: background var(--transition);
}
.toggle-label input:checked ~ .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-label input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-text { font-size: 13px; color: var(--text2); }
.rag-on { color: var(--success); font-weight: 600; }
.rag-off { color: var(--text3); font-weight: 600; }

/* Tooltip */
.tooltip-wrap { position: relative; display: flex; align-items: center; }
.help-icon {
  width: 16px; height: 16px;
  background: var(--bg4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: var(--text3);
  cursor: help;
  border: 1px solid var(--border2);
  font-style: normal;
}
.tooltip-box {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: 12.5px;
  color: var(--text2);
  width: 230px;
  line-height: 1.6;
  z-index: 100;
  pointer-events: none;
}
.tooltip-wrap:hover .tooltip-box { display: block; }

.ghost-sm-btn {
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text2);
  padding: 0.3rem 0.8rem;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.ghost-sm-btn:hover { background: var(--bg3); color: var(--text); }

/* Selected Bar */
.selected-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.45rem 1.2rem;
  background: rgba(124,106,247,0.08);
  border-bottom: 1px solid rgba(124,106,247,0.15);
  font-size: 12.5px;
  color: var(--accent2);
  flex-shrink: 0;
}
.mini-btn {
  background: transparent;
  border: 1px solid rgba(124,106,247,0.3);
  border-radius: 5px;
  color: var(--accent2);
  padding: 1px 8px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  margin-left: auto;
}
.mini-btn:hover { background: var(--accent-dim); }

/* ── CHAT ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.2rem;
  display: flex;
  flex-direction: column;
}
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Welcome */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.8rem;
  padding: 2rem;
  max-width: 520px;
  margin: 0 auto;
}
.welcome-icon { font-size: 36px; color: var(--accent2); }
.welcome-screen h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
.welcome-screen p { font-size: 14px; color: var(--text2); line-height: 1.8; }
.quick-tips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 0.5rem;
  width: 100%;
}
.tip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.5rem 1rem;
  font-size: 13px;
  color: var(--text2);
  text-align: left;
}

/* Messages */
#messages { display: flex; flex-direction: column; gap: 1.2rem; }

.msg {
  display: flex;
  gap: 10px;
  max-width: 820px;
  width: 100%;
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .msg-bubble {
  background: var(--accent);
  color: white;
  border-radius: 16px 16px 4px 16px;
}
.msg.assistant .msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  color: var(--text);
}
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg4);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.user .msg-avatar { background: var(--accent); border-color: var(--accent); }
.msg-bubble {
  padding: 0.75rem 1rem;
  font-size: 14px;
  line-height: 1.75;
  max-width: calc(100% - 42px);
  word-break: break-word;
}
.msg-bubble p { margin: 0 0 0.5rem; }
.msg-bubble p:last-child { margin: 0; }
.msg-bubble code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(0,0,0,0.2);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg-sources {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.source-chip {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--accent2);
}
.msg-thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text3);
  padding: 0.6rem 0;
}
.thinking-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%,80%,100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* ── SETTINGS PANEL ── */
.settings-panel {
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  padding: 1rem 1.2rem;
  flex-shrink: 0;
  max-height: 320px;
  overflow-y: auto;
}

/* 모바일: 설정 패널을 fixed 바텀 시트로 — input-area 위에 겹쳐 띄워 레이아웃 안 밀리게 */
@media (max-width: 700px) {
  .settings-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 150;
    max-height: 60dvh;
    max-height: 60svh;
    border-radius: 16px 16px 0 0;
    border-top: 1px solid var(--border2);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
    padding-bottom: env(safe-area-inset-bottom, 12px);
  }
  .settings-panel.hidden { display: none; }
}

/* 설정 패널 모바일 backdrop */
.settings-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 149;
  touch-action: none;
}
.settings-backdrop.active { display: block; }
.settings-panel::-webkit-scrollbar { width: 4px; }
.settings-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.9rem;
}
.icon-close {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  transition: color var(--transition);
}
.icon-close:hover { color: var(--text); }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.setting-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.setting-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.setting-top label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}
.setting-val { color: var(--accent2); }
.setting-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.setting-badge.default {
  background: rgba(76,175,130,0.15);
  color: var(--success);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0.3rem 0;
}
.setting-desc {
  font-size: 11.5px;
  color: var(--text3);
  line-height: 1.6;
  margin-top: 0.35rem;
}

/* ── INPUT AREA ── */
.input-area {
  border-top: 1px solid var(--border);
  padding: 0.7rem 1.2rem 1rem;
  background: var(--bg2);
  flex-shrink: 0;
}
.input-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.5rem;
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text2);
  padding: 0.28rem 0.65rem;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}
.tool-btn:hover { background: var(--bg3); color: var(--text); }
.input-sep { flex: 1; }
.model-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 5px;
}
.input-box {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.input-box textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 160px;
  overflow-y: auto;
  border-radius: var(--radius);
  line-height: 1.6;
  font-size: 14px;
}
.input-box textarea::-webkit-scrollbar { width: 4px; }
.input-box textarea::-webkit-scrollbar-thumb { background: var(--border2); }
.send-btn {
  width: 42px; height: 42px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.send-btn:disabled { background: var(--bg4); color: var(--text3); cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: var(--accent2); transform: translateY(-1px); }

/* ★ 일반 대화창 음성 버튼 */
.chat-voice-btn {
  width: 38px; height: 38px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.chat-voice-btn:hover { background: var(--bg5, #2a2d3a); color: var(--accent2); border-color: var(--accent2); }
.chat-voice-btn.recording {
  background: #c0392b22;
  border-color: #e74c3c;
  color: #e74c3c;
  animation: voicePulse 1s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(231,76,60,0); }
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 30px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast-dot {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}

/* ── MOBILE (사이드바 기본) ── */
@media (max-width: 700px) {
  .app { height: 100dvh; height: 100svh; }
  /* 사이드바 모바일 규칙은 아래 "반응형 — 모바일" 블록에서 통합 관리 */
  .mobile-menu-btn { display: flex; }
  .sidebar-toggle { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .mcp-json-input { min-height: 72px; max-height: 110px; }
  .mcp-dir-grid { grid-template-columns: 1fr 1fr; }
  .mcp-dir-btn { font-size: 11px; padding: 5px 7px; }
  .sidebar-bottom { padding: 0.5rem 0.6rem; gap: 4px; }
  .danger-btn, .ghost-btn { font-size: 12px; padding: 0.4rem; }
  .export-btn, .import-btn { font-size: 11px; padding: 5px 6px; }
}

/* Scrollbar global */
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

/* ── 사이드바 탭 ── */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  padding: 0.6rem 0.4rem;
  cursor: pointer;
  transition: all var(--transition);
}
.stab:hover { color: var(--text2); }
.stab.active { color: var(--accent2); border-bottom-color: var(--accent); }

.tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.tab-panel.hidden { display: none; }

.mcp-register-box {
  padding: 0 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.mcp-json-input {
  width: 100%;
  min-height: 64px;
  max-height: 120px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 0.6rem 0.75rem;
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color var(--transition);
}
.mcp-json-input:focus { border-color: var(--accent); }

.mcp-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;   /* ★ 아이템 수평 넘침 차단 */
  -webkit-overflow-scrolling: touch;
  padding: 0 0.6rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.mcp-list::-webkit-scrollbar { width: 4px; }
.mcp-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.mcp-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  transition: border-color var(--transition);
  /* overflow:hidden 제거 — tool-chip 잘림 방지 */
}
.mcp-item.disabled { opacity: 0.5; }
.mcp-item-top {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  box-sizing: border-box;
  /* overflow 제거 — 버튼이 잘리는 원인 */
}
.mcp-type-badge {
  font-size: 9px; font-weight: 600;
  padding: 1px 4px; border-radius: 4px;
  text-transform: uppercase; flex-shrink: 0;
  max-width: 90px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcp-type-badge.streamable-http { background: rgba(76,175,130,0.15); color: var(--success); }
.mcp-type-badge.smithery        { background: rgba(124,106,247,0.15); color: var(--accent2); }
.mcp-type-badge.rest-api        { background: rgba(224,152,56,0.15);  color: var(--warn); }
.mcp-type-badge.openapi         { background: rgba(76,175,130,0.15);  color: #4caf82; }
.mcp-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcp-item-actions {
  display: flex; align-items: center;
  gap: 2px; flex-shrink: 0; margin-left: 4px;
}
.icon-btn-xs {
  background: transparent; border: 1px solid var(--border2);
  border-radius: 4px; color: var(--text3);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
  flex-shrink: 0; font-size: 11px;
}
.icon-btn-xs:hover { background: var(--bg4); color: var(--text); }
.icon-btn-xs.del:hover { color: var(--danger); border-color: var(--danger); }

.mcp-url {
  font-size: 10.5px; color: var(--text3);
  font-family: var(--mono); margin: 3px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcp-apikey-row {
  display: flex; align-items: center; gap: 5px;
  margin: 4px 0 2px;
}
.mcp-creds-wrap { flex-wrap: wrap; align-items: flex-end; }
.mcp-cred-field {
  display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 120px;
}
.mcp-cred-label {
  font-size: 10px; color: var(--text3); padding-left: 2px;
}
.mcp-apikey-input {
  flex: 1; font-size: 11px; font-family: var(--mono);
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 7px; color: var(--text2);
  min-width: 0;
  transition: border-color var(--transition);
}
.mcp-apikey-input:focus { outline: none; border-color: var(--accent); }
.mcp-apikey-input::placeholder { color: var(--text3); opacity: .7; }
.mcp-apikey-save {
  flex-shrink: 0; font-size: 11px; padding: 3px 8px;
  border-radius: 5px; white-space: nowrap;
}
.mcp-tools-summary { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tool-chip {
  font-size: 10.5px; background: var(--bg4);
  border: 1px solid var(--border2); border-radius: 4px;
  padding: 1px 7px; color: var(--text2); cursor: default;
}
.tool-chip:hover { border-color: var(--accent2); color: var(--accent2); }

.mcp-on  { color: var(--success); font-weight: 600; }
.mcp-off { color: var(--text3);   font-weight: 600; }

.divider-v { width: 1px; height: 20px; background: var(--border2); margin: 0 6px; }

/* MCP 도구 호출 메시지 */
.msg.tool-call, .msg.tool-result { padding: 0 1.2rem; margin: 2px 0; }
.tool-call-block {
  background: var(--bg4);
  border: 1px solid rgba(124,106,247,0.2);
  border-radius: 8px; padding: 0.45rem 0.75rem;
  font-size: 12px; color: var(--accent2);
}
.tool-result-block {
  background: rgba(76,175,130,0.06);
  border: 1px solid rgba(76,175,130,0.15);
  border-radius: 8px; padding: 0.45rem 0.75rem;
  font-size: 12px; color: var(--text2);
}
.tc-label { font-size: 10px; color: var(--text3); font-family: var(--font); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }
.tc-name { font-family: var(--mono); font-size: 12.5px; color: var(--accent2); font-weight: 600; margin-bottom: 3px; }
.tc-args { font-family: var(--mono); font-size: 11px; color: var(--text2); line-height: 1.6; word-break: break-all; }
.tc-key { color: var(--text3); }
.tc-val { color: var(--text); }
.tr-text { color: var(--success); }

/* 첨부 미리보기 */
.attach-box { display: flex; flex-wrap: wrap; gap: 6px; padding: 0.5rem 1.2rem 0; }
.attach-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; padding: 3px 8px 3px 5px;
  font-size: 12px; color: var(--text2); max-width: 180px;
}
.attach-chip.image { border-color: rgba(124,106,247,0.3); }
.attach-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px; }
.attach-del { background: transparent; border: none; color: var(--text3); cursor: pointer; font-size: 11px; padding: 0; line-height: 1; flex-shrink: 0; transition: color var(--transition); }
.attach-del:hover { color: var(--danger); }
.drag-over-input { outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: var(--radius); }

/* 메시지 내 첨부 */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.msg-img-thumb { max-width: 220px; max-height: 160px; border-radius: 8px; object-fit: cover; border: 1px solid rgba(255,255,255,0.1); }
.msg-file-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg4); border: 1px solid var(--border2); border-radius: 6px; padding: 3px 9px; font-size: 12px; color: var(--text2); }

/* 저장 정보 */
.storage-info {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  padding: 6px 10px; margin: 6px 0 4px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  font-size: 11px; color: var(--text3); min-height: 28px;
}
.storage-info:empty { display: none; }
.si-item { color: var(--text2); font-weight: 500; }
.si-sep  { opacity: .4; }

/* code_execution 이미지/파일 */
.exec-files-wrap { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.exec-img-wrap {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 10px;
}
.exec-result-img { max-width: 100%; max-height: 520px; border-radius: 8px; object-fit: contain; display: block; cursor: zoom-in; transition: transform 0.2s ease; }
.exec-result-img:hover { transform: scale(1.01); }
.exec-img-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.exec-img-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; background: var(--accent-dim);
  border: 1px solid var(--accent); border-radius: 6px;
  color: var(--accent2); font-size: 12px; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: var(--font);
}
.exec-img-btn:hover { background: var(--accent); color: #fff; }
.exec-file-box { display: flex; align-items: center; gap: 8px; background: var(--bg3); border: 1px solid var(--border2); border-radius: 8px; padding: 8px 12px; }
.exec-file-box .file-icon { font-size: 16px; }
.exec-file-box .file-name { flex: 1; font-size: 13px; color: var(--text); font-family: var(--mono); }
.download-btn { display: inline-block; padding: 5px 10px; background: var(--accent); border-radius: 6px; color: white; font-size: 11.5px; text-decoration: none; font-weight: 500; transition: background var(--transition); }
.download-btn:hover { background: var(--accent2); }

/* 응답 복사 버튼 */
.msg-copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; padding: 4px 10px;
  background: transparent; border: 1px solid var(--border2);
  border-radius: 6px; color: var(--text3);
  font-size: 11.5px; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.msg-copy-btn:hover { background: var(--bg4); border-color: var(--accent); color: var(--accent2); }
.msg-copy-btn svg { flex-shrink: 0; }

/* 모바일 토파 로고 */
.topbar-logo { display: none; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.modal-icon { display: flex; align-items: center; justify-content: center; margin-bottom: 0.8rem; }
.welcome-icon { margin-bottom: 1.2rem; display: flex; align-items: center; justify-content: center; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* 반응형 — 모바일 (통합) */
@media (max-width: 700px) {
  body { overflow: hidden; touch-action: pan-y; }
  .app { flex-direction: column; height: 100dvh; height: 100svh; }

  /* ── 사이드바: 슬라이드 오버레이 ── */
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(300px, 85vw) !important;
    z-index: 200;
    transform: translateX(-110%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.7);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 199;
    touch-action: none;   /* 백드롭 터치 스크롤 차단 */
  }
  .sidebar-backdrop.active { display: block; }
  .main { width: 100%; height: 100dvh; height: 100svh; display: flex; flex-direction: column; overflow: hidden; }

  /* ── topbar 모바일 레이아웃 ── */
  .topbar { padding: 0 10px; height: 50px; gap: 6px; flex-shrink: 0; }
  .topbar-logo { display: flex; flex-shrink: 0; }
  /* 모바일에서 RAG/MCP 토글 숨김 — 설정 패널에서 조작 */
  .topbar-center { display: none; }
  .topbar-right { gap: 6px; flex-shrink: 0; margin-left: auto; }
  .topbar-right .ghost-sm-btn { font-size: 11px; padding: 4px 8px; }
  .voice-wake-btn { padding: 5px 9px; font-size: 11px; }
  .drive-mode-btn { padding: 5px 9px; font-size: 11px; }
  .drive-mode-label { display: none; }

  .chat-area { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .msg { gap: 6px; padding: 0 8px; }
  .msg-avatar { width: 28px; height: 28px; font-size: 10px; flex-shrink: 0; }
  .msg-bubble { font-size: 13.5px; max-width: calc(100% - 38px); }
  .msg.user .msg-bubble { max-width: calc(100% - 38px); }
  .input-area { padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); flex-shrink: 0; }
  .input-box textarea { font-size: 16px; min-height: 44px; }
  .input-toolbar { gap: 4px; }
  .tool-btn { font-size: 11px; padding: 3px 7px; }
  .model-tag { font-size: 10px; }
  .attach-box { padding: 4px 6px; gap: 6px; }
  .attach-chip { padding: 3px 7px; font-size: 11px; }
  .settings-panel { position: fixed; left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important; width: 100% !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 82dvh; overflow-y: auto; z-index: 300; }
  .welcome-screen { padding: 1.5rem 1rem; }
  .welcome-screen h2 { font-size: 17px; }
  .welcome-icon svg { width: 48px; height: 48px; }
  .quick-tips { grid-template-columns: 1fr; gap: 7px; }
  .tip { font-size: 12px; padding: 8px 10px; }
  .modal-box { border-radius: 14px; }
  .modal-header { padding: 1.5rem 1.2rem 1rem; }
  .modal-body { padding: 1.2rem; }
  .selected-bar { font-size: 11.5px; padding: 5px 10px; }
  .selected-bar .mini-btn { font-size: 11px; }
  #storageInfo { font-size: 10.5px; padding: 5px 8px; }
}

/* 아바타 */
.msg-avatar.minod-avatar { background: linear-gradient(135deg, #080a12, #1a1535); color: white; padding: 2px; display: flex; align-items: center; justify-content: center; }
.msg.assistant .msg-avatar:not(.minod-avatar) { font-size: 0; background: linear-gradient(135deg, #080a12, #1a1535); position: relative; }
.msg.assistant .msg-avatar:not(.minod-avatar)::after { content: ''; display: block; width: 15px; height: 15px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cdefs%3E%3ClinearGradient id='g2' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%233a2fa8'/%3E%3Cstop offset='1' stop-color='%235b4de0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpolygon points='24,2 44,13 44,35 24,46 4,35 4,13' fill='url(%23g2)' stroke='rgba(160,143,255,0.35)' stroke-width='1'/%3E%3Cpath d='M14 33 L14 16 L24 28 L34 16 L34 33' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }

/* 태블릿 */
@media (min-width: 701px) and (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .msg-bubble { max-width: 88%; }
  .topbar-logo { display: none; }
}

/* STDIO 모달 */
.stdio-modal-box { max-width: 560px; width: 95vw; }
.stdio-modal-header { padding: 1.8rem 1.6rem 1.2rem; text-align: center; border-bottom: 1px solid var(--border); }
.stdio-modal-icon { font-size: 2.2rem; margin-bottom: 0.6rem; }
.stdio-modal-header h2 { font-size: 17px; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }
.stdio-modal-sub { font-size: 13px; color: var(--text2); line-height: 1.6; }
.stdio-modal-body { padding: 1.2rem 1.6rem 1.6rem; }
.stdio-guide-item { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.stdio-guide-item:last-child { margin-bottom: 0; }
.stdio-guide-name { font-size: 13px; font-weight: 600; color: var(--accent2); margin-bottom: 0.8rem; display: flex; align-items: center; gap: 6px; }
.stdio-guide-step { margin-bottom: 0.8rem; }
.stdio-guide-step-label { font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stdio-guide-code { background: var(--bg); border: 1px solid var(--border2); border-radius: 7px; padding: 8px 10px; font-family: var(--mono); font-size: 11.5px; color: var(--text); word-break: break-all; line-height: 1.5; }
.stdio-copy-btn { display: flex; align-items: center; gap: 5px; margin-top: 5px; padding: 4px 10px; font-size: 11.5px; background: var(--accent-dim); color: var(--accent2); border: 1px solid var(--accent); border-radius: 6px; cursor: pointer; transition: background var(--transition); width: fit-content; }
.stdio-copy-btn:hover { background: rgba(124,106,247,0.25); }
.stdio-copy-btn.copied { background: rgba(76,175,130,0.15); color: var(--success); border-color: var(--success); }
.stdio-guide-divider { height: 1px; background: var(--border); margin: 0.7rem 0; }

/* MCP 디렉토리 */
.mcp-directory-links { margin-bottom: 0.8rem; flex-shrink: 0; padding: 0 0.9rem; }
.mcp-dir-collapse { padding: 0 0.9rem; flex-shrink: 0; }
.mcp-dir-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 7px; color: var(--text2); font-size: 12px; font-family: var(--font); padding: 5px 10px; cursor: pointer; transition: all var(--transition); margin-bottom: 5px; }
.mcp-dir-toggle:hover { background: var(--bg4); color: var(--text); }
.mcp-dir-toggle.open svg { transform: rotate(180deg); }
.mcp-dir-content { margin-bottom: 6px; }
.mcp-dir-content.hidden { display: none; }
.mcp-dir-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.mcp-dir-btn { display: flex; align-items: center; justify-content: center; padding: 5px 7px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--accent2); font-size: 11px; text-decoration: none; transition: all var(--transition); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcp-dir-btn:hover { background: var(--accent-dim); border-color: var(--accent); }
.mcp-reg-row { display: flex; gap: 6px; margin-top: 5px; }
.mcp-add-btn { flex: 1; padding: 0.45rem; font-size: 12.5px; }
.mcp-hint-btn { flex: 0 0 auto; padding: 0.45rem 0.8rem; font-size: 13px; font-weight: 700; }
.mcp-format-hint { font-size: 10.5px; color: var(--text3); background: var(--bg3); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; line-height: 1.8; margin-top: 4px; }
.mcp-format-hint code { font-family: var(--mono); font-size: 10px; color: var(--accent2); background: rgba(124,106,247,0.08); padding: 1px 3px; border-radius: 3px; }

/* MCP 체크박스 */
.mcp-check-label { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.mcp-check-label input { display: none; }
.mcp-check-box { width: 15px; height: 15px; border: 1.5px solid var(--border2); border-radius: 4px; background: var(--bg3); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all var(--transition); margin-right: 4px; }
.mcp-check-label input:checked ~ .mcp-check-box { background: var(--accent); border-color: var(--accent); }
.mcp-check-label input:checked ~ .mcp-check-box::after { content: ''; display: block; width: 4px; height: 7px; border: 1.5px solid white; border-top: none; border-left: none; transform: rotate(40deg) translateY(-1px); }
.mcp-item.mcp-unselected { opacity: 0.45; }
.mcp-item.mcp-disabled { opacity: 0.4; }
.mcp-sel-bar { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: rgba(124,106,247,0.08); border-bottom: 1px solid rgba(124,106,247,0.15); border-top: 1px solid rgba(124,106,247,0.15); font-size: 12px; color: var(--accent2); flex-shrink: 0; margin: 0 0 4px; }
.mcp-sel-bar.hidden { display: none; }

/* 내보내기 모달 */
.export-dialog-box { max-width: 380px; width: 95vw; }
.export-check-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.export-check-row:hover:not(.disabled) { border-color: var(--accent); background: var(--accent-dim); }
.export-check-row.disabled { opacity: 0.4; cursor: not-allowed; }
.export-check-row input { display: none; }
.export-check-box { width: 17px; height: 17px; border: 1.5px solid var(--border2); border-radius: 5px; background: var(--bg4); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.export-check-row input:checked ~ .export-check-box { background: var(--accent); border-color: var(--accent); }
.export-check-row input:checked ~ .export-check-box::after { content: ''; display: block; width: 5px; height: 8px; border: 2px solid white; border-top: none; border-left: none; transform: rotate(40deg) translateY(-1px); }
.export-check-info { display: flex; flex-direction: column; gap: 2px; }
.export-check-title { font-size: 13px; font-weight: 500; color: var(--text); }
.export-check-meta  { font-size: 11px; color: var(--text3); }

/* 모델 관리 UI */
.settings-section-title { font-size: 11.5px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; margin: .5rem 0 .45rem; }
.settings-divider { border: none; border-top: 1px solid var(--border); margin: .85rem 0 .7rem; }
.model-select-row { display: flex; gap: 5px; align-items: center; margin-bottom: 6px; }
.model-select { flex: 1; padding: .38rem .5rem; font-size: 12.5px; background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 7px; outline: none; cursor: pointer; }
.model-select:focus { border-color: var(--accent); }
.model-icon-btn { padding: .32rem .52rem; font-size: 13px; line-height: 1; border-radius: 7px; min-width: 30px; }
.model-icon-btn.danger-icon { color: var(--danger, #e05c5c); }
.model-add-row { display: flex; gap: 5px; align-items: center; }
.model-add-input { flex: 1; padding: .38rem .55rem; font-size: 12px; background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 7px; outline: none; min-width: 0; }
.model-add-input:focus { border-color: var(--accent); }
.model-add-btn { padding: .38rem .7rem; font-size: 12px; white-space: nowrap; border-radius: 7px; }
.model-msg { font-size: 11.5px; margin-top: 5px; padding: 4px 7px; border-radius: 5px; }
.model-msg.ok  { background: rgba(52,199,89,.12); color: #2da85c; }
.model-msg.err { background: rgba(224,92,92,.12);  color: #c94040; }

/* 내보내기/가져오기 */
.export-import-row { display: flex; gap: 6px; margin-bottom: 6px; }
.export-btn, .import-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; padding: 6px 8px; cursor: pointer; }
.import-btn { text-align: center; }
.import-dialog-box { max-width: 420px; width: 95vw; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 199; }
.sidebar-backdrop.active { display: block; }
.schema-copy-btn { color: var(--text3) !important; transition: color var(--transition); }
.schema-copy-btn:hover { color: var(--accent2) !important; }
.tool-result-block .exec-img-wrap { margin-top: 6px; }

/* 대화 세션 */
.session-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 0.6rem 0.6rem; display: flex; flex-direction: column; gap: 5px; }
.new-session-btn { display: flex; align-items: center; gap: 4px; margin-left: auto; background: var(--accent-dim); border: 1px solid var(--accent); border-radius: 7px; color: var(--accent2); font-size: 11.5px; font-weight: 500; padding: 3px 8px; cursor: pointer; font-family: var(--font); transition: background var(--transition); }
.new-session-btn:hover { background: rgba(124,106,247,0.25); }
.session-item { display: flex; align-items: flex-start; gap: 6px; padding: 0.55rem 0.65rem; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.session-item:hover { border-color: var(--border2); background: var(--bg4); }
.session-item.active { border-color: var(--accent); background: var(--accent-dim); }
.session-item-main { flex: 1; min-width: 0; }
.session-title { font-size: 12.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { font-size: 10.5px; color: var(--text3); margin-top: 2px; }
.session-prompt-tag { font-size: 10px; color: var(--accent2); background: var(--accent-dim); border-radius: 4px; padding: 1px 5px; margin-top: 3px; display: inline-block; }
.session-del { background: transparent; border: none; color: var(--text3); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-size: 11px; flex-shrink: 0; transition: all var(--transition); }
.session-del:hover { color: var(--danger); background: var(--danger-dim); }

/* 프롬프트 바 */
.prompt-bar { display: flex; align-items: center; gap: 7px; padding: 5px 14px; background: rgba(124,106,247,0.06); border-bottom: 1px solid rgba(124,106,247,0.12); font-size: 11.5px; color: var(--accent2); flex-shrink: 0; }
.prompt-bar svg { flex-shrink: 0; opacity: 0.7; }

/* 새 대화 모달 */
.new-chat-modal-box { max-width: 420px; width: 95vw; }
.new-chat-input { width: 100%; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); font-family: var(--font); font-size: 13px; padding: 0.5rem 0.75rem; outline: none; transition: border-color var(--transition); }
.new-chat-input:focus { border-color: var(--accent); }
.new-chat-prompt { width: 100%; min-height: 90px; max-height: 160px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); font-family: var(--font); font-size: 12.5px; padding: 0.5rem 0.75rem; resize: vertical; outline: none; line-height: 1.5; transition: border-color var(--transition); }
.new-chat-prompt:focus { border-color: var(--accent); }


/* ══════════════════════════════════════════════════════════════
   ★ NEW FEATURES v3.1
══════════════════════════════════════════════════════════════ */

/* ─── 1. 메시지 타임스탬프 ─── */
.msg-timestamp {
  font-size: 10px;
  color: var(--text3);
  margin-top: 5px;
  display: block;
  letter-spacing: 0.2px;
  opacity: 0.8;
}
.msg.user .msg-timestamp { text-align: right; }

/* ─── 2. MCP 결과 확장 보기 ─── */
.tr-content {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text2);
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.tr-content.expanded { max-height: 600px; }
.tr-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 5px;
  color: var(--text3);
  font-size: 10.5px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.tr-expand-btn:hover { color: var(--accent2); border-color: var(--accent); }

/* ─── 3. 업로드 진행률 바 ─── */
.upload-progress-wrap {
  margin: 0 0.9rem 0.5rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  flex-shrink: 0;
}
.upload-progress-label {
  font-size: 11.5px;
  color: var(--text2);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.upload-progress-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  color: var(--text);
  font-weight: 500;
}
.upload-progress-pct {
  color: var(--accent2);
  font-family: var(--mono);
  font-size: 11px;
  flex-shrink: 0;
}
.upload-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg4);
  border-radius: 4px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
  transition: width 0.25s ease;
}
.upload-progress-step {
  font-size: 10.5px;
  color: var(--text3);
  margin-top: 3px;
}

/* ─── 4. 대화 검색 ─── */
.session-search-wrap {
  padding: 0.4rem 0.9rem 0.2rem;
  flex-shrink: 0;
}
.session-search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 0.35rem 0.7rem;
  outline: none;
  transition: border-color var(--transition);
}
.session-search-input:focus { border-color: var(--accent); }
.session-search-input::placeholder { color: var(--text3); }

/* ─── 5. 마크다운 렌더링 개선 ─── */
.msg-bubble pre {
  position: relative;
  background: #0a0c10;
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  margin: 0.6rem 0;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.85rem;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}
.code-lang {
  font-size: 10.5px;
  color: var(--text3);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.code-copy-btn {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font);
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}
.code-copy-btn:hover { color: var(--accent2); background: var(--accent-dim); }
.code-copy-btn.copied { color: var(--success); }
.code-body {
  padding: 0.8rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #e2e8f0;
}
.code-body::-webkit-scrollbar { height: 4px; }
.code-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* 신택스 컬러 토큰 */
.tok-keyword  { color: #c792ea; }
.tok-string   { color: #c3e88d; }
.tok-comment  { color: #546e7a; font-style: italic; }
.tok-number   { color: #f78c6c; }
.tok-function { color: #82aaff; }
.tok-operator { color: #89ddff; }
.tok-builtin  { color: #ffcb6b; }

/* 마크다운 테이블 */
.md-table-wrap {
  overflow-x: auto;
  margin: 0.6rem 0;
  border-radius: 8px;
  border: 1px solid var(--border2);
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 320px;
}
.md-table th {
  background: var(--bg4);
  color: var(--text);
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
.md-table td {
  padding: 0.45rem 0.85rem;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.md-table tr:last-child td { border-bottom: none; }
.md-table tr:hover td { background: rgba(255,255,255,0.02); }

/* 인용구 */
.md-blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.5rem 0;
  padding: 0.4rem 0.9rem;
  background: var(--accent-dim);
  border-radius: 0 6px 6px 0;
  color: var(--text2);
  font-style: italic;
}

/* 리스트 */
.msg-bubble ul, .msg-bubble ol { padding-left: 1.4rem; margin: 0.3rem 0 0.5rem; }
.msg-bubble li { margin: 0.15rem 0; color: var(--text2); }
.msg-bubble li strong { color: var(--text); }

/* 헤딩 */
.msg-bubble .md-h1 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0.6rem 0 0.3rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.msg-bubble .md-h2 { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 0.5rem 0 0.25rem; }
.msg-bubble .md-h3 { font-size: 13.5px; font-weight: 600; color: var(--accent2); margin: 0.4rem 0 0.2rem; }

/* ─── 6. RAG 청크 미리보기 ─── */
.rag-chunks-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  padding: 3px 9px;
  background: transparent;
  border: 1px solid rgba(124,106,247,0.25);
  border-radius: 6px;
  color: var(--accent2);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.rag-chunks-toggle:hover { background: var(--accent-dim); }
.rag-chunks-panel {
  margin-top: 8px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
}
.rag-chunk-item {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
}
.rag-chunk-item:last-child { border-bottom: none; }
.rag-chunk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.rag-chunk-doc {
  font-size: 10.5px;
  color: var(--accent2);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}
.rag-chunk-score {
  font-size: 10px;
  color: var(--success);
  font-family: var(--mono);
  flex-shrink: 0;
}
.rag-chunk-text {
  color: var(--text2);
  line-height: 1.5;
  font-size: 11.5px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── 7. 이미지 분석 → 문서 저장 ─── */
.img-save-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(76,175,130,0.12);
  border: 1px solid rgba(76,175,130,0.3);
  border-radius: 6px;
  color: var(--success);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.img-save-doc-btn:hover { background: rgba(76,175,130,0.22); }
.img-save-doc-btn.saved { opacity: 0.6; cursor: default; }

/* ─── 8. 메시지 액션 버튼 ─── */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 5px;
  color: var(--text3);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.msg-action-btn:hover  { background: var(--bg4); border-color: var(--accent); color: var(--accent2); }
.msg-action-btn:active { opacity: 0.7; }
.msg-action-btn:disabled { opacity: 0.5; cursor: default; }
.msg-action-btn.done   { color: var(--success); border-color: var(--success); }
.msg-excel-btn { color: #1e7e45 !important; border-color: #1e7e45 !important; }
.msg-excel-btn:hover   { background: rgba(30,126,69,0.10) !important; border-color: #1e7e45 !important; color: #1e7e45 !important; }

/* ─── 9. 대화 요약 ─── */
.session-summary {
  font-size: 10px;
  color: var(--text3);
  margin-top: 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── 10. 히스토리 확장 배너 ─── */
.history-extend-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(224,152,56,0.1);
  border: 1px solid rgba(224,152,56,0.25);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--warn);
}
.history-extend-banner button {
  background: rgba(224,152,56,0.2);
  border: 1px solid rgba(224,152,56,0.4);
  border-radius: 6px;
  color: var(--warn);
  font-size: 11.5px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  flex-shrink: 0;
}
.history-extend-banner button:hover { background: rgba(224,152,56,0.3); }
.history-extend-banner .heb-dismiss { margin-left: auto; background: transparent; border: none; color: var(--text3); font-size: 13px; padding: 2px 5px; cursor: pointer; }

/* ─── 11. 생성된 이미지 액션 (기존) ─── */
.generated-image-wrap { margin-top: 12px; }
.generated-image { max-width: 100%; border-radius: 12px; display: block; }
.generated-image-actions { display: flex; gap: 8px; margin-top: 8px; }
.generated-image-actions button { padding: 6px 12px; border: none; border-radius: 8px; cursor: pointer; }

/* ─── PDF 이미지 임베딩 옵션 행 ─── */
.pdf-img-embed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  margin: 4px 0.9rem 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
  gap: 8px;
  transition: border-color var(--transition), background var(--transition);
}
.pdf-img-embed-row:has(input:checked) {
  border-color: rgba(76,175,130,0.35);
  background: rgba(76,175,130,0.06);
}
.pdf-img-embed-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  user-select: none;
  flex: 1;
}
.pdf-img-embed-label input[type="checkbox"] { display: none; }
/* 이미지 임베딩 ON 시 체크는 녹색으로 */
.pdf-img-embed-label input:checked ~ .checkbox-custom {
  background: var(--success) !important;
  border-color: var(--success) !important;
}
.pdf-img-embed-label input:checked ~ span:last-child {
  color: var(--success);
  font-weight: 500;
}

/* ── MCP 도구 스캐너 ── */
.mcp-scanner-row:hover {
  background: var(--bg2);
  border-radius: 6px;
}
.mcp-scanner-row label:hover {
  color: var(--text1);
}

/* ════════════════════════════════════════════
   ★ 의도파악 마법사 모달
════════════════════════════════════════════ */
.intent-modal-box {
  width: min(520px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.intent-header {
  padding: 1.1rem 1.4rem 0.7rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.intent-header-icon { font-size: 1.3rem; }
.intent-header h2 { font-size: 14px; font-weight: 600; flex: 1; }
.intent-step-indicator {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.intent-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.intent-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 1rem 1.4rem;
  min-height: 200px;
}
.intent-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.intent-msg.ai { flex-direction: row; }
.intent-msg.user { flex-direction: row-reverse; }
.intent-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid rgba(124,106,247,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.intent-msg.user .intent-msg-avatar {
  background: var(--bg3);
  border-color: var(--border2);
}
.intent-msg-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
}
.intent-msg.ai .intent-msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
}
.intent-msg.user .intent-msg-bubble {
  background: var(--accent-dim);
  border: 1px solid rgba(124,106,247,0.25);
  border-top-right-radius: 4px;
  color: var(--text);
}
.intent-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}
.intent-typing span {
  width: 6px;
  height: 6px;
  background: var(--text3);
  border-radius: 50%;
  animation: intentBounce 1.2s infinite;
}
.intent-typing span:nth-child(2) { animation-delay: 0.2s; }
.intent-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes intentBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
.intent-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0.5rem 1.4rem 0.8rem;
}
.intent-opt-btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.intent-opt-btn:hover,
.intent-opt-btn.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent2);
}
.intent-input-row {
  display: flex;
  gap: 8px;
  padding: 0.7rem 1.4rem 0.9rem;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
.intent-text-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font);
  resize: none;
  min-height: 38px;
  max-height: 90px;
  outline: none;
  transition: border-color var(--transition);
}
.intent-text-input:focus { border-color: var(--accent); }
.intent-send-btn {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.intent-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.intent-send-btn:hover:not(:disabled) { opacity: 0.85; }
.intent-footer {
  padding: 0.7rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.intent-skip-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.intent-skip-btn:hover { color: var(--text2); border-color: var(--text3); }
.intent-generate-now-btn {
  background: none;
  border: 1px solid var(--accent2);
  color: var(--accent2);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 5px;
  transition: all var(--transition);
}
.intent-generate-now-btn:hover { background: rgba(var(--accent2-rgb, 0,229,176), 0.08); }
.intent-done-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 6px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
  display: none;
}
.intent-done-btn:hover { opacity: 0.85; }
.intent-done-btn.visible { display: inline-flex; align-items: center; gap: 6px; }
.intent-prompt-preview {
  margin: 0 1.4rem 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  display: none;
}
.intent-prompt-preview.visible { display: block; }
.intent-prompt-preview strong {
  display: block;
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ════════════════════════════════════════════
   ★ 음성 웨이크워드 UI
════════════════════════════════════════════ */
/* 상단바 음성 버튼 */
.voice-wake-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.voice-wake-btn:hover { border-color: var(--accent); color: var(--text2); }
.voice-wake-btn.active {
  background: rgba(229,90,90,0.12);
  border-color: rgba(229,90,90,0.4);
  color: #e55a5a;
}
.voice-wake-btn.listening {
  background: rgba(124,106,247,0.12);
  border-color: rgba(124,106,247,0.5);
  color: var(--accent2);
}
.voice-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: background var(--transition);
}
.voice-wake-btn.active .voice-dot {
  background: #e55a5a;
  animation: voicePulse 1.5s infinite;
}
.voice-wake-btn.listening .voice-dot {
  background: var(--accent2);
  animation: voicePulse 0.6s infinite;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

/* 음성 대화 오버레이 */
.voice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.voice-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.voice-panel {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 2rem 2rem 1.5rem;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
.voice-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent2), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.1s ease;
}
.voice-orb::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(124,106,247,0.3);
  animation: orbRing 2s infinite;
}
.voice-orb::after {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 1px solid rgba(124,106,247,0.15);
  animation: orbRing 2s infinite 0.5s;
}
@keyframes orbRing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}
.voice-orb.speaking { animation: orbSpeak 0.3s infinite alternate; }
@keyframes orbSpeak {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}
.voice-orb svg { position: relative; z-index: 1; }
.voice-status-text {
  font-size: 14px;
  color: var(--text2);
  min-height: 20px;
}
.voice-transcript {
  font-size: 13px;
  color: var(--text);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  min-height: 44px;
  line-height: 1.6;
  text-align: left;
}
.voice-transcript.empty { color: var(--text3); font-style: italic; }
.voice-cancel-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.voice-cancel-btn:hover { border-color: var(--danger); color: var(--danger); }

/* 음성 모드 메시지 말풍선 추가 스타일 */
.msg-voice-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
.tts-play-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition);
  display: inline-flex;
  align-items: center;
}
.tts-play-btn:hover { color: var(--accent2); }

/* ── 채팅 영역 드래그오버 효과 ── */
.chat-area.drag-over {
  outline: 2px dashed var(--accent2);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--accent2) 5%, var(--bg));
}


/* ════════════════════════════════════════════
   ★ 운전 모드 버튼 (topbar)
════════════════════════════════════════════ */
.drive-mode-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 20px; font-size: 12px; color: var(--text3);
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.drive-mode-btn:hover { border-color: var(--accent); color: var(--text2); }
.drive-mode-btn.active {
  background: rgba(255,180,0,0.12);
  border-color: rgba(255,180,0,0.5);
  color: #ffb400;
}
.drive-mode-label { font-size: 12px; }

/* ════════════════════════════════════════════
   ★ 운전 모드 오버레이
════════════════════════════════════════════ */
.drive-overlay {
  position: fixed; inset: 0; z-index: 3000;
  background: #0a0c14;
  display: flex; flex-direction: column;
  transition: opacity 0.2s ease;
}
.drive-overlay.hidden { display: none; }

/* 헤더 */
.drive-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1.2rem;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drive-title { font-size: 15px; font-weight: 600; color: var(--text); }
.drive-exit-btn {
  background: none; border: 1px solid var(--border2);
  color: var(--text3); border-radius: 8px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
  transition: all var(--transition);
}
.drive-exit-btn:hover { color: var(--text); border-color: var(--text3); }

/* 대화 내역 */
.drive-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; padding: 1rem;
  padding-bottom: 220px; /* mic 버튼 공간 */
}
.drive-messages {
  flex: 1; overflow-y: auto; display: flex;
  flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.drive-msg {
  max-width: 85%; padding: 10px 14px;
  border-radius: 14px; font-size: 15px; line-height: 1.5;
}
.drive-msg.user {
  align-self: flex-end;
  background: var(--accent-dim); border: 1px solid rgba(124,106,247,0.3);
  color: var(--text);
}
.drive-msg.ai {
  align-self: flex-start;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text);
}

/* 상태 텍스트 */
.drive-status {
  text-align: center; font-size: 18px; font-weight: 500;
  color: var(--text2); padding: 0.5rem 0;
  flex-shrink: 0;
}
.drive-status.listening { color: var(--accent2); }
.drive-status.thinking  { color: #ffb400; }
.drive-status.speaking  { color: #4caf50; }

/* 인식 텍스트 */
.drive-transcript {
  text-align: center; font-size: 14px; color: var(--text3);
  min-height: 24px; padding: 0.3rem 1rem; flex-shrink: 0;
}

/* 마이크 버튼 — 화면 하단 크게 */
.drive-mic-btn {
  position: fixed; bottom: 40px;
  left: 50%; transform: translateX(-50%);
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent2), var(--accent));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 rgba(124,106,247,0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.drive-mic-btn:active { transform: translateX(-50%) scale(0.94); }
.drive-mic-btn.listening {
  animation: drivePulse 1.2s infinite;
  background: radial-gradient(circle at 35% 35%, #e55a5a, #c0392b);
}
.drive-mic-btn.thinking {
  background: radial-gradient(circle at 35% 35%, #ffb400, #e67e00);
  animation: driveThink 1.5s infinite;
}
.drive-mic-btn.speaking {
  background: radial-gradient(circle at 35% 35%, #4caf50, #2e7d32);
  animation: drivePulse 0.8s infinite;
}
@keyframes drivePulse {
  0%   { box-shadow: 0 0 0 0 rgba(124,106,247,0.5); }
  70%  { box-shadow: 0 0 0 24px rgba(124,106,247,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,106,247,0); }
}
@keyframes driveThink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* 모바일 반응형 개선 */
@media (max-width: 700px) {
  .drive-mode-label { display: none; }
  .drive-mic-btn { width: 100px; height: 100px; bottom: 32px; }
  .drive-msg { font-size: 14px; }
  .drive-status { font-size: 16px; }
  .topbar-center { gap: 6px; }
  .voice-wake-btn { padding: 4px 7px; }
  .new-session-btn { font-size: 11px; padding: 3px 7px; }
}

/* ── 모바일 전용 RAG/MCP 토글 (설정 패널 상단) ── */
#mobileToggles { display: none; }
@media (max-width: 700px) {
  #mobileToggles {
    display: flex; gap: 12px; flex-wrap: wrap;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    background: var(--bg3);
  }
  .mobile-toggle-row {
    display: flex; align-items: center; gap: 6px;
  }
}

/* ── 드라이브 모드 추가 스타일 ── */
.drive-title-wrap { display: flex; align-items: center; gap: 8px; }
.drive-mic-btn.paused {
  background: radial-gradient(circle at 35% 35%, #888, #555);
  animation: none;
}
@keyframes drivePulse {
  0%   { box-shadow: 0 0 0 0 rgba(124,106,247,0.5); }
  70%  { box-shadow: 0 0 0 28px rgba(124,106,247,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,106,247,0); }
}
.drive-mic-btn.listening {
  animation: drivePulse 1s infinite;
  background: radial-gradient(circle at 35% 35%, #e55a5a, #c0392b);
}

.mcp-config-label { color: var(--accent2) !important; }
.mcp-docs-wrap { margin-top: 6px; }
.mcp-docs-toggle {
  font-size: 11px; color: var(--text3); cursor: pointer;
  list-style: none; padding: 3px 0;
  transition: color var(--transition);
}
.mcp-docs-toggle:hover { color: var(--text2); }
.mcp-docs-list {
  margin: 5px 0 2px 14px; padding: 0;
  font-size: 11px; color: var(--text2); line-height: 1.8;
}
