/* ============================================
   DRi Vision - Page Styles
   ============================================ */

.page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
}

.page__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.page__empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.page__empty-icon svg {
  width: 28px;
  height: 28px;
}

.page__empty-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
}

.page__empty-desc {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.6;
}

/* ============================================
   DRi Vision - Space Setup
   ============================================ */

.spaces {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  padding: 20px;
}

.spaces__header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 16px;
}

.spaces__grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.spaces__card {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.spaces__card-color {
  width: 8px;
  flex-shrink: 0;
}

.spaces__card-content {
  flex: 1;
  padding: 14px 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spaces__card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.spaces__card-header > div {
  min-width: 0;
}

.spaces__card-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.spaces__card-meta,
.spaces__db-name {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spaces__card-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.spaces__color-input {
  min-height: 42px;
  padding: 4px;
}

.spaces__card {
  cursor: pointer;
}

.spaces__card-link {
  font-size: var(--font-size-xs);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.spaces__card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.space-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.space-config__topbar,
.space-config__actions,
.space-config__overview-stats,
.space-config__meta,
.space-config__filters,
.space-config__columns-header,
.space-config__column-actions,
.space-config__column-top,
.space-config__column-fields {
  display: flex;
  gap: 10px;
}

.space-config__topbar,
.space-config__columns-header,
.space-config__column-top {
  align-items: center;
  justify-content: space-between;
}

.space-config__overview,
.space-config__panel,
.space-config__stat,
.space-config__column-row,
.space-config__list-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.space-config__overview {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.space-config__title { font-size: var(--font-size-lg); margin-bottom: 4px; }
.space-config__name-row { margin-bottom: 4px; }
.space-config__name-input { font-size: var(--font-size-lg); font-weight: 600; padding: 4px 8px; max-width: 360px; }
.space-config__subtitle,
.space-config__meta span,
.space-config__panel-header p,
.space-config__list-item span,
.space-config__empty-inline { color: var(--text-muted); font-size: var(--font-size-sm); }

.space-config__meta { flex-wrap: wrap; margin-top: 10px; }
.space-config__overview-stats { flex-wrap: wrap; justify-content: flex-end; }

.space-config__filters .settings__input {
  min-width: 0;
  flex: 1 1 0;
}

.space-config__filters select.settings__input {
  flex: 0 0 130px;
  max-width: 45%;
}

.space-config__stat {
  padding: 10px 12px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
}

.space-config__workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: 500px;
}

.space-config__panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.space-config__panel-header h4 { font-size: var(--font-size-base); margin-bottom: 4px; }

.space-config__list,
.space-config__columns-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.space-config__list-item {
  width: 100%;
  text-align: left;
  padding: 10px;
  border-color: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
}

.space-config__list-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.space-config__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.space-config__textarea { min-height: 86px; resize: vertical; }

.space-config__column-row { padding: 10px; }
.space-config__column-fields { margin-top: 8px; }
.space-config__column-fields .settings__input { flex: 1; }

@media (max-width: 1100px) {
  .space-config__workspace { grid-template-columns: 1fr; }
}

/* Tabs */
.space-config__tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.space-config__tab {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.space-config__tab:hover { color: var(--text-primary); }
.space-config__tab.is-active {
  border-bottom-color: transparent;
  border-image: var(--brand-gradient) 1;
  font-weight: 600;
}

.space-config__panel-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.space-config__panel-block h4 { font-size: var(--font-size-base); margin: 0; }
.space-config__panel-block p { color: var(--text-muted); font-size: var(--font-size-sm); margin: 0; }

.space-config__row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.space-config__key-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.space-config__key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: var(--font-size-sm);
}
.space-config__key-item.is-revoked { opacity: 0.55; }
.space-config__key-meta { display: flex; flex-direction: column; gap: 2px; }
.space-config__key-meta code {
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.space-config__key-actions { display: flex; gap: 6px; }

.space-config__code-block {
  background: var(--bg-canvas, #0e1116);
  color: var(--text-on-canvas, #e6edf3);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
  position: relative;
}
.space-config__code-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255,255,255,0.08);
  border: 0;
  color: inherit;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.space-config__code-copy:hover { background: rgba(255,255,255,0.16); }

.space-config__usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.space-config__usage-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.space-config__usage-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 60px;
  gap: 8px;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.space-config__usage-bar {
  height: 8px;
  background: var(--accent-subtle, rgba(249, 36, 171,0.15));
  border-radius: 4px;
  overflow: hidden;
}
.space-config__usage-bar > div {
  height: 100%;
  background: var(--brand-gradient);
}

.space-config__newkey-banner {
  background: var(--accent-subtle, rgba(249, 36, 171,0.12));
  border: 1px solid var(--accent, #f924ab);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.space-config__newkey-banner code {
  background: rgba(0,0,0,0.18);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}

/* ============================================
   Vision Chat
   ============================================ */
.vchat {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0;
  padding: 0 0 0 12px;
  transition: grid-template-columns 250ms ease;
}
.vchat:has(.vchat__history--collapsed) {
  grid-template-columns: minmax(0, 1fr) 32px;
}

.vchat__main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 18px 12px 12px;
}

.vchat__status {
  margin-bottom: 12px;
}

.vchat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 6px 6px 24px;
}

.vchat__messages--empty {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0;
}

.vchat__messages--empty .page__empty {
  text-align: center;
}

.vchat__welcome {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  width: min(100%, 780px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, hsl(190 100% 50% / 0.16), transparent 36%),
    radial-gradient(circle at top right, hsl(48 100% 58% / 0.14), transparent 36%),
    radial-gradient(circle at bottom right, hsl(313 100% 56% / 0.14), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.2);
}

.vchat__welcome-visual {
  position: relative;
  height: 210px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  overflow: hidden;
}

.vchat__welcome-visual-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 95%);
}

.vchat__welcome-signal {
  position: absolute;
  inset: 0;
}

.vchat__welcome-signal-node {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: hsl(313 100% 56%);
  box-shadow: 0 0 18px hsl(313 100% 56% / 0.5);
}

.vchat__welcome-signal-node::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.32;
  animation: vchat-node-pulse 3s ease-out infinite;
}

.vchat__welcome-signal-node--primary {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: hsl(313 100% 56%);
  box-shadow: 0 0 22px hsl(313 100% 56% / 0.6);
  color: hsl(313 100% 56%);
}

.vchat__welcome-signal-node--top {
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  background: hsl(190 100% 50%);
  box-shadow: 0 0 18px hsl(190 100% 50% / 0.5);
  color: hsl(190 100% 50%);
}

.vchat__welcome-signal-node--right {
  top: 50%;
  right: 34px;
  transform: translateY(-50%);
  background: hsl(48 100% 58%);
  box-shadow: 0 0 18px hsl(48 100% 58% / 0.5);
  color: hsl(48 100% 58%);
}

.vchat__welcome-signal-node--bottom {
  bottom: 36px;
  left: 42px;
  background: hsl(221 100% 56%);
  box-shadow: 0 0 18px hsl(221 100% 56% / 0.5);
  color: hsl(221 100% 56%);
}

.vchat__welcome-signal-beam {
  position: absolute;
  inset: 0;
}

.vchat__welcome-signal-beam::before,
.vchat__welcome-signal-beam::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96px;
  height: 1px;
  transform-origin: left center;
  background: linear-gradient(90deg, hsl(313 100% 56% / 0.85), hsl(190 100% 50% / 0));
}

.vchat__welcome-signal-beam::before {
  transform: translate(0, -0.5px) rotate(-90deg);
  background: linear-gradient(90deg, hsl(313 100% 56% / 0.85), hsl(48 100% 58% / 0));
}

.vchat__welcome-signal-beam::after {
  width: 112px;
  transform: translate(0, -0.5px) rotate(12deg);
  background: linear-gradient(90deg, hsl(313 100% 56% / 0.85), hsl(221 100% 56% / 0));
}

.vchat__welcome-signal::after {
  content: '';
  position: absolute;
  left: 49px;
  bottom: 43px;
  width: 94px;
  height: 1px;
  transform: rotate(-32deg);
  transform-origin: left center;
  background: linear-gradient(90deg, hsl(313 100% 56% / 0.7), hsl(48 100% 58% / 0));
}

.vchat__welcome-metric {
  position: absolute;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 15, 0.72);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  animation: vchat-metric-float 5s ease-in-out infinite;
}

.vchat__welcome-metric--live {
  top: 18px;
  right: 16px;
}

.vchat__welcome-metric--ops {
  bottom: 18px;
  right: 18px;
  animation-delay: 1.6s;
}

.vchat__welcome-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.vchat__welcome-eyebrow {
  display: inline-flex;
  align-self: flex-start;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--brand-gradient-soft);
  border: 1px solid hsl(313 100% 56% / 0.3);
  color: hsl(313 95% 52%);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.vchat__welcome-title {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.vchat__welcome-desc {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.vchat__welcome-sectors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.vchat__welcome-sector {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
}

.vchat__welcome-suggestions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.vchat__welcome-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.vchat__welcome-pill {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 0.88rem;
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.vchat__welcome-pill:hover {
  transform: translateY(-1px);
  border-color: hsl(313 100% 56% / 0.4);
  background: var(--brand-gradient-soft);
  box-shadow: 0 12px 22px hsl(313 100% 56% / 0.12);
}

@keyframes vchat-node-pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.7;
  }
  70%, 100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

@keyframes vchat-metric-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.vchat__message { display: flex; width: 100%; margin-bottom: 14px; }
.vchat__message--user { justify-content: flex-end; }
.vchat__bubble {
  max-width: min(100%, 760px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
  line-height: 1.5;
  background: var(--bg-surface);
  word-break: break-word;
}
.vchat__message--user .vchat__bubble {
  background: linear-gradient(135deg, hsl(222 90% 56%) 0%, hsl(200 92% 58%) 100%);
  color: #ffffff;
  border-color: transparent;
  text-shadow: 0 1px 2px rgba(6, 26, 60, 0.28);
}

.vchat__message--assistant .vchat__bubble {
  max-width: min(100%, 760px);
}

.vchat__message--assistant.is-reported-good .vchat__bubble {
  border-color: rgba(43, 181, 110, 0.55);
  box-shadow: 0 0 0 1px rgba(43, 181, 110, 0.16);
}

.vchat__message--assistant.is-reported-bad .vchat__bubble {
  border-color: rgba(249, 36, 171, 0.6);
  box-shadow: 0 0 0 1px rgba(249, 36, 171, 0.18);
}

/* --- Markdown: Headings --- */
.vchat__message--assistant .vchat__bubble h1,
.vchat__message--assistant .vchat__bubble h2,
.vchat__message--assistant .vchat__bubble h3,
.vchat__message--assistant .vchat__bubble h4 {
  color: var(--accent);
  font-weight: 600;
  margin: 1em 0 0.4em;
  line-height: 1.3;
}
.vchat__message--assistant .vchat__bubble h1 { font-size: 1.35em; }
.vchat__message--assistant .vchat__bubble h2 { font-size: 1.18em; }
.vchat__message--assistant .vchat__bubble h3 { font-size: 1.05em; }
.vchat__message--assistant .vchat__bubble h4 { font-size: 0.95em; font-weight: 500; }

.vchat__message--assistant .vchat__bubble > :first-child { margin-top: 0; }

/* --- Markdown: Paragraphs --- */
.vchat__message--assistant .vchat__bubble p { margin: 0.5em 0; }
.vchat__message--assistant .vchat__bubble > :last-child { margin-bottom: 0; }

/* --- Markdown: Bold / Italic --- */
.vchat__message--assistant .vchat__bubble strong { font-weight: 600; }
.vchat__message--assistant .vchat__bubble em { font-style: italic; }

/* --- Markdown: Lists --- */
.vchat__message--assistant .vchat__bubble ul,
.vchat__message--assistant .vchat__bubble ol {
  margin: 0.5em 0;
  padding-left: 1.6em;
}
.vchat__message--assistant .vchat__bubble li { margin-bottom: 0.25em; }
.vchat__message--assistant .vchat__bubble ul { list-style-type: disc; }
.vchat__message--assistant .vchat__bubble ol { list-style-type: decimal; }

/* --- Markdown: Horizontal Rule --- */
.vchat__message--assistant .vchat__bubble hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1em 0;
}

/* --- Markdown: Inline Code --- */
.vchat__message--assistant .vchat__bubble code {
  background: rgba(255, 255, 255, 0.07);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* --- Markdown: Code Blocks --- */
.vchat__message--assistant .vchat__bubble pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75em 1em;
  margin: 0.6em 0;
  overflow-x: auto;
  line-height: 1.45;
}
.vchat__message--assistant .vchat__bubble pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
}

/* --- Markdown: Tables --- */
.vchat__message--assistant .vchat__bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.9em;
}
.vchat__message--assistant .vchat__bubble th,
.vchat__message--assistant .vchat__bubble td {
  border: 1px solid var(--border-light);
  padding: 0.45em 0.7em;
  text-align: left;
}
.vchat__message--assistant .vchat__bubble th {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}
.vchat__message--assistant .vchat__bubble tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

/* --- Markdown: Blockquote --- */
.vchat__message--assistant .vchat__bubble blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.3em 0.8em;
  margin: 0.5em 0;
  color: var(--text-secondary);
}

/* --- Markdown: Light theme overrides --- */
[data-theme='light'] .vchat__message--assistant .vchat__bubble code {
  background: rgba(0, 0, 0, 0.06);
}
[data-theme='light'] .vchat__message--assistant .vchat__bubble pre {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme='light'] .vchat__message--assistant .vchat__bubble tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.03);
}

.vchat__main--empty {
  justify-content: center;
  align-items: center;
  gap: 24px;
  min-height: calc(100vh - var(--header-height) - 24px);
}

.vchat__main--active {
  justify-content: flex-start;
}

.vchat__composer {
  flex: 0 0 auto;
  z-index: 10;
  width: min(920px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 12px;
}

.vchat__composer--active {
  position: sticky;
  bottom: 0;
}

.vchat__composer--empty {
  position: relative;
  bottom: auto;
  padding-bottom: 0;
}

.vchat__composer-shell {
  position: relative;
  z-index: 2;
  min-height: 112px;
  transition: box-shadow 180ms ease, min-height 220ms ease;
  border: 1px solid transparent;
  border-radius: 14px;
  background:
    linear-gradient(#1f1f1f, #1f1f1f) padding-box,
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)) border-box;
  overflow: hidden;
  box-shadow: none;
}


.vchat__input {
  width: 100%;
  resize: none;
  min-height: 64px;
  max-height: 192px;
  border: 0;
  padding: 12px 14px 8px;
  overflow-y: hidden;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.45;
  transition: height 220ms ease;
}

.vchat__input::placeholder {
  color: var(--text-secondary);
}

.vchat__input:focus {
  outline: none;
}

.vchat__composer-shell:focus-within {
  background:
    linear-gradient(#1f1f1f, #1f1f1f) padding-box,
    var(--brand-gradient) border-box;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 8px 28px hsl(313 100% 56% / 0.12);
}

.vchat__composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 12px;
}

.vchat__composer-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vchat__composer-top-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.vchat__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.vchat__icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Skills popup ── */
.vchat__skills-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  background: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
  padding: 6px 0;
}
.vchat__skills-popup.is-open {
  display: block;
}
.vchat__skills-popup-header {
  padding: 6px 14px 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
}
.vchat__skill-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  position: relative;
}
.vchat__skill-option:hover {
  background: rgba(255, 255, 255, 0.06);
}
.vchat__skill-option.is-active {
  color: hsl(200 95% 64%);
}
.vchat__skill-option-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.vchat__skill-check {
  margin-left: auto;
  font-size: 0.85rem;
  color: hsl(200 95% 64%);
}
.vchat__skill-tooltip {
  display: none;
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  width: 220px;
  padding: 10px 12px;
  background: #2a2a2a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
  z-index: 30;
  white-space: normal;
}
.vchat__skill-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #2a2a2a;
}
.vchat__skill-option:hover .vchat__skill-tooltip {
  display: block;
}

/* ── Skill pills ── */
.vchat__skills-bar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
}
.vchat__skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  background: hsl(200 95% 60% / 0.14);
  border: 1px solid hsl(200 95% 60% / 0.3);
  color: hsl(200 95% 66%);
  font-size: 0.78rem;
  line-height: 1.3;
}
.vchat__skill-pill-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.vchat__skill-pill-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 0;
  background: transparent;
  color: hsl(200 90% 72% / 0.7);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
}
.vchat__skill-pill-x:hover {
  background: hsl(200 95% 60% / 0.22);
  color: hsl(200 95% 70%);
}

/* ── Chart containers ── */
.vchat__chart-wrap {
  max-width: 600px;
  margin: 12px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.vchat__chart-error {
  color: #e57373;
  font-size: 0.85rem;
  padding: 8px;
}

.vchat__select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  padding: 0 22px 0 10px;
}

.vchat__select-wrap--model {
  min-width: 196px;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  padding: 0 36px 0 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.vchat__select-wrap--space {
  min-width: 140px;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  padding: 0 36px 0 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.vchat__select-value {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vchat__select-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.65);
  pointer-events: none;
}

.vchat__select-icon svg {
  width: 14px;
  height: 14px;
}


.vchat__select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.vchat__send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: var(--brand-gradient-soft);
  color: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 180ms ease, filter 180ms ease, color 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
  opacity: 0.6;
  cursor: not-allowed;
}

.vchat__send-btn svg {
  width: 16px;
  height: 16px;
}

.vchat__send-btn.is-active {
  background: var(--brand-gradient);
  color: #fff;
  opacity: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px hsl(313 100% 56% / 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.vchat__send-btn.is-active:hover {
  filter: brightness(1.08);
}

.vchat__send-btn.is-active:hover {
  transform: translateY(-1px);
}

.vchat__send-btn:disabled {
  pointer-events: none;
}


.vchat__history {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: visible;
  transition: width 250ms ease, min-width 250ms ease;
  width: 320px;
  min-width: 320px;
}
.vchat__history--collapsed {
  width: 32px;
  min-width: 32px;
}
.vchat__history-toggle {
  position: absolute;
  left: -12px;
  top: 14px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: 999px;
  width: 24px;
  height: 24px;
  z-index: 10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vchat__history-header { padding: 16px; border-bottom:1px solid var(--border); }
.vchat__history-list { padding: 10px; overflow-y:auto; display:flex; flex-direction:column; gap:8px; flex:1; min-height:0; }
.vchat__history-item {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  display: flex;
  align-items: stretch;
  overflow: hidden;
}
.vchat__history-select {
  text-align: left;
  padding: 10px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.vchat__history-item strong { color: var(--text-primary); }
.vchat__history-item.is-active { border-color: var(--accent); }
.vchat__history-item span { font-size: var(--font-size-xs); }
.vchat__history-delete {
  width: 42px;
  min-width: 42px;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}
.vchat__history-delete:hover {
  background: rgba(249, 36, 171, 0.08);
  color: var(--accent);
}
.vchat__history-delete svg {
  width: 16px;
  height: 16px;
}
.vchat__empty-history { color: var(--text-muted); padding: 8px; }

/* ── Light mode overrides for Vision Chat ── */
[data-theme='light'] .vchat__composer-shell {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(var(--border), var(--border)) border-box;
}
[data-theme='light'] .vchat__composer-shell:focus-within {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    var(--brand-gradient) border-box;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 8px 28px hsl(313 100% 56% / 0.12);
}
[data-theme='light'] .vchat__skills-popup {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
[data-theme='light'] .vchat__skills-popup-header {
  color: var(--text-muted);
}
[data-theme='light'] .vchat__skill-option:hover {
  background: var(--bg-surface);
}
[data-theme='light'] .vchat__skill-option.is-active,
[data-theme='light'] .vchat__skill-check { color: hsl(210 90% 46%); }
[data-theme='light'] .vchat__skill-pill {
  background: hsl(205 95% 50% / 0.12);
  border-color: hsl(205 95% 50% / 0.32);
  color: hsl(210 90% 42%);
}
[data-theme='light'] .vchat__skill-pill-x { color: hsl(210 80% 50% / 0.7); }
[data-theme='light'] .vchat__skill-pill-x:hover {
  background: hsl(205 95% 50% / 0.18);
  color: hsl(210 90% 42%);
}
[data-theme='light'] .vchat__skill-tooltip {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text-secondary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
[data-theme='light'] .vchat__skill-tooltip::before {
  border-right-color: #ffffff;
}
[data-theme='light'] .vchat__icon-btn {
  background: rgba(0, 0, 0, 0.03);
}
[data-theme='light'] .vchat__select-wrap {
  border-color: var(--border);
  background: var(--bg-input);
}
[data-theme='light'] .vchat__select-wrap--model,
[data-theme='light'] .vchat__select-wrap--space {
  border-color: var(--border);
  background: var(--bg-input);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.03);
}
[data-theme='light'] .vchat__select-icon {
  color: var(--text-muted);
}
[data-theme='light'] .vchat__send-btn {
  background: var(--brand-gradient-soft);
  color: var(--text-muted);
}
[data-theme='light'] .vchat__send-btn.is-active {
  background: var(--brand-gradient);
  color: #fff;
}
[data-theme='light'] .vchat__chart-wrap {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border);
}
[data-theme='light'] .vchat__report-btn {
  background: rgba(0, 0, 0, 0.02);
}

@media (max-width: 1200px) {
  .vchat { grid-template-columns: minmax(0, 1fr) 260px; }
  .vchat:has(.vchat__history--collapsed) { grid-template-columns: minmax(0, 1fr) 32px; }
  .vchat__history { width: 260px; min-width: 260px; }
  .vchat__history--collapsed { width: 32px; min-width: 32px; }
  .vchat__composer {
    width: min(100%, 780px);
  }

  .vchat__select-wrap--model {
    min-width: 156px;
  }
}

@media (max-width: 900px) {
  .vchat__welcome {
    grid-template-columns: 1fr;
    width: 100%;
    padding: 18px;
  }

  .vchat__welcome-visual {
    height: 168px;
  }

  .vchat__welcome-title {
    font-size: 1.35rem;
  }

  .vchat {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .vchat__main {
    padding: 12px;
  }

  .vchat__composer {
    width: 100%;
  }


  .vchat__input {
    font-size: 0.92rem;
    min-height: 64px;
    max-height: 192px;
  }

  .vchat__composer-top {
    flex-direction: column;
    align-items: stretch;
  }

  .vchat__composer-top-right {
    width: 100%;
  }

  .vchat__select-wrap--model,
  .vchat__select-wrap--space {
    min-width: 0;
    flex: 1;
  }

  .vchat__history {
    min-height: 260px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

/* ----- SQL Details (collapsible query in chat bubbles) ----- */

.vchat__sql-details {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.vchat__sql-summary {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.vchat__sql-summary:hover {
  color: var(--accent);
}

.vchat__sql-code {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-raised, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.vchat__sql-code code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ----- Thinking indicator (pulse bars) ----- */

.vchat__bubble--thinking {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 52px;
  padding: 12px 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.vchat__thinking-pulse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 28px;
  flex-shrink: 0;
}

.vchat__thinking-pulse span {
  display: block;
  width: 3px;
  border-radius: 999px;
  animation: vchat-pulse 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.vchat__thinking-pulse span:nth-child(1) { animation-delay: 0s;    height: 8px;  background: hsl(190 100% 50%); box-shadow: 0 0 8px hsl(190 100% 50% / 0.45); }
.vchat__thinking-pulse span:nth-child(2) { animation-delay: 0.12s; height: 12px; background: hsl(221 100% 56%); box-shadow: 0 0 8px hsl(221 100% 56% / 0.45); }
.vchat__thinking-pulse span:nth-child(3) { animation-delay: 0.24s; height: 16px; background: hsl(313 100% 56%); box-shadow: 0 0 8px hsl(313 100% 56% / 0.45); }
.vchat__thinking-pulse span:nth-child(4) { animation-delay: 0.36s; height: 12px; background: hsl(28 100% 55%);  box-shadow: 0 0 8px hsl(28 100% 55% / 0.45); }
.vchat__thinking-pulse span:nth-child(5) { animation-delay: 0.48s; height: 8px;  background: hsl(48 100% 58%);  box-shadow: 0 0 8px hsl(48 100% 58% / 0.45); }

@keyframes vchat-pulse {
  0%, 100% {
    height: 4px;
    opacity: 0.45;
  }
  50% {
    height: 24px;
    opacity: 1;
  }
}

.vchat__thinking-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  min-width: 28ch;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  letter-spacing: 0.01em;
  line-height: 1.4;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease, color 180ms ease;
}

.vchat__thinking-label.is-changing {
  opacity: 0;
  transform: translateY(2px);
}

.vchat__report-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.vchat__report-label {
  font-size: 12px;
  color: var(--text-muted);
}

.vchat__report-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.vchat__report-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.vchat__report-btn svg {
  width: 16px;
  height: 16px;
}

.vchat__report-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--text-primary);
}

.vchat__report-btn.is-active.is-good {
  color: #2bb56e;
  border-color: rgba(43, 181, 110, 0.45);
  background: rgba(43, 181, 110, 0.12);
}

.vchat__report-btn.is-active.is-bad {
  color: var(--accent);
  border-color: rgba(249, 36, 171, 0.45);
  background: rgba(249, 36, 171, 0.12);
}

.vchat__report-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ai-reports {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  min-height: 620px;
}

.ai-reports__sidebar,
.ai-reports__detail {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-surface);
}

.ai-reports__sidebar {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-reports__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-reports__filter {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.ai-reports__filter.is-active {
  background: rgba(249, 36, 171, 0.12);
  border-color: rgba(249, 36, 171, 0.35);
  color: var(--text-primary);
}

.ai-reports__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.ai-reports__item {
  width: 100%;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-reports__item.is-active {
  border-color: rgba(249, 36, 171, 0.45);
  box-shadow: 0 0 0 1px rgba(249, 36, 171, 0.14);
}

.ai-reports__item-title {
  font-weight: 700;
  color: var(--text-primary);
}

.ai-reports__item-meta,
.ai-reports__item-time,
.ai-reports__summary {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.ai-reports__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-reports__chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.ai-reports__chip--good {
  color: #2bb56e;
  background: rgba(43, 181, 110, 0.12);
}

.ai-reports__chip--bad {
  color: var(--accent);
  background: rgba(249, 36, 171, 0.12);
}

.ai-reports__detail {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-reports__detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.ai-reports__detail-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.ai-reports__history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 560px;
  overflow-y: auto;
}

.ai-reports__message {
  display: flex;
}

.ai-reports__message--user {
  justify-content: flex-end;
}

.ai-reports__message-bubble {
  max-width: min(100%, 720px);
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.ai-reports__message--user .ai-reports__message-bubble {
  background: var(--brand-gradient);
  border-color: transparent;
  color: var(--text-on-accent);
}

.ai-reports__message.is-good .ai-reports__message-bubble {
  border-color: rgba(43, 181, 110, 0.55);
  box-shadow: 0 0 0 1px rgba(43, 181, 110, 0.16);
}

.ai-reports__message.is-bad .ai-reports__message-bubble {
  border-color: rgba(249, 36, 171, 0.6);
  box-shadow: 0 0 0 1px rgba(249, 36, 171, 0.18);
}

.ai-reports__message-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ai-reports__flag {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ai-reports__flag--good {
  background: rgba(43, 181, 110, 0.12);
  color: #2bb56e;
}

.ai-reports__flag--bad {
  background: rgba(249, 36, 171, 0.12);
  color: var(--accent);
}

.ai-reports__empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 320px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .ai-reports {
    grid-template-columns: 1fr;
  }

  .ai-reports__history {
    max-height: none;
  }
}

@media (max-width: 700px) {
  .vchat__report-bar,
  .ai-reports__detail-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
