/* Final feature overrides. Loaded after legacy toolbar.css. */
#topbar { scrollbar-width: none !important; }
#topbar::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

.ai-context-toolbar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 7px !important;
  padding: 9px 12px 10px !important;
  container-type: inline-size;
}

.topbar-scroll-rail {
  position: fixed !important;
  z-index: 200001 !important;
  top: 43px !important;
  left: 8px !important;
  right: 8px !important;
  height: 7px !important;
  display: flex !important;
  align-items: center !important;
  pointer-events: auto !important;
}
.topbar-scroll-track { pointer-events: auto !important; }

.project-search-results {
  top: 54px !important;
  max-height: calc(100dvh - 66px) !important;
}

.ai-clear-history {
  grid-column: auto !important;
}

.ai-context-toolbar .ai-clear-history.is-confirming {
  color: #fee2e2 !important;
  border-color: rgba(248, 113, 113, .72) !important;
  background: rgba(127, 29, 29, .34) !important;
  box-shadow: inset 0 0 0 1px rgba(254, 202, 202, .08), 0 0 14px rgba(239, 68, 68, .14) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle.is-confirming {
  color: #fef3c7 !important;
  border-color: rgba(251, 191, 36, .72) !important;
  background: linear-gradient(180deg, rgba(120, 53, 15, .48), rgba(69, 26, 3, .42)) !important;
  box-shadow: inset 0 0 0 1px rgba(254, 243, 199, .08), 0 0 14px rgba(245, 158, 11, .18) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle.is-confirming .ai-deep-analysis-state {
  color: #fff7ed !important;
  background: rgba(245, 158, 11, .24) !important;
}

/* All five actions share one visual language. Purple means "active", not merely important. */
.ai-context-toolbar #aiAddSelectionBtn {
  border-color: rgba(148, 163, 184, .18) !important;
  color: #cbd5e1 !important;
  background: rgba(255, 255, 255, .045) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025) !important;
  transform: none;
}

.ai-context-toolbar #aiAddSelectionBtn:hover {
  color: #eef2ff !important;
  border-color: rgba(167, 139, 250, .44) !important;
  background: rgba(124, 58, 237, .12) !important;
}

.ai-context-toolbar #aiAddSelectionBtn.active,
.ai-context-toolbar #aiAddSelectionBtn[aria-pressed="true"] {
  color: #ffffff !important;
  border-color: rgba(167, 139, 250, .9) !important;
  background: linear-gradient(135deg, rgba(109, 40, 217, .86), rgba(124, 58, 237, .62)) !important;
  box-shadow:
    inset 0 0 0 1px rgba(221, 214, 254, .14),
    0 0 15px rgba(139, 92, 246, .4) !important;
}

.ai-journal-mode.active,
.ai-journal-mode[aria-pressed="true"] {
  color: #f5f3ff;
  border-color: rgba(139, 92, 246, .75);
  background: rgba(124, 58, 237, .28);
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, .18);
}

.ai-workspace-mode-status {
  grid-column: 1 / -1;
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 3px;
  color: #8f9bad;
  font: 650 11.5px/1.2 system-ui, sans-serif;
}

.ai-workspace-mode-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

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

.ai-workspace-mode-status.is-journal {
  color: #c4b5fd;
}

.ai-workspace-mode-status.is-journal .ai-workspace-mode-dot {
  background: #8b5cf6;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, .13);
}

.ai-context-toolbar .ai-deep-analysis-toggle {
  grid-column: 1 / -1;
  justify-self: center;
  position: relative;
  min-width: 164px;
  width: max-content;
  max-width: calc(100% - 88px);
  min-height: 36px;
  margin: 1px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid rgba(167, 139, 250, .34);
  border-radius: 999px;
  color: #c4b5d8;
  background: linear-gradient(180deg, rgba(31, 41, 58, .96), rgba(15, 23, 42, .94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .045),
    inset 0 -1px 0 rgba(0, 0, 0, .18);
  font: 750 11.5px/1 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.ai-context-toolbar .ai-deep-analysis-toggle::before,
.ai-context-toolbar .ai-deep-analysis-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30px;
  height: 1px;
  pointer-events: none;
  opacity: .72;
}

.ai-context-toolbar .ai-deep-analysis-toggle::before {
  right: calc(100% + 10px);
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .28));
}

.ai-context-toolbar .ai-deep-analysis-toggle::after {
  left: calc(100% + 10px);
  background: linear-gradient(90deg, rgba(148, 163, 184, .28), transparent);
}

.ai-context-toolbar .ai-deep-analysis-toggle:hover {
  color: #d8d3ff;
  border-color: rgba(167, 139, 250, .62);
  background: linear-gradient(180deg, rgba(63, 43, 97, .7), rgba(30, 24, 54, .92));
  transform: translateY(-1px);
}

.ai-context-toolbar .ai-deep-analysis-toggle:focus-visible {
  outline: 2px solid rgba(167, 139, 250, .9);
  outline-offset: 2px;
}

.ai-context-toolbar .ai-deep-analysis-toggle.active,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"] {
  color: #ffffff;
  border-color: rgba(167, 139, 250, .92);
  background: linear-gradient(135deg, rgba(109, 40, 217, .88), rgba(124, 58, 237, .68));
  box-shadow:
    0 0 0 1px rgba(196, 181, 253, .16) inset,
    0 0 14px rgba(139, 92, 246, .48),
    0 0 28px rgba(109, 40, 217, .24);
}

.ai-context-toolbar .ai-deep-analysis-toggle.active::before,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"]::before,
.ai-context-toolbar .ai-deep-analysis-toggle.active::after,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"]::after {
  opacity: 1;
  background: linear-gradient(90deg, transparent, rgba(167, 139, 250, .7));
}

.ai-context-toolbar .ai-deep-analysis-toggle.active::after,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"]::after {
  background: linear-gradient(90deg, rgba(167, 139, 250, .7), transparent);
}

.ai-context-toolbar .ai-deep-analysis-toggle.active .ai-deep-analysis-icon,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"] .ai-deep-analysis-icon {
  color: #ddd6fe;
  text-shadow: 0 0 8px rgba(221, 214, 254, .95);
}

.ai-quick-prompts {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.ai-quick-prompts::-webkit-scrollbar {
  display: none;
}

.ai-context-toolbar .ai-quick-prompt {
  min-height: 28px !important;
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: 999px;
  color: #9aa7b9;
  background: rgba(15, 23, 42, .38);
  font: 600 10.5px/1 system-ui, sans-serif;
  box-shadow: none;
  transform: none;
}

.ai-context-toolbar .ai-quick-prompt:hover {
  color: #e2e8f0;
  border-color: rgba(139, 92, 246, .38);
  background: rgba(124, 58, 237, .12);
  transform: none;
}

.ai-mode-message.is-journal {
  color: #d8ccff !important;
  border-color: rgba(139, 92, 246, .5) !important;
  background: rgba(124, 58, 237, .14) !important;
}

/* Four equal AI actions in the same graphite-violet language as the application. */
@property --ai-workspace-progress {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

.ai-context-toolbar > button {
  min-width: 0 !important;
  width: 100% !important;
  min-height: 42px !important;
  padding: 0 11px !important;
  gap: 7px !important;
  border: 1px solid rgba(148, 163, 184, .18) !important;
  border-radius: 10px !important;
  color: #cbd3e2 !important;
  background: rgba(255, 255, 255, .04) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025) !important;
  font: 680 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  letter-spacing: .003em !important;
  overflow: hidden !important;
  transform: none !important;
  filter: none !important;
  transition:
    color .16s ease,
    border-color .16s ease,
    background-color .16s ease,
    box-shadow .16s ease,
    transform .16s ease !important;
}

.ai-context-toolbar > button > svg,
.ai-context-toolbar > button > .ai-deep-analysis-icon,
.ai-context-toolbar > button > [aria-hidden="true"] {
  flex: 0 0 auto;
}

.ai-context-toolbar > button > .ai-context-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-context-toolbar .ai-deep-analysis-toggle > .ai-context-label {
  flex: 0 1 auto;
}

.ai-context-toolbar > button:hover:not(:disabled) {
  color: #f4f1ff !important;
  border-color: rgba(167, 139, 250, .42) !important;
  background: rgba(124, 92, 255, .105) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .045),
    0 5px 14px rgba(2, 6, 23, .16) !important;
  transform: translateY(-1px) !important;
  filter: none !important;
}

.ai-context-toolbar > button:focus-visible {
  outline: 2px solid rgba(167, 139, 250, .75) !important;
  outline-offset: 2px !important;
}

.ai-context-toolbar #aiAddSelectionBtn.active,
.ai-context-toolbar #aiAddSelectionBtn[aria-pressed="true"] {
  color: #ffffff !important;
  border-color: rgba(167, 139, 250, .72) !important;
  background: linear-gradient(180deg, rgba(105, 72, 184, .74), rgba(73, 48, 137, .8)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .09),
    0 5px 16px rgba(20, 13, 43, .24) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle {
  grid-column: auto !important;
  justify-self: stretch !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 42px !important;
  margin: 0 !important;
  padding: 0 6px !important;
  gap: 4px !important;
  border-radius: 10px !important;
  --ai-workspace-progress: 0%;
  color: #d8d2ec !important;
  border-color: rgba(148, 132, 190, .34) !important;
  background:
    linear-gradient(90deg, rgba(139, 92, 246, .16), rgba(124, 92, 255, .08)) left center / var(--ai-workspace-progress) 100% no-repeat,
    linear-gradient(180deg, rgba(50, 44, 70, .88), rgba(29, 27, 43, .94)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .055),
    inset 0 -1px 0 rgba(0, 0, 0, .18) !important;
  transition:
    color .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    transform .16s ease,
    --ai-workspace-progress .22s ease !important;
}

.ai-context-toolbar .ai-deep-analysis-icon {
  font-size: 10.5px;
  line-height: 1;
}

.ai-context-toolbar .ai-deep-analysis-toggle:hover {
  color: #f4f1ff !important;
  border-color: rgba(167, 139, 250, .52) !important;
  background:
    linear-gradient(90deg, rgba(139, 92, 246, .2), rgba(124, 92, 255, .1)) left center / var(--ai-workspace-progress) 100% no-repeat,
    linear-gradient(180deg, rgba(62, 51, 88, .92), rgba(35, 29, 53, .96)) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle.active,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"],
.ai-context-toolbar .ai-deep-analysis-toggle[data-mode="deep"] {
  color: #ffffff !important;
  border-color: rgba(167, 139, 250, .75) !important;
  background:
    linear-gradient(90deg, rgba(196, 181, 253, .18), rgba(139, 92, 246, .1)) left center / var(--ai-workspace-progress) 100% no-repeat,
    linear-gradient(180deg, rgba(102, 70, 181, .92), rgba(69, 45, 132, .94)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .1),
    0 5px 16px rgba(20, 13, 43, .28),
    0 0 0 1px rgba(139, 92, 246, .08) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle.active:hover,
.ai-context-toolbar .ai-deep-analysis-toggle[aria-pressed="true"]:hover,
.ai-context-toolbar .ai-deep-analysis-toggle[data-mode="deep"]:hover {
  border-color: rgba(196, 181, 253, .88) !important;
  background:
    linear-gradient(90deg, rgba(196, 181, 253, .22), rgba(139, 92, 246, .12)) left center / var(--ai-workspace-progress) 100% no-repeat,
    linear-gradient(180deg, rgba(113, 78, 196, .96), rgba(76, 49, 143, .96)) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle[data-mode="quick"] .ai-deep-analysis-state {
  color: #b8b2ca !important;
  background: rgba(148, 163, 184, .1) !important;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .08) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle.is-confirming,
.ai-context-toolbar .ai-deep-analysis-toggle[data-mode="confirming"],
.ai-context-toolbar .ai-deep-analysis-toggle.is-confirming:hover,
.ai-context-toolbar .ai-deep-analysis-toggle[data-mode="confirming"]:hover {
  color: #ffffff !important;
  border-color: rgba(196, 181, 253, .86) !important;
  background: linear-gradient(180deg, rgba(92, 65, 157, .95), rgba(57, 40, 104, .96)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .1),
    0 5px 16px rgba(20, 13, 43, .28) !important;
}

.ai-context-toolbar .ai-deep-analysis-toggle::before,
.ai-context-toolbar .ai-deep-analysis-toggle::after {
  display: none !important;
}

.ai-deep-analysis-state {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 3px 4px;
  border-radius: 999px;
  color: #a9b2c2;
  background: rgba(148, 163, 184, .1);
  font: 740 8.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .025em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ai-deep-analysis-toggle.active .ai-deep-analysis-state,
.ai-deep-analysis-toggle[aria-pressed="true"] .ai-deep-analysis-state {
  color: #ffffff;
  background: rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.ai-context-toolbar .ai-deep-analysis-toggle[data-mode="confirming"] .ai-deep-analysis-state {
  color: #f5f3ff !important;
  background: rgba(196, 181, 253, .17) !important;
  box-shadow: inset 0 0 0 1px rgba(221, 214, 254, .12) !important;
}

@media (prefers-reduced-motion: reduce) {
  .ai-context-toolbar > button {
    transition-duration: 0s !important;
  }
}

@container (max-width: 400px) {
  .ai-context-toolbar > button {
    padding-inline: 6px !important;
    gap: 5px !important;
    font-size: 11.5px !important;
  }

  .ai-context-toolbar .ai-deep-analysis-state {
    display: none;
  }
}

/* Quiet session cost: part of the input texture, never another toolbar pill. */
.ai-session-cost {
  min-height: 11px;
  margin: -3px 3px 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: rgba(148, 163, 184, .42);
  font: 620 9.5px/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: .045em;
  pointer-events: none;
  user-select: none;
}

.ai-evidence-strip {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid rgba(100, 116, 139, .2);
}

.ai-evidence-strip-title {
  margin-bottom: 8px;
  color: #64748b;
  font: 750 10.5px/1.2 system-ui, sans-serif;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.ai-evidence-strip-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: thin;
}

.ai-evidence-card {
  flex: 0 0 132px;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(100, 116, 139, .22);
  border-radius: 9px;
  color: #334155;
  background: #f8fafc;
  text-align: left;
  cursor: default;
}

.ai-evidence-card:hover {
  border-color: rgba(124, 58, 237, .46);
  box-shadow: 0 5px 16px rgba(15, 23, 42, .12);
}

.ai-evidence-preview {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.ai-evidence-card img {
  display: block;
  width: 100%;
  height: 82px;
  object-fit: cover;
  background: #e2e8f0;
}

.ai-evidence-link {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 6px 7px 7px;
  border: 0;
  color: #334155;
  background: transparent;
  font: 650 10px/1.25 system-ui, sans-serif;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.ai-evidence-link:disabled { cursor: default; opacity: .72; }
