/* Nabgol Chat Engine v3 — interactive components (dark + light safe) */

.nabgol-inline-components {
  margin: 10px 0 4px;
  padding: 10px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  direction: rtl;
  text-align: right;
}

.message-bubble > .nabgol-inline-components {
  margin-top: 12px;
  padding-top: 12px;
}

.message-bubble.ui-only > .text:empty {
  display: none;
  margin: 0;
  padding: 0;
  min-height: 0;
}

.nabgol-inline-doc {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.08);
  direction: rtl;
  text-align: right;
}

.nabgol-inline-doc-head {
  font-size: 13px;
  font-weight: 700;
  color: #6ee7b7;
  margin: 0 0 8px;
}

.nabgol-workflow-badge {
  direction: rtl;
  text-align: right;
}

.nabgol-component {
  box-sizing: border-box;
  max-width: 100%;
  margin: 12px 0 0;
  color: #e8edf3;
  font-size: 14px;
  line-height: 1.55;
  direction: rtl;
  text-align: right;
}

.nabgol-component button,
.nabgol-component input,
.nabgol-component textarea {
  font: inherit;
}

/* Interactive CTAs — compact responsive grid */
body:is(.desktop-chat, .mobile-chat) .nabgol-choice {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

body:is(.desktop-chat, .mobile-chat) .nabgol-choice legend {
  grid-column: 1 / -1;
}

.nabgol-choice {
  border: 0;
  padding: 0;
  margin: 0;
}

.nabgol-choice legend,
.nabgol-input-label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 10px;
  color: #f3f6fa;
}

.nabgol-choice-button,
.nabgol-text-input button,
.nabgol-multi-submit {
  display: block;
  width: 100%;
  text-align: right;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  padding: 11px 14px;
  margin: 0 0 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.nabgol-choice-button:hover,
.nabgol-text-input button:hover,
.nabgol-multi-submit:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(52, 211, 153, 0.65);
  color: #fff;
}

.nabgol-choice-button:active,
.nabgol-text-input button:active,
.nabgol-multi-submit:active {
  transform: translateY(1px);
}

.nabgol-choice-button.is-selected {
  border-color: #34d399;
  background: rgba(16, 185, 129, 0.28);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.35);
}

.nabgol-other-option {
  border-style: dashed;
  opacity: 0.92;
  grid-column: 1 / -1;
}

/* Cursor-like typeable option: full-width slot, not a mini form + green Send */
.nabgol-custom-input,
.nabgol-custom-input--composer {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.nabgol-custom-input.is-open,
.nabgol-custom-input--composer.is-open {
  opacity: 1;
  transform: translateY(0);
}

.nabgol-custom-input[hidden] {
  display: none !important;
}

.nabgol-custom-input-shell {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 48px;
  padding: 4px 4px 4px 6px;
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 14px;
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.12), 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.nabgol-custom-input-shell:focus-within {
  border-color: rgba(52, 211, 153, 0.75);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.22), 0 10px 28px rgba(0, 0, 0, 0.22);
}

.nabgol-custom-input-shell.is-empty {
  animation: nabgolCustomShake 0.4s ease;
}

@keyframes nabgolCustomShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.nabgol-custom-input-field,
.nabgol-custom-input input.nabgol-custom-input-field {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 40px;
  margin: 0;
  border: 0 !important;
  border-radius: 10px;
  background: transparent !important;
  color: #f8fafc;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  box-shadow: none !important;
  outline: none;
}

.nabgol-custom-input-field::placeholder {
  color: rgba(226, 232, 240, 0.52);
}

.nabgol-custom-input-go {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: #10b981;
  color: #042f2e;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

.nabgol-custom-input-shell.has-value .nabgol-custom-input-go {
  opacity: 1;
}

.nabgol-custom-input-go:hover {
  background: #34d399;
  transform: translateY(-1px);
}

.nabgol-custom-input-go:active {
  transform: translateY(1px);
}

.nabgol-custom-input-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.nabgol-custom-input-hint {
  font-size: 11px;
  line-height: 1.3;
  color: rgba(226, 232, 240, 0.45);
  letter-spacing: 0.01em;
}

.nabgol-custom-input-cancel {
  border: 0;
  background: transparent;
  color: rgba(226, 232, 240, 0.62);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 8px;
}

.nabgol-custom-input-cancel:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
}

/* Legacy row (text_input / older mounts) */
.nabgol-custom-input:not(.nabgol-custom-input--composer) {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
  align-items: stretch;
  opacity: 1;
  transform: none;
}

.nabgol-multi-submit {
  margin-top: 4px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(52, 211, 153, 0.55);
}

.nabgol-custom-input:not(.nabgol-custom-input--composer) input,
.nabgol-text-input-field {
  min-width: 0;
  flex: 1 1 auto;
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #f8fafc;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.nabgol-text-input-field--long {
  min-height: 120px;
  flex: 1 1 100%;
}

.nabgol-text-input-row:has(.nabgol-text-input-field--long) {
  flex-wrap: wrap;
}

.nabgol-text-input-row:has(.nabgol-text-input-field--long) .nabgol-text-input-field--long {
  flex: 1 1 100%;
}

.nabgol-text-input-row:has(.nabgol-text-input-field--long) button {
  margin-inline-start: auto;
}

.nabgol-custom-input-field::placeholder,
.nabgol-text-input-field::placeholder {
  color: rgba(226, 232, 240, 0.55);
}

.nabgol-custom-input:not(.nabgol-custom-input--composer) > button,
.nabgol-text-input button {
  width: auto;
  min-width: 72px;
  margin: 0;
  background: #10b981;
  border-color: #10b981;
  color: #fff;
  font-weight: 700;
}

.nabgol-text-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.nabgol-text-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

.nabgol-text-input form,
.nabgol-confirmation {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nabgol-chat-reply-hint {
  display: none !important;
}

.nabgol-hint-body {
  margin: 0;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.55;
}

.nabgol-hint-quiet {
  opacity: 0.75;
  font-size: 12px;
}

.nabgol-input-label {
  margin: 0;
  font-weight: 600;
  color: #f3f6fa;
}

.nabgol-confirmation p {
  margin: 0 0 4px;
  color: #f3f6fa;
  font-weight: 600;
}

.nabgol-slider {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.nabgol-slider-label,
.nabgol-slider span.nabgol-slider-label {
  color: #f3f6fa;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.5;
}

.nabgol-slider input[type="range"] {
  width: 100%;
  accent-color: #10b981;
  margin: 2px 0;
}

.nabgol-slider-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #94a3b8;
}

.nabgol-slider-value,
.nabgol-slider output.nabgol-slider-value {
  font-weight: 800;
  color: #6ee7b7;
  font-size: 14px;
}

.nabgol-slider-min,
.nabgol-slider-max {
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
}

.nabgol-component[data-committed="true"] {
  opacity: 0.5;
}

.nabgol-component button:disabled,
.nabgol-component input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.nabgol-choice-button:focus-visible,
.nabgol-text-input button:focus-visible,
.nabgol-component input:focus-visible {
  outline: 3px solid rgba(52, 211, 153, 0.45);
  outline-offset: 2px;
}

.nabgol-workflow-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 16px 0 12px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.nabgol-workflow-badge[data-completed="true"] {
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
  border-color: rgba(96, 165, 250, 0.4);
}

.nabgol-card {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.nabgol-card h3 {
  margin: 0 0 8px;
  color: #f3f6fa;
}

.nabgol-table-wrap {
  overflow: auto;
}

.nabgol-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.nabgol-table-wrap th,
.nabgol-table-wrap td {
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 8px;
  text-align: right;
}

.nabgol-chart {
  height: 300px;
  margin-inline: 0;
}

.nabgol-chart figcaption {
  font-weight: 700;
  margin-bottom: 8px;
  color: #f3f6fa;
}

.nabgol-chart canvas {
  width: 100% !important;
  height: 260px !important;
}

.nabgol-chart-fallback {
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  color: #cbd5e1;
}

.nabgol-markdown-body {
  line-height: 1.8;
  word-break: break-word;
  color: #e8edf3;
}

.nabgol-markdown-body h1,
.nabgol-markdown-body h2,
.nabgol-markdown-body h3 {
  margin: 16px 0 8px;
  color: #f8fafc;
}

.nabgol-markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.nabgol-markdown-body th,
.nabgol-markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 8px;
  text-align: right;
}

.nabgol-markdown-body pre {
  background: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
}

/* Light theme fallback (if ever used) */
html[data-theme="light"] .nabgol-component,
html.light .nabgol-component {
  color: #0f172a;
}

html[data-theme="light"] .nabgol-choice legend,
html[data-theme="light"] .nabgol-input-label,
html.light .nabgol-choice legend,
html.light .nabgol-input-label {
  color: #0f172a;
}

html[data-theme="light"] .nabgol-choice-button,
html.light .nabgol-choice-button {
  background: #fff;
  color: #0f172a;
  border-color: #cbd5e1;
}

html[data-theme="light"] .nabgol-custom-input-shell,
html.light .nabgol-custom-input-shell {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(5, 150, 105, 0.4);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.1), 0 6px 18px rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] .nabgol-custom-input-shell:focus-within,
html.light .nabgol-custom-input-shell:focus-within {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(5, 150, 105, 0.65);
}

html[data-theme="light"] .nabgol-custom-input-field,
html.light .nabgol-custom-input-field {
  color: #0f172a;
  background: transparent !important;
}

html[data-theme="light"] .nabgol-custom-input-field::placeholder,
html.light .nabgol-custom-input-field::placeholder {
  color: rgba(100, 116, 139, 0.75);
}

html[data-theme="light"] .nabgol-custom-input-hint,
html.light .nabgol-custom-input-hint {
  color: rgba(100, 116, 139, 0.7);
}

html[data-theme="light"] .nabgol-custom-input-cancel,
html.light .nabgol-custom-input-cancel {
  color: rgba(71, 85, 105, 0.85);
}

html[data-theme="light"] .nabgol-custom-input-cancel:hover,
html.light .nabgol-custom-input-cancel:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .nabgol-custom-input:not(.nabgol-custom-input--composer) input,
html.light .nabgol-custom-input:not(.nabgol-custom-input--composer) input {
  background: #fff;
  color: #0f172a;
  border-color: #cbd5e1;
}

/* Mobile — Material 3 chip style + thumb zone (Android parity) */
body.mobile-chat .nabgol-inline-components {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

body.mobile-chat .nabgol-choice {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

body.mobile-chat .nabgol-choice legend {
  display: block;
  width: 100%;
  margin-bottom: 6px;
}

body.mobile-chat .nabgol-choice-button,
body.mobile-chat .nabgol-multi-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 16px;
  margin: 0;
  touch-action: manipulation;
}

body.mobile-chat .nabgol-panel-badge {
  position: sticky;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 12;
}

body.mobile-chat .messages {
  padding-bottom: 8px;
}

body.mobile-chat .chat-input:focus-within ~ .nabgol-panel-badge,
body.mobile-chat .chat-input:focus-within .nabgol-panel-badge {
  transform: translateY(-4px);
}

/* Typing indicator — classic 3 dots (never break this) */
.typing-indicator.show {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.typing-indicator .typing-dots,
.typing-indicator .nabgol-skeleton.typing-dots {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 5px;
  margin: 0;
  max-width: none;
}

.typing-indicator .typing-dots span,
.typing-indicator.show .typing-dots span {
  display: inline-block !important;
  width: 8px !important;
  height: 8px !important;
  border-radius: 50% !important;
  background: var(--text-secondary, #94a3b8) !important;
  animation: typing 1.4s infinite !important;
  background-image: none !important;
}

.typing-indicator .typing-dots span:nth-child(1) { animation-delay: 0s !important; width: 8px !important; }
.typing-indicator .typing-dots span:nth-child(2) { animation-delay: 0.2s !important; width: 8px !important; }
.typing-indicator .typing-dots span:nth-child(3) { animation-delay: 0.4s !important; width: 8px !important; }

/* Optional skeleton bars only if explicitly requested (not used on public chat) */
.typing-indicator .nabgol-skeleton:not(.typing-dots) {
  display: none;
}

@keyframes nabgol-skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Chat bubble markdown parity (tables + code copy) */
.message.assistant,
.message.user {
  direction: rtl;
}

.message-body {
  direction: rtl;
  text-align: right;
}

.message.assistant .text,
.message.user .text {
  line-height: 1.75;
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: isolate;
}

body.desktop-chat .message,
body.desktop-chat .message-body,
body.desktop-chat .message-bubble,
body.desktop-chat .message .text,
body.mobile-chat .message,
body.mobile-chat .message-body,
body.mobile-chat .message-bubble,
body.mobile-chat .message .text {
  direction: rtl !important;
  text-align: right !important;
}

.message.assistant .text p,
.message.user .text p,
.message.assistant .text li,
.message.user .text li,
.message.assistant .text h1,
.message.assistant .text h2,
.message.assistant .text h3,
.message.assistant .text h4,
.message.user .text h1,
.message.user .text h2,
.message.user .text h3,
.message.user .text h4,
.nabgol-markdown-body,
.nabgol-markdown-body p,
.nabgol-inline-doc,
.nabgol-inline-doc p {
  direction: rtl !important;
  text-align: right !important;
}

.message.assistant .text pre,
.message.user .text pre,
.message.assistant .text code,
.message.user .text code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.message.assistant .text p,
.message.user .text p {
  margin: 0 0 0.9em;
}

.message.assistant .text p:last-child,
.message.user .text p:last-child {
  margin-bottom: 0;
}

.message.assistant .text li,
.message.user .text li {
  margin: 0.35em 0;
  line-height: 1.7;
}

.message.assistant .text ol,
.message.user .text ol,
.nabgol-markdown-body ol {
  margin: 0.55em 0 0.9em;
  padding-inline-start: 1.5em;
  list-style-type: persian;
}

.message.assistant .text ul,
.message.user .text ul,
.nabgol-markdown-body ul {
  margin: 0.55em 0 0.9em;
  padding-inline-start: 1.35em;
}

.message.assistant .text ol > li::marker,
.message.user .text ol > li::marker,
.nabgol-markdown-body ol > li::marker {
  unicode-bidi: isolate;
  font-weight: 700;
  color: #86efac;
}

.nabgol-workflow-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  margin: 16px 0 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #bbf7d0;
  font-size: 12px;
  font-weight: 700;
  direction: rtl;
  text-align: right;
}

.nabgol-markdown-body {
  direction: rtl;
  text-align: right;
}

.nabgol-workspace-title,
#splitPanel .nabgol-markdown-body {
  direction: rtl;
  text-align: right;
}

.message.assistant .text .nabgol-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px 0;
}

.message.assistant .text .nabgol-code-block {
  position: relative;
  margin: 10px 0;
}

.message.assistant .text .nabgol-code-block pre {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
}

.message.assistant .text .nabgol-copy-code {
  position: absolute;
  top: 8px;
  left: 8px;
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

/* Keyboard avoidance — mobile (Android parity step 9) */
body.mobile-chat {
  min-height: var(--app-height, 100dvh);
}

body.mobile-chat .chat-main {
  max-height: calc(var(--app-height, 100dvh) - 120px);
}

body.mobile-chat .chat-messages,
body.mobile-chat #messages {
  max-height: calc(var(--app-height, 100dvh) - 168px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.mobile-chat .chat-input {
  position: sticky;
  bottom: 0;
  z-index: 20;
  transition: transform 0.16s ease;
}

body.mobile-chat.nabgol-keyboard-open .chat-input {
  transform: translateY(calc(-1 * var(--keyboard-offset, 0px)));
}

body.mobile-chat.nabgol-keyboard-open .nabgol-inline-components {
  transform: translateY(calc(-1 * var(--keyboard-offset, 0px)));
  transition: transform 0.16s ease;
}

/* Nabgol plant DB card + organ / mode pickers */
.plant-organ-picker {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 0.35rem;
}
.plant-organ-label,
.plant-mode-label {
  display: block;
  font-size: 0.82rem;
  color: #143222;
  margin-bottom: 0.45rem;
  font-weight: 700;
}
.plant-organ-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.plant-mode-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}
@media (min-width: 560px) {
  .plant-mode-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.plant-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: right;
  border: 1.5px solid #b7cfc0;
  background: #fff;
  color: #13261a;
  border-radius: 14px;
  padding: 0.65rem 0.7rem;
  cursor: pointer;
  min-height: 64px;
  font-family: inherit;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.plant-mode-card__title {
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.35;
}
.plant-mode-card__hint {
  font-size: 0.72rem;
  line-height: 1.4;
  color: #3d5c4a;
  font-weight: 600;
}
.plant-mode-card--species {
  border-color: #7cbc8e;
}
.plant-mode-card--disease {
  border-color: #e0a28a;
}
.plant-mode-card--both {
  border-color: #8bb8d8;
}
.plant-mode-card--chat {
  border-color: #c4b5a0;
}
.plant-mode-card.is-active {
  box-shadow: 0 0 0 2px rgba(27, 94, 42, 0.18);
  transform: translateY(-1px);
}
.plant-mode-card--species.is-active {
  background: linear-gradient(180deg, #e8f7ec, #d7efdf);
  border-color: #1b7a3a;
  color: #0b3a1c;
}
.plant-mode-card--disease.is-active {
  background: linear-gradient(180deg, #fff1ea, #ffe2d4);
  border-color: #c45a2e;
  color: #5a220e;
}
.plant-mode-card--both.is-active {
  background: linear-gradient(180deg, #eaf5ff, #d9ecfb);
  border-color: #2a6f9e;
  color: #123a52;
}
.plant-mode-card--chat.is-active {
  background: linear-gradient(180deg, #f7f1e8, #efe6d8);
  border-color: #8a6b3d;
  color: #3d2a12;
}
.plant-mode-card:hover {
  transform: translateY(-1px);
}
.plant-organ-chip {
  border: 1px solid #9ab89f;
  background: #ffffff;
  color: #14261a;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.plant-organ-chip.active {
  border-color: #1b5e2a;
  background: #dcefe0;
  color: #0d2f18;
  font-weight: 700;
}
.external-tool-card {
  margin: 0.5rem 0.75rem;
  padding: 0.95rem 1.05rem;
  border-radius: 16px;
  background: #ffffff;
  color: #13261a;
  border: 1px solid #2f6b3a;
  box-shadow: 0 2px 10px rgba(19, 38, 26, 0.1);
  max-width: 36rem;
}
.external-tool-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.45rem;
  background: #dcefe0;
  color: #0d3b1c;
}
.external-tool-card--disease .external-tool-badge {
  background: #ffe5d8;
  color: #7a2e14;
}
.external-tool-card.is-error {
  background: #fff8f6;
  border-color: #a03c28;
  color: #3a1a14;
}
.external-tool-title {
  font-weight: 800;
  font-size: 0.98rem;
  color: #0f3d1f;
  margin-bottom: 0.4rem;
  line-height: 1.45;
}
.external-tool-card.is-error .external-tool-title {
  color: #7a2418;
}
.external-tool-summary {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #1a2e22;
  font-weight: 600;
}
.external-tool-cands {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.external-tool-cand {
  background: #f3faf5;
  border: 1px solid #cfe3d5;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  color: #14261a;
}
.external-tool-cand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.external-tool-cand-name {
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f3d1f;
  line-height: 1.4;
}
.external-tool-cand-score {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 800;
  color: #0d3b1c;
  background: #dff3e6;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
}
.external-tool-cand-meta {
  font-size: 0.78rem;
  color: #345040;
  margin-top: 0.28rem;
  line-height: 1.45;
  font-weight: 600;
}
.external-tool-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}
.external-tool-thumb {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #c5d9ca;
  background: #eef5f0;
}
.external-tool-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.plant-analysis-picker {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 0.45rem;
}

/* Telegram-like user photo bubble */
.message.user .tg-attachments {
  margin: 0 0 0.35rem;
  max-width: min(78vw, 420px);
}
.message.user .msg-attach-photo {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #0b1a10;
  line-height: 0;
}
.message.user .msg-attach-photo-img {
  display: block;
  width: 100%;
  max-width: min(78vw, 420px);
  max-height: min(62vh, 520px);
  height: auto;
  object-fit: contain;
  border-radius: 14px;
}
.message.user .msg-attach-doc {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
  border: 1px solid rgba(255,255,255,0.12);
  max-width: min(78vw, 420px);
}
.message.user .msg-attach-doc-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(145deg, #3f8f55, #24663a);
}
.message.user .msg-attach-doc-icon[data-kind="pdf"] {
  background: linear-gradient(145deg, #e25555, #b42323);
}
.message.user .msg-attach-doc-icon[data-kind="audio"] {
  background: linear-gradient(145deg, #5b7cfa, #3550c7);
}
.message.user .msg-attach-doc-icon[data-kind="video"] {
  background: linear-gradient(145deg, #7a5cff, #4b2fc4);
}
.message.user .msg-attach-doc-icon .ico {
  width: 22px;
  height: 22px;
}

/* Laser scan while Nabgol DB runs */
.msg-attach-photo .photo-laser-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(8, 40, 18, 0.15), rgba(8, 40, 18, 0.35));
}
.msg-attach-photo .photo-laser-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 18%;
  top: -20%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(80, 255, 160, 0.15) 35%,
    rgba(120, 255, 190, 0.55) 50%,
    rgba(80, 255, 160, 0.15) 65%,
    transparent 100%
  );
  box-shadow: 0 0 18px rgba(90, 255, 170, 0.45);
  animation: nabgolLaserScan 1.6s ease-in-out infinite;
}
.msg-attach-photo .photo-scan-label {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f4fff8;
  background: rgba(10, 40, 20, 0.72);
  border: 1px solid rgba(140, 230, 170, 0.45);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  line-height: 1.3;
  backdrop-filter: blur(4px);
}
@keyframes nabgolLaserScan {
  0% { top: -22%; opacity: 0.35; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 105%; opacity: 0.25; }
}

/* Composer attachment — Telegram-class preview (all robots, desktop + mobile) */
.chat-input .file-preview {
  display: none;
  width: 100%;
  box-sizing: border-box;
}
.chat-input .file-preview.show,
body:is(.desktop-chat, .mobile-chat) .chat-input .file-preview.show {
  display: flex !important;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.7rem !important;
  margin: 0 0 0.55rem !important;
  border-radius: 18px !important;
  border: 1px solid rgba(47, 107, 58, 0.22) !important;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.92), rgba(236, 246, 239, 0.96)) !important;
  box-shadow:
    0 10px 28px rgba(16, 36, 24, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.45) inset !important;
  align-items: stretch !important;
}
body.dark-mode .chat-input .file-preview.show,
html.dark body .chat-input .file-preview.show,
body.mobile-chat .chat-input .file-preview.show {
  border-color: rgba(120, 200, 140, 0.22) !important;
  background:
    linear-gradient(165deg, rgba(28, 38, 32, 0.98), rgba(18, 26, 22, 0.98)) !important;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset !important;
}

.chat-input .file-preview .fp-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
}
.chat-input .file-preview[data-kind="image"] .fp-main,
.chat-input .file-preview[data-kind="video"] .fp-main {
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "media media"
    "info remove";
  align-items: start;
}
.chat-input .file-preview[data-kind="image"] .fp-media,
.chat-input .file-preview[data-kind="video"] .fp-media {
  grid-area: media;
}
.chat-input .file-preview[data-kind="image"] .file-preview-info,
.chat-input .file-preview[data-kind="video"] .file-preview-info {
  grid-area: info;
  padding-top: 0.15rem;
}
.chat-input .file-preview[data-kind="image"] .file-remove,
.chat-input .file-preview[data-kind="video"] .file-remove {
  grid-area: remove;
  align-self: start;
}

.chat-input .file-preview .fp-media {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #0f1c14;
  box-shadow: 0 4px 14px rgba(8, 24, 14, 0.18);
}
.chat-input .file-preview[data-kind="image"] .fp-media,
.chat-input .file-preview[data-kind="video"] .fp-media {
  width: 100%;
  max-height: min(42vh, 280px);
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(70, 140, 90, 0.22), transparent 55%),
    #0c1610;
}
.chat-input .file-preview .fp-image,
.chat-input .file-preview #filePreviewImage {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: min(42vh, 280px) !important;
  object-fit: contain !important;
  border-radius: 14px !important;
  border: 0 !important;
  background: transparent !important;
  margin: 0 !important;
}
.chat-input .file-preview .fp-image[hidden],
.chat-input .file-preview #filePreviewImage[hidden],
.chat-input .file-preview .fp-video[hidden],
.chat-input .file-preview #filePreviewVideo[hidden],
.chat-input .file-preview .fp-icon[hidden],
.chat-input .file-preview .file-preview-icon[hidden],
.chat-input .file-preview .fp-kind-badge[hidden] {
  display: none !important;
}
.chat-input .file-preview .fp-video,
.chat-input .file-preview #filePreviewVideo {
  display: block;
  width: 100%;
  max-height: min(42vh, 280px);
  object-fit: contain;
  border-radius: 14px;
  background: #000;
}

.chat-input .file-preview .fp-icon,
.chat-input .file-preview .file-preview-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(145deg, #3f8f55, #24663a);
  box-shadow: 0 8px 18px rgba(36, 102, 58, 0.28);
}
.chat-input .file-preview .fp-icon[data-kind="pdf"],
.chat-input .file-preview .file-preview-icon[data-kind="pdf"] {
  background: linear-gradient(145deg, #e25555, #b42323);
  box-shadow: 0 8px 18px rgba(180, 35, 35, 0.28);
}
.chat-input .file-preview .fp-icon[data-kind="audio"],
.chat-input .file-preview .file-preview-icon[data-kind="audio"] {
  background: linear-gradient(145deg, #5b7cfa, #3550c7);
  box-shadow: 0 8px 18px rgba(53, 80, 199, 0.28);
}
.chat-input .file-preview .fp-icon[data-kind="video"],
.chat-input .file-preview .file-preview-icon[data-kind="video"] {
  background: linear-gradient(145deg, #7a5cff, #4b2fc4);
}
.chat-input .file-preview .fp-icon .ico,
.chat-input .file-preview .file-preview-icon .ico {
  width: 28px;
  height: 28px;
}

.chat-input .file-preview .fp-kind-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f4fff7;
  background: rgba(8, 20, 12, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  pointer-events: none;
}
.chat-input .file-preview:not([data-kind="image"]):not([data-kind="video"]) .fp-media {
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.chat-input .file-preview:not([data-kind="image"]):not([data-kind="video"]) .fp-kind-badge {
  left: auto;
  right: -6px;
  bottom: -6px;
  background: #13261a;
  border-color: rgba(255, 255, 255, 0.12);
}

.chat-input .file-preview-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.chat-input .file-preview .file-name {
  display: block;
  font-weight: 750;
  color: #102418 !important;
  font-size: 0.92rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-input .file-preview .file-meta {
  display: block;
  color: #3f5c48 !important;
  font-size: 0.76rem;
  font-weight: 600;
}
.chat-input .file-preview .fp-caption-hint {
  display: block;
  margin-top: 0.2rem;
  color: #2f6b3a;
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.4;
}
body.dark-mode .chat-input .file-preview .file-name,
html.dark body .chat-input .file-preview .file-name,
body.mobile-chat .chat-input .file-preview .file-name {
  color: #f2faf4 !important;
}
body.dark-mode .chat-input .file-preview .file-meta,
html.dark body .chat-input .file-preview .file-meta,
body.mobile-chat .chat-input .file-preview .file-meta {
  color: #a9c2b1 !important;
}
body.dark-mode .chat-input .file-preview .fp-caption-hint,
html.dark body .chat-input .file-preview .fp-caption-hint,
body.mobile-chat .chat-input .file-preview .fp-caption-hint {
  color: #8fdb9f;
}

.chat-input .file-preview .plant-analysis-picker,
.chat-input .file-preview .plant-organ-picker {
  grid-column: 1 / -1;
  width: 100%;
}
.chat-input .file-preview .file-remove {
  border: 0 !important;
  background: rgba(255, 255, 255, 0.92) !important;
  border-radius: 999px !important;
  width: 36px !important;
  height: 36px !important;
  display: grid !important;
  place-items: center !important;
  cursor: pointer;
  color: #8a2f24 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12) !important;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.15s ease;
}
.chat-input .file-preview .file-remove:hover {
  transform: scale(1.05);
  background: #fff !important;
}
.chat-input .file-preview .file-remove .ico {
  width: 16px;
  height: 16px;
}
body.dark-mode .chat-input .file-preview .file-remove,
html.dark body .chat-input .file-preview .file-remove,
body.mobile-chat .chat-input .file-preview .file-remove {
  background: rgba(20, 28, 24, 0.92) !important;
  color: #ffb4a8 !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35) !important;
}

/* Connected composer: preview + caption field feel like one unit */
.chat-input.composer-has-attach .input-wrapper {
  border-color: rgba(47, 107, 58, 0.35) !important;
  box-shadow:
    0 6px 22px rgba(16, 36, 24, 0.1),
    0 0 0 3px rgba(47, 107, 58, 0.1) !important;
}
body.mobile-chat .chat-input.composer-has-attach .input-wrapper {
  border-color: rgba(120, 200, 140, 0.28) !important;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.22),
    0 0 0 2px rgba(80, 180, 110, 0.12) !important;
}

@media (max-width: 720px) {
  .chat-input .file-preview[data-kind="image"] .fp-media,
  .chat-input .file-preview[data-kind="video"] .fp-media,
  .chat-input .file-preview .fp-image,
  .chat-input .file-preview #filePreviewImage,
  .chat-input .file-preview .fp-video,
  .chat-input .file-preview #filePreviewVideo {
    max-height: min(38vh, 220px) !important;
  }
  .chat-input .file-preview .fp-icon,
  .chat-input .file-preview .file-preview-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }
}

.plant-organ-chip {
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.plant-organ-chip:hover {
  transform: translateY(-1px);
  border-color: #2f6b3a;
}
