:root {
  --bg: #07080c;
  --bg-elevated: #0f1118;
  --bg-hover: #171b26;
  --border: rgba(255, 255, 255, 0.07);
  --text: #eef1f7;
  --text-muted: #8b93a8;
  --teal: #3ee8cf;
  --teal-dim: rgba(62, 232, 207, 0.12);
  --violet: #b49cff;
  --violet-dim: rgba(180, 156, 255, 0.12);
  --amber: #ffc857;
  --amber-dim: rgba(255, 200, 87, 0.12); 
  --coral: #ff8b6a;
  --sky: #5ec8ff;
  --user-bg: linear-gradient(135deg, #1a3352 0%, #141c32 100%);
  --assistant-bg: #12151d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --sidebar-width: 280px;
  --chat-mini-width: 34%;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(45, 212, 191, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(167, 139, 250, 0.06), transparent),
    var(--bg);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.55rem max(1rem, env(safe-area-inset-right, 0px)) 0.55rem max(1rem, env(safe-area-inset-left, 0px));
  padding-top: max(0.55rem, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 18, 0.95);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 20;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 10rem;
}

.app-brand-name {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.app-topbar-spacer {
  flex: 1;
}

.topbar-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: auto;
}

.view-tabs {
  display: flex;
  gap: 0.35rem;
}

.view-tab {
  position: relative;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.view-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.view-tab.active {
  color: var(--teal);
  background: var(--teal-dim);
  border-color: rgba(62, 232, 207, 0.25);
}

.tab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1400;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
}

.hidden {
  display: none !important;
}

.btn-topbar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.btn-topbar:hover,
.btn-topbar[aria-expanded="true"] {
  color: var(--teal);
  background: var(--teal-dim);
  border-color: rgba(62, 232, 207, 0.35);
}

.sidebar-backdrop {
  display: none;
}

.app-body {
  flex: 1;
  min-height: 0;
  display: grid;
  overflow: hidden;
}

/* ——— Vue Chat : sidebar GPU + chat pleine largeur ——— */
.app.view-chat .app-body {
  grid-template-columns: var(--sidebar-width) 14px 1fr;
}

.app.view-chat .sidebar {
  display: flex;
  grid-column: 1;
}

.app.view-chat .splitter-sidebar {
  display: block;
  grid-column: 2;
}

.app.view-chat .pane-docs,
.app.view-chat .splitter-docs {
  display: none !important;
}

.app.view-chat .pane-chat {
  grid-column: 3;
}

/* ——— Vue Documentation : dossiers à gauche, chat réduit à droite ——— */
.app.view-docs .app-body {
  grid-template-columns: 1fr 14px var(--chat-mini-width);
}

.app.view-docs .sidebar,
.app.view-docs .splitter-sidebar {
  display: none !important;
}

.app.view-docs .pane-docs {
  display: flex;
  grid-column: 1;
}

.app.view-docs .splitter-docs {
  display: block;
  grid-column: 2;
}

.app.view-docs .pane-chat {
  grid-column: 3;
  min-width: 280px;
}

.app.view-docs .composer-hint-full {
  display: none;
}

/* ——— Vue Index : tableau de bord pleine largeur ——— */
.app.view-index .app-body {
  grid-template-columns: 1fr;
}

.app.view-index .sidebar,
.app.view-index .splitter-sidebar,
.app.view-index .pane-docs,
.app.view-index .splitter-docs,
.app.view-index .pane-chat {
  display: none !important;
}

.app.view-index .pane-index {
  display: flex;
  grid-column: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pane-index[hidden] {
  display: none !important;
}

.index-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 11, 16, 0.7);
  flex-shrink: 0;
}

.index-hero h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.index-summary {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.index-hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-index-primary,
.btn-index-secondary {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  border: 1px solid var(--border);
}

.btn-index-primary {
  background: var(--teal-dim);
  color: var(--teal);
  border-color: rgba(62, 232, 207, 0.35);
}

.btn-index-secondary {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.index-prefs {
  margin: 0.75rem 1.25rem 0;
  padding: 0.65rem 0.85rem !important;
}

.index-pref-row {
  margin: 0 !important;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.65rem;
  padding: 0.85rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.index-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid var(--border);
}

.index-viz-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 11, 16, 0.55);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.index-viz-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.index-viz-tab {
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.index-viz-tab.active {
  background: var(--teal-dim);
  color: var(--teal);
}

.index-viz-search-wrap {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
}

.index-viz-search-wrap.hidden,
.index-viz-toolbar-actions.hidden {
  display: none;
}

.index-viz-search {
  width: 100%;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
}

.index-viz-search:focus {
  outline: none;
  border-color: rgba(62, 232, 207, 0.45);
}

.index-viz-toolbar-actions {
  display: flex;
  gap: 0.35rem;
}

.index-viz-stats {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
}

.index-viz-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.index-viz-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.index-viz-panel.active {
  display: flex;
  flex-direction: column;
}

.index-viz-split {
  flex-direction: row;
}

.index-tree {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 0.75rem 1rem 1rem;
}

.index-tree-node {
  --tree-accent: var(--teal);
  margin-left: 0;
}

.index-tree-node[data-depth="1"] { margin-left: 0.35rem; }
.index-tree-node[data-depth="2"] { margin-left: 1.1rem; }
.index-tree-node[data-depth="3"] { margin-left: 1.85rem; }
.index-tree-node[data-depth="4"] { margin-left: 2.6rem; }

.index-tree-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.45rem;
  border-radius: 8px;
  cursor: default;
  transition: background 0.12s;
}

.index-tree-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.index-tree-row.is-clickable {
  cursor: pointer;
}

.index-tree-toggle {
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.62rem;
  cursor: pointer;
  flex-shrink: 0;
}

.index-tree-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.index-tree-toggle.placeholder {
  visibility: hidden;
}

.index-tree-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tree-accent, var(--teal));
  flex-shrink: 0;
  box-shadow: 0 0 8px color-mix(in srgb, var(--tree-accent, var(--teal)) 45%, transparent);
}

.index-tree-label {
  font-size: 0.74rem;
  line-height: 1.35;
  min-width: 0;
}

.index-tree-label strong {
  font-weight: 600;
}

.index-tree-meta-inline {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 400;
}

.index-tree-meta {
  margin-left: auto;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-family: var(--mono);
  flex-shrink: 0;
}

.index-tree-children {
  display: none;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  margin-left: 0.55rem;
  padding-left: 0.15rem;
}

.index-tree-node.expanded > .index-tree-children {
  display: block;
}

.index-tree-node.filtered-out {
  display: none;
}

.index-tree-node.match > .index-tree-row {
  background: rgba(62, 232, 207, 0.08);
}

.index-tree-file .index-tree-dot {
  width: 6px;
  height: 6px;
  opacity: 0.7;
}

.index-file-preview {
  width: min(420px, 42%);
  min-width: 280px;
  border-left: 1px solid var(--border);
  background: rgba(8, 10, 14, 0.92);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.index-file-preview.hidden {
  display: none;
}

.index-file-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.index-file-preview-head strong {
  font-size: 0.78rem;
  display: block;
}

.index-file-preview-path {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-top: 0.2rem;
}

.btn-close-preview {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
}

.index-file-preview-body {
  flex: 1;
  margin: 0;
  padding: 0.75rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.45;
  color: #c5cad6;
  white-space: pre-wrap;
  word-break: break-word;
}

.index-treemap {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 1.25rem 1.25rem;
}

.index-treemap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.85rem;
}

.index-treemap-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.index-treemap-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.index-treemap-source {
  margin-bottom: 0.85rem;
}

.index-treemap-source-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.index-treemap-source-head strong {
  font-size: 0.78rem;
}

.index-treemap-source-head span {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.index-treemap-row {
  display: flex;
  gap: 3px;
  min-height: 2.4rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.index-treemap-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
  min-width: 2rem;
  border: 1px solid rgba(0, 0, 0, 0.25);
  transition: filter 0.12s, transform 0.12s;
  cursor: default;
}

.index-treemap-cell:hover {
  filter: brightness(1.12);
  z-index: 1;
  transform: scale(1.01);
}

.index-treemap-cell-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.index-treemap-cell[title] {
  cursor: help;
}

.index-treemap-cell-count {
  display: none;
}

.index-card {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.index-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.index-card-name {
  font-size: 0.82rem;
  font-weight: 600;
}

.index-card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.index-card-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.62rem;
  color: #7dd3fc;
  line-height: 1.35;
}

.index-help {
  margin: 0.65rem 0 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.index-help code {
  font-family: var(--font-mono);
  font-size: 0.62rem;
}

.index-card-rows {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.index-card-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.btn-index-mini {
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.62rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
}

.index-section {
  padding: 0.5rem 1.25rem 1rem;
  min-height: 0;
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 28%;
}

.index-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.discovered-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.discovered-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(62, 232, 207, 0.25);
  background: rgba(62, 232, 207, 0.04);
  font-size: 0.72rem;
}

.discovered-path {
  font-family: var(--mono);
  font-size: 0.65rem;
  word-break: break-all;
  color: var(--text-muted);
}

.index-journal {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-height: 8rem;
  overflow-y: auto;
}

.index-journal-entry {
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.index-empty {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.index-validation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.index-validation-summary {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.index-validation-summary.status-ok {
  color: var(--ok);
}

.index-validation-summary.status-warn {
  color: var(--warn);
}

.index-validation-report {
  font-size: 0.75rem;
  line-height: 1.5;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

.index-validation-report.hidden {
  display: none;
}

.validation-block {
  margin-bottom: 0.5rem;
}

.validation-smoke-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.validation-smoke-list .smoke-fail {
  color: var(--warn);
}

.docs-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.discovered-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.add-source-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 32rem;
  width: calc(100% - 2rem);
  background: var(--surface);
  color: var(--text);
}

.add-source-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.add-source-dialog form {
  padding: 1rem 1.1rem;
}

.add-source-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.add-source-head h2 {
  margin: 0;
  font-size: 1rem;
}

.add-source-hint {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-text {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
}

.add-source-detect-row {
  margin: 0.5rem 0 0.75rem;
}

.add-entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 10rem;
  overflow-y: auto;
  margin-top: 0.35rem;
}

.add-entry-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.5rem;
  font-size: 0.72rem;
  align-items: start;
}

.add-entry-row code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
}

.add-validate-result {
  margin: 0.75rem 0;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.2);
}

.add-validate-ok {
  border-left: 3px solid var(--ok);
}

.add-validate-warn {
  border-left: 3px solid var(--warn);
}

.add-validate-error {
  border-left: 3px solid var(--danger);
}

.add-source-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.field-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.disabled-sources-wrap {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.disabled-sources-title {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.disabled-source-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.disabled-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
}

.btn-inspector-danger {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.app.view-docs .welcome .suggestions {
  flex-direction: column;
}

.app.view-docs .welcome h2 {
  font-size: 1.1rem;
}

.pane-chat,
.pane-docs {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane-docs {
  background: rgba(10, 12, 18, 0.5);
  border-right: none;
}

.pane-docs[hidden] {
  display: none !important;
}

.splitter-docs[hidden] {
  display: none !important;
}

.splitter {
  position: relative;
  z-index: 10;
  background: rgba(255, 255, 255, 0.04);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: col-resize;
  touch-action: none;
  transition: background 0.15s;
}

.splitter:hover,
.splitter.dragging {
  background: var(--teal-dim);
}

.splitter-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 48px;
  border-radius: 4px;
  background: repeating-linear-gradient(
    to bottom,
    var(--text-muted) 0,
    var(--text-muted) 2px,
    transparent 2px,
    transparent 5px
  );
  opacity: 0.5;
}

.splitter:hover .splitter-grip,
.splitter.dragging .splitter-grip {
  opacity: 1;
}

/* Settings modal (legacy, unused) */
.settings-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2rem);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.settings-dialog-inner {
  max-height: min(85vh, 720px);
  overflow-y: auto;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

.settings-header h2 {
  margin: 0;
  font-size: 1rem;
}

.settings-dialog .panel {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.settings-dialog .panel h2 {
  margin-bottom: 0.65rem;
}

.sidebar {
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(10, 12, 18, 0.92);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.panel-details {
  border-bottom: 1px solid var(--border);
}

.panel-details summary {
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 1rem;
  list-style: none;
}

.panel-details summary::-webkit-details-marker {
  display: none;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.5rem;
  color: var(--teal);
  filter: drop-shadow(0 0 8px rgba(45, 212, 191, 0.4));
}

.logo h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo p {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.panel {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-grow { flex: 1; }

.sidebar-footer {
  padding: 0.65rem 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#status-line {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.panel-head h2 { margin: 0; }

.btn-link {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  line-height: 1;
}

.btn-link:hover {
  color: var(--teal);
  background: var(--teal-dim);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.field > span {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.field-row span { flex: 1; }

.field input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
  height: 4px;
}

.field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}

.field output {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--teal);
}

.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-card {
  position: relative;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}

.profile-card:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.profile-card.active {
  border-color: rgba(45, 212, 191, 0.5);
  background: var(--teal-dim);
}

.profile-card.active.violet {
  border-color: rgba(167, 139, 250, 0.5);
  background: var(--violet-dim);
}

.profile-card.active.amber {
  border-color: rgba(251, 191, 36, 0.5);
  background: var(--amber-dim);
}

.profile-card.offline {
  opacity: 0.55;
}

.profile-card .name {
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.profile-card .meta {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.status-dot.online { background: #34d399; box-shadow: 0 0 6px #34d399; }
.status-dot.offline { background: #f87171; }

.select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--teal);
}

/* Documentation pane (right) */
.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.docs-header-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.docs-header h2,
.docs-header-text h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.docs-alert-badge {
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1400;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
}

.docs-alert-badge.hidden {
  display: none;
}

.btn-docs-refresh {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.btn-docs-refresh:hover {
  border-color: rgba(62, 232, 207, 0.4);
  color: var(--teal);
}

.docs-list {
  flex: 0 0 auto;
  max-height: 38%;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.doc-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: start;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.doc-row:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.doc-row.active {
  border-color: rgba(62, 232, 207, 0.45);
  background: var(--teal-dim);
}

.doc-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.35rem;
}

.doc-row-body {
  min-width: 0;
}

.doc-row-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

.doc-row-meta {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.doc-row-path {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  word-break: break-all;
  line-height: 1.35;
}

.doc-row-disk {
  display: block;
  font-size: 0.62rem;
  color: var(--teal);
  margin-top: 0.15rem;
  opacity: 0.9;
}

.doc-row-dot.teal { background: var(--teal); }
.doc-row-dot.amber { background: var(--amber); }
.doc-row-dot.violet { background: var(--violet); }
.doc-row-dot.coral { background: var(--coral); }
.doc-row-dot.sky { background: var(--sky); }

.doc-row-status {
  margin-top: 0.2rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}

.doc-row-status.status-ok { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; }
.doc-row-status.status-info { background: rgba(56, 189, 248, 0.12); color: #7dd3fc; }
.doc-row-status.status-warn { background: var(--amber-dim); color: var(--amber); }
.doc-row-status.status-err { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }
.doc-row-status.status-muted { color: var(--text-muted); }

.docs-detail {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.inspector-empty {
  padding: 1rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.inspector-empty p {
  margin: 0;
}

.inspector-panel {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.inspector-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.inspector-lead {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.inspector-note code {
  font-family: var(--mono);
  font-size: 0.85em;
}

.inspector-commit {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.inspector-subtitle {
  margin: 0.75rem 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.git-divergence {
  margin: 0.65rem 0 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.76rem;
  line-height: 1.45;
}

.git-divergence-aligned {
  border-left: 3px solid var(--ok);
}

.git-divergence-local-ahead {
  border-left: 3px solid var(--teal);
}

.git-divergence-remote-ahead {
  border-left: 3px solid var(--warn);
}

.git-divergence-diverged {
  border-left: 3px solid var(--danger, #f87171);
  background: rgba(248, 113, 113, 0.06);
}

.git-divergence-dirty {
  border-left: 3px solid var(--warn);
}

.git-divergence-headline {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.git-divergence-stats {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.git-divergence-stats dt {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.git-divergence-stats dd {
  margin: 0.1rem 0 0;
}

.git-divergence-next {
  margin: 0.55rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.git-ref {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--teal);
}

.inspector-commit-field {
  margin-bottom: 0.5rem;
}

.inspector-commit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.inspector-commit .input-text {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
}

.inspector-close {
  margin-left: auto;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.inspector-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.inspector-facts {
  display: grid;
  gap: 0.65rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

.inspector-fact {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.inspector-fact dt {
  color: var(--text-muted);
}

.inspector-fact dd {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  word-break: break-all;
}

.path-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.path-main {
  font-family: var(--mono);
  font-size: 0.72rem;
  word-break: break-all;
}

.path-disk {
  font-family: var(--font);
  font-size: 0.68rem;
  color: var(--teal);
}

.inspector-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inspector-block {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

.inspector-block-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inspector-block-text {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
}

.inspector-block-hint {
  margin: 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.status-pill {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
}

.status-pill.status-ok {
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
}

.status-pill.status-warn {
  background: var(--amber-dim);
  color: var(--amber);
}

.status-pill.status-err {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.status-pill.status-muted {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.status-pill.status-info {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
}

.git-dirty-files-wrap {
  margin: 0.5rem 0 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
}

.git-dirty-files-title {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  color: #7dd3fc;
}

.git-dirty-files {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.65rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.git-dirty-code {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--amber);
}

.git-dirty-files-more {
  margin: 0.35rem 0 0;
  font-size: 0.62rem;
  color: var(--text-muted);
}

.btn-inspector.btn-align:not(:disabled) strong {
  color: var(--amber);
}

.btn-inspector.btn-push:not(:disabled) strong {
  color: var(--sky);
}

.btn-inspector {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}

.btn-inspector:hover:not(:disabled) {
  border-color: rgba(62, 232, 207, 0.4);
  background: var(--teal-dim);
}

.btn-inspector:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-inspector strong {
  font-size: 0.82rem;
  color: var(--text);
}

.btn-inspector span {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.inspector-note {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  border: 1px solid rgba(255, 200, 87, 0.2);
  font-size: 0.72rem;
  color: var(--amber);
  line-height: 1.4;
}

.catalog-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.catalog-bar-icon {
  font-size: 1.5rem;
  color: var(--teal);
  opacity: 0.7;
}

.catalog-bar-content {
  flex: 1;
  min-width: 0;
}

.catalog-bar-content strong {
  display: block;
  font-size: 0.85rem;
}

.catalog-bar-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--teal);
  font-family: var(--mono);
  margin-top: 0.1rem;
}

.catalog-bar-content p {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-catalog {
  flex-shrink: 0;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, rgba(62, 232, 207, 0.25), rgba(62, 232, 207, 0.12));
  color: var(--teal);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 0 20px rgba(62, 232, 207, 0.15);
}

.btn-catalog:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(62, 232, 207, 0.25);
}

.btn-catalog:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-teal { background: var(--teal); box-shadow: 0 0 8px rgba(62, 232, 207, 0.4); }
.dot-amber { background: var(--amber); }
.dot-violet { background: var(--violet); }
.dot-coral { background: var(--coral); }
.dot-sky { background: var(--sky); }

/* Main chat */
.main,
.pane-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 11, 16, 0.6);
  backdrop-filter: blur(8px);
}

.chat-header-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-header-info .sep { margin: 0 0.35rem; opacity: 0.4; }

.btn-ghost {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scroll-behavior: smooth;
}

.welcome {
  max-width: 520px;
  margin: 4rem auto;
  text-align: center;
}

.welcome-icon {
  font-size: 2rem;
  color: var(--teal);
  margin-bottom: 1rem;
  opacity: 0.9;
}

.welcome h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.welcome p {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.suggestion {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 780px;
  margin-bottom: 1.25rem;
  animation: fadeIn 0.3s ease;
}

.message.user { margin-left: auto; align-items: flex-end; }
.message.assistant { margin-right: auto; align-items: flex-start; }

.message-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.message-bubble {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  line-height: 1.6;
  font-size: 0.92rem;
  max-width: 100%;
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--user-bg);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(0,0,0,0.3);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.message-bubble pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  overflow-x: auto;
  font-size: 0.82rem;
}

.message-bubble pre code {
  background: none;
  padding: 0;
}

.meta-panel {
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 100%;
}

.meta-panel strong { color: var(--text); font-weight: 500; }

.meta-files {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.file-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: rgba(45, 212, 191, 0.1);
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.2);
  text-decoration: none;
}

.file-tag:hover {
  background: rgba(45, 212, 191, 0.18);
  text-decoration: underline;
}

.ctx-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.cfg-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--violet);
}

#models-panel.offline {
  opacity: 0.55;
  pointer-events: none;
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.25rem 0;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Composer */
.composer {
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(9, 11, 16, 0.85);
  backdrop-filter: blur(12px);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.65rem 0.65rem 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer-inner:focus-within {
  border-color: rgba(45, 212, 191, 0.4);
  box-shadow: 0 0 0 3px var(--teal-dim);
}

.composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  resize: none;
  max-height: 160px;
  line-height: 1.5;
}

.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--text-muted); }

.btn-mic {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-base);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
}

.btn-mic:hover:not(:disabled) {
  color: var(--sky, #38bdf8);
  border-color: rgba(56, 189, 248, 0.45);
}

.btn-mic:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-mic.recording {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.6);
  background: rgba(127, 29, 29, 0.35);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.stt-stack-badge {
  font-size: 0.62rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.stt-stack-badge.status-ok {
  color: var(--teal);
  border-color: rgba(62, 232, 207, 0.35);
  background: var(--teal-dim);
}

.stt-stack-badge.status-warn {
  color: var(--amber);
  border-color: rgba(255, 200, 87, 0.35);
  background: var(--amber-dim);
}

.stt-stack-badge.status-off {
  color: var(--text-muted);
}

.stt-stack-summary {
  margin: 0 0 0.55rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.stt-stack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.stt-stack-actions .hidden {
  display: none;
}

.stt-stack-hint {
  margin: 0.55rem 0 0;
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), #14b8a6);
  color: #042f2e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
}

.btn-send:hover:not(:disabled) { transform: scale(1.05); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.composer-hint {
  margin: 0.45rem 0 0 0.25rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

@media (max-width: 900px) and (min-width: 769px) {
  .app.view-docs .app-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 14px minmax(260px, 40%);
  }

  .app.view-docs .pane-docs { grid-column: 1; grid-row: 1; }
  .app.view-docs .splitter-docs { grid-column: 1; grid-row: 2; }
  .app.view-docs .pane-chat { grid-column: 1; grid-row: 3; }
}

@media (max-width: 768px) {
  .topbar-status { display: none; }

  .app.view-chat .btn-topbar {
    display: inline-flex;
  }

  .app-brand {
    min-width: 0;
    flex: 1;
  }

  .app-brand-name {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .view-tabs {
    flex-shrink: 0;
    gap: 0.2rem;
    max-width: 52vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .view-tabs::-webkit-scrollbar {
    display: none;
  }

  .view-tab {
    padding: 0.45rem 0.65rem;
    font-size: 0.72rem;
    white-space: nowrap;
    min-height: 2.5rem;
  }

  /* Chat : plein écran, sidebar en tiroir */
  .app.view-chat .app-body {
    grid-template-columns: 1fr !important;
  }

  .app.view-chat .splitter-sidebar {
    display: none !important;
  }

  .app.view-chat .pane-chat {
    grid-column: 1 !important;
    grid-row: 1;
  }

  .app.view-chat .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    max-width: 100%;
    z-index: 110;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
    border-right: 1px solid var(--border);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .app.view-chat.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 105;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
  }

  .app.view-chat.sidebar-open .sidebar-backdrop {
    display: block;
  }

  /* Documentation : plein écran sans chat, défilement unique */
  .app.view-docs .app-body {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
  }

  .app.view-docs .splitter-docs,
  .app.view-docs .pane-chat {
    display: none !important;
  }

  .app.view-docs .pane-docs {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .app.view-docs .docs-header {
    position: sticky;
    top: 0;
    z-index: 6;
    background: rgba(10, 12, 18, 0.96);
    backdrop-filter: blur(12px);
  }

  .app.view-docs .docs-list {
    max-height: none;
    flex: 0 0 auto;
    overflow: visible;
  }

  .app.view-docs .docs-detail {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
    padding-bottom: 0.5rem;
  }

  .app.view-docs .catalog-bar {
    position: sticky;
    bottom: 0;
    z-index: 6;
    background: rgba(8, 10, 14, 0.96);
    backdrop-filter: blur(12px);
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  }

  .docs-header h2 {
    font-size: 0.82rem;
  }

  .catalog-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .btn-catalog {
    width: 100%;
    min-height: 2.75rem;
  }

  /* Index : une seule colonne scrollable (plus de panneaux imbriqués) */
  .app.view-index .pane-index {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .app.view-index .index-prefs {
    flex-shrink: 0;
  }

  .app.view-index .index-main {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
    border-bottom: 1px solid var(--border);
  }

  .app.view-index .index-viz-body {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
  }

  .app.view-index .index-viz-panel.active {
    display: block;
    min-height: auto;
    overflow: visible;
  }

  .app.view-index .index-grid,
  .app.view-index .index-tree,
  .app.view-index .index-treemap {
    overflow: visible;
    flex: none;
    min-height: auto;
  }

  .app.view-index .index-section {
    overflow: visible;
    max-height: none;
    flex-shrink: 0;
  }

  .app.view-index .index-journal {
    max-height: none;
  }

  /* Index : colonnes et aperçu fichier en sheet */
  .index-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1rem;
  }

  .index-hero-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .index-hero-actions .btn-index-primary,
  .index-hero-actions .btn-index-secondary {
    flex: 1 1 auto;
    min-height: 2.75rem;
  }

  .index-prefs {
    margin: 0.65rem 0.85rem 0;
  }

  .index-grid {
    grid-template-columns: 1fr;
    padding: 0.75rem 0.85rem;
  }

  .index-viz-toolbar {
    padding: 0.5rem 0.85rem;
    align-items: stretch;
  }

  .index-viz-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .index-viz-tab {
    flex: 1;
    text-align: center;
    min-height: 2.25rem;
  }

  .index-viz-search-wrap {
    max-width: none;
    width: 100%;
  }

  .index-viz-stats {
    margin-left: 0;
    width: 100%;
    white-space: normal;
  }

  .index-viz-split {
    flex-direction: column;
  }

  .index-file-preview {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 0;
    max-height: min(58vh, 520px);
    border-left: none;
    border-top: 1px solid var(--border);
    z-index: 90;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .index-section {
    padding: 0.5rem 0.85rem 1rem;
  }

  .app.view-index .pane-index > .index-section:last-of-type {
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  }

  .discovered-row {
    grid-template-columns: 1fr;
  }

  .discovered-actions {
    align-items: stretch;
  }

  /* Treemap : grilles portrait / barres paysage (mobile uniquement) */
  .index-treemap {
    padding: 0.65rem 0.85rem 1rem;
  }

  .index-treemap-legend {
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.65rem;
  }

  .index-treemap-legend-item {
    font-size: 0.62rem;
  }

  .index-treemap-source {
    margin-bottom: 1rem;
  }

  .index-treemap-source-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    margin-bottom: 0.5rem;
  }

  .index-treemap-source-head span {
    word-break: break-word;
  }

  .index-treemap-row--portrait {
    display: grid;
    grid-template-columns: repeat(var(--treemap-cols, 6), minmax(0, 1fr));
    gap: 4px;
    min-height: auto;
    overflow: visible;
  }

  .index-treemap-row--portrait .index-treemap-cell {
    flex: unset !important;
    min-width: 0;
    min-height: 3.75rem;
    padding: 0.35rem 0.3rem;
  }

  .index-treemap-row--landscape {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 4px;
    min-height: auto;
    overflow: visible;
  }

  .index-treemap-row--landscape .index-treemap-cell {
    min-height: 2.85rem;
    max-height: 4.5rem;
  }

  .index-treemap-cell-count {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.55rem;
    font-weight: 700;
    font-family: var(--mono);
    color: rgba(255, 255, 255, 0.82);
    line-height: 1;
  }

  .index-treemap-cell-label {
    font-size: 0.58rem;
    line-height: 1.15;
    -webkit-line-clamp: 3;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .index-treemap-cell:hover {
    transform: none;
  }

  /* Chat */
  .chat-header {
    padding: 0.65rem 0.85rem;
    gap: 0.5rem;
  }

  .chat-header-info {
    font-size: 0.72rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .messages {
    padding: 1rem 0.75rem;
  }

  .welcome {
    margin: 2rem auto 1.5rem;
    padding: 0 0.35rem;
  }

  .welcome h2 {
    font-size: 1.15rem;
  }

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

  .suggestion {
    min-height: 2.75rem;
  }

  .composer {
    padding: 0.65rem 0.75rem max(0.65rem, env(safe-area-inset-bottom, 0px));
  }

  .composer-inner {
    align-items: flex-end;
  }

  .composer-hint-full {
    display: none;
  }

  #question-input,
  .select,
  .input-text,
  .index-viz-search {
    font-size: 16px;
  }

  .btn-mic,
  .btn-send {
    width: 44px;
    height: 44px;
  }

  .btn-index-mini,
  .btn-ghost,
  .stt-stack-actions .btn-index-mini {
    min-height: 2.5rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }

  .add-source-dialog {
    max-width: none;
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
  }

  .add-source-dialog form {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
  }

  .add-source-foot {
    flex-wrap: wrap;
  }

  .add-source-foot .btn-index-primary,
  .add-source-foot .btn-index-secondary {
    flex: 1 1 auto;
    min-height: 2.75rem;
  }
}

@media (max-width: 420px) {
  .app-brand-name {
    display: none;
  }

  .view-tabs {
    max-width: 62vw;
  }
}
