/* CodexIQ Design System v9 — active from Phase 4d-1 (June 2026).
   Applied: login (4d-1). Shell/dashboard/admin/ingest: Phase 4d-2+.
   Theme: data-theme="light"|"dark" on <html>. Canonical toggle via JS + localStorage.
   Lens widget rings: lens-dots-*.png in static/images/ (idle/ambient/recording). */


/* ──────────────────────────────────────────────
   CodexIQ — Theme tokens
   light = default, dark = [data-theme="dark"]
────────────────────────────────────────────── */

[data-theme="light"] {
  color-scheme: light;
  --bg:           #FAFAF7;
  --panel:        #FFFFFF;
  --sidebar:      #F4F2EE;
  --sidebar-soft: #EFEDE8;
  --statusbar:    #ECEAE4;
  --hover:        rgba(20,17,30,0.045);
  --active:       rgba(110,86,207,0.08);
  --t1: #1A1721;
  --t2: #56535F;
  --t3: #8C8995;
  --t4: #B5B2BC;
  --line:  rgba(20,17,30,0.08);
  --line2: rgba(20,17,30,0.14);
  --violet:      #4A3A9E;       /* matches brand IQ */
  --violet-2:    #6E56CF;
  --violet-deep: #382B7A;
  --violet-soft: #EEEAFB;
  --violet-line: rgba(74,58,158,0.22);
  --insight:     #C97B16;
  --tg-cyan:   #1F8A95;
  --tg-rose:   #B23A6C;
  --tg-moss:   #4A7A3F;
  --tg-indigo: #3E4FB5;
  --tg-plum:   #7A3B8A;
  --tg-gold:   #A1781D;
  --ok:    #2F8C5A;
  --warn:  #C97B16;
  --err:   #C04444;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #14121A;
  --panel:        #1B1822;
  --sidebar:      #1F1C26;
  --sidebar-soft: #25222D;
  --statusbar:    #221F2A;
  --hover:        rgba(255,255,255,0.045);
  --active:       rgba(155,140,235,0.13);
  --t1: #ECEAF0;
  --t2: #A6A2AE;
  --t3: #6F6B79;
  --t4: #45424E;
  --line:  rgba(255,255,255,0.07);
  --line2: rgba(255,255,255,0.13);
  --violet:      #9B8CEB;
  --violet-2:    #8470DD;
  --violet-deep: #B5A8F0;
  --violet-soft: rgba(155,140,235,0.10);
  --violet-line: rgba(155,140,235,0.30);
  --insight:     #E0A858;
  --tg-cyan:   #4DBAC4;
  --tg-rose:   #DA6692;
  --tg-moss:   #82B374;
  --tg-indigo: #7A8AEA;
  --tg-plum:   #B57AC4;
  --tg-gold:   #D4AC54;
  --ok:    #5CCB8A;
  --warn:  #E0A858;
  --err:   #E47373;
}

/* Box-sizing: safe to apply globally when data-theme is present */
[data-theme] *, [data-theme] *::before, [data-theme] *::after {
  box-sizing: border-box;
}
/* Margin/padding reset: scoped to v9 layout containers only.
   Prevents breaking legacy page layouts (admin, ingest, dashboard)
   when data-theme is on <html> for shell theming before full migration. */
[data-theme] .cx-shell *,
[data-theme] .cx-shell *::before,
[data-theme] .cx-shell *::after {
  margin: 0; padding: 0;
}
/* Base theme rule: font-family + color + bg on <html>.
   font-size intentionally omitted — set only on .cx-shell to avoid
   breaking rem calculations on legacy pages that use codexiq.css rem units.
   button reset scoped to .cx-shell to avoid overriding codexiq.css .btn styles. */
[data-theme] {
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02","cv03","cv04","cv11";
  width: 100%; height: 100%;
  position: relative;
}
[data-theme] .cx-shell { font-size: 13px; }
[data-theme] .cx-shell button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
[data-theme] .cx-shell input  { font: inherit; }
[data-theme] input  { font: inherit; }
[data-theme] ::-webkit-scrollbar { width: 6px; height: 6px; }
[data-theme] ::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.25); border-radius: 999px; }
[data-theme] ::-webkit-scrollbar-track { background: transparent; }

/* ── Shell ── */
.cx-shell {
  width: 100%; height: 100%;
  display: grid;
  grid-template-columns: var(--left-w, 256px) 1fr var(--right-w, 44px);
  grid-template-rows: 1fr 28px;
  background: var(--bg);
  position: relative;
  --left-w: 256px;
  --right-w: 44px;
}
.cx-shell.expanded { --right-w: 320px; }

/* Drag handles */
.drag-handle {
  position: absolute;
  top: 0; bottom: 28px;
  width: 5px;
  cursor: col-resize;
  z-index: 50;
  transform: translateX(-2px);
  transition: background 140ms;
}
.drag-handle::before {
  content: ''; position: absolute;
  left: 2px; top: 50%; transform: translateY(-50%);
  width: 1px; height: 38px;
  background: var(--line2);
  transition: background 140ms, height 140ms;
  border-radius: 1px;
}
.drag-handle.hover {
  background: var(--violet-line);
}
.drag-handle.hover::before {
  background: var(--violet);
  width: 2px;
  height: 64px;
  left: 1.5px;
  box-shadow: 0 0 0 1px var(--violet-line);
}
.drag-left  { left: var(--left-w); }
.drag-right { left: calc(100% - var(--right-w)); }

/* Divider hover label */
.drag-label {
  position: absolute;
  top: 50%; left: 12px;
  transform: translateY(-50%);
  background: var(--t1);
  color: var(--bg);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  display: flex; align-items: center; gap: 5px;
}
.drag-label::before {
  content: ''; width: 0; height: 0;
  border: 4px solid transparent;
  border-right-color: var(--t1);
  position: absolute; right: 100%; top: 50%;
  transform: translateY(-50%);
}
.drag-label svg { width: 10px; height: 10px; }

/* ──────────────────────────────────────────────
   LEFT PANEL
────────────────────────────────────────────── */
.cx-left {
  grid-column: 1; grid-row: 1;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}

.cx-brandbar {
  min-height: 56px;
  padding: 10px 12px 8px;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
}
.cx-brandbar img {
  width: 140px; height: auto;
  display: block;
}

.cx-left-head {
  padding: 8px 9px 4px;
  display: flex; flex-direction: column; gap: 5px;
}

.cx-search {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.cx-search svg { width: 11px; height: 11px; color: var(--t3); flex-shrink: 0; }
.cx-search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 12px; color: var(--t1);
}
.cx-search input::placeholder { color: var(--t4); }
.kbd {
  font-family: "JetBrains Mono", monospace; font-size: 9.5px;
  color: var(--t3); padding: 1px 4px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--sidebar-soft);
}

.cx-left-tools {
  display: flex; align-items: center; gap: 1px;
  padding: 1px 5px 3px;
}
.tool-btn {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  color: var(--t2);
  transition: background 120ms, color 120ms;
}
.tool-btn:hover { background: var(--hover); color: var(--t1); }
.tool-btn svg { width: 12px; height: 12px; }
.tool-spacer { flex: 1; }
.new-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px 0 6px;
  border-radius: 4px;
  background: var(--violet);
  color: #fff; font-size: 11px; font-weight: 600;
}
.new-btn:hover { background: var(--violet-deep); }
.new-btn svg { width: 10px; height: 10px; }

.cx-tree { flex: 1; overflow-y: auto; padding: 2px 4px 6px; min-height: 0; }

.section-head {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px 3px 4px;
  margin: 4px 0 1px;
  font-size: 10.5px; font-weight: 700;
  color: var(--t3); text-transform: uppercase; letter-spacing: 0.07em;
  user-select: none;
}
.section-head .chev { width: 9px; height: 9px; color: var(--t4); flex-shrink: 0; }
.section-head.collapsed .chev { transform: rotate(-90deg); }
.section-head .count { margin-left: auto; font-family: "JetBrains Mono", monospace; font-size: 9.5px; color: var(--t4); font-weight: 500; }

.codex-head {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 7px 3px 5px;
  border-radius: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.005em;
  cursor: pointer;
}
.codex-head:hover { background: var(--hover); }
.codex-head .chev { width: 9px; height: 9px; color: var(--t3); flex-shrink: 0; transition: transform 120ms; }
.codex-head.collapsed .chev { transform: rotate(-90deg); }
.codex-icon { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.codex-count { margin-left: auto; font-family: "JetBrains Mono", monospace; font-size: 9.5px; color: var(--t4); }

.row {
  display: flex; align-items: center; gap: 5px;
  height: 21px;
  padding: 0 8px 0 6px;
  border-radius: 4px;
  color: var(--t1);
  font-size: 12px;
  position: relative;
  cursor: pointer;
}
.row:hover { background: var(--hover); }
.row.node { font-weight: 600; }
.row.node .node-chip { width: 3px; height: 12px; border-radius: 2px; flex-shrink: 0; }
.row.glyph { font-weight: 400; font-size: 11.75px; color: var(--t2); }
.row.glyph .gdot { width: 4px; height: 4px; border-radius: 50%; background: var(--t4); flex-shrink: 0; margin: 0 4px 0 1px; }
.row.insight { font-weight: 400; font-size: 11.75px; color: var(--t2); }
.row.insight .gdot {
  width: 11px; height: 11px; color: var(--insight);
  background: none; margin: 0 1px 0 -1px;
  display: grid; place-items: center; border-radius: 0;
}
.row.insight .gdot svg { width: 11px; height: 11px; }
.row.active { background: var(--active); color: var(--violet-deep); }
.row.node.active { color: var(--violet-deep); font-weight: 700; }
.row.active::before {
  content: ''; position: absolute; left: -3px; top: 3px; bottom: 3px;
  width: 2px; background: var(--violet); border-radius: 2px;
}
.row .chev { width: 8px; height: 8px; color: var(--t4); flex-shrink: 0; transition: transform 120ms; }
.row.collapsed .chev { transform: rotate(-90deg); }
.row .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-family: "JetBrains Mono", monospace; font-size: 9px; color: var(--t4); }
.row.active .meta { color: var(--violet); }

.nest { padding-left: 10px; position: relative; }
.nest::before {
  content: ''; position: absolute; left: 9px; top: 0; bottom: 0;
  width: 1px; background: var(--line);
}
.nest-2 { padding-left: 18px; }
.nest-2::before { left: 17px; }

.fav-list { padding: 0 2px; }
.fav-row {
  display: flex; align-items: center; gap: 6px;
  height: 21px; padding: 0 6px 0 5px;
  border-radius: 4px;
  font-size: 11.75px;
  color: var(--t1);
  font-weight: 500;
  cursor: pointer;
}
.fav-row:hover { background: var(--hover); }
.fav-row .drag-grip {
  width: 9px; opacity: 0; color: var(--t4);
  display: grid; place-items: center;
  cursor: grab; flex-shrink: 0;
  transition: opacity 120ms;
  margin-left: -2px;
}
.fav-row:hover .drag-grip { opacity: 1; }
.fav-row .drag-grip svg { width: 9px; height: 9px; }
.fav-row .codex-mini { width: 4px; height: 10px; border-radius: 1px; flex-shrink: 0; }
.fav-row .fav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-row .star-fill { color: var(--warn); margin-left: auto; display: grid; place-items: center; }
.fav-row .star-fill svg { width: 9px; height: 9px; }

/* Hover star on every tree row */
.row .row-star {
  display: grid; place-items: center;
  width: 15px; height: 15px;
  border-radius: 3px;
  color: var(--t4);
  opacity: 0;
  margin-right: -3px;
  flex-shrink: 0;
  transition: opacity 120ms, color 120ms;
}
.row:hover .row-star { opacity: 0.65; }
.row .row-star:hover { opacity: 1; color: var(--warn); background: var(--hover); }
.row .row-star.filled { opacity: 1; color: var(--warn); }
.row .row-star svg { width: 11px; height: 11px; }

.cx-account {
  border-top: 1px solid var(--line);
  padding: 7px 8px 9px;
  background: var(--sidebar);
  display: flex; align-items: center; gap: 8px;
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet-2), var(--tg-rose));
  color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--t3); margin-top: 1px; }
.tier {
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 4px; border-radius: 3px;
  background: var(--violet-soft); color: var(--violet);
  text-transform: uppercase;
}

/* ──────────────────────────────────────────────
   CENTER PANEL
────────────────────────────────────────────── */
.cx-center { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.tabstrip {
  display: flex; align-items: stretch;
  height: 36px;
  padding: 6px 8px 0;
  gap: 1px;
  background: var(--sidebar-soft);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 0 10px 0 11px;
  height: 30px;
  border-radius: 6px 6px 0 0;
  color: var(--t2);
  font-size: 11.5px; font-weight: 500;
  border: 1px solid transparent;
  border-bottom: 0;
  cursor: pointer;
  position: relative;
}
.tab:hover { background: var(--hover); color: var(--t1); }
.tab.active { background: var(--panel); color: var(--t1); border-color: var(--line); font-weight: 600; }
.tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--panel); }
.tab .tab-ic { width: 12px; height: 12px; flex-shrink: 0; }

/* Tab group — colored underbar spanning all tabs */
.tab-group {
  display: flex; align-items: stretch;
  position: relative;
  margin-left: 6px;
  padding-top: 3px;
  --tg-color: var(--tg-cyan);
}
.tab-group::before {
  /* top color indicator strip */
  content: ''; position: absolute;
  left: 4px; right: 4px; top: 0; height: 3px;
  background: var(--tg-color);
  border-radius: 2px 2px 0 0;
}
.tab-group::after {
  /* bottom underbar — spans entire group, sits below the tab strip baseline */
  content: ''; position: absolute;
  left: 0; right: 0; bottom: -3px; height: 2px;
  background: var(--tg-color);
  border-radius: 1px;
  opacity: 0.85;
}
.tab-group .tab-parent {
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 10px;
  height: 30px; line-height: 1.2; overflow: hidden;
  border-radius: 5px 5px 0 0;
  background: color-mix(in srgb, var(--tg-color) 12%, transparent);
  color: var(--tg-color);
  font-weight: 600; font-size: 11.5px;
  border: 1px solid color-mix(in srgb, var(--tg-color) 22%, transparent);
  border-bottom: 0;
  cursor: pointer;
}
.tab-group .tab-parent .group-swatch {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--tg-color);
  border: 1px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.tab-group .tab-parent .group-chev { width: 9px; height: 9px; opacity: 0.6; }
.tab-child {
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px 0 11px;
  height: 30px; line-height: 1.2; overflow: hidden;
  border-radius: 5px 5px 0 0;
  background: color-mix(in srgb, var(--tg-color) 7%, transparent);
  color: var(--t2);
  font-size: 11.5px;
  border: 1px solid color-mix(in srgb, var(--tg-color) 16%, transparent);
  border-left: 0;
  border-bottom: 0;
  cursor: pointer;
  position: relative;
}
.tab-child:hover { background: color-mix(in srgb, var(--tg-color) 12%, transparent); color: var(--t1); }
.tab-child.active { background: var(--panel); color: var(--t1); font-weight: 600; }
.tab-child.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--panel); }
.tab-child .glyph-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--insight); flex-shrink: 0; }
.tab-child .close { display: grid; place-items: center; width: 14px; height: 14px; border-radius: 3px; color: var(--t4); margin-right: -3px; }
.tab-child .close:hover { background: var(--hover); color: var(--t1); }
.tab-child .close svg { width: 8px; height: 8px; }

.tab-label {
  flex: 1; min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tab-new {
  display: grid; place-items: center;
  width: 26px; height: 27px;
  margin: 3px 0 0 6px;
  border-radius: 5px;
  color: var(--t3);
  align-self: flex-start;
}
.tab-new:hover { background: var(--hover); color: var(--t1); }
.tab-new svg { width: 12px; height: 12px; }

.toolbar {
  display: flex; align-items: center; gap: 1px;
  height: 36px;
  padding: 0 16px 0 36px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tb-btn { display: grid; place-items: center; width: 28px; height: 26px; border-radius: 4px; color: var(--t2); }
.tb-btn:hover { background: var(--hover); color: var(--t1); }
.tb-btn.text { width: auto; padding: 0 8px; font-size: 11.5px; font-weight: 600; }
.tb-btn svg { width: 13px; height: 13px; }
.tb-divider { width: 1px; height: 16px; background: var(--line); margin: 0 6px; }
.tb-end { flex: 1; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--t3); }
.breadcrumbs .sep { color: var(--t4); }
.breadcrumbs .current { color: var(--t1); font-weight: 500; }

.doc { flex: 1; overflow-y: auto; background: var(--panel); min-height: 0; }
.doc-inner { max-width: 860px; padding: 28px 48px 80px 36px; }
.doc-title { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; color: var(--t1); margin-bottom: 16px; line-height: 1.15; }

.props { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0 12px; margin-bottom: 20px; }
.props-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; padding: 4px 0; min-height: 24px; }
.props-label { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--t3); font-weight: 500; }
.props-label svg { width: 12px; height: 12px; color: var(--t4); }
.props-value { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12.5px; color: var(--t1); }

.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 5px 0 8px; border-radius: 999px; font-size: 11px; font-weight: 500; border: 1px solid transparent; }
.pill .x { display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; opacity: 0.5; }
.pill .x svg { width: 8px; height: 8px; }
.pill .weight { font-family: "JetBrains Mono", monospace; font-size: 9.5px; padding: 0 4px; background: rgba(255,255,255,0.55); border-radius: 999px; opacity: 0.85; }

[data-theme="light"] .prism-1 { background: oklch(0.92 0.08 280); color: oklch(0.38 0.12 280); border-color: oklch(0.85 0.10 280); }
[data-theme="light"] .prism-2 { background: oklch(0.92 0.08 30);  color: oklch(0.38 0.12 30);  border-color: oklch(0.85 0.10 30); }
[data-theme="light"] .prism-3 { background: oklch(0.92 0.08 150); color: oklch(0.38 0.12 150); border-color: oklch(0.85 0.10 150); }
[data-theme="light"] .prism-4 { background: oklch(0.92 0.08 210); color: oklch(0.38 0.12 210); border-color: oklch(0.85 0.10 210); }

[data-theme="dark"] .prism-1 { background: oklch(0.28 0.10 280); color: oklch(0.82 0.14 280); border-color: oklch(0.38 0.12 280); }
[data-theme="dark"] .prism-2 { background: oklch(0.28 0.10 30);  color: oklch(0.82 0.14 30);  border-color: oklch(0.38 0.12 30); }
[data-theme="dark"] .prism-3 { background: oklch(0.28 0.10 150); color: oklch(0.82 0.14 150); border-color: oklch(0.38 0.12 150); }
[data-theme="dark"] .prism-4 { background: oklch(0.28 0.10 210); color: oklch(0.82 0.14 210); border-color: oklch(0.38 0.12 210); }
[data-theme="dark"] .pill .weight { background: rgba(255,255,255,0.10); }

.prism-add { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; color: var(--t3); border: 1px dashed var(--line2); }
.prism-add:hover { color: var(--violet); border-color: var(--violet-line); background: var(--violet-soft); }
.prism-add svg { width: 9px; height: 9px; }

.codex-link { display: inline-flex; align-items: center; gap: 5px; color: var(--t1); border-bottom: 1px dotted var(--line2); padding-bottom: 1px; }
.codex-link::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--tg-rose); }
.mono-prop { font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--t2); }

.add-property { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--t3); padding: 4px 0; margin-top: 4px; }
.add-property:hover { color: var(--violet); }
.add-property svg { width: 10px; height: 10px; }

.ai-summary {
  position: relative;
  margin-bottom: 22px;
  padding: 12px 16px 12px 18px;
  background: var(--violet-soft);
  border-radius: 8px;
  border: 1px solid var(--violet-line);
}
.ai-summary::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--violet); border-radius: 2px; }
.ai-head { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.ai-label { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; color: var(--violet); letter-spacing: 0.06em; text-transform: uppercase; }
.ai-label svg { width: 11px; height: 11px; }
.ai-stamp { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--t3); margin-left: 4px; }
.ai-refresh { margin-left: auto; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; color: var(--violet); }
.ai-text { font-size: 13.5px; color: var(--t1); line-height: 1.55; text-wrap: pretty; }
[data-theme="dark"] .ai-text { color: #DCD8E5; }

.glyph-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.glyph-section-title { font-size: 10.5px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.08em; }
.glyph-section-count { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--t4); }
.glyph-section-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.gs-input { display: flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; background: var(--sidebar); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; color: var(--t3); width: 150px; }
.gs-input svg { width: 10px; height: 10px; }
.gs-input input { border: 0; background: transparent; outline: 0; flex: 1; font-size: 11px; color: var(--t1); }
.gs-btn { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11px; color: var(--t2); border: 1px solid var(--line); background: var(--panel); }
.gs-btn svg { width: 10px; height: 10px; }

.glyph-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.gl-headrow { display: grid; grid-template-columns: 20px 1fr 70px 78px; gap: 10px; padding: 6px 12px; background: var(--sidebar); border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: 0.05em; }
.gl-row { display: grid; grid-template-columns: 20px 1fr 70px 78px; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.gl-row:last-child { border-bottom: 0; }
.gl-row:hover { background: var(--sidebar); }
.gl-check { width: 13px; height: 13px; border: 1.5px solid var(--line2); border-radius: 3px; flex-shrink: 0; }
.gl-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gl-type { width: 12px; height: 12px; flex-shrink: 0; display: grid; place-items: center; color: var(--t4); }
.gl-type svg { width: 11px; height: 11px; }
.gl-row.is-insight .gl-type { color: var(--insight); }
.gl-title { font-size: 12.5px; font-weight: 600; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; max-width: 200px; }
.gl-preview { font-size: 11.75px; color: var(--t3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gl-prisms { display: flex; align-items: center; gap: 3px; }
.gl-prism-dot { width: 6px; height: 6px; border-radius: 50%; }
.gl-date { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--t3); text-align: right; }

/* ──────────────────────────────────────────────
   RIGHT — Smart Panel (collapsed icon strip + expanded)
────────────────────────────────────────────── */
.cx-right {
  grid-column: 3; grid-row: 1;
  background: var(--sidebar);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}

/* Collapsed: 44px icon strip */
.cx-right.collapsed {
  align-items: center;
  padding: 6px 0;
}
.rail-btn {
  width: 32px; height: 36px;
  display: grid; place-items: center;
  color: var(--t3);
  margin-bottom: 1px;
  position: relative;
  cursor: pointer;
  border-radius: 4px;
}
.rail-btn:hover { color: var(--t1); background: var(--hover); }
.rail-btn.active { color: var(--violet); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--violet); border-radius: 0 2px 2px 0;
}
.rail-btn svg { width: 17px; height: 17px; }
.rail-btn .dot {
  position: absolute; top: 5px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--violet);
  border: 1.5px solid var(--sidebar);
}
.rail-spacer { flex: 1; }
.rail-tip {
  position: absolute; right: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  background: var(--t1);
  color: var(--bg);
  font-size: 11px; font-weight: 500;
  padding: 4px 8px; border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.18);
  z-index: 60;
}
.rail-tip::after {
  content: ''; position: absolute; left: 100%; top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-left-color: var(--t1);
}

/* Expanded: full panel */
.cx-right.expanded {
  padding: 0;
}
.sp-head {
  display: flex; align-items: center;
  height: 36px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--sidebar);
  gap: 6px;
}
.sp-head .sp-title { font-size: 11px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.08em; }
.sp-head .sp-actions { margin-left: auto; display: flex; gap: 1px; }
.sp-head .sp-actions .tool-btn { color: var(--t3); }
.sp-head .sp-actions .tool-btn.pinned { color: var(--violet); background: var(--violet-soft); }
.sp-tabs {
  display: flex; align-items: stretch;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--sidebar);
  gap: 2px;
}
.sp-tab {
  display: flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 9px;
  font-size: 11px; font-weight: 500;
  color: var(--t3);
  cursor: pointer;
  position: relative;
}
.sp-tab.active { color: var(--t1); font-weight: 600; }
.sp-tab.active::after {
  content: ''; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px;
  background: var(--violet); border-radius: 2px;
}
.sp-tab .sp-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--violet-soft);
  color: var(--violet);
  font-weight: 600;
}
.sp-tab svg { width: 12px; height: 12px; opacity: 0.7; }
.sp-body { flex: 1; overflow-y: auto; min-height: 0; padding: 12px 14px 16px; }

.sp-section { margin-bottom: 20px; }
.sp-section-head {
  display: flex; align-items: baseline; gap: 6px;
  margin-bottom: 8px;
}
.sp-section-title { font-size: 10.5px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.07em; }
.sp-section-count { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--t4); }
.sp-section-action { margin-left: auto; font-size: 10.5px; color: var(--violet); font-weight: 600; cursor: pointer; }
.sp-section-action:hover { text-decoration: underline; }

.sp-card {
  padding: 9px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
}
.sp-card:hover { border-color: var(--line2); }

.sp-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.sp-card-chip { width: 3px; height: 11px; border-radius: 1.5px; flex-shrink: 0; }
.sp-card-title { font-size: 12px; font-weight: 600; color: var(--t1); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-card-score {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; color: var(--t3);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--hover);
}
.sp-card-meta { font-size: 11px; color: var(--t3); }
.sp-card-meta strong { color: var(--t2); font-weight: 600; }

/* Prism rec card */
.sp-prism-card {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 6px;
}
.sp-prism-card .sp-prism-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sp-prism-card .sp-prism-name { font-size: 12px; font-weight: 600; color: var(--t1); flex: 1; }
.sp-prism-card .sp-prism-conf { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--t3); }
.sp-prism-actions { display: flex; gap: 4px; }
.sp-mini-btn {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 4px;
  color: var(--t3);
  border: 1px solid var(--line);
  background: var(--bg);
}
.sp-mini-btn:hover { color: var(--t1); border-color: var(--line2); }
.sp-mini-btn.accept { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.sp-mini-btn svg { width: 11px; height: 11px; }

/* Insight card */
.sp-insight {
  position: relative;
  padding: 10px 12px 10px 14px;
  background: color-mix(in srgb, var(--insight) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--insight) 22%, transparent);
  border-radius: 6px;
  margin-bottom: 6px;
}
.sp-insight::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 2px; background: var(--insight); border-radius: 2px;
}
.sp-insight-head { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.sp-insight-icon { color: var(--insight); display: grid; place-items: center; }
.sp-insight-icon svg { width: 11px; height: 11px; }
.sp-insight-title { font-size: 12px; font-weight: 700; color: var(--t1); flex: 1; }
.sp-insight-meta { font-family: "JetBrains Mono", monospace; font-size: 9.5px; color: var(--t3); }
.sp-insight-text { font-size: 11.5px; color: var(--t2); line-height: 1.5; text-wrap: pretty; }

/* ──────────────────────────────────────────────
   STATUS BAR
────────────────────────────────────────────── */
.statusbar {
  grid-column: 1 / span 3; grid-row: 2;
  display: flex; align-items: center;
  height: 28px; padding: 0 10px;
  background: var(--statusbar);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--t2);
  gap: 4px;
}
.sb-toggle { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 9px; border-radius: 999px; background: color-mix(in srgb, var(--panel) 55%, transparent); border: 1px solid var(--line); font-size: 10.5px; font-weight: 500; }
.sb-toggle .sb-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px color-mix(in srgb, var(--ok) 50%, transparent); }
.sb-segmented { display: inline-flex; align-items: stretch; height: 20px; border-radius: 999px; background: color-mix(in srgb, var(--panel) 55%, transparent); border: 1px solid var(--line); padding: 1px; }
.sb-seg { display: inline-flex; align-items: center; gap: 5px; padding: 0 9px; border-radius: 999px; font-size: 10.5px; font-weight: 500; color: var(--t3); }
.sb-seg.active { background: var(--violet); color: #fff; }
.sb-seg .sb-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.ai-gauge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px; border-radius: 999px; background: color-mix(in srgb, var(--panel) 55%, transparent); border: 1px solid var(--line); color: var(--t2); font-family: "JetBrains Mono", monospace; font-size: 10px; cursor: pointer; }
.ai-gauge .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.ai-gauge .bar { width: 28px; height: 4px; background: var(--line2); border-radius: 2px; overflow: hidden; position: relative; }
.ai-gauge .bar::after { content: ''; position: absolute; inset: 0; width: 62%; background: var(--warn); border-radius: 2px; }
.sb-divider { width: 1px; height: 14px; background: var(--line); margin: 0 4px; }
.sb-text { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--t3); display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; }
.sb-end { flex: 1; }
.sb-btn { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 4px; color: var(--t2); font-size: 10.5px; }
.sb-btn:hover { background: var(--hover); color: var(--t1); }
.sb-btn svg { width: 11px; height: 11px; }
.sb-badge { background: var(--err); color: #fff; font-family: "JetBrains Mono", monospace; font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 999px; min-width: 14px; text-align: center; line-height: 13px; }

/* ──────────────────────────────────────────────
   AI USAGE METER — color-coded, with hover tooltip
────────────────────────────────────────────── */
.ai-meter {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  border: 1px solid var(--line);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px; color: var(--t2);
  cursor: pointer;
  --meter-color: var(--ok);
}
.ai-meter:hover { background: var(--panel); }
.ai-meter.ok   { --meter-color: var(--ok); }
.ai-meter.warn { --meter-color: var(--warn); }
.ai-meter.high { --meter-color: #D86A2A; }
.ai-meter.crit { --meter-color: var(--err); }
.ai-meter .meter-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--meter-color);
  flex-shrink: 0;
  box-shadow: 0 0 5px color-mix(in srgb, var(--meter-color) 55%, transparent);
}
.ai-meter .meter-track {
  width: 34px; height: 4px;
  background: var(--line2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.ai-meter .meter-fill {
  position: absolute; inset: 0;
  background: var(--meter-color);
  border-radius: 2px;
}
.ai-meter .meter-label { color: var(--t2); letter-spacing: -0.02em; }

/* Tooltip popover (opens upward from the status bar) */
.ai-meter-pop {
  position: absolute; bottom: calc(100% + 9px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 224px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.16);
  padding: 12px;
  opacity: 0; pointer-events: none;
  transition: opacity 140ms, transform 140ms;
  z-index: 300;
  text-align: left;
  font-family: "Inter Tight", sans-serif;
}
.ai-meter:hover .ai-meter-pop { opacity: 1; transform: translateX(-50%) translateY(0); }
.ai-meter-pop::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--panel);
}
.amp-row { display: flex; justify-content: space-between; align-items: baseline; }
.amp-title { font-size: 10.5px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.05em; }
.amp-pct { font-size: 14px; font-weight: 700; color: var(--meter-color); font-family: "Inter Tight"; }
.amp-bar { height: 6px; background: var(--line); border-radius: 999px; margin: 9px 0 7px; overflow: hidden; }
.amp-bar-fill { height: 100%; border-radius: 999px; background: var(--meter-color); }
.amp-foot { font-size: 11px; color: var(--t3); display: flex; justify-content: space-between; }
.amp-foot + .amp-foot { margin-top: 2px; }
.amp-link { display: block; margin: 9px -12px -12px; font-size: 11px; color: var(--violet); font-weight: 600; text-align: center; padding: 6px 0; border-top: 1px solid var(--line); }
.amp-link:hover { background: var(--violet-soft); }

/* ──────────────────────────────────────────────
   LENS WIDGET — floating, repositionable overlay
────────────────────────────────────────────── */
.lens-widget {
  position: absolute;
  z-index: 400;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  width: 53px; height: 53px;
  --lens-ink: #837c72;
  touch-action: none;
}

/* ── Radial fly-out menu — buttons emerge from the ring ── */
.lens-radial { position: absolute; inset: 0; pointer-events: none; }
/* invisible hover bridge — only active while open, so the pointer can
   travel from the ring out to the pills without the menu closing */
.lens-widget::before {
  content: ''; position: absolute;
  left: 50%; top: 50%;
  width: 230px; height: 230px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}
.lens-widget.menu-open::before { pointer-events: auto; }
.lens-widget .lens-rb {
  position: absolute; left: 50%; top: 50%;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
  font-size: 11px; font-weight: 600; color: var(--t1);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -50%) scale(0.4);
  transition: transform 240ms cubic-bezier(.2,.9,.25,1.25), opacity 180ms ease;
  z-index: 2;
}
.lens-rb .rb-ic {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--sidebar); color: var(--violet);
}
.lens-rb .rb-ic svg { width: 13px; height: 13px; }
.lens-rb.feedback .rb-ic { color: var(--tg-rose); }
.lens-rb:hover { background: var(--sidebar); border-color: var(--line2); }

.lens-rb.pos-capture  { --tx: 0px;   --ty: -52px; }
.lens-rb.pos-explore  { --tx: 80px;  --ty: 0px;   }
.lens-rb.pos-help     { --tx: 54px;  --ty: 50px;  }
.lens-rb.pos-feedback { --tx: -60px; --ty: 54px;  }

.lens-widget.menu-open .lens-rb {
  opacity: 1; pointer-events: auto;
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1);
}
/* staggered emergence */
.lens-widget.menu-open .lens-rb.pos-capture  { transition-delay: 0ms; }
.lens-widget.menu-open .lens-rb.pos-explore  { transition-delay: 45ms; }
.lens-widget.menu-open .lens-rb.pos-help     { transition-delay: 90ms; }
.lens-widget.menu-open .lens-rb.pos-feedback { transition-delay: 135ms; }

/* ── The FAB: transparent — the dot-ring icon floats freely ── */
.lens-widget .lens-fab {
  position: absolute; inset: 0;
  width: 53px; height: 53px;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: grab;
  display: grid; place-items: center;
  transition: transform 160ms;
}
.lens-fab:active { cursor: grabbing; }
.lens-widget:hover .lens-fab { transform: scale(1.03); }

.lens-graphic { position: absolute; inset: 0; width: 100%; height: 100%; }
.lens-dots-img {
  position: absolute;
  left: -13%; top: -13%;
  width: 126%; height: 126%;
  object-fit: contain;
  transform-origin: 50% 50%;
  animation: lens-spin 13s linear infinite;
  pointer-events: none; user-select: none;
}
.lens-symbol-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  color: var(--lens-ink);
  pointer-events: none;
}
.lens-symbol { transform-box: fill-box; transform-origin: center; transition: opacity 200ms; }
.lens-symbol--help { opacity: 0; }
.lens-widget:has(.lens-rb.pos-help:hover) .lens-symbol--main { opacity: 0; }
.lens-widget:has(.lens-rb.pos-help:hover) .lens-symbol--help { opacity: 1; }
@keyframes lens-spin { to { transform: rotate(360deg); } }

/* state tag */
.lens-state-tag {
  position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  margin-top: 9px;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  font-family: "JetBrains Mono", monospace;
  white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
  opacity: 0; transition: opacity 160ms;
}
.lens-ambient .lens-state-tag,
.lens-recording .lens-state-tag { opacity: 1; }
/* hide the state tag while the radial menu is open (avoids colliding with the bottom pills) */
.lens-widget.menu-open .lens-state-tag { opacity: 0; }
.lens-ambient .lens-state-tag { color: #fff; background: var(--violet-2); }
.lens-recording .lens-state-tag { color: #fff; background: var(--err); }

/* ── IDLE — slow spin, muted, unobtrusive ── */
.lens-idle { --lens-ink: #837c72; }
.lens-idle .lens-dots-img { animation-duration: 13s; }

/* ── AMBIENT ON — normal spin, violet, breathing symbol ── */
.lens-ambient { --lens-ink: var(--violet-2); }
.lens-ambient .lens-dots-img { animation-duration: 8s; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--violet-2) 45%, transparent)); }
.lens-ambient .lens-symbol--main { animation: lens-breathe 3s ease-in-out infinite; }
.lens-ambient .lens-symbol-svg { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--violet-2) 55%, transparent)); }
@keyframes lens-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ── SESSION RECORDING — fast spin, red, glow, flicker ── */
.lens-recording { --lens-ink: var(--err); }
.lens-recording .lens-dots-img {
  animation: lens-spin 3.4s linear infinite, lens-flicker 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--err) 60%, transparent));
}
.lens-recording .lens-symbol-svg { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--err) 80%, transparent)); }
@keyframes lens-flicker { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ──────────────────────────────────────────────
   Shared Shell Chrome — Phase 4d-2
   Header, nav, user area, command bar, AI mode.

   Load order: codexiq-design.css before codexiq.css.
   Specificity: [data-theme] .element = 0,1,1 always
   beats codexiq.css .element = 0,0,1 regardless of order.
   Tokens used: --panel, --statusbar, --line, --line2,
   --hover, --violet, --violet-soft, --violet-deep,
   --t1/t2/t3, --ok, --warn, --err, --violet-line, --insight.
   All these are ONLY in codexiq-design.css (not in codexiq.css),
   so there is no token name conflict.
────────────────────────────────────────────── */

/* Header bar */
[data-theme] .global-header {
  background: var(--panel);
  border-bottom-color: var(--line);
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Logo: light visible by default; dark hidden until [data-theme="dark"] */
.app-logo-dark { display: none; }
[data-theme="dark"] .app-logo-light { display: none; }
[data-theme="dark"] .app-logo-dark  { display: block; }

/* Nav links */
[data-theme] .app-nav-link {
  color: var(--t2);
  font-weight: 600;
}
[data-theme] .app-nav-link:hover {
  background: var(--hover);
  color: var(--t1);
}
[data-theme] .app-nav-link.is-active {
  background: var(--violet-soft);
  color: var(--violet-deep);
}

/* User area */
[data-theme] #current-user-email { color: var(--t3); }

/* Logout / secondary button in header */
[data-theme] .global-header .btn-secondary,
[data-theme] .global-header .secondary-button {
  background: var(--panel);
  color: var(--t1);
  border-color: var(--line2);
}
[data-theme] .global-header .btn-secondary:hover,
[data-theme] .global-header .secondary-button:hover {
  background: var(--hover);
}

/* Command / status bar */
[data-theme] .command-bar {
  background: var(--statusbar);
  border-bottom-color: var(--line);
  color: var(--t2);
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* AI mode control */
[data-theme] .ai-mode-control {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .ai-mode-label   { color: var(--t3); }
[data-theme] .ai-mode-toggle  { background: var(--sidebar); border-color: var(--line); }
[data-theme] .ai-mode-option  { color: var(--t2); }
[data-theme] .ai-mode-option.is-active { background: var(--violet); color: #fff; }

/* AI usage meter */
[data-theme] .ai-usage-progress { color: var(--t2); }
[data-theme] .ai-usage-track    { background: var(--line); }
[data-theme] .ai-usage-fill     { background: var(--ok); }
[data-theme] .ai-usage-progress.is-moderate .ai-usage-fill  { background: var(--warn); }
[data-theme] .ai-usage-progress.is-high     .ai-usage-fill  { background: var(--warn); }
[data-theme] .ai-usage-progress.is-exhausted .ai-usage-fill { background: var(--err); }

/* Processing / insights indicators */
[data-theme] .processing-indicator {
  background: color-mix(in srgb, var(--violet) 8%, var(--panel));
  color: var(--violet);
  border-color: var(--violet-line);
}
[data-theme] .insights-indicator {
  background: color-mix(in srgb, var(--insight) 10%, var(--panel));
  color: var(--insight);
  border-color: color-mix(in srgb, var(--insight) 30%, transparent);
}

/* ──────────────────────────────────────────────
   DASHBOARD BODY — Phase 4d-3a
   Panel surfaces, typography, borders for the three-panel layout.
   Scope: dashboard-unique classes overridden globally (safe);
   shared interactive elements scoped to panel containers.
   Specificity: [data-theme] .element = 0,1,1 > codexiq.css .element = 0,0,1

   Cascade note: codexiq.css :root { --bg, --text, --muted, --border… }
   loads AFTER this file at equal specificity (both 0-1-0), so those token
   names resolve to codexiq.css values. Only v9-unique tokens are used here
   (--panel, --sidebar, --sidebar-soft, --statusbar, --line, --line2,
   --t1/t2/t3/t4, --hover, --active, --violet, --violet-*,
   --insight, --ok, --warn, --err). Explicit dark hex values used only for
   body/page bg where --bg is conflicted.
────────────────────────────────────────────── */

/* Body / page baseline — explicit values needed because --bg / --text
   from codexiq.css :root win the specificity tie */
[data-theme="dark"] body  { background: #14121A; color: #ECEAF0; }
[data-theme="light"] body { background: #FAFAF7; }
[data-theme] .page        { background: var(--bg); }
[data-theme="dark"] .page { background: #14121A; }

/* ── Left panel ── */
[data-theme] .sidebar {
  background: var(--sidebar);
  border-right-color: var(--line);
}
[data-theme] .capture-panel {
  background: var(--sidebar);
  border-bottom-color: var(--line);
}
[data-theme] .capture-title { color: var(--t2); }
[data-theme] .capture-panel label { color: var(--t2); }
[data-theme] .capture-panel textarea {
  background: var(--sidebar-soft);
  color: var(--t1);
  border-color: var(--line);
}
[data-theme] .capture-panel textarea::placeholder { color: var(--t4); }
[data-theme] .capture-panel textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px var(--violet-line);
}
/* Nodes panel inside sidebar */
[data-theme] .sidebar > .panel {
  background: var(--sidebar);
  border-color: transparent;
}
[data-theme] .sidebar .section-heading-actions h2 { color: var(--t1); }
[data-theme] .sidebar select {
  background: var(--panel);
  color: var(--t1);
  border-color: var(--line);
}
/* Node list cards */
[data-theme] .item-card {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .item-card h3 { color: var(--t1); }
[data-theme] .item-card p  { color: var(--t2); }
[data-theme] .item-card.is-clickable:hover {
  background: var(--hover);
  border-color: var(--line2);
  box-shadow: none;
}
[data-theme] .item-card.is-selected {
  background: var(--active);
  border-color: var(--violet);
  box-shadow: inset 3px 0 0 var(--violet);
}
[data-theme] .item-card.is-selected:hover {
  background: var(--active);
  border-color: var(--violet);
}
/* Empty state */
[data-theme] .empty-state { color: var(--t3); }
/* Sidebar buttons */
[data-theme] .sidebar .icon-button,
[data-theme] .sidebar .btn-icon {
  background: var(--sidebar-soft);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .sidebar .icon-button:hover,
[data-theme] .sidebar .btn-icon:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .sidebar .btn-primary {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
[data-theme] .sidebar .btn-primary:hover {
  background: var(--violet-deep);
  border-color: var(--violet-deep);
}
[data-theme] .sidebar .btn-secondary,
[data-theme] .sidebar .secondary-button {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .sidebar .btn-secondary:hover,
[data-theme] .sidebar .secondary-button:hover { background: var(--hover); }
/* Trash / node-open buttons in sidebar (own classes, not icon-button) */
[data-theme] .sidebar .trash-button {
  background: var(--sidebar-soft);
  border-color: var(--line);
  color: var(--t3);
}
[data-theme] .sidebar .node-open-button {
  background: var(--sidebar-soft);
  border-color: var(--line);
  color: var(--t2);
}

/* ── Center panel (workspace) ── */
[data-theme] .workspace          { background: var(--panel); }
[data-theme] .workspace-header   { background: var(--panel); border-bottom-color: var(--line); }
[data-theme] .workspace-body     { background: var(--panel); }
[data-theme] .workspace-header h2 { color: var(--t1); }
[data-theme] .node-summary-card {
  background: var(--sidebar);
  border-color: var(--line);
}
[data-theme] .node-summary-card[aria-disabled="false"]:hover {
  background: var(--hover);
  border-color: var(--line2);
}
[data-theme] #selected-node-title     { color: var(--t1); }
[data-theme] .node-summary-card .meta { color: var(--t3); }

/* ── Node detail action toolbar ── */
[data-theme] .node-detail-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 4px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
[data-theme] .node-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
[data-theme] .node-toolbar-danger {
  display: flex;
  align-items: center;
  gap: 4px;
}
[data-theme] .node-toolbar-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border-color: transparent;
  color: var(--t3);
  transition: background 120ms, border-color 120ms, color 120ms;
}
[data-theme] .node-toolbar-btn:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .node-toolbar-btn-danger {
  color: var(--err);
  opacity: 0.65;
}
[data-theme] .node-toolbar-btn-danger:hover {
  background: color-mix(in srgb, var(--err) 10%, var(--panel));
  border-color: var(--err);
  color: var(--err);
  opacity: 1;
}

/* ── Node center pane: click-to-edit + save indicator ── */
/* Card no longer acts as a button */
[data-theme] .node-summary-card { cursor: default; }
[data-theme] .node-summary-card[aria-disabled="false"]:hover {
  border-color: var(--line);
  background: var(--sidebar);
}
/* Right-side action buttons stacked */
[data-theme] .node-summary-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  flex-shrink: 0;
}
/* Inline actions (connect + delete) level with the node title */
[data-theme] .node-title-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}
/* Field rows: field + indicator side by side */
[data-theme] .node-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
[data-theme] .node-desc-row {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}
[data-theme] .node-desc-row.is-collapsed #header-overview-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Expanded description row: p fills width, textarea takes comfortable height */
[data-theme] .node-desc-row:not(.is-collapsed) #header-overview-text {
  flex: 1; min-width: 0;
}
[data-theme] .node-desc-row:not(.is-collapsed) .inline-edit-textarea {
  min-height: max(120px, calc(100vh - 280px));
  max-height: max(120px, calc(100vh - 280px));
  width: 100%;
  overflow-y: auto;
  resize: none;
  display: block;
}
/* Editable hover hint — no layout shift */
[data-theme] .node-field-editable {
  cursor: text;
  border-radius: 4px;
  transition: background 100ms;
}
[data-theme] .node-field-editable:hover { background: var(--hover); }
/* Save indicator — hidden at rest */
[data-theme] .node-field-save-indicator {
  display: none;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border-radius: 4px;
  padding: 1px 4px;
  flex-shrink: 0;
  white-space: nowrap;
}
[data-theme] .node-field-save-indicator.is-dirty {
  display: inline-flex;
  color: var(--t3);
}
[data-theme] .node-field-save-indicator.is-saving {
  display: inline-flex;
  color: var(--t3);
  animation: ciq-save-pulse 0.8s ease infinite;
}
[data-theme] .node-field-save-indicator.is-success {
  display: inline-flex;
  color: var(--ok);
  animation: ciq-save-fadeout 1.5s ease forwards;
}
[data-theme] .node-field-save-indicator.is-error {
  display: inline-flex;
  color: var(--err);
  cursor: pointer;
  text-decoration: underline dotted;
}
@keyframes ciq-save-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 1; }
}
@keyframes ciq-save-fadeout {
  0%   { opacity: 1; }
  65%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── AI content spinner ─────────────────────────────────────────────────────
   Reusable loading indicator for any AI-generated section.
   Uses the lens-dots-idle.png brand mark — already cached on every page.
   Usage: <span class="ai-spinner"></span> — replaced by content on arrival.  */
@keyframes ai-spin { to { transform: rotate(360deg); } }
[data-theme] .ai-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  background: url('/static/images/lens-dots-idle.png') center / contain no-repeat;
  animation: ai-spin 1.5s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
  margin: 2px 0;
}
[data-theme] .ai-spinner--violet {
  background-image: url('/static/images/lens-dots-ambient.png');
}

/* AI Summary card */
[data-theme] .summary-card .overview-card {
  background: var(--sidebar-soft);
  border-color: var(--line);
}
[data-theme] .eyebrow        { color: var(--t3); }
[data-theme] .summary-card p { color: var(--t1); }
/* Glyph cards */
[data-theme] .glyph-card {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .glyph-card:hover {
  background: var(--sidebar);
  border-color: var(--line2);
  box-shadow: none;
}
[data-theme] .glyph-card h4 { color: var(--t1); }
[data-theme] .glyph-card p  { color: var(--t2); }
[data-theme] .glyph-card.is-new {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 14%, transparent);
}
/* Status / node detail box */
[data-theme] .status-box {
  background: var(--sidebar-soft);
  color: var(--t3);
}
[data-theme] .status-box.error {
  background: color-mix(in srgb, var(--err) 10%, var(--panel));
  color: var(--err);
}
/* Workspace inputs / textareas */
[data-theme] .workspace textarea,
[data-theme] .workspace input[type="text"] {
  background: var(--panel);
  color: var(--t1);
  border-color: var(--line);
}
[data-theme] .workspace textarea:focus,
[data-theme] .workspace input[type="text"]:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-line);
}
[data-theme] .workspace textarea::placeholder,
[data-theme] .workspace input::placeholder { color: var(--t4); }
/* Workspace buttons */
[data-theme] .workspace .icon-button,
[data-theme] .workspace .btn-icon {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .workspace .icon-button:hover,
[data-theme] .workspace .btn-icon:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .workspace .btn-secondary,
[data-theme] .workspace .secondary-button {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .workspace .btn-secondary:hover,
[data-theme] .workspace .secondary-button:hover { background: var(--hover); }
/* Trash / open buttons in workspace (own classes, not icon-button) */
[data-theme] .workspace .trash-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t3);
}
[data-theme] .workspace .trash-button:hover {
  background: color-mix(in srgb, var(--err) 8%, var(--panel));
  border-color: var(--err);
  color: var(--err);
}
[data-theme] .workspace .node-open-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .workspace .node-open-button:hover {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet);
}
/* Node header connect button */
[data-theme] .node-header-connect-button {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t2);
}
/* Related header pills */
[data-theme] .related-header-pill {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t2);
}
[data-theme] .related-header-pill:hover {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet-deep);
}

/* ── Right panel (Insights / Explore rail) ── */
[data-theme] .copilot-rail   { background: var(--sidebar); border-left-color: var(--line); }
[data-theme] .copilot-header { background: var(--sidebar); border-bottom-color: var(--line); }
[data-theme] .copilot-header h2    { color: var(--t1); }
[data-theme] .copilot-header .meta { color: var(--t3); }
[data-theme] .copilot-body         { background: var(--sidebar); }
/* Insight cards */
[data-theme] .answer-box {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t1);
}
[data-theme] .answer-box.is-insight {
  background: color-mix(in srgb, var(--insight) 8%, var(--panel));
  border-color: color-mix(in srgb, var(--insight) 28%, transparent);
}
[data-theme] .answer-box.is-answer {
  background: color-mix(in srgb, var(--violet) 7%, var(--panel));
  border-color: color-mix(in srgb, var(--violet) 20%, transparent);
}
[data-theme] .answer-box.is-related {
  background: var(--sidebar);
  border-color: var(--line);
}
[data-theme] .answer-box .answer-content h3 { color: var(--t1); }
[data-theme] .answer-box .answer-content p  { color: var(--t2); }
/* Card type pills — adapt insight/answer labels in dark mode */
[data-theme="dark"] .card-type-pill.is-insight {
  background: color-mix(in srgb, var(--insight) 16%, transparent);
  color: var(--insight);
}
[data-theme="dark"] .card-type-pill.is-answer {
  background: var(--violet-soft);
  color: var(--violet);
}
/* Selection context */
[data-theme] .selection-context        { background: var(--sidebar); border-bottom-color: var(--line); }
[data-theme] .selection-context .meta  { color: var(--t3); }
[data-theme] #selection-context-text   { color: var(--t1); }
/* Ask/Explore panel */
[data-theme] .ask-panel        { background: var(--sidebar); border-top-color: var(--line); }
[data-theme] .ask-panel h2     { color: var(--t1); }
[data-theme] .ask-panel .meta  { color: var(--t2); }
[data-theme] .ask-panel label  { color: var(--t2); }
[data-theme] .ask-web-search-label { color: var(--t2); }
[data-theme] .ask-panel input[type="text"],
[data-theme] .ask-panel textarea {
  background: var(--panel);
  color: var(--t1);
  border-color: var(--line);
}
[data-theme] .ask-panel input[type="text"]:focus,
[data-theme] .ask-panel textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-line);
  outline: none;
}
[data-theme] .ask-panel input::placeholder,
[data-theme] .ask-panel textarea::placeholder { color: var(--t4); }
[data-theme] .ask-help-popover {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t1);
}
/* Insights ? popover — CSS-hover triggered (no JS needed) */
[data-theme] .insights-help-wrap:hover .insights-help-popover,
[data-theme] .insights-help-wrap:focus-within .insights-help-popover {
  display: block;
}
/* Insights ? popover: open downward (not upward) to avoid clipping under AI Summary */
[data-theme] .insights-help-popover {
  bottom: auto;
  top: calc(100% + 4px);
}
[data-theme] .insights-help-wrap {
  z-index: 60;
}
/* Right rail buttons */
[data-theme] .copilot-rail .icon-button,
[data-theme] .copilot-rail .btn-icon {
  background: var(--sidebar-soft);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .copilot-rail .icon-button:hover,
[data-theme] .copilot-rail .btn-icon:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .copilot-rail .btn-ghost       { background: transparent; color: var(--t2); border-color: transparent; }
[data-theme] .copilot-rail .btn-ghost:hover { background: var(--hover); color: var(--t1); }
[data-theme] .copilot-rail .btn-secondary,
[data-theme] .copilot-rail .secondary-button {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .copilot-rail .btn-secondary:hover,
[data-theme] .copilot-rail .secondary-button:hover { background: var(--hover); }

/* ── Right panel Smart / Properties tab bar ── */
[data-theme] .copilot-rail {
  grid-template-rows: auto minmax(0, 1fr) auto;
}
[data-theme] .right-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--sidebar);
  flex-shrink: 0;
}
[data-theme] .right-tab {
  flex: 1;
  padding: 9px 12px 8px;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--t3);
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
  text-align: center;
  letter-spacing: 0.01em;
}
[data-theme] .right-tab:hover { color: var(--t1); }
[data-theme] .right-tab.is-active {
  color: var(--violet);
  border-bottom-color: var(--violet);
}
/* Smart tab panel — flex column; summary card auto, content wrapper fills rest */
[data-theme] #smart-tab-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
/* AI Summary card inside Smart tab — flat, no scroll cap */
[data-theme] .smart-tab-summary-card {
  border-radius: 0;
  margin: 0;
  flex-shrink: 0;
}
[data-theme] .smart-tab-summary-card .eyebrow-row {
  padding: 6px 16px 2px;
}
[data-theme] .smart-tab-summary-card .overview-card {
  padding: 0 16px 8px;
  font-size: 11.5px;
  color: var(--t2);
  line-height: 1.5;
}
/* Node Smart content — Insights header + feed (fills remaining space) */
[data-theme] #node-smart-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[data-theme] #node-smart-content .copilot-header { flex-shrink: 0; }
[data-theme] #node-smart-content .copilot-body {
  flex: 1;
  min-height: 0;
}
/* Node Prism Suggestions card — cluster-level analysis (Properties tab, mirrors Glyph prism suggestions) */
[data-theme] .node-prism-suggestions-card {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
[data-theme] .node-prism-suggestions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
[data-theme] .node-prism-suggestions-header .eyebrow {
  margin: 0;
}
[data-theme] .node-prism-suggestions-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
[data-theme] .node-prism-suggestions-loading {
  font-size: 11.5px;
  color: var(--t3);
  padding: 4px 0;
}
[data-theme] .node-prism-suggestion-group {
  margin-top: 6px;
}
[data-theme] .node-prism-suggestion-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t3);
  margin: 0 0 4px;
}
[data-theme] .node-prism-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
/* Stale-clue indicator: amber/yellow — unmistakably distinct from Favorite star */
[data-theme] .node-cluster-stale-clue {
  font-size: 11px;
  font-weight: 700;
  color: #b8860b;
  background: rgba(184, 134, 11, 0.10);
  border: 1px solid rgba(184, 134, 11, 0.30);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: default;
  line-height: 1.4;
  letter-spacing: -0.02em;
}
[data-theme="dark"] .node-cluster-stale-clue {
  color: #e6b800;
  background: rgba(230, 184, 0, 0.10);
  border-color: rgba(230, 184, 0, 0.28);
}
/* Glyph Smart shell — shown when a Glyph is the active center entity */
[data-theme] #glyph-smart-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
[data-theme] .glyph-smart-coming-note {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--t3);
  font-style: italic;
  margin: 0;
}
/* Properties tab panel — Prisms scroll, metadata pinned at bottom */
[data-theme] #properties-tab-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
/* Node Properties content fills the panel and splits vertically */
[data-theme] #node-properties-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Glyph Properties shell — mirrors node-properties-content layout */
[data-theme] #glyph-properties-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
[data-theme] .glyph-properties-content .node-prism-section {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin: 0;
}
[data-theme] .glyph-props-coming-note {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--t3);
  font-style: italic;
  margin: 0;
}
/* ── v9 Step 3: Glyph center inline editor ─────────────────────────────── */
[data-theme] .glyph-center-detail {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
[data-theme] .glyph-center-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
[data-theme] .glyph-center-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0;
  border-radius: 5px;
  padding: 3px 5px;
  flex: 1;
  min-width: 0;
}
/* Body row: body div + save indicator on same line (mirrors .node-desc-row) */
[data-theme] .glyph-center-body-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
[data-theme] .glyph-center-body {
  flex: 1;
  font-size: 13.5px;
  color: var(--t2);
  line-height: 1.65;
  border-radius: 5px;
  padding: 6px 5px;
  min-height: 48px;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
[data-theme] .glyph-center-body.node-field-editable:hover { background: var(--hover); }
/* Textarea fills body div; min-height fills visible center pane below title */
[data-theme] .glyph-center-body .inline-edit-textarea {
  width: 100%;
  min-height: max(280px, calc(100vh - 320px));
  resize: vertical;
  display: block;
}
/* Explore Further pending result block */
[data-theme] .glyph-explore-result {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
[data-theme] .glyph-explore-result-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3);
  margin: 0;
}
[data-theme] .glyph-explore-result-text {
  font-size: 13.5px;
  color: var(--t2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
[data-theme] .glyph-explore-result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* ── v9 Step 3: Glyph right column analysis card ────────────────────────── */
[data-theme] .glyph-right-analyze-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 6px;
}
/* Refresh-only action row (replaces Analysis eyebrow-row) */
[data-theme] .glyph-analyze-action-row {
  display: flex;
  justify-content: flex-end;
  padding: 0 16px 2px;
}
[data-theme] .glyph-analyze-section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--t3);
  margin: 0 0 4px;
  padding: 8px 0 0;
}
[data-theme] .glyph-right-analyze-card .glyph-analyze-section {
  padding: 0 16px;
  border-top-color: var(--line);
}
/* Content text — readable in both themes */
[data-theme] .glyph-analyze-text,
[data-theme] .glyph-analyze-list {
  color: var(--t2);
}
/* Suggested Questions — violet link, works in both themes */
[data-theme] .glyph-analyze-question {
  color: var(--violet);
}
[data-theme] .glyph-analyze-question:hover {
  color: var(--violet-2);
  text-decoration: underline;
  background: transparent;
  border-color: transparent;
}
/* Loading indicator — theme-aware */
[data-theme="dark"] .glyph-analyze-loading {
  border-color: var(--violet-line);
  background: var(--violet-soft);
  color: var(--violet);
}
[data-theme] .glyph-right-explore-row {
  padding: 10px 16px 6px;
  display: flex;
  gap: 6px;
}
/* Suggested Prisms in Properties tab */
[data-theme] #glyph-right-prism-section .glyph-prism-suggestions {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
[data-theme] #glyph-right-prism-section .glyph-prism-suggestions .eyebrow {
  margin: 0 0 6px;
}
/* Suggestion chips — theme-aware */
[data-theme] .glyph-prism-suggestion-chip {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--t2);
}
[data-theme] .glyph-prism-suggestion-chip:hover {
  background: var(--violet-soft);
  border-color: var(--violet);
  color: var(--violet);
}
/* Prism chips — compact pill style */
[data-theme] .semantic-prism-chip.glyph-prism-chip {
  display: inline-flex;
  align-items: center;
  width: auto;
  padding: 2px 5px;
  background: var(--sidebar-soft);
  border-color: var(--line2);
  color: var(--t2);
}
[data-theme] .semantic-prism-chip.glyph-prism-chip:hover {
  border-color: var(--violet-line);
  background: var(--violet-soft);
  color: var(--t1);
}
[data-theme] .glyph-prism-chip .glyph-prism-weight {
  width: 16px;
  height: 16px;
  min-width: 16px;
  background: transparent;
  font-size: 0.7rem;
}
[data-theme] .glyph-prism-chip .glyph-prism-label {
  flex: 0 1 auto;
  width: auto;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset;
}
[data-theme] .semantic-prism-chip.node-prism-chip {
  display: inline-flex;
  align-items: center;
  width: auto;
  padding: 2px 5px;
  background: var(--sidebar-soft);
  border-color: var(--line2);
  color: var(--t2);
}
[data-theme] .semantic-prism-chip.node-prism-chip:hover {
  border-color: var(--violet-line);
  background: var(--violet-soft);
  color: var(--t1);
}
[data-theme] .node-prism-chip .node-prism-weight {
  width: 16px;
  height: 16px;
  min-width: 16px;
  background: transparent;
  font-size: 0.7rem;
}
[data-theme] .node-prism-chip .node-prism-label {
  flex: 0 1 auto;
  width: auto;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset;
}
[data-theme] .properties-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  color: var(--t3);
  font-size: 13px;
  line-height: 1.6;
}
/* Properties metadata section theming */
[data-theme] .properties-meta-section {
  background: var(--sidebar-soft);
  border-color: var(--line2);
}
[data-theme] .properties-meta-label { color: var(--t3); }
[data-theme] .properties-meta-value { color: var(--t2); }
[data-theme] .node-properties-content .summary-card {
  margin: 0;
}
[data-theme] .node-properties-content .node-prism-section {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin: 0;
}
[data-theme] .node-meta-details {
  flex-shrink: 0;
  border-color: var(--line2);
  background: var(--sidebar-soft);
}
[data-theme] .node-meta-summary { color: var(--t3); }
[data-theme] .node-meta-details[open] .node-meta-summary { border-bottom-color: var(--line2); }
[data-theme] .node-meta-details .properties-meta-section {
  background: transparent;
  border-color: transparent;
}

[data-theme] .selection-chip {
  background: var(--sidebar-soft);
  border-color: var(--line2);
  color: var(--t2);
}

/* ── Status drawer ── */
[data-theme] .status-drawer {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .status-drawer-header { border-bottom-color: var(--line); }
[data-theme] .status-title          { color: var(--t1); }
[data-theme] .status-message        { color: var(--t1); }
[data-theme] .status-message time   { color: var(--t3); }
[data-theme] .status-drawer .icon-button,
[data-theme] .status-drawer .btn-icon {
  background: transparent;
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .status-drawer .icon-button:hover,
[data-theme] .status-drawer .btn-icon:hover {
  background: var(--hover);
  color: var(--t1);
}

/* ──────────────────────────────────────────────
   ADMIN BODY — Phase 4d-3b
   Themes the User Management body to match the v9 shell + dashboard
   (4d-3a). Scope: admin-unique classes/ids overridden globally (safe);
   bare elements scoped to admin's classless `body > main` so the
   dashboard (main.workspace > section.center-stack) and ingest are
   untouched. Body/page bg already themed globally by 4d-3a.
   Specificity: [data-theme] .el = 0,1,1+ > template inline <style>
   (loads last but is 0,0,1 element / 0,1,0 class).
   Tokens only (--panel/--sidebar-soft/--line/--line2/--t1..t4/
   --hover/--violet*/--ok/--err); status pills kept legible via
   color-mix tints in both modes.
────────────────────────────────────────────── */

/* Cards */
[data-theme] body > main > section {
  background: var(--panel);
  border-color: var(--line);
}
/* Typography */
[data-theme] body > main h1,
[data-theme] body > main h2 { color: var(--t1); }
[data-theme] .admin-page-intro p { color: var(--t3); }
[data-theme] body > main label { color: var(--t2); }
/* Add User form + Users toolbar inputs/selects */
[data-theme] body > main input,
[data-theme] body > main select {
  background: var(--panel);
  color: var(--t1);
  border-color: var(--line);
}
[data-theme] body > main input::placeholder { color: var(--t4); }
[data-theme] body > main input:focus,
[data-theme] body > main select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px var(--violet-line);
}
/* Primary action button → violet, matching dashboard */
[data-theme] body > main .btn-primary {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
[data-theme] body > main .btn-primary:hover {
  background: var(--violet-deep);
  border-color: var(--violet-deep);
}
/* Users table */
[data-theme] .admin-table-wrap { border-color: var(--line); }
[data-theme] #admin-users-table { background: var(--panel); }
[data-theme] #admin-users-table th,
[data-theme] #admin-users-table td { border-bottom-color: var(--line); }
[data-theme] #admin-users-table td { color: var(--t1); }
[data-theme] #admin-users-table .admin-user-email { color: var(--t1); }
[data-theme] #admin-users-table th {
  background: var(--sidebar-soft);
  color: var(--t3);
}
[data-theme] #admin-users-table th button { color: var(--t3); }
[data-theme] #admin-users-table th button:hover { color: var(--t1); }
/* Role pill (neutral) + status pills (Active green / Inactive red) */
[data-theme] .admin-pill {
  background: var(--sidebar-soft);
  border-color: var(--line2);
  color: var(--t2);
}
[data-theme] .admin-pill-active {
  background: color-mix(in srgb, var(--ok) 14%, var(--panel));
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 32%, transparent);
}
[data-theme] .admin-pill-inactive {
  background: color-mix(in srgb, var(--err) 12%, var(--panel));
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 30%, transparent);
}
/* Actions icons — themed surface; preserves enable=green / disable=red
   hover semantics from the inline 4d-3a fix (token-mapped) */
[data-theme] .admin-actions .btn-icon {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .admin-actions .btn-icon:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .admin-enable-user:hover {
  background: color-mix(in srgb, var(--ok) 12%, var(--panel));
  color: var(--ok);
  border-color: var(--ok);
}
[data-theme] .admin-disable-user:hover {
  background: color-mix(in srgb, var(--err) 12%, var(--panel));
  color: var(--err);
  border-color: var(--err);
}
/* User Details modal (overlay, sibling of <main>) — kept coherent in dark */
[data-theme="dark"] .admin-modal-backdrop { background: rgba(0, 0, 0, 0.6); }
[data-theme] .admin-modal {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .admin-modal-header,
[data-theme] .admin-modal-footer { border-color: var(--line); }
[data-theme] .admin-modal-title { color: var(--t1); }
[data-theme] .admin-detail {
  background: var(--sidebar-soft);
  border-color: var(--line);
}
[data-theme] .admin-detail-label { color: var(--t3); }
[data-theme] .admin-detail-value { color: var(--t1); }
[data-theme] .admin-modal-edit label { color: var(--t2); }
[data-theme] .admin-modal input,
[data-theme] .admin-modal select {
  background: var(--panel);
  color: var(--t1);
  border-color: var(--line);
}
[data-theme] .admin-modal .btn-secondary {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .admin-modal .btn-secondary:hover { background: var(--hover); }
[data-theme] .admin-modal .btn-danger {
  background: var(--panel);
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
}
[data-theme] .admin-modal .btn-danger:hover {
  background: color-mix(in srgb, var(--err) 12%, var(--panel));
  border-color: var(--err);
}

/* ──────────────────────────────────────────────
   INGEST BODY — Phase 4d-3b
   Themes the Ingestion body to match the v9 shell + dashboard (4d-3a).
   Scope: ingest-unique classes/ids; bare elements scoped to
   `.ingest-shell`. `.page` bg + `.status-drawer` already themed by
   4d-3a. Same token approach as admin above.
────────────────────────────────────────────── */

/* Cards */
[data-theme] .ingest-shell > section {
  background: var(--panel);
  border-color: var(--line);
}
/* Typography */
[data-theme] .ingest-shell h2 { color: var(--t1); }
[data-theme] .ingest-shell label { color: var(--t2); }
[data-theme] .ingest-shell .selected-count { color: var(--t3); }
/* Inputs / textarea / selects (Add Source, filters, Target Nodes) */
[data-theme] .ingest-shell input,
[data-theme] .ingest-shell textarea,
[data-theme] .ingest-shell select {
  background: var(--sidebar-soft);
  color: var(--t1);
  border-color: var(--line);
}
[data-theme] .ingest-shell input::placeholder,
[data-theme] .ingest-shell textarea::placeholder { color: var(--t4); }
[data-theme] .ingest-shell input:focus,
[data-theme] .ingest-shell textarea:focus,
[data-theme] .ingest-shell select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px var(--violet-line);
}
/* Buttons — primary (Add to Library / Promote) violet; secondary themed */
[data-theme] .ingest-shell .btn-primary {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
[data-theme] .ingest-shell .btn-primary:hover {
  background: var(--violet-deep);
  border-color: var(--violet-deep);
}
[data-theme] .ingest-shell .btn-secondary {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .ingest-shell .btn-secondary:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
/* Source Library table */
[data-theme] .ingest-shell .table-wrap { border-color: var(--line); }
[data-theme] .ingest-shell table { background: var(--panel); }
[data-theme] .ingest-shell th,
[data-theme] .ingest-shell td { border-bottom-color: var(--line); color: var(--t1); }
[data-theme] .ingest-shell th { color: var(--t3); }
[data-theme] .ingest-shell tr.source-row:hover { background: var(--hover); }
/* Processing-status pills — legible tints in both modes */
[data-theme] .ingest-shell .status-pill {
  background: var(--sidebar-soft);
  color: var(--t2);
}
[data-theme] .ingest-shell .processing-status-pill { border-color: var(--line2); }
[data-theme] .ingest-shell .processing-status-pill.status-pending {
  background: var(--sidebar-soft);
  color: var(--t3);
  border-color: var(--line2);
}
[data-theme] .ingest-shell .processing-status-pill.status-processing,
[data-theme] .ingest-shell .processing-status-pill.status-analyzing {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: var(--violet-line);
}
[data-theme] .ingest-shell .processing-status-pill.status-ready {
  background: color-mix(in srgb, var(--ok) 14%, var(--panel));
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 32%, transparent);
}
[data-theme] .ingest-shell .processing-status-pill.status-error {
  background: color-mix(in srgb, var(--err) 12%, var(--panel));
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 30%, transparent);
}
/* Status drawer text legibility (surface already themed by 4d-3a) */
[data-theme] #ingest-status { color: var(--t2); }
/* Source detail modal (overlay, sibling of <main>) — coherent in dark */
[data-theme="dark"] #source-modal { background: rgba(0, 0, 0, 0.55); }
[data-theme] #source-modal .modal {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] #source-modal h2 { color: var(--t1); }
[data-theme] #source-modal .selected-count { color: var(--t3); }
[data-theme] #source-modal .btn-secondary {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] #source-modal .btn-secondary:hover { background: var(--hover); }
[data-theme] .source-prose-block,
[data-theme] .source-transcript-block,
[data-theme] .source-transcript-speaker,
[data-theme] .source-transcript-text { color: var(--t1); }
[data-theme] .source-transcript-time { color: var(--t3); }
[data-theme] .source-code-block {
  background: var(--sidebar-soft);
  border-color: var(--line);
}
[data-theme] .source-code-block pre { color: var(--t1); }
[data-theme] .source-code-label {
  background: var(--sidebar-soft);
  color: var(--t3);
}

/* ──────────────────────────────────────────────
   FAVORITES + V9 TREE TREATMENT — Phase 4d-3c part 2
   Scope: .sidebar only. Panel grid updated to 3 rows
   (favorites / heading / node-list). Star button on node
   cards; fav-row in favorites list; tree-row visual overrides
   on .sidebar .item-card. Tokens: same set as 4d-3a.
────────────────────────────────────────────── */

/* Extend sidebar panel to accommodate favorites + divider + nodes heading + card list */
[data-theme] .sidebar > .panel {
  grid-template-rows: auto auto auto minmax(0, 1fr) !important;
  padding: 0;
}

/* ── Favorites section ── */
.favorites-section {
  flex-shrink: 0;
  padding: 10px 14px 0;
}
.favorites-section.is-collapsed .favorites-list { display: none; }
.favorites-section.is-collapsed .favorites-chevron { transform: rotate(-90deg); }

.favorites-header {
  all: unset;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  cursor: pointer;
  padding: 4px 0 6px;
  box-sizing: border-box;
}
.favorites-heading-text {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  flex: 1;
}
.favorites-chevron {
  font-size: 0.75rem;
  color: var(--muted);
  transition: transform 160ms ease;
  line-height: 1;
}
.favorites-count-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  min-height: auto;
  border-radius: 999px;
}

[data-theme] .favorites-heading-text { color: var(--t3); }
[data-theme] .favorites-chevron      { color: var(--t3); }
[data-theme] .favorites-header:hover .favorites-heading-text,
[data-theme] .favorites-header:hover .favorites-chevron { color: var(--t1); }
[data-theme] .favorites-count-badge {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet);
}

.favorites-list {
  display: grid;
  gap: 1px;
  padding-bottom: 6px;
}

/* Favorite row */
.fav-row {
  display: flex;
  align-items: center;
  gap: 7px;
  height: auto;
  padding: 4px 6px 4px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 100ms ease;
}
.fav-row:hover { background: var(--hover, rgba(20,17,30,0.045)); }
[data-theme] .fav-row:hover { background: var(--hover); }

.fav-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted, #8899aa);
  transition: background 120ms;
}
[data-theme] .fav-dot { background: var(--violet); }

.fav-title {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text, #111827);
}
[data-theme] .fav-title { color: var(--t1); }

.fav-unstar-btn {
  all: unset;
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  color: var(--muted, #8899aa);
  opacity: 0;
  transition: opacity 100ms, color 100ms, background 100ms;
}
.fav-row:hover .fav-unstar-btn { opacity: 1; }
.fav-unstar-btn:hover {
  color: var(--warn, #C97B16);
  background: color-mix(in srgb, var(--warn, #C97B16) 10%, transparent);
}
[data-theme] .fav-unstar-btn        { color: var(--violet); }
[data-theme] .fav-unstar-btn:hover  { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }

/* Divider between favorites and nodes heading */
.favorites-divider {
  height: 1px;
  margin: 0 14px 0;
  background: var(--border, rgba(20,17,30,0.08));
  flex-shrink: 0;
}
[data-theme] .favorites-divider { background: var(--line); }

/* Re-pad the section-heading-row and card-list now that .panel has no padding */
[data-theme] .sidebar > .panel .section-heading-row {
  padding: 8px 14px 4px;
}
[data-theme] .sidebar > .panel .card-list {
  padding: 2px 10px 12px;
}

/* ── v9 tree-row treatment on sidebar node cards ── */
[data-theme] .sidebar .item-card {
  border: none;
  border-left: 2px solid transparent;
  border-radius: 7px;
  padding: 5px 36px 5px 8px;  /* right room for card-control-stack */
  background: transparent;
  box-shadow: none;
  margin-bottom: 1px;
  transition: background 100ms ease, border-color 100ms ease;
}
[data-theme] .sidebar .item-card.is-clickable:hover {
  background: var(--hover);
  border-color: transparent;
  box-shadow: none;
}
[data-theme] .sidebar .item-card.is-selected {
  background: var(--active);
  border-left-color: var(--violet);
  border-color: transparent;
  box-shadow: none;
}
[data-theme] .sidebar .item-card.is-selected:hover {
  background: var(--active);
  border-left-color: var(--violet);
  border-color: transparent;
  box-shadow: none;
}

/* Node card text in tree mode */
[data-theme] .sidebar .item-card h3 {
  font-size: 0.82rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.3;
}
[data-theme] .sidebar .item-card p {
  font-size: 0.74rem;
  margin: 1px 0 0;
  line-height: 1.3;
}
[data-theme] .sidebar .item-card.is-selected h3 { color: var(--violet); font-weight: 600; }

/* ── Star button on node cards ── */
.node-star-button {
  all: unset;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  font-size: 0.76rem;
  cursor: pointer;
  color: var(--muted, #8899aa);
  opacity: 0;
  transition: opacity 100ms, color 100ms, background 100ms;
}
/* show on card hover or when already favorited */
.item-card:hover .node-star-button,
.node-star-button.is-favorited { opacity: 1; }
.node-star-button:hover {
  background: color-mix(in srgb, var(--warn, #C97B16) 10%, transparent);
}
.node-star-button.is-favorited {
  color: var(--warn, #C97B16);
}
[data-theme] .node-star-button               { color: var(--t3); }
[data-theme] .node-star-button.is-favorited  { color: var(--warn); }
[data-theme] .node-star-button:hover         { background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn); }

/* ──────────────────────────────────────────────
   POLISH — Phase 4d-3c polish
   Remaining dashboard elements still on hardcoded light colors,
   scrollbar theming, and tree-row alignment fixes.
   Scope: dashboard body + modals. Token pattern same as 4d-3a.
────────────────────────────────────────────── */

/* ── Glyph panel wrapper (hardcoded #fff in codexiq.css) ── */
[data-theme] .glyphs-panel {
  background: var(--panel);
  border-color: var(--line);
}

/* ── node-open-button and glyph-checkbox in sidebar tree rows ──
   node-open-button has background: #fff in codexiq.css; themed here
   for sidebar context only */
[data-theme] .sidebar .node-open-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .sidebar .node-open-button:hover {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet);
}

/* ── object-modal-scroll (hardcoded #fff) ── */
[data-theme] .object-modal-scroll {
  background: var(--sidebar-soft);
  border-color: var(--line);
  color: var(--t1);
}

/* ── Mail / recycle bin / help modals (mail-modal: #fff in codexiq.css) ── */
[data-theme] .mail-modal {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .modal-header,
[data-theme] .modal-footer {
  border-color: var(--line);
}
[data-theme] .modal-header h2 { color: var(--t1); }
[data-theme] .modal-footer {
  background: var(--panel);
}
[data-theme] .modal-body { color: var(--t1); }

/* ── Recycle-bin table (hardcoded #fff in codexiq.css) ── */
[data-theme] .recycle-table { background: var(--panel); }
[data-theme] .recycle-table th,
[data-theme] .recycle-table td { border-bottom-color: var(--line); color: var(--t1); }
[data-theme] .recycle-table th {
  background: var(--sidebar-soft);
  color: var(--t3);
}
[data-theme] .recycle-table-wrap { border-color: var(--line); }

/* ── Floating modal context label (backdrop-blur pill) ── */
[data-theme="dark"] .modal-set-context-label {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-color: var(--line2);
  color: var(--t2);
}
[data-theme="dark"] .modal-set-close-button {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}

/* ── Node/Glyph modal panels (row-card inside workspace modals) ── */
[data-theme] .row-card {
  background: var(--panel);
  border-color: var(--line);
}
[data-theme] .row-card.is-clickable:hover {
  background: var(--hover);
  border-color: var(--line2);
}
[data-theme] .row-card h3 { color: var(--t1); }
[data-theme] .row-card strong,
[data-theme] .row-card p { color: var(--t2); }

/* ── Sidebar tree-row: cap card-control-stack height so buttons don't
   overflow the card; star + open are shown-on-hover so the effective
   visual height matches the two-line text. ── */
[data-theme] .sidebar .card-control-stack {
  top: 50%;
  transform: translateY(-50%);
}

/* ── Scrollbars: themed to v9 tokens, thin on all surfaces ── */
:root {
  scrollbar-width: thin;
  scrollbar-color: rgba(20,17,30,0.18) transparent;
}
[data-theme="dark"] {
  scrollbar-color: rgba(255,255,255,0.16) transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(20,17,30,0.16);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(20,17,30,0.28); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.24); }

/* ── Theme-toggle button active state (dark mode = is-active) ── */
[data-theme="dark"] #theme-toggle-button {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet);
}

/* ── Checkbox accent-color: live dashboard checkboxes, both themes ──
   `.glyph-checkbox` kept for forward-compat (its glyph-card list is currently
   dead code); `.tree-checkbox` (bulk-select) and `#nav-explore-web` (command-bar
   Web) added so every live checkbox shares the violet accent instead of the
   browser default. --violet is a deep violet in light, lighter in dark, so the
   checked fill reads well in both. */
[data-theme] .glyph-checkbox,
[data-theme] .tree-checkbox,
[data-theme] #public-web-search-checkbox,
[data-theme] #nav-explore-web {
  accent-color: var(--violet);
}

/* ── ?-button dark-theme consistency ── */
/* Header help button */
[data-theme] .global-header .icon-button,
[data-theme] .global-header .btn-icon {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .global-header .icon-button:hover,
[data-theme] .global-header .btn-icon:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}
/* btn-help hover tint in dark mode (golden → violet).
   Includes .icon-button so it reaches 0,4,0 specificity — the container rules
   ([data-theme] .copilot-rail/.global-header .icon-button:hover) are also 0,4,0
   and would otherwise clobber a plain .btn-help override; this rule wins by
   source order. */
[data-theme="dark"] .btn-help.icon-button:hover,
[data-theme="dark"] .btn-help.icon-button.is-active {
  border-color: var(--violet-line);
  background: var(--violet-soft);
  color: var(--violet);
}
/* pressed state: keep the violet family in dark mode (was flashing light gold) */
[data-theme="dark"] .btn-help.icon-button:active {
  border-color: var(--violet-line);
  background: color-mix(in srgb, var(--violet-soft) 72%, black);
  color: var(--violet);
}
/* AI-mode help (?) button: server-rendered with `.ai-mode-help` but WITHOUT
   `.icon-button`, and it lives in the command bar (not .global-header /
   .copilot-rail), so the rules above never reach it and it falls through to the
   white `.btn-icon` base. Give it the same treatment, scoped to its container. */
[data-theme] .ai-mode-control .btn-help {
  background: var(--panel);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme="dark"] .ai-mode-control .btn-help:hover,
[data-theme="dark"] .ai-mode-control .btn-help.is-active {
  border-color: var(--violet-line);
  background: var(--violet-soft);
  color: var(--violet);
}
[data-theme="dark"] .ai-mode-control .btn-help:active {
  border-color: var(--violet-line);
  background: color-mix(in srgb, var(--violet-soft) 72%, black);
  color: var(--violet);
}
/* Prism panel ?-buttons */
[data-theme] .prism-dock-modal .icon-button,
[data-theme] .prism-dock-modal .btn-icon {
  background: var(--sidebar-soft);
  border-color: var(--line);
  color: var(--t2);
}
[data-theme] .prism-dock-modal .icon-button:hover,
[data-theme] .prism-dock-modal .btn-icon:hover {
  background: var(--hover);
  border-color: var(--line2);
  color: var(--t1);
}

/* ── Smart-tab density: insight-new-dot marker ── */
[data-theme] .insight-new-dot { color: var(--violet); }

/* ── v9 Step 2a: Center multi-tab strip + breadcrumb ── */
/* 4-row workspace grid: row 1=tabstrip, 2=breadcrumb, 3=header, 4=body */
[data-theme] .workspace { grid-template-rows: auto auto auto minmax(0, 1fr); }
/* Explicit row assignments — force visual order regardless of DOM/auto-placement */
[data-theme] .workspace > .cx-tabstrip      { grid-row: 1; }
[data-theme] .workspace > .cx-breadcrumb    { grid-row: 2; }
[data-theme] .workspace > .workspace-header { grid-row: 3; }
[data-theme] .workspace > .workspace-body   { grid-row: 4; }

/* Tab strip — reuses .tab / .tab-group / .tab-parent / .tab-child classes */
[data-theme] .cx-tabstrip {
  display: flex; align-items: stretch;
  height: 36px; padding: 0 4px 0 8px; gap: 0;
  background: var(--sidebar-soft);
  border-bottom: 1px solid var(--line);
  overflow: hidden; flex-shrink: 0;
}
[data-theme] .cx-tabstrip .tab { align-self: center; }

/* Scrollable tab body — sits between pinned Discover and arrow buttons */
[data-theme] .cx-tabs-body {
  display: flex; align-items: stretch;
  flex: 1; min-width: 0; gap: 1px;
  overflow: auto hidden;
  scrollbar-width: none;
}
[data-theme] .cx-tabs-body::-webkit-scrollbar { display: none; }

/* Scroll arrow buttons flanking the tab body */
[data-theme] .cx-tabs-arrow {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: 20px;
  background: var(--sidebar-soft);
  border: none; padding: 0; margin: 0; cursor: pointer;
  color: var(--t3);
}
[data-theme] .cx-tabs-arrow:hover { color: var(--t1); background: var(--hover); }
[data-theme] .cx-tabs-arrow svg { width: 8px; height: 12px; pointer-events: none; }

/* Breadcrumb bar */
[data-theme] .cx-breadcrumb {
  display: flex; align-items: center;
  padding: 0 16px; height: 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
[data-theme] .cx-bc-nav {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--t3);
}
[data-theme] .cx-bc-sep { color: var(--t4); }
[data-theme] .cx-bc-active { color: var(--t1); font-weight: 500; }

/* Discover placeholder in center body */
[data-theme] .cx-discover-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 56px 32px; color: var(--t3); text-align: center;
}
[data-theme] .cx-discover-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--sidebar-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
[data-theme] .cx-discover-icon svg { width: 22px; height: 22px; color: var(--t4); }
[data-theme] .cx-discover-placeholder p { font-size: 13px; color: var(--t3); margin: 0; }

/* ── v9 Step 2b: Tab close buttons ── */
[data-theme] .tab-close {
  display: grid; place-items: center;
  width: 14px; height: 14px; border-radius: 3px;
  background: transparent; border: none; cursor: pointer;
  color: var(--t4); flex-shrink: 0;
  padding: 0; margin-left: 4px; margin-right: -2px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.1s;
}
[data-theme] .tab-close svg { width: 8px; height: 8px; pointer-events: none; }
[data-theme] .tab-parent .tab-close,
[data-theme] .tab-child .tab-close { opacity: 1; pointer-events: auto; }
[data-theme] .tab-close:hover { background: var(--hover); color: var(--t1); }

/* ── Discover Alpha surface (v9 tokens) ── */
[data-theme] .cx-discover-container { overflow-y: auto; height: 100%; }
[data-theme] .cx-discover-heading { color: var(--t1); }
[data-theme] .cx-discover-lede { color: var(--t2); }
[data-theme] .cx-discover-stat {
  background: var(--sidebar-soft);
  border-color: var(--line);
}
[data-theme] .cx-ds-value { color: var(--violet-2); }
[data-theme] .cx-ds-label { color: var(--t3); }
[data-theme] .cx-discover-explore-heading { color: var(--t1); }
[data-theme] .cx-discover-input {
  background: var(--panel);
  border-color: var(--line2);
  color: var(--t1);
}
[data-theme] .cx-discover-input::placeholder { color: var(--t4); }
[data-theme] .cx-discover-input:focus {
  border-color: var(--violet-2);
  box-shadow: 0 0 0 2px var(--violet-soft);
}
[data-theme] .cx-discover-seed {
  border-color: var(--line2);
  color: var(--t2);
  background: transparent;
}
[data-theme] .cx-discover-seed:hover {
  background: var(--violet-soft);
  border-color: var(--violet-line);
  color: var(--violet);
}

