/* ============================================================
   이현 AI Legal — Main Stylesheet
   Base: ui_sample.html (lines 8–169)
   Enhanced: responsive breakpoints, form styling, modals,
             toasts, loading animations, pipeline steps,
             file upload drop zone, hamburger menu,
             print prevention, skeleton screens
   ============================================================ */

/* ── Reset & Custom Properties ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #FBF7F4;
  --surface: #FFFFFF;
  --text: #2D2424;
  --text2: #8C7B75;
  --accent: #A91C51;
  --accent-h: #8B1743;
  --accent-light: rgba(169,28,81,.08);
  --success: #059669;
  --warning: #D97706;
  --error: #DC2626;
  --info: #2563EB;
  --sidebar-bg: #F0E5DF;
  --sidebar-text: #4A3840;
  --sidebar-active: #A91C51;
  --sidebar-text-muted: rgba(74,56,64,.5);
  --sidebar-text-faint: rgba(74,56,64,.25);
  --sidebar-hover: rgba(74,56,64,.06);
  --sidebar-border: rgba(74,56,64,.1);
  --sidebar-active-bg: rgba(169,28,81,.1);
  --caption: #A39489;
  --border: #EDE5DF;
  --rail-w: 60px;
  --sidebar-w: 310px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.10);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

/* ── Dark Mode ── */
body.dark-mode {
  --bg: #1A1418;
  --surface: #251E23;
  --text: #F0E8EC;
  --text2: #A39498;
  --accent: #E8548A;
  --accent-h: #D63F78;
  --accent-light: rgba(232,84,138,.12);
  --success: #34D399;
  --warning: #FBBF24;
  --error: #F87171;
  --info: #60A5FA;
  --sidebar-bg: #120E11;
  --sidebar-text: #C8BDC4;
  --sidebar-active: #E8548A;
  --sidebar-text-muted: rgba(200,189,196,.45);
  --sidebar-text-faint: rgba(200,189,196,.25);
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-border: rgba(255,255,255,.08);
  --sidebar-active-bg: rgba(232,84,138,.15);
  --caption: #6B5E65;
  --border: #3D3238;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}
body.dark-mode .login-bg {
  background: var(--sidebar-bg);  /* 다크모드 사이드바 색 */
}
body.dark-mode .login-card {
  background: var(--surface);
  border-color: rgba(255,255,255,.08);
  color: var(--text);
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
body.dark-mode .login-card h1 { color: var(--text); }
body.dark-mode .login-card .subtitle { color: var(--sidebar-text-muted); }
body.dark-mode .field input {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.1);
  color: var(--text);
}
body.dark-mode .field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,84,138,.12);
  background: rgba(255,255,255,.08);
}
body.dark-mode .field label { color: var(--sidebar-text-muted); }
body.dark-mode .field input:focus + label,
body.dark-mode .field input:not(:placeholder-shown) + label,
body.dark-mode .field input:-webkit-autofill + label {
  background: var(--surface);
  color: var(--accent);
}
body.dark-mode .login-toggle { color: var(--sidebar-text-muted); }
body.dark-mode .login-contact { color: var(--sidebar-text-faint); }
body.dark-mode .login-contact strong { color: var(--sidebar-text-muted); }
body.dark-mode .skeleton {
  background: linear-gradient(90deg, #3D3238 25%, #4A3E45 50%, #3D3238 75%);
  background-size: 800px 100%;
}
body.dark-mode button {
  color: var(--text);
}
body.dark-mode select {
  color: var(--text);
  background-color: var(--surface);
}

body {
  font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Security: prevent all drag/select/copy */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* Allow select only inside chat input and form fields */
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; }
.msg-bubble { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; user-drag: none; pointer-events: none; }


/* ── Login ── */
#login-view {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .4s, transform .4s;
}
#login-view.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

/* ── 로그인 배경: 메인 앱과 동일한 크림/웜 톤 ── */
.login-bg {
  position: absolute;
  inset: 0;
  background: #F0E5DF;  /* 사이드바와 같은 웜 베이지 */
}
.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 85%, rgba(169,28,81,.08) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 10%, rgba(169,28,81,.06) 0%, transparent 45%);
}

/* ── 로그인 카드: 메인 앱 surface 색 ── */
.login-card {
  position: relative;
  z-index: 1;
  background: #FFFFFF;
  border: 1px solid #EDE5DF;
  border-radius: 20px;
  padding: 48px 40px 36px;
  width: 420px;
  color: #2D2424;
  box-shadow: 0 8px 40px rgba(169,28,81,.10), 0 2px 12px rgba(0,0,0,.06);
}
.login-card .logo {
  text-align: center;
  font-size: 40px;
  margin-bottom: 8px;
}
.login-card h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #2D2424;
  margin-bottom: 4px;
}
.login-card .subtitle {
  text-align: center;
  font-size: 13px;
  color: rgba(74,56,64,.5);
  margin-bottom: 32px;
}

/* ── 인풋 필드 ── */
.field {
  position: relative;
  margin-bottom: 20px;
}
.field input {
  width: 100%;
  padding: 14px 16px;
  background: #FBF7F4;
  border: 1px solid #EDE5DF;
  border-radius: 10px;
  color: #2D2424;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169,28,81,.08);
  background: #fff;
}
.field label {
  position: absolute;
  left: 16px;
  top: 14px;
  font-size: 14px;
  color: rgba(74,56,64,.55);
  pointer-events: none;
  transition: .2s;
  font-weight: 500;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field input:-webkit-autofill + label,
.field input:-webkit-autofill:hover + label,
.field input:-webkit-autofill:focus + label {
  top: -9px;
  left: 12px;
  font-size: 11px;
  background: #fff;
  padding: 1px 7px;
  border-radius: 4px;
  color: var(--accent);
  font-weight: 600;
}

/* ── 비밀번호 토글 버튼 ── */
.field.has-toggle input { padding-right: 46px; }
.pw-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: rgba(74,56,64,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  border-radius: 4px;
}
.pw-toggle:hover { color: var(--accent); }
body.dark-mode .pw-toggle { color: rgba(255,255,255,.4); }
body.dark-mode .pw-toggle:hover { color: var(--accent); }

/* ── Caps Lock 경고 ── */
.caps-warning {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(234,179,8,.08);
  border: 1px solid rgba(234,179,8,.3);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: #92700a;
  margin-top: -10px;
  margin-bottom: 14px;
  font-weight: 500;
}
.caps-warning.visible { display: flex; }

/* ── 로그인 버튼 ── */
.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform .1s;
  font-family: inherit;
  letter-spacing: .3px;
}
.login-btn:hover { background: var(--accent-h); }
.login-btn:active { transform: scale(.98); }

/* ── 하단 토글 (회원가입) ── */
.login-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: rgba(74,56,64,.5);
}
.login-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  margin-left: 4px;
}
.login-toggle a:hover { color: var(--accent-h); text-decoration: underline; }

/* ── 기획실 문의 안내 ── */
.login-contact {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: rgba(74,56,64,.4);
}
.login-contact strong { color: rgba(74,56,64,.65); font-weight: 600; }

.reg-fields { display: none; }
.login-card.register .reg-fields { display: block; }


/* ── App Shell ── */
#app-view { display: none; height: 100vh; }
#app-view.active { display: flex; }


/* ── Sidebar (fixed expanded by default, click to collapse) ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: width .3s cubic-bezier(.4,0,.2,1), min-width .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  position: relative;
  z-index: 100;
}
.sidebar.collapsed {
  width: var(--rail-w);
  min-width: var(--rail-w);
}

/* ── Sidebar top row (toggle + brand) ── */
.sidebar-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 8px;
  white-space: nowrap;
}
.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}
.sidebar-top-row .brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}
.sidebar-top-row .brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.sidebar-top-row .brand-user {
  font-size: 12px;
  font-weight: 500;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar.collapsed .sidebar-top-row .brand-text { display: none; }
.sidebar.collapsed .sidebar-top-row {
  justify-content: center;
  padding: 14px 0 8px;
}

/* ── Agent toggle row ── */
.sidebar-agent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-agent-row .ai-toggle-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  flex-shrink: 0;
}
.sidebar-agent-row .ai-toggle-switch::after {
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
}
.sidebar-agent-row .ai-toggle-switch.on::after {
  transform: translateX(16px);
}
.sidebar.collapsed .sidebar-agent-row { display: none; }
.agent-label-group {
  flex: 1;
  min-width: 0;
}
.agent-label-main {
  font-size: 13px;
  font-weight: 700;
  color: #7C5CFC;
  letter-spacing: .02em;
  line-height: 1.2;
}
[data-theme="dark"] .agent-label-main {
  color: #A78BFA;
}
/* OFF state */
.sidebar-agent-row.agent-off .agent-label-main {
  color: var(--sidebar-text-muted);
  opacity: .55;
}
.sidebar-agent-row.agent-off .agent-label-desc {
  opacity: .4;
}
.agent-label-desc {
  font-size: 11px;
  font-weight: 400;
  color: var(--sidebar-text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

.sidebar-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-section-title {
  padding: 8px 16px 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--sidebar-text);
  white-space: nowrap;
  transition: opacity .2s;
}
.sidebar.collapsed .sidebar-section-title { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  border-radius: 0;
  position: relative;
  font-size: 16px;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active-bg); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--sidebar-active);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon {
  min-width: 28px;
  text-align: center;
  font-size: 20px;
}
.nav-item .label {
  transition: opacity .2s;
}
.sidebar.collapsed .nav-item .label { display: none; }
.nav-item .badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: auto;
  transition: opacity .2s;
}
.sidebar.collapsed .nav-item .badge { display: none; }
.sidebar.collapsed .ai-toggle-desc { display: none; }
.sidebar.collapsed #conversationHistory { display: none; }
.sidebar.collapsed .sidebar-section { border-bottom: none; }

/* ── Document type categories (collapsible) ── */
.doc-type-section {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-text-faint) transparent;
  padding-bottom: 4px;
}
.doc-type-section::-webkit-scrollbar { width: 4px; }
.doc-type-section::-webkit-scrollbar-thumb { background: var(--sidebar-text-faint); border-radius: 2px; }

.doc-type-section > .sidebar-section-title {
  font-size: 12px;
  letter-spacing: .1em;
  padding: 8px 16px 6px;
  color: var(--sidebar-text-faint);
}

.doc-category {
  border-bottom: 1px solid var(--sidebar-border);
}
.doc-category:last-child { border-bottom: none; }

.doc-category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
  transition: background .15s;
  white-space: nowrap;
}
.doc-category-header:hover { background: var(--sidebar-hover); }
.doc-category.open .doc-category-header { background: var(--sidebar-active-bg); }
.doc-category-header .cat-arrow {
  font-size: 10px;
  color: var(--sidebar-text-faint);
  transition: transform .2s;
  min-width: 12px;
}
.doc-category.open .doc-category-header .cat-arrow {
  transform: rotate(90deg);
  color: var(--accent);
}
.doc-category-header .cat-icon {
  font-size: 16px;
  min-width: 22px;
  text-align: center;
}
.doc-category-header .cat-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--sidebar-text-faint);
  background: var(--sidebar-hover);
  padding: 1px 7px;
  border-radius: 8px;
}
.doc-category.open .doc-category-header .cat-count {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-muted);
}
.doc-category-items {
  display: none;
  padding-left: 14px;
  background: rgba(0,0,0,.15);
}
.doc-category.open .doc-category-items {
  display: block;
}
.doc-category-items .nav-item {
  padding: 7px 16px 7px 24px;
  font-size: 13px;
  gap: 0;
  border-left: 2px solid transparent;
  transition: border-color .15s, background .15s;
}
.doc-category-items .nav-item:hover {
  border-left-color: rgba(169,28,81,.4);
}
.doc-category-items .nav-item.active {
  border-left-color: var(--accent);
  background: rgba(169,28,81,.12);
}
.doc-category-items .nav-item .label {
  font-size: 13px;
}

/* Hide labels when sidebar collapsed */
.doc-category-header .label,
.doc-category-header .cat-arrow,
.doc-category-header .cat-count {
  transition: opacity .2s;
}
.sidebar.collapsed .doc-category-header .label,
.sidebar.collapsed .doc-category-header .cat-arrow,
.sidebar.collapsed .doc-category-header .cat-count { opacity: 0; }
.sidebar.collapsed .doc-category-items { display: none !important; }

/* ── Multi-Agent description ── */
.multi-agent-desc {
  padding: 6px 16px 8px;
  font-size: 10px;
  line-height: 1.6;
  color: var(--sidebar-text-muted);
  transition: opacity .2s, max-height .3s;
  overflow: hidden;
  max-height: 80px;
}
.multi-agent-desc strong { color: var(--sidebar-text); }
.multi-agent-desc .desc-detail { color: var(--sidebar-text-faint); font-size: 9px; }
.multi-agent-desc .desc-note { color: var(--success); font-size: 9px; font-weight: 500; }
.multi-agent-desc.off .desc-note { color: var(--caption); }
.sidebar.collapsed .multi-agent-desc { opacity: 0; max-height: 0; padding: 0 16px; }

/* ── AI Mode Slide Toggle ── */
.ai-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  white-space: nowrap;
}
.ai-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
}
.ai-toggle-switch {
  position: relative;
  width: 42px;
  height: 22px;
  background: var(--sidebar-text-faint);
  border-radius: 11px;
  cursor: pointer;
  transition: background .3s;
  flex-shrink: 0;
}
.ai-toggle-switch.on {
  background: var(--accent);
}
.ai-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.ai-toggle-switch.on::after {
  transform: translateX(20px);
}
.ai-toggle-desc {
  padding: 4px 16px 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--sidebar-text-muted);
  overflow: hidden;
  max-height: 60px;
  transition: opacity .8s ease, max-height .5s ease;
}
.ai-toggle-desc.fade-out {
  opacity: 0;
  max-height: 0;
}
.sidebar.collapsed .ai-toggle-wrap .ai-toggle-label { opacity: 0; }
.sidebar.collapsed .ai-toggle-desc { opacity: 0; max-height: 0; }
/* (legacy .sidebar-brand removed — now .sidebar-top-row) */

/* ── Sidebar collapse button styles handled in .sidebar-toggle-btn above ── */

.sidebar-menu-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 4px;
}
.sidebar-bottom {
  padding: 12px 0;
  border-top: 1px solid var(--sidebar-border);
}

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 15px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: color .15s, background .15s;
  white-space: nowrap;
  font-weight: 500;
}
.chat-history-item:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
/* ── 대화 항목 dot: 기본 회색(off) ── */
.chat-history-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #999;
  min-width: 7px;
  flex-shrink: 0;
  transition: background .2s;
}
/* 활성(현재 들어간) 대화: 자주색(on) */
.chat-history-item.active .dot {
  background: var(--accent);
  opacity: 1;
}

/* ── 생성 중 스피너 (dot 자리에) ── */
.conv-sending-spinner {
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 2px solid rgba(169,28,81,.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
/* 스피너 표시 중 dot 숨김 */
.chat-history-item:has(.conv-sending-spinner) .dot {
  display: none;
}
.chat-history-item .hist-title {
  font-size: 15px;
}
.chat-history-item .hist-date {
  font-size: 12px;
}
.chat-history-item .label {
  font-size: 15px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.chat-history-item .menu-trigger {
  opacity: 0;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  color: var(--sidebar-text-muted);
  transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.chat-history-item:hover .menu-trigger { opacity: 1; }
.chat-history-item .menu-trigger:hover { background: var(--sidebar-hover); }
.conv-menu {
  position: absolute;
  right: 8px;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 140px;
  z-index: 100;
  padding: 4px 0;
  font-size: 13px;
}
.conv-menu-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  transition: background .1s;
}
.conv-menu-item:hover { background: var(--bg); }
.conv-menu-item.danger { color: #ef4444; }
.conv-menu-item.danger:hover { background: #fef2f2; }
body.dark-mode .conv-menu-item.danger:hover { background: rgba(239,68,68,.1); }


/* ── Main Content ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ── Command Bar ── */
.command-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 200;
}
.cmd-input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: text;
  transition: border-color var(--transition);
}
.cmd-input:focus-within { border-color: var(--accent); }
.cmd-input .search-icon { color: var(--caption); font-size: 14px; }
.cmd-input input {
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  flex: 1;
}
.cmd-input input::placeholder { color: var(--caption); }
.cmd-input .shortcut {
  font-size: 11px;
  color: var(--caption);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}
.cmd-search-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.cmd-search-btn:hover { opacity: .9; }

.cmd-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cmd-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.cmd-user .name { font-size: 13px; font-weight: 500; }


/* ── Search keyword highlight ── */
mark.search-hl {
  background: #ffe066;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* ── Search Flash (대화 버블 키워드 강조) ── */
@keyframes searchFlash {
  0%   { box-shadow: 0 0 0 3px rgba(169,28,81,0.7); background: rgba(169,28,81,0.08); }
  40%  { box-shadow: 0 0 0 4px rgba(169,28,81,0.5); background: rgba(169,28,81,0.06); }
  100% { box-shadow: 0 0 0 0px rgba(169,28,81,0); background: transparent; }
}
.search-flash {
  border-radius: 10px;
  animation: searchFlash 1.8s ease-out forwards;
}

/* ── Search Dropdown ── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.13);
  z-index: 9000;
  overflow: hidden;
  max-height: 480px;
  overflow-y: auto;
}
.sd-section-title {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--caption);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-top: 1px solid var(--border);
}
.sd-section-title:first-child { border-top: none; }
.sd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}
.sd-item:hover { background: var(--hover); }
.sd-icon { font-size: 14px; flex-shrink: 0; }
.sd-text { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-badge {
  font-size: 10px;
  color: var(--caption);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.sd-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11px;
  color: var(--caption);
  line-height: 1.4;
  margin-top: 2px;
  /* white-space: nowrap 제거 → 2줄 wrapping으로 키워드 하이라이트 가시성 확보 */
}
.sd-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  text-align: right;
}
.sd-view-all {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background var(--transition);
}
.sd-view-all:hover { background: var(--hover); }

/* ── Search Full Panel ── */
.search-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.search-panel-back-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
  flex-shrink: 0;
}
.search-panel-back-btn:hover { background: var(--hover); }
.search-panel-query {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.sp-section {
  margin-bottom: 28px;
}
.sp-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--caption);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sp-empty {
  font-size: 13px;
  color: var(--caption);
  padding: 8px 0;
}
.sp-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 4px;
  border: 1px solid var(--border);
}
.sp-item:hover { background: var(--hover); border-color: var(--accent); }
.sp-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.sp-item-sub {
  font-size: 12px;
  color: var(--caption);
}
.sp-item-snippet {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}


/* ── Breadcrumb ── */
.breadcrumb-bar {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
}
.breadcrumb-bar .crumb {
  cursor: pointer;
  transition: color .15s;
}
.breadcrumb-bar .crumb:hover { color: var(--text); }
.breadcrumb-bar .crumb.current { color: var(--text); font-weight: 600; }
.breadcrumb-bar .sep { font-size: 11px; color: var(--caption); }


/* ── Workspace ── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 0 24px 0 24px;
  gap: 16px;
}
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}


/* ── Chat ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: msgIn .35s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg.ai .msg-avatar  { background: linear-gradient(135deg, var(--accent), #c0392b); color: #fff; }
.msg.user .msg-avatar { background: #374151; color: #fff; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.7;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.ai .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.msg.ai .msg-bubble .doc-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.8;
  white-space: pre-wrap;
}
.msg-meta {
  font-size: 10px;
  color: var(--caption);
  margin-top: 4px;
  padding: 0 4px;
}


/* ── Chat Input ── */
.chat-input-area { padding: 12px 0 16px; }
.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  transition: border-color var(--transition);
}
.chat-input-wrap:focus-within { border-color: var(--accent); }
.chat-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  background: none;
  color: var(--text);
  max-height: 120px;
}
.chat-input-wrap textarea::placeholder { color: var(--caption); }
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-h); }
.send-btn:active { transform: scale(.92); }


/* ── Status Bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--caption);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FBBF24;
  display: inline-block;
  margin-right: 4px;
}
.status-bar .sep { color: var(--border); }



/* ── Content Tabs ── */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.tab-content.active { display: block; animation: fadeTab .3s ease; }
@keyframes fadeTab {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
  cursor: pointer;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.card p  { font-size: 12px; color: var(--text2); line-height: 1.6; }
.card .card-tag {
  display: inline-block;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(169,28,81,.08);
  color: var(--accent);
  margin-top: 10px;
  font-weight: 500;
}


/* ── Scrollbar ── */
::-webkit-scrollbar { width: 0; display: none; }
* { scrollbar-width: none; }


/* =============================================================
   ENHANCEMENTS
   ============================================================= */


/* ── Responsive: 900px — hide preview, collapse sidebar ── */
@media (max-width: 900px) {
  .sidebar { width: var(--rail-w); min-width: var(--rail-w); }
  .sidebar .sidebar-top-row .brand-text,
  .sidebar .sidebar-section-title,
  .sidebar .nav-item .label,
  .sidebar .nav-item .badge,
  .sidebar .doc-category-header .label,
  .sidebar .doc-category-header .cat-arrow,
  .sidebar .doc-category-header .cat-count { opacity: 0; }
  .sidebar .doc-category-items { display: none !important; }
}


/* ── Responsive: 768px — hide sidebar, show hamburger ── */
@media (max-width: 768px) {
  body { overflow: auto; }

  #app-view { flex-direction: column; }

  .sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 500;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.mobile-open {
    display: flex;
    transform: translateX(0);
  }
  /* Always show labels when sidebar is visible on mobile */
  .sidebar.mobile-open .sidebar-top-row .brand-text,
  .sidebar.mobile-open .sidebar-section-title,
  .sidebar.mobile-open .nav-item .label,
  .sidebar.mobile-open .nav-item .badge,
  .sidebar.mobile-open .doc-category-header .label,
  .sidebar.mobile-open .doc-category-header .cat-arrow,
  .sidebar.mobile-open .doc-category-header .cat-count { opacity: 1; }
  /* Only show items for open categories on mobile */
  .sidebar.mobile-open .doc-category.open .doc-category-items { display: block; }

  .sidebar-overlay {
    display: block !important;
  }

  .command-bar { padding: 10px 16px; gap: 8px; }
  .cmd-input .shortcut { display: none; }

  .breadcrumb-bar { padding: 10px 16px; font-size: 12px; }

  .workspace { padding: 0 16px; }

  .chat-input-area { padding: 8px 0 12px; }

  .status-bar { padding: 6px 16px; gap: 10px; font-size: 10px; overflow-x: auto; }

  .tab-content { padding: 16px; }

  .card-grid { grid-template-columns: 1fr; }

  .login-card { width: calc(100% - 32px); max-width: 420px; padding: 36px 24px; }
}


/* ── Responsive: 480px — mobile optimizations ── */
@media (max-width: 480px) {
  .command-bar { padding: 8px 12px; }
  .cmd-input { padding: 6px 10px; }
  .cmd-input input { font-size: 12px; }

  .breadcrumb-bar { padding: 8px 12px; font-size: 11px; gap: 4px; }

  .workspace { padding: 0 12px; gap: 0; }

  .chat-messages { padding: 12px 0; gap: 10px; }
  .msg { max-width: 95%; }
  .msg-bubble { padding: 10px 13px; font-size: 13px; }
  .msg-avatar { width: 26px; height: 26px; font-size: 12px; }

  .chat-input-wrap { padding: 8px 10px; }
  .chat-input-wrap textarea { font-size: 13px; }
  .send-btn { width: 32px; height: 32px; }

  .status-bar { padding: 5px 12px; font-size: 10px; }
  .status-bar .sep { display: none; }

  .tab-content { padding: 12px; }
  .card { padding: 14px; }
  .card h4 { font-size: 13px; }
  .card p  { font-size: 11px; }

  .login-card { padding: 28px 20px; }
  .login-card h1 { font-size: 19px; }
  .login-card .logo { font-size: 32px; }
  .field input { padding: 12px 14px; font-size: 13px; }
  .login-btn { padding: 12px; font-size: 14px; }

  /* Larger touch targets */
  .nav-item { padding: 13px 16px; }
}


/* ── Sidebar Overlay (mobile backdrop) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 490;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ── Hamburger Menu Button ── */
.hamburger-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: var(--radius-sm);
  transition: background .15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--bg); }
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
  transform-origin: center;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 768px) {
  .hamburger-btn { display: flex; }
}


/* ── Form Styling (dynamic content) ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.form-group .hint {
  font-size: 11px;
  color: var(--caption);
  margin-top: 2px;
}
.form-group .error-msg {
  font-size: 11px;
  color: var(--error);
  margin-top: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169,28,81,.1);
}
.form-input.has-error,
.form-select.has-error,
.form-textarea.has-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(220,38,38,.08);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--caption); }

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), transform .1s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 4px 12px rgba(169,28,81,.25); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #EEEEF2; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger   { background: var(--error); color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-ghost    { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-ghost:hover { background: rgba(169,28,81,.06); }
.btn-sm  { padding: 6px 14px; font-size: 12px; }
.btn-lg  { padding: 13px 28px; font-size: 15px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }


/* ── Modal Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalBgIn .2s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes modalBgIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
  overflow-y: auto;
}
.modal-lg { max-width: 760px; }
.modal-sm { max-width: 420px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.9) translateY(-20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Interrupt Modal ── */
.interrupt-modal {
  padding: 24px;
  text-align: center;
}
.interrupt-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.interrupt-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.5;
}
.interrupt-desc {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 20px;
}
.interrupt-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.interrupt-actions .btn {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Stop Generation Button ── */
.stop-gen-row {
  margin-top: 8px;
  margin-bottom: 4px;
}
.stop-gen-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.stop-gen-btn:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #ef4444;
}
body.dark-mode .stop-gen-btn:hover {
  background: rgba(239,68,68,.1);
}

/* ── 단계별 수정 버튼 ── */
.edit-stage-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: var(--transition);
  z-index: 2;
  font-family: inherit;
}
.edit-stage-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
body.dark-mode .edit-stage-btn {
  background: var(--surface);
  border-color: rgba(255,255,255,.12);
}
body.dark-mode .edit-stage-btn:hover {
  background: rgba(169,28,81,.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--caption);
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .modal { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 85vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-header { padding: 16px 20px 12px; }
  .modal-body { padding: 16px 20px; }
  .modal-footer { padding: 12px 20px 20px; }
}


/* ── Toast Notification System ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1A1A2E;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  pointer-events: all;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 400px;
  min-width: 240px;
}
.toast.toast-exit {
  animation: toastOut .25s ease forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to   { opacity: 0; transform: translateY(8px) scale(.95); }
}

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; }
.toast-dismiss {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.5);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color .15s;
}
.toast-dismiss:hover { color: #fff; }

.toast.toast-success { background: #064E3B; border-left: 3px solid var(--success); }
.toast.toast-error   { background: #7F1D1D; border-left: 3px solid var(--error); }
.toast.toast-warning { background: #78350F; border-left: 3px solid var(--warning); }
.toast.toast-info    { background: #1E3A5F; border-left: 3px solid var(--info); }

/* Progress bar inside toast */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255,255,255,.3);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  animation: toastProgress linear forwards;
}
@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0; }
}


/* ── Loading / Spinner Animations ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
.spinner-white { border-color: rgba(255,255,255,.3); border-top-color: #fff; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Dot pulse loader */
.dot-loader {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dot-loader span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.dot-loader span:nth-child(2) { animation-delay: .2s; }
.dot-loader span:nth-child(3) { animation-delay: .4s; }
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* Full-page loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(248,248,250,.88);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  animation: fadeIn .2s ease;
}
.loading-overlay.hidden { display: none; }
.loading-overlay p {
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--caption);
  animation: typingBounce 1s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}


/* ── Pipeline Step Indicator ── */
.pipeline {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 20px 0;
  overflow-x: auto;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 80px;
  position: relative;
}

/* Connector line between steps */
.pipeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--border);
  transition: background .3s;
}
.pipeline-step.completed:not(:last-child)::after { background: var(--success); }
.pipeline-step.active:not(:last-child)::after    { background: var(--border); }

.pipeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--caption);
  position: relative;
  z-index: 1;
  transition: border-color .3s, background .3s, color .3s;
}
.pipeline-step.completed .pipeline-dot {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.pipeline-step.active .pipeline-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(169,28,81,.15);
  animation: pipelinePulse 1.6s ease-in-out infinite;
}
.pipeline-step.error .pipeline-dot {
  border-color: var(--error);
  background: var(--error);
  color: #fff;
}
@keyframes pipelinePulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(169,28,81,.15); }
  50%      { box-shadow: 0 0 0 8px rgba(169,28,81,.05); }
}

.pipeline-label {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--caption);
  text-align: center;
  line-height: 1.3;
  max-width: 80px;
}
.pipeline-step.completed .pipeline-label,
.pipeline-step.active    .pipeline-label { color: var(--text); }

.pipeline-sublabel {
  font-size: 10px;
  color: var(--caption);
  text-align: center;
  margin-top: 3px;
}
.pipeline-step.active .pipeline-sublabel { color: var(--accent); }

/* Vertical pipeline variant */
.pipeline-vertical {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0;
}
.pipeline-vertical .pipeline-step {
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  flex: none;
  min-width: unset;
  padding-bottom: 24px;
}
.pipeline-vertical .pipeline-step:not(:last-child)::after {
  top: 32px;
  left: 15px;
  right: auto;
  width: 2px;
  height: calc(100% - 8px);
}
.pipeline-vertical .pipeline-label {
  margin-top: 6px;
  text-align: left;
  max-width: none;
}


/* ── File Upload Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  outline: none;
}
.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(169,28,81,.03);
}
.drop-zone.drag-over { box-shadow: 0 0 0 4px rgba(169,28,81,.1); }

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
  transition: transform .2s;
}
.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon { transform: scale(1.1); }

.drop-zone-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.drop-zone-sub {
  font-size: 12px;
  color: var(--caption);
}
.drop-zone-sub span {
  color: var(--accent);
  font-weight: 500;
}

/* File list after upload */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  animation: msgIn .2s ease;
}
.file-item-icon { font-size: 18px; flex-shrink: 0; }
.file-item-name { flex: 1; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { font-size: 11px; color: var(--caption); flex-shrink: 0; }
.file-item-remove {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--caption);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.file-item-remove:hover { background: rgba(220,38,38,.08); color: var(--error); }

/* File chip (compact upload indicator in chat) */
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.file-chip-meta { font-size: 11px; color: var(--caption); font-weight: 400; }

/* Upload progress */
.upload-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.upload-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s ease;
}


/* ── Skeleton Loading Screens ── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #E5E7EB 25%, #F3F4F6 50%, #E5E7EB 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text  { height: 14px; border-radius: 7px; margin-bottom: 8px; }
.skeleton-title { height: 20px; border-radius: 10px; margin-bottom: 12px; }
.skeleton-block { height: 80px; border-radius: var(--radius-md); }
.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}
.skeleton-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Skeleton message bubble */
.skeleton-msg {
  display: flex;
  gap: 10px;
  padding: 4px 0;
}
.skeleton-msg-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  max-width: 60%;
}

/* Skeleton card */
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.skeleton-card .skeleton-title { width: 60%; }
.skeleton-card .skeleton-text:nth-child(2) { width: 90%; }
.skeleton-card .skeleton-text:nth-child(3) { width: 75%; }
.skeleton-card .skeleton-text:last-child   { width: 35%; margin-bottom: 0; }


/* ── Print Prevention ── */
@media print {
  *,
  *::before,
  *::after {
    visibility: hidden !important;
  }
  body::after {
    content: '이 페이지는 인쇄할 수 없습니다.';
    visibility: visible !important;
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #1A1A2E;
    background: #fff;
  }
}


/* ── Attach button (chat input) ── */
.attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.attach-btn:hover {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--accent);
}

.attached-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 4px 0;
}
.attached-files .file-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(169,28,81,.06);
  border: 1px solid rgba(169,28,81,.12);
  border-radius: 6px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}


/* ── Welcome bubble (new conversation) ── */
.welcome-bubble {
  max-width: 520px;
}

.welcome-upload-zone {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.welcome-upload-zone:hover {
  border-color: var(--accent);
  background: rgba(169,28,81,.02);
}
.welcome-upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(169,28,81,.04);
  box-shadow: 0 0 0 4px rgba(169,28,81,.08);
}

/* ── Welcome file list ── */
.wc-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 4px;
  font-size: 12px;
}
.wc-file-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.wc-file-name {
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wc-file-meta {
  margin-left: auto;
  font-size: 10px;
  color: var(--caption);
  white-space: nowrap;
}

/* ── Document select panel ── */
.doc-select-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  animation: fadeTab .2s ease;
}
.wc-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 4px;
}
.wc-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.wc-select:focus {
  border-color: var(--accent);
}
.wc-select:disabled {
  opacity: .5;
  cursor: not-allowed;
}
/* 웰컴 모드 토글 */
.wc-mode-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.wc-mode-btn {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.wc-mode-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(169,28,81,.25);
}
.wc-mode-btn:not(.active):hover {
  background: var(--hover);
  color: var(--text);
}

/* 서면 검토 결과 카드 */
.review-result-card {
  min-width: 0;
}
.review-sections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-section-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s;
}
.review-section-row:hover {
  border-color: var(--accent);
  background: rgba(169,28,81,.04);
}
.review-section-row.selected {
  border-color: var(--accent);
  background: rgba(169,28,81,.08);
}
.review-chk-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: transparent;
  transition: all .15s;
}
.review-section-row.selected .review-chk-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.review-action-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.review-action-bar .btn[disabled] {
  opacity: .45;
  cursor: default;
}
.review-opponent-row:hover {
  border-color: #d97706;
  background: rgba(217,119,6,.04);
}
.review-opponent-row.selected {
  border-color: #d97706;
  background: rgba(217,119,6,.1);
}
.review-opponent-row.selected .review-chk-box {
  background: #d97706;
  border-color: #d97706;
  color: #fff;
}
.review-section-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

.wc-structured-input {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wc-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wc-field-row {
  display: flex;
  gap: 12px;
}
.wc-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}
.wc-required {
  color: var(--accent);
}
.wc-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.wc-input:focus {
  border-color: var(--accent);
}
.wc-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  resize: vertical;
  line-height: 1.6;
  transition: border-color .15s;
  box-sizing: border-box;
}
.wc-textarea:focus {
  border-color: var(--accent);
}

/* ── Next document prompt ── */
.next-doc-card {
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
}

/* ── Sidebar new conv position ── */
.new-conv-wrap {
  padding: 6px 12px;
}
.sidebar-new-conv {
  font-size: 13px;
  padding: 10px 14px;
}
.sidebar.collapsed .new-conv-wrap {
  padding: 6px 0;
  display: flex;
  justify-content: center;
}
.sidebar.collapsed .sidebar-new-conv span {
  display: none;
}
.sidebar.collapsed .sidebar-new-conv {
  padding: 0;
  font-size: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  gap: 0;
}
.sidebar.collapsed .sidebar-new-conv::before {
  content: '+';
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

/* ── Analysis Card ── */
.analysis-card {
  max-width: 560px;
}
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.analysis-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}
.analysis-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--caption);
  margin-bottom: 3px;
}
.analysis-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.analysis-value.accent {
  color: var(--accent);
}
.analysis-summary {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.7;
  margin-top: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.analysis-tag {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(37,99,235,.08);
  color: var(--info);
  font-weight: 500;
  margin: 2px 2px 2px 0;
}
.analysis-issues {
  margin: 4px 0 0 16px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text);
}
.analysis-issues li {
  margin-bottom: 2px;
}

.analysis-details-toggle {
  margin-top: 10px;
}
.analysis-details-toggle summary {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
  user-select: none;
  list-style: none;
}
.analysis-details-toggle summary::-webkit-details-marker { display: none; }
.analysis-details-toggle summary::after {
  content: ' ▸';
  font-size: 11px;
  transition: transform .2s;
}
.analysis-details-toggle[open] summary::after {
  content: ' ▾';
}
.analysis-details-toggle summary:hover {
  text-decoration: underline;
}

.analysis-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


/* ── Similar Cases ── */
.analysis-similar {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(169,28,81,.03);
  border: 1px solid rgba(169,28,81,.08);
  border-radius: 8px;
}
.similar-case-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  font-size: 12px;
}
.similar-case-item:hover {
  background: rgba(169,28,81,.06);
}
.similar-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.similar-title {
  flex: 1;
  font-weight: 500;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.similar-score {
  font-size: 10px;
  color: var(--caption);
  flex-shrink: 0;
}


/* ── Evidence Template (in chat) ── */
.evidence-template {
  max-width: 520px;
}
.evidence-upload-area {
  padding: 10px 0;
}
.evidence-form-template {
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  margin-top: 8px;
}
.evidence-form-item label {
  display: block;
  margin-bottom: 4px;
}
.evidence-form-item .form-input {
  width: 100%;
}
.evidence-actions {
  display: flex;
  gap: 8px;
}


/* ── Info icon (circle) ── */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--caption);
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  color: var(--caption);
  cursor: default;
  position: relative;
  flex-shrink: 0;
  transition: border-color .15s, color .15s;
}
.info-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.info-icon .info-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: normal;
  width: 240px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  z-index: 100;
  pointer-events: none;
}
.info-icon .info-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
}
.info-icon:hover .info-tooltip {
  display: block;
}


/* ── Spinner ── */
.ai-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* ── Pipeline Bar (in-chat mini pipeline) ── */
.pipeline-bar .pl-step {
  color: var(--caption);
  background: transparent;
}
.pipeline-bar .pl-step.pl-active {
  color: var(--accent);
  background: rgba(169,28,81,.08);
  font-weight: 600;
}
.pipeline-bar .pl-step.pl-active .pl-icon {
  animation: pipelinePulse 1.2s ease-in-out infinite;
}
.pipeline-bar .pl-step.pl-done {
  color: var(--success);
  background: rgba(5,150,105,.06);
  font-weight: 500;
}

/* ── 섹션 공통 ── */
.ref-section, .defense-section, .supplement-section, .sv-section {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.ref-header, .defense-header, .supplement-header, .sv-header {
  padding: 10px 14px;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
  transition: background .15s;
}
.ref-header:hover, .defense-header:hover, .supplement-header:hover, .sv-header:hover {
  background: var(--surface);
}
.ref-toggle {
  font-size: 11px;
  color: var(--caption);
  transition: transform .2s;
}
.ref-body, .defense-body, .supplement-body, .sv-body {
  animation: fadeTab .2s ease;
}

/* ── AI 자기검증 ── */
.sv-summary {
  padding: 10px 14px 6px;
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.sv-group {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.sv-group:last-child { border-bottom: none; }
.sv-group-title {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--caption);
}
.sv-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}
.sv-item:last-child { border-bottom: none; }
.sv-citation {
  font-weight: 600;
  color: var(--text);
}
.sv-note {
  font-size: 11px;
  color: var(--caption);
}
.sv-contradiction .sv-location {
  font-size: 11px;
  color: var(--caption);
  font-style: italic;
}

/* ── 서면 이어쓰기 확인 프롬프트 ── */
.continue-prompt {
  margin: 8px 0 4px;
  animation: fadeIn .25s ease;
}
.continue-prompt-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #d97706;
  border-radius: 10px;
  background: #fffbeb;
  font-size: 13px;
}
[data-theme="dark"] .continue-prompt-inner {
  background: #1c1508;
  border-color: #92400e;
}
.continue-prompt-msg {
  color: #92400e;
  font-weight: 500;
  line-height: 1.5;
}
[data-theme="dark"] .continue-prompt-msg {
  color: #fcd34d;
}
.continue-btns {
  display: flex;
  gap: 8px;
}
.continue-yes,
.continue-no {
  padding: 7px 18px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: opacity .15s;
}
.continue-yes {
  background: var(--accent);
  color: #fff;
}
.continue-yes:hover { opacity: .85; }
.continue-no {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.continue-no:hover { opacity: .8; }
.ref-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--success);
  margin-left: 6px;
}
.defense-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  margin-left: 6px;
}

/* ── 인용 법령 및 판례 ── */
.ref-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.ref-item:last-child { border-bottom: none; }
.ref-type-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
}
.ref-type-law {
  background: #ede9fe;
  color: #6d28d9;
}
.ref-type-case {
  background: #dbeafe;
  color: #1d4ed8;
}
.ref-item-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.ref-name {
  font-weight: 500;
  color: var(--text);
}
.ref-detail {
  font-size: 11px;
  color: var(--caption);
  line-height: 1.4;
}
.ref-note {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--caption);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* ── 선제적 방어 전략 ── */
.defense-item {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.defense-item:last-child { border-bottom: none; }
.defense-threat {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 3px;
}
.defense-threat-icon {
  color: #ef4444;
  margin-right: 2px;
}
.defense-response {
  font-size: 12px;
  color: var(--success);
  padding-left: 18px;
  line-height: 1.5;
}
.defense-response-icon {
  color: var(--success);
  font-weight: 700;
  margin-right: 4px;
}

/* ── 사건 보완 안내 ── */
.supplement-body {
  padding: 0 14px 10px;
}
.supplement-summary {
  padding: 8px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.supplement-group {
  margin-top: 8px;
}
.supplement-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.supplement-item {
  font-size: 12px;
  color: var(--text2);
  padding: 3px 0 3px 16px;
  position: relative;
  line-height: 1.6;
}
.supplement-item::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

/* ── Utility Classes ── */
.hidden      { display: none !important; }
.invisible   { visibility: hidden; }
.sr-only     { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2  { gap: 8px; }
.gap-4  { gap: 16px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mb-2   { margin-bottom: 8px; }
.mb-4   { margin-bottom: 16px; }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-caption { color: var(--caption); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }

/* ── New Conversation Button ── */
.new-conv-btn {
  width: 100%;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, box-shadow .15s;
}
.new-conv-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 2px 8px rgba(169,28,81,.2);
}

/* ── Edit Mode Button ── */
.conv-edit-btn {
  background: none;
  border: 1px solid var(--sidebar-border, var(--border));
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--sidebar-text-muted, var(--caption));
  cursor: pointer;
  transition: all .15s;
}
.conv-edit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.conv-edit-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Bulk Action Bar ── */
.conv-bulk-actions {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  align-items: center;
}
.conv-bulk-actions button {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--sidebar-border, var(--border));
  background: none;
  color: var(--sidebar-text, var(--text));
  transition: all .15s;
}
.conv-bulk-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.conv-bulk-actions button.danger {
  color: #ef4444;
  border-color: #ef4444;
}
.conv-bulk-actions button.danger:hover {
  background: rgba(239,68,68,.08);
}

/* ── Conversation Checkbox ── */
.conv-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Admin Sub-tabs ── */
.admin-sub-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  padding-bottom: 0;
}
.admin-sub-tab {
  padding: 10px 18px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.admin-sub-tab:hover {
  color: var(--text);
}
.admin-sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Notices Board ── */
.notice-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.notice-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(169,28,81,.06);
}
.notice-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
}
.notice-badge.\uC218\uC815 { background: #dbeafe; color: #1e40af; }
.notice-badge.\uC624\uB958 { background: #fef2f2; color: #991b1b; }
.notice-badge.\uACF5\uC9C0 { background: #dcfce7; color: #166534; }
.notice-content {
  display: none;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.notice-item.expanded .notice-content {
  display: block;
}
.notice-write-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: filter .15s;
}
.notice-write-btn:hover {
  filter: brightness(1.1);
}
.notice-action-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.notice-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.notice-del-btn:hover {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
}

/* ── Danger Button ── */
.btn-danger {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: filter .15s;
}
.btn-danger:hover {
  filter: brightness(.9);
}

/* ── 회원가입 이메일 힌트 ── */
.reg-email-hint {
  background: rgba(169,28,81,.07);
  border: 1px solid rgba(169,28,81,.18);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 12px;
}
.reg-email-preview {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
}
.reg-email-domain {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

/* ── 보안 이벤트 배지 ── */
.sec-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
}
.sec-badge.WARNING { background: #fef9c3; color: #92700a; }
.sec-badge.ERROR   { background: #fef2f2; color: #991b1b; }
.sec-badge.INFO    { background: #f0fdf4; color: #166534; }

/* ── 채팅 랜딩 화면 ── */
.chat-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  padding: 40px 20px;
  text-align: center;
}
.chat-landing-icon {
  font-size: 52px;
  margin-bottom: 20px;
  filter: drop-shadow(0 2px 8px rgba(169,28,81,.2));
}
.chat-landing-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.chat-landing-desc {
  font-size: 14px;
  color: var(--caption);
  line-height: 1.7;
  margin-bottom: 28px;
  max-width: 360px;
}
.chat-landing-btn {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(169,28,81,.30);
  transition: transform .15s, box-shadow .15s;
  margin-bottom: 16px;
}
.chat-landing-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(169,28,81,.38);
}
.chat-landing-hint {
  font-size: 12px;
  color: var(--caption);
}

/* ── 로그인/회원가입 도메인 suffix ── */
.field.with-suffix {
  position: relative;
}
.field.with-suffix input {
  padding-right: 140px;
  box-sizing: border-box;
}
.domain-suffix {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  display: flex;
  align-items: center;
  padding: 0 14px 0 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #A91C51;
  background: rgba(169,28,81,.07);
  border-left: 1px solid rgba(169,28,81,.18);
  border-radius: 0 9px 9px 0;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

/* ── 회원가입 설명 박스 ── */
.reg-desc-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(169,28,81,.05);
  border: 1px solid rgba(169,28,81,.15);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #5A3A3A;
  margin-bottom: 14px;
  line-height: 1.55;
}
.reg-desc-box strong { color: var(--accent); font-weight: 700; }
