:root {
  /* 1. Primitives (Static) */
  --white: #ffffff;
  --black: #000000;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* 2. Brand Palette */
  --color-primary: #2a7a57;
  --color-primary-rgb: 42, 122, 87;
  --color-primary-strong: var(--text-main);
  --color-primary-soft: rgba(42, 122, 87, 0.2);

  /* 3. Background & Text Color Palettes */
  --bg-highlight: #fff59d;
  --bg-none: transparent;
  --bg-gray: #f1f1ef;
  --bg-brown: #f3eeee;
  --bg-orange: #f8ecdf;
  --bg-yellow: #faf3dd;
  --bg-green: #eef3ed;
  --bg-blue: #e9f3f7;
  --bg-purple: #f6f3f8;
  --bg-pink: #f9f2f5;
  --bg-red: #faecec;

  --bg-text-main: var(--text-main);
  --bg-text-gray: #787774;
  --bg-text-brown: #976d57;
  --bg-text-orange: #cc782f;
  --bg-text-yellow: #c29343;
  --bg-text-green: #548164;
  --bg-text-blue: #487ca5;
  --bg-text-purple: #8a67ab;
  --bg-text-pink: #b35488;
  --bg-text-red: #c4554d;

  /* 4. Functional Theme Tokens (DONT USE DIRECTLY) */
  --bg-app: #000000;
  --bg-surface: #222222;
  --bg-surface-soft: #424242;
  --text-main: #373530;
  --text-muted: #9ca3af;
  --border-main: #262626;
  --border-strong: #404040;

  /* 5. Radii & Effects */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.6);

  /* 6. Intent States */
  --intent-info-border: var(--bg-text-blue);
  --intent-success-border: var(--bg-text-green);
  --intent-warning-border: var(--bg-text-orange);
  --intent-error-border: var(--bg-text-red);
  --intent-important-border: var(--bg-text-purple);
  --intent-quote-border: var(--bg-text-gray);
  --intent-quote-border: var(--bg-text-gray);

  /* Legacy Compat/Internal */
  --tooltip-bg: rgba(0, 0, 0, 0.85);
  --muted: var(--text-muted);
  --scrollbar-thumb: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.3);
}

/* --- Theme Overrides --- */

/* App Shell (Light) Theme */
[data-theme="app"] {
  color-scheme: light;
  --bg-app: #f1f5f9; 
  --bg-surface: #ebe5e5; 
  --bg-surface-soft: #c7c7c7; 
  --text-main: #0f172a; 
  --text-muted: #64748b;
  --border-main: #dfe3f5;
  --border-strong: #cdd4ed;
}

/* Memo (Cream) Theme */
[data-theme="cream"] {
  color-scheme: light;
  --bg-app: #f5f2eb;
  --bg-surface: #fff9f9; 
  --bg-surface-soft: #f3ecec; 
  --text-main: #2f2922;
  --text-muted: #817a71;
  --border-main: #ece4e4;
  --border-strong: #ededed;
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 18px 40px rgba(47, 41, 34, 0.08);
  --color-primary-soft: rgba(42, 122, 87, 0.08);
}

/* Dark Theme */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-app: #000000;
  --bg-surface: #222222;
  --bg-surface-soft: #363636;
  --text-main: #f5f5f5;
  --text-muted: #6d6664;
  --border-main: #4b4949;
  --border-strong: #7d7979;
  --bg-text-gray: #9b9b9b;
  --bg-text-brown: #a27763;
  --bg-text-orange: #cb7b37;
  --bg-text-yellow: #c19138;
  --bg-text-green: #4f9768;
  --bg-text-blue: #447acb;
  --bg-text-purple: #865dbb;
  --bg-text-pink: #ba4a78;
  --bg-text-red: #be524b;
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.15);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.6);
  --color-primary-soft: rgba(42, 122, 87, 0.2);

  /* Dark Intents */
  --intent-info-border: var(--bg-text-blue);
  --intent-success-border: var(--bg-text-green);
  --intent-warning-border: var(--bg-text-orange);
  --intent-error-border: var(--bg-text-red);
  --intent-important-border: var(--bg-text-purple);
}

/* Logo Theme Switch */
.logo-dark {
  display: none !important;
}

[data-theme="dark"] .logo-light {
  display: none !important;
}

[data-theme="dark"] .logo-dark {
  display: block !important;
}

.lucide-spin {
  animation: lucide-spin 1.4s linear infinite;
}

@keyframes lucide-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.lucide-pulse {
  animation: lucide-pulse 1.2s ease-in-out infinite;
  transform-origin: center;
}

@keyframes lucide-pulse {
  0% {
    transform: scale(1);
  }
  20% {
    transform: scale(1.18);
  }
  40% {
    transform: scale(0.98);
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

* {
  box-sizing: border-box;
}


body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
}

body.app-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
}

.page {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.page::-webkit-scrollbar {
  display: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  padding: 0 12px;
  margin-bottom: 2px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  font-size: 14px;
  color: var(--color-primary-strong);
}

.app-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  width: 28px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  font-size: 12px;
  color: var(--color-primary-strong);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.app-home-link:hover,
.app-home-link:focus-visible {
  border-color: var(--color-primary);
  outline: none;
}


.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.tab,
.tab-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--color-primary-strong);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab.active,
.tab-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--white);
}

.tab-action {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--color-primary-strong);
  font-size: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-tab-panels-wrapper {
  position: relative;
  width: 100%;
}

.settings-tab-panel {
  display: none;
  flex-direction: column;
}

.settings-tab-panel:not([hidden]) {
  display: flex;
}

#chatPromptTextarea {
  width: 100%;
  min-height: 200px;
  height: 100%;
  resize: vertical;
  flex: 1;
  box-sizing: border-box;
}

.settings-tab-panel {
  margin-bottom: 16px;
}


.nav-switch-btn {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--color-primary-strong, var(--color-primary-strong));
  padding: 6px 6px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.nav-switch-btn:hover,
.nav-switch-btn:focus-visible {
  border-color: var(--color-primary, var(--color-primary));
  outline: none;
  box-shadow: var(--shadow-sm);
}

.nav-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-switch-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 50;
}

.nav-switch-menu.open {
  display: block;
}

.nav-switch-link {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-primary-strong);
}

.nav-switch-link:hover,
.nav-switch-link:focus-visible {
  background: var(--color-primary-soft);
}

.btn,
button.btn,
.btn-ghost,
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--color-primary-strong, var(--color-primary-strong));
  padding: 6px 10px;
  min-height: 24px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    color 0.15s ease;
  box-shadow: none;
}

.menu-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.menu-panel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--color-primary-strong);
  padding: 8px 12px;
  width: 100%;
  text-align: left;
  border-radius: 0;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.menu-panel-btn:hover,
.menu-panel-btn:focus-visible {
  background: var(--color-primary-soft);
  outline: none;
}

.btn:hover,
.btn:focus-visible,
button.btn:hover,
button.btn:focus-visible {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.context-menu button .btn-primary,
.btn-primary,
button.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--white);
}

/* Shared connect layout + panels */
.connect-layout {
  --context-panel-width: 350px;
  flex: 1;
  padding: 5px 10px;
  display: flex;
  gap: 10px;
  min-height: 0;
}

.connect-left,
.connect-right {
  flex: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.connect-left {
  position: relative;
  flex: 0 0 var(--context-panel-width, 350px);
  max-width: var(--context-panel-width, 350px);
  width: 100%;
  padding: 10px;
}

.connect-left.collapsed {
  display: none;
}

.connect-right {
  padding: 0;
}

.gt-context-modal {
  position: relative;
  --context-panel-width: 350px;
}

.context-panels {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.command-panel,
.script-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;

}

.command-panel {
  flex: 1 1 auto;
}

.script-panel {
  flex: 0 0 auto;
}

.command-panel textarea,
.script-panel textarea {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.context-vertical-resizer {
  position: relative;
  flex: 0 0 auto;
  height: 2px;
  cursor: ns-resize;
  margin: 4px 0;
}

.context-vertical-resizer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 2px;
  background: var(--border-main);
  border-radius: var(--radius-full);
  transform: translate(-50%, -50%);
}

.context-resizer {
  position: absolute;
  top: 0;
  left: -3px;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
  z-index: 2;
  background: transparent;
  display: none;
  touch-action: none;
}

.context-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--border-main);
  transform: translate(-50%, -50%);
}

.connect-left:not(.collapsed) .context-resizer,
.gt-context-modal.open .context-resizer {
  display: block;
}

body.context-resizing {
  cursor: ew-resize;
}

.connect-right.full-width {
  flex: 1 1 100%;
  width: 100%;
}

.connect-left textarea {
  font-size: 12px;
  font-family: var(--font-sans);
}

.gt-context-label {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary-strong);
}

.prompt-input-wrapper {
  position: relative;
  height:100%;
}

.prompt-input-wrapper textarea {
  position: relative;
  background: var(--bg-surface-soft);
  z-index: 1;
  padding: 8px;
  margin: 0;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  box-sizing: border-box;
}

.speech-field-wrapper {
  position: relative;
  height: 100%;
}

.speech-field-wrapper textarea {
  padding-right: 40px;
  position: relative;
  z-index: 2;
}

.chat-composer .speech-button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: none;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.speech-button.active {
  background: var(--color-primary);
  color: var(--white);
}

/* Shared share menu + context menu */
.menu-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.context-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0;
  min-width: 150px;
  max-width: 340px;
  display: none;
  z-index: 1000;
}

.context-menu.open {
  display: block;
}

.context-menu.share-menu {
  right: 0;
  left: auto;
  min-width: 220px;
}

.context-menu.share-menu .menu-panel {
  padding: 12px;
  gap: 8px;
}

.context-menu.share-menu button {
  border-radius: var(--radius-md);
}

.context-menu.share-menu button:hover,
.context-menu.share-menu button:focus {
  border-radius: var(--radius-md);
}

.menu-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
}

.menu-header {
  font-size: 14px;
  font-weight: 700;
}

.share-link-line {
  display: flex;
  gap: 6px;
}

.share-link-field {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-surface-soft);
}

mark {
  background-color: var(--bg-highlight);
}


.share-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.share-menu-status {
  min-height: 16px;
  margin: 0;
  font-size: 12px;
}

.share-menu-status.error {
  color: var(--intent-error-border);
}

/* Shared toast/status area */
.toast,
.status-toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: black;
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 120000;
}

.toast.visible,
.status-toast.visible {
  opacity: 1;
  pointer-events: auto;
}

.feedback-app-launcher-row {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 220;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-app-launcher-row--inline {
  position: static;
  left: auto;
  bottom: auto;
  z-index: auto;
}

.ai-request-counter-toaster {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 140000;
  font-family: "Menlo", "SFMono-Regular", "Consolas", "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.5px;
}

.ai-request-counter-toaster.visible {
  opacity: 1;
  pointer-events: auto;
}

.feedback-app-button {
  border: 1px solid var(--border-main);
  background: var(--bg-app);
  color: var(--text-main);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  text-decoration: none;
}

.feedback-app-button:hover,
.feedback-app-button:focus-visible {
  box-shadow: var(--shadow-lg);
  outline: none;
}

.feedback-app-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 2105;
}

.feedback-app-backdrop.open {
  display: flex;
}

.feedback-app-dialog {
  width: min(95vw, 960px);
  min-width: 800px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow: auto;
  font-size: 13px;
}

.feedback-app-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.feedback-app-dialog h3 {
  margin: 0;
  font-size: 16px;
}

.feedback-app-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-app-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-main);
}

.feedback-app-input,
.feedback-app-dialog select {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--bg-surface-soft);
  color: var(--text-main);
}

.feedback-app-textarea {
  min-height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  background: var(--bg-surface-soft);
  color: var(--text-main);
  resize: vertical;
}

.feedback-app-helper {
  margin: 0;
  font-size: 12px;
  color: var(--text-main);
}

.feedback-app-share-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-app-share-checkbox {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.feedback-app-share-info {
  font-size: 12px;
  color: var(--text-main);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-main);
  background: var(--bg-surface-soft);
}

.feedback-app-share-link {
  display: block;
  word-break: break-word;
  color: var(--color-primary);
  text-decoration: underline;
  margin-top: 4px;
}

.feedback-app-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.feedback-app-cgu-btn {
  margin-right: auto;
}

.feedback-app-actions .btn {
  min-width: 0;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.feedback-app-close-btn {
  border: none;
  background: transparent;
  padding: 4px;
  font-size: 16px;
  color: var(--text-main);
  cursor: pointer;
}

.feedback-app-toast {
  position: fixed;
  bottom: 96px;
  right: 16px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.feedback-app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.btn-secondary,
button.btn-secondary {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 12px;
}

.btn-ghost,
button.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-primary-strong);
}

.btn-small,
button.btn-small {
  min-height: 26px;
  padding: 4px 8px;
  font-size: 11px;
  border-radius:6px;
}

.btn-small-active,
button.btn-small-active {
  background: transparent;
  color: var(--color-primary-strong);
  border-color: var(--color-primary);
}

.tab-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--color-primary-strong);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--white);
}

.global-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.drawer-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  padding: 4px 8px;
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
}

/* Modal shell shared across modules */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 3000;
}

.modal-overlay.open {
  display: flex;
}

.modal-overlay.chat-prompt-shortcuts-overlay {
  z-index: 12050;
}

/* Excalidraw app-wide overrides: ensure left menu max-height and tighter panel spacing */


.app .excalidraw .shapes-section {
  position: absolute;
  right: 0;
  left: auto;
}

.app .excalidraw .HintViewer {
  display: none !important;
}

.app .excalidraw .App-menu__left,
.app .excalidraw .Island.App-menu__left {
  max-height: 500px ;
  overflow-y: auto ;
  position:absolute;
  left: auto ;
  right: 0;
}
.app .excalidraw .panelColumn {
  row-gap: 2px ;
}

.app .excalidraw {
  --editor-container-padding:0px;
}

.app .excalidraw .App-menu_bottom{
  padding: 0px;
  flex-direction: row-reverse ;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 18px;
  width: min(800px, 100%);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header,
.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
  flex-direction: row;
  gap: 4px;
  height: 20px;
}

.modal-header h3,
.modal header h3 {
  margin: 0;
  font-size: 18px;
}

.modal header button {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-main);
}

.modal input,
.modal textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  padding: 10px 12px;
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 14px;
  font-family: var(--font-sans);
}

.modal textarea {
  min-height: 110px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.documents-modal-status {
  font-size: 0.9rem;
  min-height: 1.2rem;
  color: var(--text-main);
}
.documents-modal-status--danger {
  color: var(--intent-error-border);
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-main);
}

label {
  font-size: 14px;
  color: var(--text-main);
  display: block;
  margin-bottom: 4px;
}


.btn-primary {
  border: none;
  background: var(--color-primary);
  color: var(--white);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
}

.gt-template-modal__dialog {
  width: min(1400px, 98vw);
  height: auto;
  max-height: 98vh;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.gt-template-modal__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  --gallery-row-min: 120px;
  grid-auto-rows: minmax(var(--gallery-row-min), auto);
  min-height: calc((var(--gallery-row-min) * 2) + 12px);
  gap: 12px;
  margin: 0;
  overflow-y: auto;
  max-height: 60vh;
}

.gt-template-card {
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
  height: var(--gallery-row-min, 120px);
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
}

.gt-template-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.gt-template-card.gt-template-card--selected {
  border: 2px solid var(--color-primary);
  box-shadow: 0 10px 22px rgba(42, 122, 87, 0.12);
}

.gt-template-card__title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
  text-align: left;
  line-height: 1.2;
}

.gt-template-card__desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-main);
  text-align: left;
  line-height: 1.4;
}

.gt-template-card__superpowers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}

.superpower-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.superpower-pill:hover {
  border-color: var(--color-primary);
}

.superpower-pill.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

@media (max-width: 899px) {
  .gutenberg-card {
    position: fixed;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: auto;
    z-index: 80;
    overflow: auto;
  }
}

/* Shared CGU modal styles */
.gt-nexus-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 260;
}

.gt-nexus-backdrop.open {
  display: flex;
}

#closeNexusBtn {
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 18px;
}

.nexus-modal {
  width: min(1000px, 95vw);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 95vh;
  overflow-y: auto;
  font-size: 15px;
}

.nexus-modal header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  position: relative;
}

.nexus-modal header button {
  position: absolute;
  top: 0;
  right: 0;
}

.nexus-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nexus-content p {
  margin: 0;
  line-height: 1.4;
}

.nexus-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Shared info modal styles */
.info-popup {
  position: absolute;
  top: 56px;
  right: 12px;
  width: 280px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  padding: 15px;
  display: none;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  z-index: 2100;
}

.info-popup.open {
  display: flex;
}

.info-popup img {
  width: 144px;
  height: 144px;
  object-fit: contain;
  align-self: center;
}

.info-popup a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.info-popup button {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  min-width: 110px;
}

.info-popup button.update-btn {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.info-popup button.secondary {
  background: var(--bg-surface);
  border-width: 1px;
  border-style: solid;
  border-color: var(--border-main);
  color: var(--text-main);
}

.info-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.info-actions--stacked {
  flex-direction: column;
  align-items: stretch;
}

.info-actions-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

#__bs_notify__,
.__bs_notify__ {
  display: none !important;
}

#chat-root {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2000;
  --chat-sidebar-width: 0px;
}

.chat-sidebar {
  position: fixed;
  right: 0 !important;
  top: 0 !important;
  height: 100vh !important;
  background: var(--bg-surface) !important;
  border-left: 1px solid var(--border-main);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.05);
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  z-index: 2001;
  overflow: visible;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(100%);
}

.chat-sidebar--open {
  transform: translateX(0) !important;
}

@media (max-width: 1200px) {
  .chat-sidebar {
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
    border-left: none;
    width: 380px;
    max-width: 90vw;
  }
}

.chat-resizer {
  position: absolute;
  left: -5px;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  z-index: 100;
}
#fileMenuBtn,#assistLauncherBtn{
  background: var(--bg-surface);
  border:1px solid var(--border-main);
  margin-right:0px;
  margin-top: 2px;
  margin-bottom: 2px;
}

.chat-resizer:hover {
  background: rgba(0, 0, 0, 0.05);
}

.is-resizing,
.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-main);
}

.chat-header span {
  font-weight: 700;
  font-size : 11px;
  letter-spacing: 0.02em;
}

.chat-header-title {
  order: 0;
  margin-right:auto;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.chat-header-title [data-lucide] {
  width: 24px !important;
  height: 24px !important;
}

.chat-header-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.chat-memoire-modal-toggle {
  font-size: 0.85rem;
  color: var(--text-main);
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid var(--border-main);
  font-weight: 500!important;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.chat-memoire-modal-toggle--refreshing {
  opacity: 0.5;
}

.chat-header-btn {
  padding: 6px 10px;
  position: relative;
}

.chat-header-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 14px;
  height: 14px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: bold;
  padding: 0 3px;
  border: 1.5px solid var(--bg-surface);
  line-height: 1;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  padding: 5px 10px 5px 4px;
  margin-right: -6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
}

.chat-message {
  display: flex;
}

.chat-message--user {
  justify-content: flex-end;
}

.chat-message--bot {
  justify-content: flex-start;
}

.chat-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 100%;
}

.chat-message--bot .chat-content-wrapper {
  align-items: flex-start;
}

.chat-bubble-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.chat-message--bot .chat-bubble-row {
  justify-content: flex-start;
}

.chat-edit-btn,
.chat-undo-btn,
.chat-restore-redo-btn {
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  align-self: center;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: 999px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.chat-message--user:hover .chat-edit-btn,
.chat-message--user:hover .chat-undo-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-1px);
}

.chat-edit-btn:hover,
.chat-undo-btn:hover,
.chat-restore-redo-btn:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.chat-restore-redo-btn {
  opacity: 1;
  pointer-events: auto;
}

.chat-prepend {
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: auto;
  max-width: 100%;
}

.chat-bubble {
  width: auto;
  max-width: 100%;
  border-radius: var(--radius-md);
  padding: 10px 6px 10px 4px;
  background: var(--bg-surface);
  border: 1px solid transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#shareBtn{
  background: var(--bg-surface);
}

.chat-message--user .chat-bubble {
  background: var(--bg-surface-soft);
  border-color: var(--border-main);
  box-shadow: none;
  margin-right: 10px;
  
}

.chat-content {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.45;
}

.chat-content h1,
.chat-content h2,
.chat-content h3 {
  margin: 0 0 6px;
  font-weight: 600;
  line-height: 1.25;
}

.chat-content h1 {
  font-size: 1.05rem;
}

.chat-content h2 {
  font-size: 1rem;
}

.chat-content h3 {
  font-size: 0.95rem;
}

.chat-content p {
  margin: 0 0 6px;
}

.chat-content ul {
  margin: 0 0 6px 18px;
  padding: 0;
}

.chat-content ol {
  margin: 0 0 6px 20px;
  padding: 0;
}

.chat-content blockquote {
  margin: 0 0 6px;
  padding-left: 10px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-main);
}

.chat-content code {
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

.chat-content pre {
  margin: 0 0 6px;
  background: black;
  color: white;
  padding: 10px;
  border-radius: var(--radius-md);
  overflow: auto;
}

.chat-content pre.chat-pre-has-copy {
  position: relative;
  padding-top: 30px;
}

.chat-pre-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 1px solid var(--border-main);
  background: transparent;
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.chat-pre-copy-btn:hover {
  background: var(--bg-surface);
}

.chat-references,
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-references-title,
.chat-suggestions-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chat-references-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-reference-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-reference-link {
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-weight: 600;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.chat-reference-link:hover {
  text-decoration: underline;
}

.chat-reference-detail {
  font-size: 0.75rem;
  color: var(--text-main);
}

.chat-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-suggestion-btn {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: var(--radius-md);
  width: 100%;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-suggestion-btn:hover, .chat-attachment:hover {
  border: 2px solid var(--color-primary);
}

.chat-attachment-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Chat bubble action buttons (Accept/Reject all) */
.chat-bubble-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-main);
}

.chat-bubble-action-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-soft);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
}

.chat-bubble-action-btn:hover {
  background: var(--bg-app);
  border-color: var(--border-strong);
}

.chat-bubble-action-keep {
  color: var(--intent-success-border);
}

.chat-bubble-action-reject {
  color: var(--intent-error-border);
}.chat-attachment {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  background: transparent;
  font-size: 0.75rem;
  color: var(--text-main);
  border: 1px solid var(--border-main);
}

.chat-doc-preview {
  position: fixed;
  top: 0;
  left: 0;
  right: var(--chat-sidebar-width, 0px);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-main);
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 28;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
  overflow: hidden;
}

.chat-doc-preview.open {
  transform: translateX(0);
}

.chat-doc-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-doc-preview__back {
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-main);
}

.chat-doc-preview__title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-doc-preview__close {
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-main);
}

.chat-doc-preview__import {
  margin-left: auto;
}

.chat-doc-preview__body {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--bg-surface);
  font-size: 0.78rem;
  line-height: 1.45;
}

.chat-knowledge-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: var(--chat-sidebar-width, 0px);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-main);
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
  overflow: hidden;
  font-size: 14px;
}

.chat-knowledge-modal.open {
  transform: translateX(0);
}

.chat-knowledge-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-knowledge-modal__header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-knowledge-modal__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-knowledge-modal__title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-main);
}

.chat-knowledge-modal__title[data-status="error"] {
  color: var(--intent-error-border);
}

.chat-knowledge-modal__close {
  border: none;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-main);
}

.chat-knowledge-modal__add, .chat-knowledge-modal__reset {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-main);
}


.chat-knowledge-modal__list {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--bg-surface-soft);
  font-size: 14px;
}

.chat-knowledge-modal__row {
  display: grid;
  grid-template-columns: 24px minmax(180px, 1.2fr) 90px minmax(240px, 2fr) 110px;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
}

.chat-knowledge-modal__row--header {
  font-weight: 600;
  color: var(--text-main);
  padding-top: 0;
}

.chat-knowledge-modal__header-sort {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

@media (max-width: 900px) {
  .modal,
  .feedback-app-dialog {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
  }

  .gt-template-modal__dialog {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 98vh;
    margin: 0;
    border-radius: 0;
  }
}

.chat-knowledge-modal__header-sort[data-direction="asc"]::after,
.chat-knowledge-modal__header-sort[data-direction="desc"]::after {
  font-size: 0.65em;
  margin-left: 4px;
}

.chat-knowledge-modal__header-sort[data-direction="asc"]::after {
  content: "\25B2";
}

.chat-knowledge-modal__header-sort[data-direction="desc"]::after {
  content: "\25BC";
}

.chat-knowledge-modal__checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
}

.chat-knowledge-modal__name {
  border: none;
  background: transparent;
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  text-align: left;
}

.chat-knowledge-modal__header-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
}

.chat-knowledge-modal__name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-knowledge-modal__edit {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-main);
  font-size: 14px;
  padding: 0;
}

.chat-knowledge-modal__reindex {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-main);
  font-size: 14px;
  padding: 0;
}

.chat-knowledge-modal__source {
  color: var(--text-main);
  font-size: 14px;
}

.chat-knowledge-modal__name:hover {
  text-decoration: underline;
}

.chat-knowledge-modal__abstract {
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chat-knowledge-modal__date {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.chat-knowledge-modal__empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px;
}

.chat-doc-preview__body h1,
.chat-doc-preview__body h2,
.chat-doc-preview__body h3,
.chat-doc-preview__body h4 {
  margin: 1rem 0 0.5rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-main);
}

.chat-doc-preview__body p {
  margin: 0 0 0.75rem;
  color: var(--text-main);
}

.chat-doc-preview__body ul,
.chat-doc-preview__body ol {
  margin: 0 0 0.75rem 1.25rem;
  color: var(--text-main);
}

.chat-doc-preview__body blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-main);
  background: rgba(128, 128, 128, 0.1);
}

.chat-doc-preview__body pre,
.chat-doc-preview__body code {
  background-color: var(--bg-app);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", monospace;
  font-size: 12px;
}

.chat-doc-preview__body pre {
  padding: 0.75rem;
  overflow: auto;
}

.chat-doc-preview__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
}

.chat-doc-preview__body th,
.chat-doc-preview__body td {
  border: 1px solid var(--border-main);
  padding: 0.4rem;
  text-align: left;
}
.chat-doc-preview__iframe {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: none;
}

.chat-doc-preview__loading {
  color: var(--text-muted);
}

.chat-doc-preview__error {
  margin-top: 12px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--intent-error-border);
  border: 1px solid var(--intent-error-border);
  font-weight: 600;
}

.chat-doc-preview__line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
  border-radius: var(--radius-md);
  vertical-align: top;
  margin-right: 1rem;
}

.chat-doc-preview__line--highlight {
  background: var(--bg-surface);
}

.chat-doc-preview__text-match {
  background: rgba(253, 224, 71, 0.4);
  border-radius: 3px;
  padding: 0 2px;
}

.chat-doc-preview__line-number {
  min-width: 24px;
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chat-doc-preview__line-text {
  white-space: pre-wrap;
  word-break: break-word;
  display: block;
  flex: 1;
}

.chat-attachment-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}





.chat-composer {
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 6px;
  background: var(--bg-surface-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border 0.15s ease;
  position: relative;
}

.chat-composer--inline {
  flex: 1;
  width: 100%;
}

.chat-composer-attachments {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 2px 0;
}

.chat-composer-attachments__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chat-composer-queue {
  display: flex;
  width: 100%;
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 4px;
}

.chat-composer-queue__list {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 2px;
}

.chat-composer-queue__item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 2px 4px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
}

.chat-composer-queue__name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-main);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-composer-queue__remove {
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 1;
  color: var(--text-main);
  padding: 0;
  flex: 0 0 auto;
}

.chat-composer-queue__remove:hover,
.chat-composer-queue__remove:focus-visible {
  color: var(--text-main);
  outline: none;
}

.chat-composer-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 8px;
  background: transparent;
  border-radius: var(--radius-full);
  color: var(--text-main);
  border: 1px solid var(--border-main);
  cursor: pointer;
}

.chat-composer-attachment__name {
  color: var(--text-main);
}

.chat-composer-attachment[data-enabled="true"] {
  border: 2px solid var(--color-primary);
}

.chat-composer-attachment[data-enabled="false"] {
  border: 1px solid var(--border-main);
  color: var(--text-muted);
}

.chat-composer-attachment__remove {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  color: var(--text-main);
  padding: 0;
}

.chat-composer-attachment__remove:hover,
.chat-composer-attachment__remove:focus-visible {
  color: var(--text-main);
  outline: none;
}

.chat-composer--listening {
  border: 2px solid var(--intent-error-border) !important;
  animation: speech-border 2s infinite ease-in-out;
}

@keyframes speech-border {
  0% {
    border-color: rgba(177, 18, 38, 0.6);
  }
  50% {
    border-color: rgba(177, 18, 38, 1);
    box-shadow: 0 0 16px rgba(177, 18, 38, 0.4);
  }
  100% {
    border-color: rgba(177, 18, 38, 0.6);
  }
}

.chat-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0;
  resize: none;
  font-family: var(--font-sans);
  font-size: 14px;
  min-height: 56px;
  max-height: 140px;
  color: var(--text-main);
  background-color: transparent;
}

.chat-input:focus {
  border-color: transparent;
  box-shadow: none;
  outline: none;
}

.chat-composer:focus-within {
  border: 2px solid var(--color-primary);
}

.chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-composer-left-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-prompt-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-prompt-btn {
  min-width: 32px;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 12px;
}

.chat-prompt-shortcuts-btn {
  min-width: 32px;
  padding: 4px 8px;
}

.chat-prompt-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  z-index: 40;
}

.chat-prompt-menu.open {
  display: flex;
}

.chat-prompt-menu-item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  color: var(--text-main);
}

.chat-prompt-menu-item.active {
  background: var(--color-primary-soft);
  font-weight: 600;
}

.chat-prompt-menu-item:hover {
  background: var(--bg-surface-soft);
}

.chat-prompt-shortcuts-modal {
  width: min(95vw, 1100px);
  height: auto;
  max-width: 1100px;
  max-height: 95vh;
  overflow: hidden;
  z-index: 12050;
  display: flex;
  flex-direction: column;
}

.chat-prompt-shortcuts__header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-prompt-shortcuts__search {
  padding: 0;
}

.chat-prompt-shortcuts__search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13px;
}

.chat-prompt-shortcuts__search-input::placeholder {
  color: var(--text-muted);
}

.chat-prompt-shortcuts__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-main);
}

.chat-prompt-shortcuts__filter {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-prompt-shortcuts__filter.active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--text-main);
}

.chat-prompt-shortcuts__filter i {
  width: 14px;
  height: 14px;
}

.chat-prompt-shortcuts__filter span {
  text-transform: uppercase;
}

.chat-prompt-shortcuts__pager {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 8px;
}

.chat-prompt-shortcuts__pager-btn {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-main);
}

.chat-prompt-shortcuts__pager-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-prompt-shortcuts__pager-label {
  font-variant-numeric: tabular-nums;
}

.chat-prompt-shortcuts__grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
  min-height: 0;
}

.prompt-card {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 10px 10px 25px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  color: var(--text-main);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.prompt-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.prompt-card__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.prompt-card__meta i {
  width: 14px;
  height: 14px;
}

.prompt-card__meta span {
  text-transform: uppercase;
}

.prompt-card__title {
  font-weight: 600;
  font-size: 14px;
}

.prompt-card__content {
  font-size: 12px;
  color: var(--text-main);
  opacity: 0.85;
  display: block;
  overflow: visible;
  line-height: 1.5;
}

.chat-prompt-shortcuts__empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 12px;
}

@media (max-width: 720px) {
  .chat-prompt-shortcuts__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
}

.chat-input-wrapper {
  position: relative;
}

.chat-input-wrapper .speech-button {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 32px;
  height: 32px;
  background: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  color: var(--text-main);
  border-radius: var(--radius-full);
  transition: box-shadow 0.2s ease, opacity 0.2s ease;
  opacity: 1;
  pointer-events: auto;
  z-index: 3;
}

.chat-input-wrapper .speech-button.active {
  color: var(--intent-error-border);
}

.speech-button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  color: var(--text-main);
  border-radius: var(--radius-full);
  transition: box-shadow 0.2s ease, opacity 0.2s ease;
  opacity: 1;
  pointer-events: auto;
  z-index: 3;
}
.chat-composer .speech-button.active {
  color: var(--intent-error-border);
  box-shadow: 0 0 12px rgba(177, 18, 38, 0.35);
}

.chat-scroll-btn {
  min-width: 36px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  padding-left: 8px;
  padding-right: 8px;
}

.chat-scroll-btn:hover,
.chat-scroll-btn:focus-visible {
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
}

.chat-speech-btn.active {
  color: var(--intent-error-border);
  box-shadow: 0 0 12px rgba(177, 18, 38, 0.35);
}

.chat-selection-follow-btn.active {
  color: var(--color-primary);
  box-shadow: 0 0 10px rgba(41, 74, 190, 0.2);
}

.chat-docs-indicator {
  min-width: 32px;
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 8px;
  min-width: 110px;
  text-align: left;
}

/* Ensure [hidden] always hides the attachment indicator (author display rules would otherwise override). */
.chat-docs-indicator[hidden],
.chat-attached-files-indicator[hidden] {
  display: none !important;
}

.chat-docs-indicator__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.modal select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font: inherit;
}

.chat-delete .chat-docs-indicator__delete {
  padding-left: 8px;
  cursor: pointer;
  padding: 0 4px;
  font-weight: 700;
  color: #fff;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}

.chat-docs-indicator__delete:hover {
  opacity: 1;
}

.chat-attached-files-indicator.ai-request-counter-toaster {
  cursor: pointer;
}

.chat-attached-files-indicator__delete {
  margin-left: 6px;
  font-weight: 700;
  opacity: 0.8;
}

.chat-attached-files-indicator__delete:hover {
  opacity: 1;
}

.chat-send-btn {
  min-width: 36px;
  padding: 6px 0px;
}

.chat-toggle-button {
  position: static;
  box-shadow: none;
  margin-right: 6px;
}

@media (max-width: 720px) {
  .chat-sidebar {
    width: auto;
    max-width: 90vw;
  }

  .chat-bubble {
    max-width: 96%;
  }

  .chat-toggle-button {
    position: static;
    margin-right: 0;
  }
}

.chat-input::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 3px;
}

.chat-input::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages:hover::-webkit-scrollbar-thumb {
  opacity: 1;
}

.chat-input {
  scrollbar-width: thin;
}

.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.chat-messages:hover {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* Highlight added text in pale yellow */
.highlight-added {
    background-color: var(--bg-surface) !important;
    transition: background-color 2s ease-out;
}

/* Markdown highlight color for == markers */
.markdown-highlighting .cl-mark-text {
    background-color: var(--bg-surface) !important;
}
/* Bubble menu (contextual buttons for selection) */
.bubble-menu {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.bubble-menu-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-main);
  border-radius: 3px;
  background: var(--bg-surface-soft);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.bubble-menu-btn:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.bubble-keep {
  color: var(--intent-success-border);
}

.bubble-reject {
  color: var(--intent-error-border);
}

.table-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 20px);
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
  z-index: 1100;
  pointer-events: auto;
}

.table-color-option {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border-main);
}

/* Toolbar action buttons (global keep/reject all) */
.toolbar-action-btn {
  min-width: 28px;
  padding: 0 !important;
  font-size: 12px;
  font-weight: 600;
}

.toolbar-keep {
  color: var(--intent-success-border);
}

.toolbar-reject {
  color: var(--intent-error-border);
}

/* Inline Editor Floating Component */
#chat-inline-editor-container {
  position: fixed;
  pointer-events: none;
  z-index: 999;
}

.chat-inline-editor {
  display: flex;
  gap: 0;
  align-items: stretch;
  background: var(--bg-surface);
  padding: 0.25rem;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2), 4px 0 12px rgba(0, 0, 0, 0.1), -4px 0 12px rgba(0, 0, 0, 0.1);
  pointer-events: auto;
}

.chat-inline-editor__wrapper {
  position: relative;
  display: flex;
  width: max(700px,70vh);
  height: auto;
  pointer-events: auto;
}

.chat-inline-editor__input {
  width: 100%;
  min-height: 32px;
  max-height: calc(1.4em * 5 + 16px);
  padding: 8px 22px 8px 8px;
  border: none;
  border-radius: 0;
  font-family: inherit;
  font-size: 0.85rem;
  resize: none;
  overflow-y: hidden;
  word-wrap: break-word;
  line-height: 1.4;
  background: var(--bg-surface);
  pointer-events: auto;
}

.chat-inline-editor__input:focus {
  outline: none;
}

.chat-inline-editor__input::placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8rem;
}

.chat-inline-editor__btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  padding: 0;
  width: 20px;
  height: 20px;
  background: transparent;
  color: var(--text-main);
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 400;
  white-space: nowrap;
  transition: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: auto;
}

.chat-inline-editor__btn:hover {
  background: transparent;
  box-shadow: none;
  opacity: 0.7;
}

.chat-inline-editor__btn:active {
  transform: none;
  opacity: 0.5;
}

.gallery-nav {
  position: relative;
}

.gallery-nav__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  z-index: 2;
}

.gallery-nav__btn i {
  width: 16px;
  height: 16px;
}

.gallery-nav__btn:hover {
  background: var(--bg-surface-soft);
}

.gallery-nav__prev {
  left: -18px;
}

.gallery-nav__next {
  right: -18px;
}
