/* =============================================================================
   4INLAB MFG AI Assistant — Premium dual theme
   Dark: industrial / AI ops  ·  Light: executive / modern enterprise
   ============================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  --font-sans: "Inter", "Pretendard", "Plus Jakarta Sans", system-ui, sans-serif;
  --sidebar-w: 340px;
  --preview-w: 420px;
  --header-h: 56px;
  --r-paper: #f1f5f9;
  --r-ink: #0f172a;
  --r-line: #e2e8f0;
  /* Rich response — enterprise table / chart tokens (default = light) */
  --rich-table-bg: #ffffff;
  /* Table header: 연한 회색 배경 + 진한 글자 */
  --rich-table-header-bg: #e8eaed;
  --rich-table-header-text: #334155;
  --rich-table-row-bg: #ffffff;
  --rich-table-row-alt: #f8fafc;
  --rich-table-row-hover: #eef2ff;
  --rich-table-border: #e2e8f0;
  --rich-table-text: #0f172a;
  --rich-kpi-bg: #ffffff;
  --rich-kpi-border: #e2e8f0;
  --rich-kpi-value: #0f172a;
  --rich-kpi-label: #64748b;
  --rich-chart-c1: #f97316;
  --rich-chart-c2: #2563eb;
  --rich-chart-c3: #16a34a;
  --rich-chart-c4: #dc2626;
  --rich-chart-c5: #facc15;
  --chart-axis: #475569;
  --chart-grid: #e2e8f0;
  --motion-duration: 0.35s;
  --motion-ease: cubic-bezier(0.4, 0, 0.2, 1);
  /* Central chat column + bubble widths (wider frame; messages not full-bleed) */
  --chat-content-max: 1600px;
  --msg-user-bubble-max: min(82%, 40rem);
  --msg-assistant-bubble-max: min(100%, 88rem);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #07111f;
  --bg-panel: #0f172a;
  --bg-card: #111c31;
  --bg-soft: #172554;
  --bg-elev: #0c1424;
  --line: #24324a;
  --line-sub: rgba(36, 50, 74, 0.65);
  /* Enterprise sidebar (dark) */
  --sidebar-surface: #0b1220;
  --sidebar-border: #1f2937;
  --sidebar-text-muted: #94a3b8;
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-mute: #64748b;
  --orange: #f97316;
  --orange-hover: #fb923c;
  --orange-deep: #ea580c;
  --green: #22c55e;
  --yellow: #facc15;
  --red: #ef4444;
  --blue: #38bdf8;
  --md-prose-ink: #e2e8f0;
  --user-bubble-shadow: 0 4px 20px rgba(249, 115, 22, 0.28);
  --assistant-surface: linear-gradient(165deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.92) 100%);
  --assistant-border: var(--line);
  --topbar-bg: linear-gradient(180deg, #0b1628 0%, #0a1220 100%);
  --topbar-border: rgba(36, 50, 74, 0.9);
  --topbar-workspace: #64748b;
  --topbar-name: #f1f5f9;
  --topbar-center: #94a3b8;
  --topbar-icon-bg: rgba(15, 23, 42, 0.85);
  --topbar-icon-border: #24324a;
  --topbar-icon-fg: #94a3b8;
  --topbar-icon-hover-bg: rgba(249, 115, 22, 0.12);
  --sidebar-edge: 1px solid rgba(36, 50, 74, 0.65);
  --composer-panel: var(--bg-card);
  --composer-border: var(--line);
  --rich-chrome: rgba(5, 10, 20, 0.5);
  --rich-pre-bg: #050a12;
  --chip-bg: var(--bg-card);
  --session-card-bg: rgba(15, 23, 42, 0.45);
  --preview-outer: #0a0e16;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-elev: 0 0 0 1px rgba(255, 255, 255, 0.05);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  /* Rich response — dark theme tables / KPI / charts */
  --rich-table-bg: #111827;
  --rich-table-header-bg: #334155;
  --rich-table-header-text: #f1f5f9;
  --rich-table-row-bg: #0f172a;
  --rich-table-row-alt: #111827;
  --rich-table-row-hover: #1e293b;
  --rich-table-border: #334155;
  --rich-table-text: #f8fafc;
  --rich-kpi-bg: #111827;
  --rich-kpi-border: #334155;
  --rich-kpi-value: #f8fafc;
  --rich-kpi-label: #cbd5e1;
  --chart-axis: #cbd5e1;
  --chart-grid: #334155;
  --rich-chart-c1: #fb923c;
  --rich-chart-c2: #38bdf8;
  --rich-chart-c3: #22c55e;
  --rich-chart-c4: #ef4444;
  --rich-chart-c5: #facc15;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f8fafc;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #eef2ff;
  --bg-elev: #ffffff;
  --line: #e2e8f0;
  --line-sub: rgba(226, 232, 240, 0.9);
  /* Enterprise sidebar (light) */
  --sidebar-surface: #ffffff;
  --sidebar-border: #e5e7eb;
  --sidebar-text-muted: #6b7280;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --text-mute: #94a3b8;
  --orange: #f97316;
  --orange-hover: #fb923c;
  --orange-deep: #ea580c;
  --green: #16a34a;
  --yellow: #ca8a04;
  --red: #dc2626;
  --blue: #0284c7;
  --md-prose-ink: #1e293b;
  --user-bubble-shadow: 0 4px 16px rgba(234, 88, 12, 0.22);
  --assistant-surface: #ffffff;
  --assistant-border: #e2e8f0;
  --topbar-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --topbar-border: #e2e8f0;
  --topbar-workspace: #64748b;
  --topbar-name: #0f172a;
  --topbar-center: #64748b;
  --topbar-icon-bg: #f8fafc;
  --topbar-icon-border: #e2e8f0;
  --topbar-icon-fg: #475569;
  --topbar-icon-hover-bg: #fff7ed;
  --sidebar-edge: 1px solid #e2e8f0;
  --composer-panel: #ffffff;
  --composer-border: #e2e8f0;
  --rich-chrome: #f1f5f9;
  --rich-pre-bg: #f1f5f9;
  --chip-bg: #ffffff;
  --session-card-bg: #f8fafc;
  --preview-outer: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-elev: 0 1px 0 rgba(15, 23, 42, 0.04), 0 8px 32px rgba(15, 23, 42, 0.06);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  /* Rich — light (explicit) */
  --rich-table-bg: #ffffff;
  --rich-table-header-bg: #e8eaed;
  --rich-table-header-text: #334155;
  --rich-table-row-bg: #ffffff;
  --rich-table-row-alt: #f8fafc;
  --rich-table-row-hover: #eef2ff;
  --rich-table-border: #e2e8f0;
  --rich-table-text: #0f172a;
  --rich-kpi-bg: #ffffff;
  --rich-kpi-border: #e2e8f0;
  --rich-kpi-value: #0f172a;
  --rich-kpi-label: #64748b;
  --chart-axis: #475569;
  --chart-grid: #e2e8f0;
  --rich-chart-c1: #f97316;
  --rich-chart-c2: #2563eb;
  --rich-chart-c3: #16a34a;
  --rich-chart-c4: #dc2626;
  --rich-chart-c5: #facc15;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  transition: background-color var(--motion-duration) var(--motion-ease), color 0.25s ease;
}
body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
  transition: background-color var(--motion-duration) var(--motion-ease), color 0.25s ease;
}
@media (prefers-reduced-motion: reduce) {
  html,
  body,
  .sidebar,
  .session-item,
  .msg,
  .assistant-card,
  .composer-surface,
  .chip,
  .btn-cta,
  .icon-btn,
  .chat-topbar,
  .quick-chips,
  .welcome-hero,
  .logo-glow,
  .cmd-inner {
    transition: none !important;
    animation: none !important;
  }
}

.app {
  display: flex;
  height: 100vh;
  min-height: 0;
}
body.modal-open {
  overflow: hidden;
}

/* ============== SIDEBAR ============== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-surface, var(--bg-panel));
  border-right: 1px solid var(--sidebar-border, var(--line));
  transition: background-color var(--motion-duration) var(--motion-ease), border-color 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 30;
  transition: transform 0.28s ease, box-shadow 0.28s ease, background-color 0.3s ease;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 1rem 0.9rem 0.75rem;
  border-bottom: 1px solid var(--sidebar-border, var(--line-sub));
  background: var(--sidebar-surface, var(--bg-panel));
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.sidebar-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-panel[hidden] {
  display: none !important;
}

.sidebar-fade {
  animation: sb-fade-in 0.22s var(--motion-ease) both;
}
@keyframes sb-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Segmented tabs: 채팅 | 보고서 */
.sidebar-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg-soft, rgba(15, 23, 42, 0.4));
  border: 1px solid var(--sidebar-border, var(--line));
  margin-top: 0.6rem;
}
html[data-theme="light"] .sidebar-tabs {
  background: #f3f4f6;
}
.sidebar-tab {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 9px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--sidebar-text-muted, var(--text-sub));
  background: transparent;
  transition: background 0.2s var(--motion-ease), color 0.2s, transform 0.15s;
}
.sidebar-tab:hover:not(.is-active) {
  color: var(--text-main);
  background: rgba(249, 115, 22, 0.08);
}
.sidebar-tab.is-active {
  background: linear-gradient(135deg, #ea580c, #f97316 55%, #fb923c);
  color: #fff;
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.35);
}
.sidebar-tab:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* Global search (pill) */
.sidebar-search-wrap {
  position: relative;
  margin-bottom: 0.25rem;
}
.sidebar-search-ico {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  opacity: 0.75;
}
html[data-theme="dark"] .sidebar-search-ico {
  filter: brightness(1.2);
}
.sidebar-search-wrap input {
  width: 100%;
  background: var(--bg-card, #fff);
  border: 1px solid var(--sidebar-border, var(--line));
  color: var(--text-main);
  border-radius: 999px;
  padding: 0.55rem 0.75rem 0.55rem 2.4rem;
  font-size: 0.8125rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-search-wrap input::placeholder {
  color: var(--sidebar-text-muted, var(--text-mute));
}
.sidebar-search-wrap input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.22);
}

.report-scroller {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.4rem 0.5rem 0.5rem;
  min-height: 0;
}

/* Report library tree */
.rt-empty {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
  font-size: 0.875rem;
  color: var(--sidebar-text-muted, var(--text-mute));
  line-height: 1.5;
}
.rt-node {
  margin-bottom: 0.2rem;
}
.rt-node > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  user-select: none;
  transition: background 0.15s;
}
.rt-node > summary::-webkit-details-marker {
  display: none;
}
.rt-node > summary::before {
  content: "▶";
  font-size: 0.55rem;
  opacity: 0.6;
  transition: transform 0.2s var(--motion-ease);
}
.rt-node[open] > summary::before {
  transform: rotate(90deg);
}
.rt-node > summary:hover {
  background: var(--hover-row, rgba(249, 115, 22, 0.06));
}
html[data-theme="light"] {
  --hover-row: #f9fafb;
}
html[data-theme="dark"] {
  --hover-row: rgba(255, 255, 255, 0.05);
}
.rt-node-l1 > summary {
  font-size: 0.8rem;
  color: var(--text-main);
}
.rt-node-children {
  padding-left: 0.5rem;
  border-left: 1px solid var(--sidebar-border, var(--line));
  margin: 0.2rem 0 0.35rem 0.35rem;
}
.report-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.5rem;
  border-radius: 12px;
  margin-bottom: 0.2rem;
  cursor: pointer;
  transition: background 0.18s, transform 0.12s, border-color 0.15s;
  border: 1px solid transparent;
}
.report-item:hover {
  background: var(--hover-row);
  transform: translateX(1px);
}
.report-item-ico {
  font-size: 1rem;
  line-height: 1.2;
  flex-shrink: 0;
}
.report-item-body {
  flex: 1;
  min-width: 0;
}
.report-item-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.report-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  color: var(--sidebar-text-muted, var(--text-mute));
}
.report-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
.report-badge--quality {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
}
.report-badge--production {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
  border: 1px solid rgba(22, 163, 74, 0.25);
}
.report-badge--inventory {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.25);
}
.report-badge--equipment {
  background: rgba(249, 115, 22, 0.15);
  color: #ea580c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}
.report-badge--management {
  background: rgba(100, 116, 139, 0.15);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.25);
}
html[data-theme="dark"] .report-badge--quality {
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.2);
}
html[data-theme="dark"] .report-badge--production {
  color: #86efac;
  background: rgba(22, 163, 74, 0.2);
}
html[data-theme="dark"] .report-badge--inventory {
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.2);
}
html[data-theme="dark"] .report-badge--equipment {
  color: #fdba74;
  background: rgba(249, 115, 22, 0.18);
}
html[data-theme="dark"] .report-badge--management {
  color: #cbd5e1;
  background: rgba(100, 116, 139, 0.25);
}

.report-kebab {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
}
.report-item:hover .report-kebab,
.report-item:focus-within .report-kebab {
  opacity: 1;
}
@media (hover: none) {
  .report-kebab {
    opacity: 1;
  }
}
.report-kebab-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.report-kebab-btn:hover {
  background: rgba(249, 115, 22, 0.1);
  color: var(--orange);
}
.report-kebab-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  min-width: 160px;
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--sidebar-border, var(--line));
  background: var(--bg-card, var(--bg-panel));
  box-shadow: var(--shadow-lg);
  margin-top: 2px;
}
.report-kebab-menu[hidden] {
  display: none;
}
.report-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
}
.report-menu-item:hover {
  background: var(--hover-row);
}
.report-menu-item--danger {
  color: #ef4444;
}

/* Chat time groups */
.sb-pinned-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sidebar-text-muted, var(--text-mute));
  padding: 0.35rem 0.4rem 0.5rem;
}
.sb-pin-ico {
  display: inline-block;
  margin-right: 0.15em;
  font-style: normal;
}
.sb-group {
  border: none;
  margin-bottom: 0.5rem;
}
.sb-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--sidebar-text-muted, var(--text-mute));
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.sb-group > summary::-webkit-details-marker {
  display: none;
}
.sb-group > summary::after {
  content: "▾";
  font-size: 0.6rem;
  opacity: 0.5;
}
.sb-group[open] > summary::after {
  transform: rotate(0);
}
.sb-group > summary:hover {
  background: var(--hover-row);
}
.sb-group-list {
  padding-top: 0.25rem;
}

.brand-block {
  display: flex;
  gap: 0.75rem;
  padding: 0.15rem 0.1rem 0.85rem;
  margin-bottom: 0.25rem;
  border: none;
}
.logo-glow {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--orange-deep) 0%, var(--orange) 45%, var(--orange-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 8px 28px rgba(249, 115, 22, 0.35);
  flex-shrink: 0;
  animation: logo-pulse 4s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 8px 28px rgba(249, 115, 22, 0.35);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 8px 32px rgba(249, 115, 22, 0.5);
  }
}
.brand-text h1 {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-main);
}
.brand-text .sub {
  font-size: 0.6875rem;
  color: var(--text-sub);
  margin-top: 0.2rem;
  line-height: 1.35;
}

/* Primary CTA under brand */
.sidebar-header .btn-cta {
  margin-bottom: 1rem;
}

.session-actions {
  margin-bottom: 0.6rem;
  padding: 0 0.25rem;
}
.session-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
.session-actions-row--bulk {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.45rem;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 1px;
}
.session-actions-row--bulk .session-all-label {
  flex-shrink: 0;
}
.session-actions-row--bulk .session-select-hint {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
}
.session-actions-btns {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}
.btn-session-ghost,
.btn-session-danger {
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-session-ghost {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-sub);
}
.btn-session-ghost:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--topbar-icon-hover-bg, rgba(249, 115, 22, 0.08));
}
.btn-session-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-session-danger {
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
  color: var(--red, #f87171);
}
.btn-session-danger:hover {
  background: rgba(248, 113, 113, 0.18);
  border-color: var(--red, #f87171);
}
.session-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
}
.session-all-label input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--orange);
  cursor: pointer;
}
.session-select-hint {
  font-size: 0.6875rem;
  color: var(--text-mute);
}

.btn-cta {
  display: block;
  width: 100%;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.875rem;
  min-height: 48px;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #ea580c, #f97316 50%, #fb923c);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.28), var(--shadow-inset);
  transition: filter 0.2s, transform 0.18s var(--motion-ease), box-shadow 0.2s;
}
.btn-cta:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.35), var(--shadow-inset);
}
.btn-cta:active {
  transform: translateY(0);
}

.session-scroller {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.3rem 0.45rem 0.5rem;
  min-height: 0;
  margin: 0;
}
.sidebar-panel .session-actions {
  flex-shrink: 0;
  padding: 0.4rem 0.45rem 0.1rem;
}
.chat-empty {
  text-align: center;
  font-size: 0.875rem;
  color: var(--sidebar-text-muted, var(--text-mute));
  padding: 2rem 0.75rem 1.5rem;
  line-height: 1.5;
}
.session-item {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.65rem 0.5rem 0.65rem 0.55rem;
  border-radius: 14px;
  border: 1px solid transparent;
  margin-bottom: 0.35rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s ease;
  background: var(--session-card-bg);
}
.session-cb-label {
  display: none;
  flex-shrink: 0;
  margin-top: 0.15rem;
  cursor: pointer;
}
.session-item--select .session-cb-label {
  display: flex;
  align-items: center;
}
.session-cb-label input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--orange);
  cursor: pointer;
}
.session-item-inner {
  flex: 1;
  min-width: 0;
}
.session-item--select .session-btns,
.session-item--select .session-kebab {
  display: none !important;
}
.session-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background 0.2s;
}
.session-item:hover {
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.session-item.active {
  border-color: var(--line);
  background: var(--bg-card);
  box-shadow: var(--shadow-inset);
}
.session-item.active::before {
  background: var(--orange);
}
.session-item .t {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.session-item .meta {
  font-size: 0.6875rem;
  color: var(--text-mute);
  margin-top: 0.35rem;
  padding-left: 0;
}
.session-item .session-btns {
  display: none;
}
.session-head-row {
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
  min-width: 0;
}
.session-kebab {
  position: relative;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.18s;
}
.session-item:hover .session-kebab,
.session-item:focus-within .session-kebab {
  opacity: 1;
}
@media (hover: none) {
  .session-item .session-kebab {
    opacity: 1;
  }
}
.session-kebab-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.session-kebab-btn:hover,
.session-kebab-btn[aria-expanded="true"] {
  background: rgba(249, 115, 22, 0.12);
  color: var(--orange);
}
.session-kebab-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 40;
  min-width: 140px;
  margin-top: 2px;
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid var(--sidebar-border, var(--line));
  background: var(--bg-card, var(--bg-panel));
  box-shadow: var(--shadow-lg);
}
.session-kebab-menu[hidden] {
  display: none;
}
.session-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
}
.session-menu-item:hover {
  background: var(--hover-row, rgba(249, 115, 22, 0.08));
}
.session-menu-item--danger {
  color: #ef4444;
}

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--sidebar-border, var(--line-sub));
  padding: 0.65rem 0.9rem 0.75rem;
  font-size: 0.65rem;
  color: var(--sidebar-text-muted, var(--text-mute));
  line-height: 1.55;
  background: var(--sidebar-surface, var(--bg-panel));
}
.footer-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.2rem;
  gap: 0.5rem;
}
.footer-version {
  margin-top: 0.35rem;
  opacity: 0.9;
}
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 0.35rem;
  box-shadow: 0 0 8px var(--green);
  vertical-align: middle;
}
.version-pill {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--text-sub);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-size: 0.65rem;
}

/* ============== APP MAIN ============== */
.app-main {
  flex: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.mobile-menu-btn {
  display: none;
  position: fixed;
  z-index: 50;
  bottom: 1rem;
  left: 1rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  cursor: pointer;
}
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: min(360px, 90vw);
    max-width: 360px;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.with-preview .msg-scroll {
  max-width: 100% !important;
}
/* 상단 바: 테마별 프리미엄 (다크=커맨드 센터 / 라이트=이그제큐티브 클린) */
.chat-topbar {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 0 1.25rem;
  position: relative;
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
  box-shadow: var(--shadow-elev);
  z-index: 10;
  transition: background 0.35s ease, border-color 0.3s ease, box-shadow 0.35s ease;
}
.chat-topbar .topbar-left .workspace {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--topbar-workspace);
}
.chat-topbar .topbar-left .name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 0.1rem;
  color: var(--topbar-name);
  letter-spacing: -0.02em;
}
.chat-topbar .topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--topbar-center);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-topbar .topbar-center .topbar-title {
  font-size: clamp(0.95rem, 2.1vw, 1.2rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
}
.chat-topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.chat-topbar .icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--topbar-icon-border);
  background: var(--topbar-icon-bg);
  color: var(--topbar-icon-fg);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.chat-topbar .icon-btn:hover {
  color: var(--orange-deep);
  border-color: rgba(249, 115, 22, 0.5);
  background: var(--topbar-icon-hover-bg);
  transform: translateY(-1px);
}
.chat-topbar .icon-btn.active {
  color: var(--orange);
  border-color: var(--orange);
  background: rgba(249, 115, 22, 0.15);
}
.chat-topbar #themeToggle .theme-ico {
  font-size: 1.05rem;
  line-height: 1;
}
/* 사이드바·기타 구역용 기본 .icon-btn (다크 UI) */
.topbar-left .workspace {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
}
.topbar-left .name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 0.1rem;
}
.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-sub);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.icon-btn:hover {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--bg-soft);
}
.icon-btn.active {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--bg-soft);
}
.msg-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  min-height: 0;
  width: 100%;
  max-width: var(--chat-content-max);
  margin: 0 auto;
}

/* ============== WELCOME HERO ============== */
.welcome-hero {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  animation: hero-in 0.5s ease-out;
}
@keyframes hero-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.welcome-hero h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, var(--text-main), var(--text-sub));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--text-main);
}
.welcome-hero .lead {
  color: var(--text-sub);
  font-size: 0.9rem;
  max-width: 32rem;
  margin: 0 auto 1.5rem;
  line-height: 1.55;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.6rem;
  max-width: 44rem;
  margin: 0 auto 1.5rem;
  text-align: left;
}
.feature-item {
  font-size: 0.8rem;
  color: var(--text-sub);
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}
.hero-cta--chips {
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}
.hero-foot {
  font-size: 0.75rem;
  color: var(--text-mute);
  margin-top: 1rem;
}
.hero-cta .btn-cta {
  width: auto;
  padding: 0.5rem 1.25rem;
  font-size: 0.8rem;
}

/* 예시 질문(카테고리) */
.welcome-example-wrap {
  margin: 0 auto 1.5rem;
  max-width: 48rem;
  text-align: left;
}
.example-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.85rem;
  text-align: center;
  letter-spacing: -0.02em;
}
.example-section-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-mute);
  margin: -0.35rem 0 0.85rem;
  line-height: 1.45;
  padding: 0 0.5rem;
}
.example-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}
.example-cat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.7rem;
}
.example-cat-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--orange);
  margin-bottom: 0.45rem;
}
.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip.chip--example {
  font-size: 0.74rem;
  padding: 0.4rem 0.55rem;
  line-height: 1.35;
  text-align: left;
  max-width: 100%;
  white-space: normal;
}
@media (max-width: 520px) {
  .example-categories {
    grid-template-columns: 1fr;
  }
}

/* ============== MESSAGES ============== */
.msg {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: msg-in 0.35s ease-out;
  gap: 0;
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.msg.user {
  align-items: flex-end;
}
.msg.assistant {
  align-items: flex-start;
}
.msg-meta {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--text-mute);
  margin-top: 0.4rem;
  max-width: var(--msg-assistant-bubble-max);
  padding: 0 0.1rem 0.1rem;
  letter-spacing: 0.01em;
  user-select: text;
}
.msg.user .msg-meta {
  align-self: flex-end;
  text-align: right;
  max-width: var(--msg-user-bubble-max);
  padding-left: 0.25rem;
}
.msg.assistant .msg-meta {
  text-align: left;
}
.msg .bubble {
  max-width: var(--msg-assistant-bubble-max);
  border-radius: var(--radius-xl);
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
}
.msg.user .bubble {
  max-width: var(--msg-user-bubble-max);
  padding: 0.75rem 1.1rem;
  background: linear-gradient(145deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  white-space: pre-wrap;
  box-shadow: var(--user-bubble-shadow);
  transition: box-shadow 0.25s ease, transform 0.2s ease;
}
html[data-theme="light"] .msg.user .bubble {
  /* Executive: solid premium orange */
  background: #f97316;
  box-shadow: var(--user-bubble-shadow);
}
html[data-theme="light"] .msg.user .bubble a {
  color: #fff7ed;
}
.msg.assistant .bubble {
  max-width: var(--msg-assistant-bubble-max);
  width: auto;
  align-self: flex-start;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.assistant-card {
  width: 100%;
  background: var(--assistant-surface);
  border: 1px solid var(--assistant-border);
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-md), var(--shadow-inset);
  backdrop-filter: blur(10px);
  transition: background 0.35s ease, border-color 0.3s ease, box-shadow 0.35s ease;
}
html[data-theme="light"] .assistant-card {
  backdrop-filter: none;
  box-shadow: var(--shadow-elev);
}
.assistant-card-inner {
  padding: 28px 32px;
}
@media (max-width: 1024px) {
  .assistant-card-inner {
    padding: 24px;
  }
}
@media (max-width: 640px) {
  .assistant-card-inner {
    padding: 18px;
  }
}
.assistant-card.rich-wrap .rich-root {
  padding: 0;
  margin: 0;
}
/* 차트 캔버스가 overflow:hidden 카드에서 잘리지 않도록 */
.assistant-card.rich-wrap:has(.chart-card) {
  overflow: visible;
}
.loading-card .assistant-card-inner {
  padding-bottom: 1.5rem;
}
.assistant-card-inner .user-attach,
.assistant-card-inner .user-attach--pdf {
  margin-top: 1rem;
}

/* ============== MARKDOWN ============== */
.md-prose {
  color: var(--text-main);
  line-height: 1.75;
  font-size: 15px;
  transition: color 0.25s ease;
}
.md-prose p {
  margin: 0 0 14px;
}
.md-prose p:last-child {
  margin-bottom: 0;
}
.md-prose p:first-child {
  margin-top: 0;
}
.md-prose ul,
.md-prose ol {
  margin: 12px 0 0;
  padding-left: 22px;
}
.md-prose li {
  margin: 8px 0;
  padding-left: 4px;
}
.md-prose a {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  word-break: break-all;
}
.md-prose--report-followup {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.md-prose h1,
.md-prose h2,
.md-prose h3,
.md-prose h4 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.3;
  margin: 1.1em 0 0.5em;
}
.md-prose h1 {
  font-size: 1.2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
}
.md-prose strong {
  color: var(--text-main);
}
html[data-theme="dark"] .md-prose h1,
html[data-theme="dark"] .md-prose h2,
html[data-theme="dark"] .md-prose h3,
html[data-theme="dark"] .md-prose h4,
html[data-theme="dark"] .md-prose strong {
  color: #f8fafc;
}
html[data-theme="light"] .md-prose pre {
  background: var(--rich-pre-bg);
  color: #334155;
  border-color: #e2e8f0;
}
.md-prose a.md-link,
.md-prose a.file-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid rgba(56, 189, 248, 0.35);
}
.md-prose a.md-link:hover,
.md-prose a.file-link:hover {
  color: #7dd3fc;
}

/* ============== Report completion (assistant) ============== */
.report-completion-card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 1.15rem 1.25rem 1.2rem;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
html[data-theme="light"] .report-completion-card {
  background: #ffffff;
  border-color: #e2e8f0;
}
.report-completion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.report-completion-badge {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--orange-deep);
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
  padding: 0.32rem 0.6rem;
  border-radius: 8px;
}
.report-completion-pill {
  font-size: 0.7rem;
  font-weight: 800;
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.25);
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
}
html[data-theme="dark"] .report-completion-pill {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
}
.report-completion-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.45;
  margin-bottom: 0.5rem;
}
.report-completion-id {
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-bottom: 0.2rem;
}
.report-completion-id code {
  font-size: 0.85em;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line-sub);
  color: var(--text-main);
}
.report-completion-note {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-top: 0.75rem;
  line-height: 1.5;
}
.report-link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
a.report-action-btn,
button.report-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  box-sizing: border-box;
  word-break: normal;
  max-width: none;
}
a.report-action-btn.md-link,
a.report-action-btn.file-link {
  color: inherit;
}
a.report-action-btn:hover,
button.report-action-btn:hover {
  border-color: var(--orange);
  color: var(--orange-deep);
  background: var(--bg-soft);
}
a.report-action-btn--primary,
button.report-action-btn--primary {
  background: #fff7ed;
  border-color: rgba(249, 115, 22, 0.45);
  color: #c2410c;
}
html[data-theme="dark"] a.report-action-btn--primary,
html[data-theme="dark"] button.report-action-btn--primary {
  background: rgba(249, 115, 22, 0.12);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.4);
}

/* ============== Report created (structured JSON) ============== */
.report-created-card {
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 28px 32px 32px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  max-width: 100%;
  box-sizing: border-box;
}
html[data-theme="dark"] .report-created-card {
  background: var(--bg-elev);
  border-color: var(--line);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.report-created-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.report-created-badge {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--orange-deep);
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.32);
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
}
.report-created-pill-pdf {
  font-size: 0.7rem;
  font-weight: 800;
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.25);
  padding: 0.32rem 0.55rem;
  border-radius: 8px;
}
html[data-theme="dark"] .report-created-pill-pdf {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
}
.report-created-title-h {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 1.1rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}
.report-created-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: var(--bg-soft, rgba(241, 245, 249, 0.6));
  border: 1px solid var(--line-sub, #e2e8f0);
}
html[data-theme="dark"] .report-created-meta-grid {
  background: rgba(15, 23, 42, 0.45);
}
.report-created-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.report-created-meta-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sub);
}
.report-created-meta-value {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.4;
  word-break: break-word;
}
.report-created-section {
  margin-top: 1.35rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line-sub, #e2e8f0);
}
.report-created-meta-grid + .report-created-section {
  border-top: none;
  margin-top: 0.25rem;
  padding-top: 0;
}
.report-created-h3 {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 0.7rem;
  letter-spacing: -0.01em;
}
.report-created-para {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-main);
}
.report-created-para .md-prose--report-created,
.report-created-para .md-prose {
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}
html[data-theme="light"] .md-prose--report-created {
  --md-prose-ink: #1e293b;
}
.md-prose--report-created p {
  margin: 0.45em 0;
}
.md-prose--report-created p:first-child {
  margin-top: 0;
}
.md-prose--report-created p:last-child {
  margin-bottom: 0;
}
.report-created-empty {
  font-size: 0.86rem;
  color: var(--text-sub);
  margin: 0;
}
.report-created-kf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.report-created-kf-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-main);
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: var(--bg-soft, #f8fafc);
  border: 1px solid var(--line-sub, #e2e8f0);
}
html[data-theme="dark"] .report-created-kf-item {
  background: rgba(15, 23, 42, 0.35);
}
.report-created-kf-bull {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 0.4rem;
  background: var(--orange, #f97316);
}
.report-created-risk-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.report-created-risk-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card, #fff);
  font-size: 0.85rem;
  line-height: 1.45;
}
html[data-theme="dark"] .report-created-risk-item {
  background: var(--bg-elev);
}
.report-created-sev-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.report-sev-high .report-created-sev-badge {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.25);
}
.report-sev-med .report-created-sev-badge {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.report-sev-low .report-created-sev-badge,
.report-sev-note .report-created-sev-badge {
  color: var(--text-sub);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.report-created-risk-txt {
  flex: 1;
  min-width: 0;
  color: var(--text-main);
}
.report-created-action-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rca;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.report-created-action-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  counter-increment: rca;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.06), rgba(99, 102, 241, 0.05));
  border: 1px solid rgba(56, 189, 248, 0.2);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-main);
}
html[data-theme="dark"] .report-created-action-item {
  background: rgba(15, 23, 42, 0.5);
  border-color: var(--line);
}
.report-created-action-num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-main);
  border: 1px solid var(--line);
}
.report-created-section--missing {
  border-top: 1px solid var(--line-sub);
  margin-top: 1.2rem;
  padding-top: 1.1rem;
}
.report-created-miss-ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.55;
}
.report-created-section--file {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-sub);
}
.report-created-file-row {
  margin-top: 0.75rem;
}
.report-created-pdf-err,
.report-created-note {
  font-size: 0.82rem;
  color: var(--orange-deep);
  margin: 0 0 0.65rem;
  line-height: 1.5;
}
.report-created-note {
  color: var(--text-sub);
}

/* ============== Intent router — system_notice / direct_answer ============== */
.system-notice {
  border-radius: 16px;
  padding: 1.1rem 1.2rem 1.15rem;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-main);
}
.notice-title {
  font-size: 0.82rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
  color: var(--text-main);
}
.notice-body {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text-sub);
}
.system-notice--security {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(127, 29, 29, 0.12);
}
.system-notice--out_of_scope {
  border-color: rgba(2, 132, 199, 0.35);
  background: rgba(2, 132, 199, 0.08);
}
.system-notice--clarify {
  border-color: rgba(202, 138, 4, 0.4);
  background: rgba(202, 138, 4, 0.08);
}
.system-notice--no_data {
  border-color: var(--line-sub);
  background: var(--bg-soft);
}
.assistant-card.notice-card {
  max-width: 100%;
}
.direct-answer-wrap {
  text-align: left;
}
.da-summary {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-sub);
  margin: 0 0 0.65rem;
}
.da-body .md-prose--direct,
.da-body .md-prose {
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

.md-prose pre {
  margin: 0.9em 0;
  padding: 0.85rem 1rem;
  background: var(--rich-pre-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  overflow-x: auto;
  font-size: 0.85rem;
}
html[data-theme="dark"] .md-prose pre {
  color: #e2e8f0;
}
.md-prose .table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin: 0.85em 0;
}
.md-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.md-prose th,
.md-prose td {
  border: 1px solid var(--line-sub);
  padding: 0.5rem 0.65rem;
}
.md-prose th {
  background: var(--rich-table-header-bg);
  color: var(--rich-table-header-text);
  font-weight: 700;
  border-color: var(--rich-table-border);
}
.md-prose thead th a,
.md-prose th strong {
  color: inherit;
}
.md-prose .md-img {
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.msg.user .bubble a {
  color: #ffedd5;
}

/* ============== COMPOSER ============== */
.composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 0.75rem 1rem 1.25rem;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.22);
  transition: background 0.35s ease, border-color 0.3s ease;
}
html[data-theme="light"] .composer {
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.06);
}
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  max-width: var(--chat-content-max);
  margin-left: auto;
  margin-right: auto;
  padding: 0 0.25rem;
}
.chip {
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--text-sub);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.chip:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--bg-soft);
}
.composer-config {
  max-width: var(--chat-content-max);
  margin: 0 auto 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  align-items: center;
}
.composer-config label {
  font-size: 0.65rem;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 100%;
}
.composer-config select {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text-main);
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.composer-hint {
  width: 100%;
  font-size: 0.7rem;
  color: var(--text-mute);
  line-height: 1.4;
}
.composer-surface {
  position: relative;
  max-width: var(--chat-content-max);
  margin: 0 auto;
  background: var(--composer-panel);
  border: 1px solid var(--composer-border);
  border-radius: var(--radius-xl);
  padding: 0.45rem 0.5rem 0.5rem 0.55rem;
  box-shadow: var(--shadow-inset);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.composer-suggestions {
  position: absolute;
  left: 0.35rem;
  right: 0.35rem;
  bottom: calc(100% + 0.4rem);
  z-index: 40;
  max-height: min(240px, 40vh);
  overflow-y: auto;
  padding: 0.45rem 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--composer-border);
  background: var(--composer-panel);
  box-shadow: var(--shadow-lg);
}
.composer-suggestions[hidden] {
  display: none !important;
}
.composer-suggestion-hint {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-mute);
  padding: 0.2rem 0.45rem 0.4rem;
}
.composer-suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-main);
  padding: 0.5rem 0.5rem 0.5rem 0.55rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.composer-suggestion-item:hover,
.composer-suggestion-item:focus {
  background: var(--bg-soft);
  color: var(--orange);
  outline: none;
}
.composer-suggestion-item.is-hidden {
  display: none;
}
.composer-surface.composer-surface--suggest-open {
  border-color: rgba(249, 115, 22, 0.35);
  box-shadow: var(--shadow-inset), 0 0 0 2px rgba(249, 115, 22, 0.12);
}
html[data-theme="dark"] .composer-surface {
  box-shadow: var(--shadow-inset), 0 2px 12px rgba(0, 0, 0, 0.2);
}
html[data-theme="light"] .composer-surface {
  box-shadow: var(--shadow-sm), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
}
.composer-attach {
  display: flex;
  gap: 0.2rem;
  align-self: center;
  padding-bottom: 0.25rem;
}
.composer-attach .icon-btn {
  width: 40px;
  height: 40px;
}
#tinput {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.4rem;
  resize: none;
  line-height: 1.4;
}
#tinput:focus {
  outline: none;
}
#tinput::placeholder {
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding-bottom: 0.2rem;
}
.send-round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f97316, #ea580c);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
  transition: filter 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.send-round:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: scale(1.03);
}
.send-round:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.badge-tiny {
  position: relative;
  width: 40px;
  height: 40px;
}
.badge-tiny input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: var(--chat-content-max);
  margin: 0 auto 0.4rem;
}
.previews .thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
}
.previews .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.previews .thumb button {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 0 0 0 4px;
}
.previews .thumb--pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  min-width: 64px;
}
.previews .thumb-doc-label {
  font-size: 0.65rem;
  color: var(--text-sub);
  padding: 0.25rem;
  text-align: center;
  line-height: 1.2;
  word-break: break-all;
}

/* 저장된 대화: 첨부(이미지·PDF) */
.user-attach {
  margin-top: 0.5rem;
}
.user-attach--pdf {
  padding: 0.45rem 0.55rem;
  background: rgba(7, 17, 31, 0.55);
  border: 1px solid var(--line-sub);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.user-attach-hint {
  font-size: 0.7rem;
  color: var(--text-mute);
  margin-top: 0.3rem;
}
.msg.user .user-attach-hint a {
  color: #ffedd5;
}

/* ============== LOADING ============== */
.loading-card {
  border-radius: 18px;
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  max-width: 28rem;
}
.loading-card.loading-card--premium {
  max-width: min(100%, 42.5rem);
  width: 100%;
  min-width: 0;
  padding: 0;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
  animation: aiProcPanelIn 0.45s var(--motion-ease) both;
  overflow: hidden;
}
html[data-theme="light"] .loading-card.loading-card--premium {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 55%, #f1f5f9 100%);
  border-color: #e2e8f0;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 4px 24px rgba(15, 23, 42, 0.08);
}
html[data-theme="dark"] .loading-card.loading-card--premium {
  background: linear-gradient(165deg, rgba(20, 32, 52, 0.55) 0%, rgba(7, 17, 31, 0.97) 100%);
  box-shadow: var(--shadow-lg);
}
.loading-card.loading-card--premium .assistant-card-inner.ai-processing-panel {
  padding: 1.25rem 1.35rem 1.35rem;
  max-width: 100%;
}
@media (min-width: 480px) {
  .loading-card.loading-card--premium .assistant-card-inner.ai-processing-panel {
    padding: 1.4rem 1.5rem 1.5rem;
  }
}
.ai-proc-head {
  margin-bottom: 1rem;
}
.ai-proc-kicker {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 0.45rem;
}
html[data-theme="light"] .ai-proc-kicker {
  color: #94a3b8;
}
.ai-proc-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.3;
}
.ai-proc-line {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-sub);
}
.ai-proc-line .dot-typing {
  color: var(--orange);
  font-weight: 700;
}
.ai-proc-desc {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-mute);
}
.ai-proc-bar-wrap {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--line-sub);
  overflow: hidden;
  margin-bottom: 0.65rem;
  box-shadow: var(--shadow-inset);
}
html[data-theme="light"] .ai-proc-bar-wrap {
  background: #e2e8f0;
}
.ai-proc-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ea580c, #f97316 40%, #fb923c 100%);
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.45);
  transition: width 0.35s var(--motion-ease);
  animation: aiProcBarShine 2.2s ease-in-out infinite;
}
html[data-theme="dark"] .ai-proc-bar {
  box-shadow: 0 0 24px rgba(249, 115, 22, 0.35);
}
.ai-proc-metric-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-bottom: 0.9rem;
}
.ai-proc-metric-row b {
  color: var(--text-main);
  font-weight: 600;
}
.ai-proc-pct {
  min-width: 2.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: -0.02em;
}
ol.ai-proc-steps {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  counter-reset: aistep;
}
ol.ai-proc-steps li {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.38rem 0.45rem 0.38rem 0.4rem;
  margin-bottom: 0.2rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  border: 1px solid transparent;
  transition:
    background 0.25s ease,
    border-color 0.25s ease;
}
ol.ai-proc-steps li:last-child {
  margin-bottom: 0;
}
.ai-proc-ix {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-mute);
  background: var(--bg-elev);
  border: 1px solid var(--line);
}
html[data-theme="light"] .ai-proc-ix {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}
.ai-proc-lab {
  flex: 1;
  min-width: 0;
  color: var(--text-sub);
  padding-top: 0.08rem;
}
.ai-proc-step.pend .ai-proc-ix,
.ai-proc-step.pend .ai-proc-lab {
  color: var(--text-mute);
}
html[data-theme="light"] .ai-proc-step.pend {
  opacity: 0.9;
}
.ai-proc-step.done {
  background: color-mix(in srgb, var(--green) 8%, transparent);
  border-color: color-mix(in srgb, var(--green) 25%, var(--line));
}
.ai-proc-step.done .ai-proc-ix {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}
.ai-proc-step.done .ai-proc-lab {
  color: var(--text-main);
  font-weight: 500;
}
.ai-proc-step.run {
  background: color-mix(in srgb, var(--orange) 10%, transparent);
  border-color: color-mix(in srgb, var(--orange) 40%, var(--line));
  animation: aiProcRunPulse 1.4s ease-in-out infinite;
}
.ai-proc-step.run .ai-proc-ix {
  color: #fff;
  background: var(--orange);
  border-color: var(--orange-deep);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--orange) 35%, transparent);
}
.ai-proc-step.run .ai-proc-lab {
  color: var(--text-main);
  font-weight: 600;
}
.ai-proc-step.err {
  background: color-mix(in srgb, var(--red) 8%, transparent);
  border-color: color-mix(in srgb, var(--red) 30%, var(--line));
}
.ai-proc-step.err .ai-proc-ix {
  color: #fff;
  background: var(--red);
  border-color: #dc2626;
}
/* 답변 작성 단계 — 스트리밍 점(생성 응답) */
.ai-proc-lab--stream::after {
  content: "…";
  color: var(--orange);
  font-weight: 700;
  display: inline-block;
  min-width: 0.5em;
  margin-left: 0.1em;
  animation: dots 1.2s steps(3, end) infinite;
  vertical-align: bottom;
}
@supports not (color: color-mix(in srgb, red, blue)) {
  .ai-proc-step.done {
    background: rgba(34, 197, 94, 0.12);
  }
  .ai-proc-step.run {
    background: rgba(249, 115, 22, 0.12);
  }
  .ai-proc-step.err {
    background: rgba(239, 68, 68, 0.1);
  }
}
.ai-proc-h {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ai-proc-tag {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--orange) 20%, var(--bg-elev));
  color: var(--orange);
  letter-spacing: 0.06em;
}
html[data-theme="light"] .ai-proc-tag {
  background: #ffedd5;
  color: #c2410c;
}
.ai-proc-agents-block {
  margin-bottom: 0.75rem;
}
.ai-proc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.ai-proc-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-sub);
  box-shadow: var(--shadow-sm);
}
html[data-theme="light"] .ai-proc-chip {
  background: #f8fafc;
  color: #475569;
}
html[data-theme="dark"] .ai-proc-chip {
  background: rgba(15, 23, 42, 0.55);
  border-color: #334155;
  color: #cbd5e1;
}
.ai-proc-logs-wrap {
  margin-bottom: 0.75rem;
}
.ai-proc-logs {
  max-height: 6.2rem;
  overflow-y: auto;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-sub);
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.5rem;
}
html[data-theme="light"] .ai-proc-logs {
  background: #f1f5f9;
  color: #475569;
}
.ai-proc-log-line {
  display: flex;
  gap: 0.4rem;
  padding: 0.1rem 0;
}
.ai-proc-log-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  margin-top: 0.35em;
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--green);
}
.ai-proc-insight {
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--blue) 6%, var(--bg-elev));
  margin-bottom: 0.55rem;
}
html[data-theme="light"] .ai-proc-insight {
  background: #eff6ff;
  border-color: #bfdbfe;
}
html[data-theme="dark"] .ai-proc-insight {
  background: rgba(30, 41, 59, 0.5);
  border-color: #334155;
}
.ai-proc-insight .ai-proc-h {
  margin-bottom: 0.25rem;
  color: var(--text-sub);
}
.ai-proc-insight-body {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-main);
  font-weight: 500;
}
.ai-proc-report-bonus {
  border-radius: 12px;
  margin-top: 0.2rem;
  padding: 0.55rem 0.7rem 0.65rem;
  border: 1px dashed var(--line);
  background: var(--bg-elev);
  animation: aiProcPanelIn 0.5s 0.1s var(--motion-ease) both;
}
html[data-theme="light"] .ai-proc-report-bonus {
  background: #fffbeb;
  border-color: #fcd34d;
}
html[data-theme="dark"] .ai-proc-report-bonus {
  background: rgba(15, 23, 42, 0.55);
  border-color: #475569;
}
.ai-proc-subtle {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  margin-bottom: 0.4rem;
}
.ai-rep-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--text-mute);
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line-sub);
  transition: color 0.2s;
}
.ai-rep-line:last-child {
  border-bottom: none;
}
.ai-rep-line.done {
  color: var(--text-sub);
}
.ai-rep-line.done .ai-rep-ix {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.ai-rep-line.run {
  color: var(--text-main);
  font-weight: 600;
  animation: aiRepLinePulse 1.2s ease-in-out infinite;
}
.ai-rep-line.run .ai-rep-ix {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
.ai-rep-ix {
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0.12rem 0.3rem;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  min-width: 1.6rem;
  text-align: center;
  letter-spacing: 0.04em;
}
@keyframes aiProcPanelIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes aiProcBarShine {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.08);
  }
}
@keyframes aiProcRunPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--orange) 0%, transparent);
  }
  50% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--orange) 22%, transparent);
  }
}
@keyframes aiRepLinePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.75;
  }
}
.loading-steps {
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-sub);
}
.loading-steps li {
  padding: 0.3rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.loading-steps li.done {
  color: var(--green);
}
.loading-steps li.current {
  color: var(--orange, #f97316);
  font-weight: 600;
}
.loading-steps li.wait {
  color: var(--text-sub, #6b7280);
  opacity: 0.85;
}
.loading-steps .dot-typing::after {
  content: "…";
  animation: dots 1.2s steps(3, end) infinite;
}
.msg.assistant .bubble .loading-card.loading-card--premium {
  max-width: min(100%, 42.5rem);
}
@media (max-width: 480px) {
  .loading-card.loading-card--premium {
    max-width: 100%;
    border-radius: 16px;
  }
  .ai-proc-metric-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }
}
@keyframes dots {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60%,
  100% {
    content: "...";
  }
}

/* ============== PREVIEW PANEL ============== */
.preview-resizer {
  width: 4px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
  position: relative;
  z-index: 5;
}
.preview-resizer:hover,
.preview-resizer.drag {
  background: var(--orange);
}
.preview-col {
  display: none;
  width: var(--preview-w);
  min-width: 280px;
  max-width: 700px;
  background: #fff;
  color: #0f172a;
  border-left: 3px solid var(--preview-outer);
  flex-direction: column;
  flex-shrink: 0;
  transition: border-color 0.3s ease;
}
html[data-theme="light"] .preview-col {
  border-left-color: #e2e8f0;
}
.preview-col.open {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.with-preview {
  /* reserved */
}
.ph-header {
  padding: 0.65rem 0.75rem 0.75rem 1rem;
  border-bottom: 1px solid var(--r-line);
  background: #fff;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}
.ph-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: #0f172a;
  min-width: 0;
}
.ph-title-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}
.ph-title-main .file-ico {
  width: 32px;
  height: 32px;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.ph-close-x {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.ph-close-x:hover {
  background: #fee2e2;
  color: #b91c1c;
}
.ph-close-x:active {
  transform: scale(0.96);
}
.ph-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.ph-meta {
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 0.35rem;
}
.ph-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.ph-actions a,
.ph-actions button {
  font-size: 0.7rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
}
.ph-actions a:hover,
.ph-actions button:hover {
  border-color: #f97316;
  color: #ea580c;
}
.ph-body {
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
  background: #f1f5f9;
  overflow: auto;
}
.ph-body--chart-view {
  background: var(--bg-panel, #0f172a);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.preview-chart-viewport {
  flex: 1;
  min-height: 280px;
  padding: 24px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 var(--radius-md, 12px) var(--radius-md, 12px);
}
html[data-theme="dark"] .preview-chart-viewport {
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px #e2e8f0;
}
.preview-chart-img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
  background: #fff;
}
.ph-body iframe,
.ph-body:not(.ph-body--chart-view) img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: none;
  object-fit: contain;
  background: #fff;
  display: block;
}
.ph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  color: #64748b;
}
.ph-empty .ico-big {
  font-size: 3.5rem;
  opacity: 0.4;
  margin-bottom: 0.75rem;
}
.ph-empty p {
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 18rem;
}
.preview-note {
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.45;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

/* ============== Lightbox: chart / image full screen ============== */
body.lightbox-open {
  overflow: hidden;
}
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  box-sizing: border-box;
}
.lightbox-modal[hidden] {
  display: none !important;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.88);
  cursor: pointer;
  z-index: 0;
}
.lightbox-frame {
  position: relative;
  z-index: 1;
  max-width: min(100vw - 2rem, 1920px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}
.lightbox-img-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: calc(100vh - 6.5rem);
  padding: 0.5rem;
  background: #0f172a;
  border-radius: 14px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.2);
}
html[data-theme="light"] .lightbox-img-wrap {
  background: #f8fafc;
  border-color: #e2e8f0;
}
.lightbox-img {
  max-width: 100%;
  max-height: calc(100vh - 7rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.75);
  color: #f8fafc;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lightbox-close:hover {
  background: rgba(30, 41, 59, 0.95);
}
@media (max-width: 640px) {
  .lightbox-close {
    top: 0.25rem;
    right: 0.25rem;
  }
  .lightbox-img-wrap {
    max-height: calc(100vh - 5.5rem);
  }
}
.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 0.25rem;
}
.lightbox-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
  max-width: 100%;
  word-break: break-word;
}
html[data-theme="light"] .lightbox-title {
  color: #0f172a;
}
.lightbox-download {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border-radius: 10px;
  text-decoration: none;
  color: #ea580c;
  background: #fff7ed;
  border: 1px solid rgba(249, 115, 22, 0.45);
  flex-shrink: 0;
}
.lightbox-download:hover {
  background: #ffedd5;
}
.lightbox-download[hidden] {
  display: none;
}

/* ============== RICH (orchestrator) — enterprise ============== */
.rich-root {
  --rich-block-space: 1.5rem;
}
.rich-root > * {
  margin-bottom: var(--rich-block-space);
}
.rich-root > *:last-child {
  margin-bottom: 0;
}
/* 여러 개의 표가 연속일 때 살짝 더 벌림 */
.rich-root .rich-table-wrap + .rich-table-wrap {
  margin-top: 0.75rem;
}
.md-prose .table-wrap {
  margin-bottom: 1.1rem;
}
.md-prose .table-wrap + .table-wrap {
  margin-top: 1.1rem;
}
.rich-summary {
  margin-bottom: 1.25rem;
  line-height: 1.6;
  font-size: 0.9375rem;
}
.rich-warn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text-main);
}
.rich-data-basis-badge {
  margin-bottom: 0.55rem;
}
.rich-basis-tag {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-main);
  border: 1px solid rgba(59, 130, 246, 0.28);
}

.rich-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
@media (max-width: 900px) {
  .rich-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.rich-kpi-card {
  background: var(--rich-kpi-bg);
  border: 1px solid var(--rich-kpi-border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  min-height: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.rich-kpi-card:hover {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
.rich-kpi-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rich-kpi-label);
}
.rich-kpi-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--rich-kpi-value);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.rich-kpi-target {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 0.25rem;
}
.rich-kpi-delta {
  font-size: 0.75rem;
  color: var(--green);
  margin-top: 0.2rem;
  font-weight: 500;
}
.rich-kpi-delta.negative {
  color: var(--red);
}
.rich-kpi-desc {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-top: 0.35rem;
  line-height: 1.4;
}
.rich-table-wrap {
  border-radius: 14px;
  border: 1px solid var(--rich-table-border);
  overflow: hidden;
  margin: 0;
  background: var(--rich-table-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.rich-table-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 0.9rem 1rem 0.5rem;
  background: var(--rich-table-bg);
  border-bottom: 1px solid var(--rich-table-border);
}
.rich-csv {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-sub);
  cursor: pointer;
}
.rich-csv:hover {
  color: var(--orange);
  border-color: var(--orange);
}
.rich-table-scroll {
  max-height: 400px;
  overflow: auto;
  background: var(--rich-table-bg);
}
.rich-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  --table-bg: var(--rich-table-bg);
  --border: var(--rich-table-border);
  --text-main: var(--rich-table-text);
  --table-header-bg: var(--rich-table-header-bg);
  --table-header-text: var(--rich-table-header-text);
  --table-row-bg: var(--rich-table-row-bg);
  --table-row-alt: var(--rich-table-row-alt);
  --table-row-hover: var(--rich-table-row-hover);
  background: var(--table-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  font-size: 14px;
}
.rich-table-scroll .rich-table {
  border: none;
  border-radius: 0;
}
.rich-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--table-header-bg);
  color: var(--table-header-text);
  font-weight: 700;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.rich-table tbody td {
  background: var(--table-row-bg);
  color: var(--text-main);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.rich-table tbody tr:nth-child(even) td {
  background: var(--table-row-alt);
}
.rich-table tbody tr:hover td {
  background: var(--table-row-hover);
}
.rich-tbody-more td,
.rich-tbody-main td {
  color: var(--text-main);
}
/* alternate: keep same premium navy header (legacy class name) */
.rich-table-wrap.head-light .rich-table thead th {
  background: var(--rich-table-header-bg);
  color: var(--rich-table-header-text);
  border-bottom-color: var(--rich-table-border);
}

.rich-insight-card {
  background: #f8fafc;
  border-left: 4px solid #f97316;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 0.9rem 1rem;
  margin: 0;
  border: 1px solid var(--line);
  border-left-width: 4px;
}
html[data-theme="dark"] .rich-insight-card {
  background: #111827;
  border-color: #334155;
  border-left-color: #f97316;
}
.rich-recommended-wrap {
  margin: 0;
}
.rich-insight-card .rich-block-title {
  color: #ea580c;
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
}
.rich-insight-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-main);
  font-size: 0.875rem;
  line-height: 1.55;
}
.rich-insight-card li {
  margin: 0.35rem 0;
}

.rich-action-cards {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.rich-action-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  align-items: start;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.rich-action-card-main {
  min-width: 0;
}
.rich-action-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}
.rich-action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-sub);
}
.rich-pri {
  font-weight: 800;
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  flex-shrink: 0;
  line-height: 1.2;
  align-self: start;
  margin-top: 0.1rem;
}
.rich-pri--p1 {
  background: rgba(220, 38, 38, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.rich-pri--p2 {
  background: rgba(249, 115, 22, 0.12);
  color: #ea580c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}
.rich-pri--p3 {
  background: rgba(100, 116, 139, 0.15);
  color: #64748b;
  border: 1px solid var(--line);
}
html[data-theme="light"] .rich-pri--p1 {
  color: #b91c1c;
}
html[data-theme="light"] .rich-pri--p2 {
  color: #c2410c;
}
.rich-block-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--orange);
  margin-bottom: 0.4rem;
}
.rich-badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 0.3rem;
}
.st-ok {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.st-warn {
  background: rgba(250, 204, 21, 0.15);
  color: #facc15;
}
.st-alert {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
}
.st-crit {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}
.st-muted {
  background: rgba(100, 116, 139, 0.25);
  color: #cbd5e1;
}
html[data-theme="light"] .st-ok {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}
html[data-theme="light"] .st-warn {
  background: rgba(202, 138, 4, 0.12);
  color: #a16207;
}
html[data-theme="light"] .st-alert {
  background: rgba(234, 88, 12, 0.12);
  color: #c2410c;
}
html[data-theme="light"] .st-crit {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}
html[data-theme="light"] .st-muted {
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
}

/* Chart card (rich response) */
.chart-card {
  margin: 0;
  min-height: 280px;
  padding: 1.1rem 1.15rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chart-card:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}
.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.chart-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}
.chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 0.2rem;
}
.chart-expand-btn {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}
.chart-expand-btn:hover {
  background: #fff7ed;
  border-color: var(--orange);
  color: var(--orange-deep);
}
html[data-theme="dark"] .chart-expand-btn:hover {
  background: rgba(249, 115, 22, 0.12);
}
.chart-canvas-wrap {
  position: relative;
  min-height: 220px;
  height: 280px;
  cursor: zoom-in;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-main);
  border: 1px solid var(--line-sub);
  /* flex 레이아웃 직후 GPU 레이어(일부 환경에서 캔버스 페인트 보정) */
  transform: translateZ(0);
}
.chart-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.rich-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 1rem;
  color: var(--text-sub);
  font-size: 0.85rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
}

.rich-raw {
  margin-top: 0.6rem;
  font-size: 0.75rem;
}
.rich-pre {
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
  background: var(--rich-pre-bg);
  color: var(--text-main);
  border: 1px solid var(--line);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.rich-more-btn {
  margin: 0.5rem 0.75rem 0.75rem;
  font-size: 0.8rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-sub);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.rich-table-meta {
  font-size: 0.75rem;
  color: var(--text-sub);
  padding: 0.5rem 0.9rem 0.75rem;
  background: var(--rich-table-bg);
  border-top: 1px solid var(--rich-table-border);
}

/* ============== COMMAND PALETTE ============== */
.cmd-palette {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(6px);
  transition: background 0.35s ease;
}
html[data-theme="light"] .cmd-palette {
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(8px);
}
.cmd-palette.open {
  display: flex;
}
.cmd-inner {
  width: min(520px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cmd-inner input {
  width: 100%;
  border: none;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}
.cmd-inner input:focus {
  outline: none;
}
.cmd-inner input::placeholder {
  color: var(--text-mute);
}
.cmd-hint {
  font-size: 0.65rem;
  color: var(--text-mute);
  padding: 0.4rem 0.9rem 0.6rem;
}
.cmd-list {
  max-height: 220px;
  overflow-y: auto;
}
.cmd-item {
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-sub);
  border-bottom: 1px solid var(--line-sub);
}
.cmd-item:hover,
.cmd-item.sel {
  background: var(--bg-soft);
  color: var(--text-main);
}

/* ============== THEME (prose link contrast in light) ============== */
html[data-theme="light"] .md-prose a.md-link,
html[data-theme="light"] .md-prose a.file-link {
  color: #0284c7;
  border-bottom-color: rgba(2, 132, 199, 0.35);
}
html[data-theme="light"] .md-prose a.md-link:hover,
html[data-theme="light"] .md-prose a.file-link:hover {
  color: #0369a1;
}
html[data-theme="light"] .md-prose p,
html[data-theme="light"] .md-prose li {
  color: #334155;
}

/* ============== Report side preview (빠른 보기) ============== */
.report-side-panel {
  --rsp-w: min(480px, 100%);
  display: none;
  flex: 0 0 var(--rsp-w);
  width: var(--rsp-w);
  min-width: 320px;
  max-width: min(95vw, 900px);
  min-height: 0;
  background: var(--sidebar-surface, var(--bg-panel, #0b1220));
  color: var(--text-main, #f8fafc);
  border-left: 1px solid var(--sidebar-border, var(--line, #1f2937));
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  flex-direction: column;
  z-index: 20;
  transition: transform 0.25s var(--motion-ease, ease), box-shadow 0.25s;
}
html[data-theme="light"] .report-side-panel {
  background: #ffffff;
  color: #111827;
  box-shadow: -6px 0 28px rgba(15, 23, 42, 0.08);
}
.app-main.with-report-side .report-side-panel {
  display: flex;
  flex-direction: column;
}
/* 보고서 패널 왼쪽 드래그로 너비 조절 (채팅 영역↔PDF 미리보기) */
.rsp-resizer {
  display: none;
  width: 4px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
  position: relative;
  z-index: 6;
  align-self: stretch;
  touch-action: none;
}
.rsp-resizer:hover,
.rsp-resizer.drag {
  background: var(--orange, #f97316);
}
.app-main.with-report-side .rsp-resizer {
  display: block;
}
.rsp-chrome {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.rsp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem 0.5rem;
  border-bottom: 1px solid var(--sidebar-border, var(--line));
  flex-shrink: 0;
}
.rsp-header-text {
  min-width: 0;
  flex: 1;
}
.rsp-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  color: var(--text-main, inherit);
  letter-spacing: -0.02em;
}
.rsp-badges {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-sub, #94a3b8);
}
.rsp-badge-tag {
  font-weight: 600;
}
.rsp-badge-type {
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.65rem;
}
.rsp-badge-type--quality { color: #2563eb; background: rgba(37, 99, 235, 0.12); }
.rsp-badge-type--production { color: #16a34a; background: rgba(22, 163, 74, 0.12); }
.rsp-badge-type--inventory { color: #7c3aed; background: rgba(124, 58, 237, 0.12); }
.rsp-badge-type--equipment { color: #ea580c; background: rgba(234, 88, 12, 0.12); }
.rsp-badge-type--management { color: #64748b; background: rgba(100, 116, 139, 0.15); }
.rsp-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub, #94a3b8);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.rsp-close:hover {
  background: var(--hover-row, rgba(255, 255, 255, 0.06));
  color: var(--text-main, #f8fafc);
}
html[data-theme="light"] .rsp-close:hover {
  background: #f3f4f6;
  color: #0f172a;
}
.rsp-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem 0.55rem;
  border-bottom: 1px solid var(--sidebar-border, var(--line));
  flex-shrink: 0;
}
.rsp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--line, #334155);
  background: var(--bg-soft, #1e293b);
  color: var(--text-main, #e2e8f0);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
html[data-theme="light"] .rsp-btn {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #374151;
}
.rsp-btn--ghost:hover {
  border-color: var(--orange, #f97316);
  color: var(--orange, #f97316);
}
.rsp-btn--primary {
  background: linear-gradient(135deg, #ea580c, #f97316);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.3);
}
.rsp-btn--primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.rsp-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.9rem 1.25rem;
  font-size: 0.8rem;
}
.rsp-h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sub, #94a3b8);
  margin: 0 0 0.4rem 0;
  font-weight: 700;
}
.rsp-block {
  margin-bottom: 1rem;
}
.rsp-block:last-child {
  margin-bottom: 0;
}
.rsp-meta-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}
.rsp-meta-dl > div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.4rem;
  font-size: 0.75rem;
}
.rsp-meta-dl dt {
  margin: 0;
  color: var(--text-mute, #64748b);
  font-weight: 500;
}
.rsp-meta-dl dd {
  margin: 0;
  color: var(--text-main, #e2e8f0);
  word-break: break-word;
}
/* 보고 PDF 미리보기: 가로는 패널+rsp-resizer로 조절, 세로는 기본 2배(360→720) */
.rsp-iframe-wrap {
  width: 100%;
  max-width: 100%;
  height: 720px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line, #334155);
  background: #0a0a0a;
}
html[data-theme="light"] .rsp-iframe-wrap {
  background: #f1f5f9;
}
.rsp-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.rsp-iframe-fallback {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  color: var(--text-mute, #94a3b8);
  font-size: 0.8rem;
  background: var(--bg-soft, rgba(15, 23, 42, 0.3));
  border-radius: 10px;
  border: 1px dashed var(--line, #334155);
}
.rsp-bullets {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-main, #e2e8f0);
  line-height: 1.5;
}
.rsp-bullets li {
  margin-bottom: 0.3rem;
}
.rsp-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.45rem;
}
.rsp-kpi-card {
  border: 1px solid var(--line, #334155);
  background: var(--bg-card, rgba(15, 23, 42, 0.5));
  border-radius: 9px;
  padding: 0.45rem 0.5rem;
}
html[data-theme="light"] .rsp-kpi-card {
  background: #f8fafc;
}
.rsp-kpi-name {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--text-mute, #94a3b8);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.rsp-kpi-value {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.2rem;
  color: var(--text-main, #f8fafc);
}
.rsp-kpi-card--empty {
  opacity: 0.6;
  font-size: 0.75rem;
  padding: 0.5rem;
}
.rsp-risk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.rsp-risk-pill {
  font-size: 0.68rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  max-width: 100%;
}
.rsp-actions-mini {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.45;
  color: var(--text-sub, #cbd5e1);
  font-size: 0.75rem;
}
.rsp-muted {
  color: var(--text-mute, #64748b);
  font-size: 0.75rem;
}
@media (max-width: 900px) {
  .report-side-panel {
    --rsp-w: 100%;
    max-width: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    border-left: none;
    width: 100% !important;
    flex: none !important;
  }
  .app-main.with-report-side .rsp-resizer {
    display: none;
  }
  .app-main.with-report-side .chat-wrap {
    filter: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
