.senti-widget,
.senti-widget * {
  box-sizing: border-box;
}

.senti-widget {
  --senti-brand: #0069b2;
  --senti-brand-dark: #004f89;
  --senti-text: #172033;
  --senti-muted: #687085;
  --senti-surface: #fff;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1100;
  color: var(--senti-text);
  font-family: Inter, Poppins, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.senti-widget .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.senti-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 18px 8px 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--senti-brand), var(--senti-brand-dark));
  box-shadow: 0 14px 38px rgba(0, 68, 117, .28);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.senti-launcher-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  font-size: 20px;
  font-weight: 800;
}

.senti-launcher-badge {
  display: grid;
  min-width: 22px;
  height: 22px;
  margin-left: -4px;
  padding: 0 6px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #f5a623;
  color: #172033;
  font-size: 11px;
  font-weight: 800;
}

/* Keep the account assistant reachable without covering form actions in the
   bottom-right corner of the lector back office. The accessible name remains
   available through aria-label and the full panel is unchanged after opening. */
.senti-widget--lector .senti-launcher {
  padding: 8px;
}

.senti-widget--lector .senti-launcher-label {
  display: none;
}

.senti-widget--lector .senti-launcher-badge {
  margin-left: 0;
}

/* Content editors keep their primary action in a fixed bottom bar. Lift only
   the closed launcher above that bar so course and product saves stay usable. */
body:has([data-content-editor]) .senti-widget--lector {
  bottom: max(84px, calc(84px + env(safe-area-inset-bottom)));
}

@media (min-width: 561px) {
  body:has([data-content-editor]) .senti-widget--lector .senti-panel {
    bottom: -44px;
  }
}

.senti-insights {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
}

.senti-insight {
  display: grid;
  grid-template-columns: 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(0, 105, 178, .42);
  border-radius: 12px;
  background: #f4faff;
}

.senti-insight--warning {
  border-color: rgba(224, 143, 12, .65);
  background: #fff9ed;
}
.senti-insight button {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.senti-insight button span { color: var(--senti-muted); font-size: 12px; }
.senti-insight a { align-self: center; padding: 10px; color: var(--senti-brand); font-size: 12px; }

.senti-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr) auto auto;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid rgba(16, 45, 74, .12);
  border-radius: 22px;
  background: var(--senti-surface);
  box-shadow: 0 22px 60px rgba(21, 46, 72, .24);
}

.senti-panel[hidden] {
  display: none;
}

.senti-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 18px;
  background: linear-gradient(135deg, #0069b2, #004f89);
  color: #fff;
}

.senti-header > div:first-child {
  display: grid;
  gap: 2px;
}

.senti-header strong {
  font-size: 17px;
}

.senti-header span {
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
}

.senti-header-actions {
  display: flex;
  gap: 6px;
}

.senti-header-actions button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.senti-header-actions .senti-usage-link {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 18px;
  text-decoration: none;
}

.senti-messages {
  overflow: auto;
  padding: 18px;
  background: #f5f8fb;
  overscroll-behavior: contain;
}

.senti-center {
  overflow-y: auto;
  padding: 16px;
  background: #f5f8fb;
  overscroll-behavior: contain;
}

.senti-center[hidden],
.senti-threads[hidden] { display: none; }

.senti-threads {
  overflow-y: auto;
  padding: 16px;
  background: #f5f8fb;
  overscroll-behavior: contain;
}

.senti-thread-list {
  display: grid;
  gap: 9px;
}

.senti-thread-card {
  overflow: hidden;
  border: 1px solid rgba(0, 105, 178, .28);
  border-radius: 12px;
  background: #fff;
}

.senti-thread-card.is-current {
  border-color: var(--senti-brand);
  box-shadow: 0 0 0 2px rgba(0, 105, 178, .09);
}

.senti-thread-card.is-archived {
  opacity: .72;
}

.senti-thread-open {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 11px 12px 8px;
  border: 0;
  background: transparent;
  color: var(--senti-text);
  text-align: left;
  cursor: pointer;
}

.senti-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.senti-thread-top strong { font-size: 12px; }
.senti-thread-top small,
.senti-thread-meta { color: var(--senti-muted); font-size: 9px; }
.senti-thread-preview {
  overflow: hidden;
  color: var(--senti-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.senti-thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 10px;
}

.senti-thread-action {
  padding: 4px 7px;
  border: 1px solid rgba(0, 105, 178, .2);
  border-radius: 7px;
  background: #f4faff;
  color: var(--senti-brand-dark);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.senti-center-heading,
.senti-center-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.senti-center-heading { margin-bottom: 12px; }
.senti-center-heading strong { color: var(--senti-text); font-size: 16px; }
.senti-center-heading span { color: var(--senti-muted); font-size: 12px; }

.senti-center-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.senti-center-metric {
  display: grid;
  gap: 2px;
  padding: 10px 11px;
  border: 1px solid rgba(0, 105, 178, .32);
  border-radius: 12px;
  background: #eef8ff;
}

.senti-center-metric span,
.senti-center-metric small { color: var(--senti-muted); font-size: 11px; }
.senti-center-metric strong { color: var(--senti-brand-dark); font-size: 19px; }

.senti-center-section { margin-top: 16px; }
.senti-center-section h3 { margin: 0 0 8px; color: var(--senti-text); font-size: 13px; }
.senti-center-list { display: grid; gap: 8px; }

.senti-center-card {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid rgba(0, 105, 178, .34);
  border-radius: 12px;
  background: #f4faff;
}

.senti-center-card--warning {
  border-color: rgba(224, 143, 12, .65);
  background: #fff9ed;
}
.senti-center-queue--urgent { border-color: #f1416c; background: #fff5f8; }
.senti-center-queue--high { border-color: #ffc700; background: #fffaf0; }

.senti-center-card strong { color: var(--senti-text); font-size: 12px; }
.senti-center-card p { margin: 0; color: var(--senti-muted); font-size: 11px; line-height: 1.45; }
.senti-center-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.senti-center-action {
  padding: 6px 8px;
  border: 1px solid var(--senti-brand);
  border-radius: 8px;
  background: var(--senti-brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.senti-center-action--secondary {
  border-color: rgba(0, 105, 178, .28);
  background: #fff;
  color: var(--senti-brand-dark);
}

.senti-center-status {
  padding: 3px 6px;
  border-radius: 999px;
  background: #dff6e9;
  color: #18794e;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.senti-center-status--failed {
  background: #fee8e7;
  color: #a12b2b;
}

.senti-center-status--executed {
  background: #dff6e9;
  color: #18794e;
}

.senti-center-status--pending {
  background: #fff2cc;
  color: #765500;
}

.senti-center-agenda-item p {
  text-transform: none;
}

.senti-center-empty,
.senti-center-loading { margin: 0; color: var(--senti-muted); font-size: 12px; }

.senti-center-loading,
.senti-center-loading-dots {
  display: inline-flex;
  align-items: center;
}

.senti-center-loading { gap: 9px; }
.senti-center-loading-dots { gap: 5px; }
.senti-center-loading .senti-typing-dot { width: 6px; height: 6px; }

.senti-header-actions .senti-center-toggle.is-active,
.senti-header-actions .senti-threads-toggle.is-active {
  background: #fff;
  color: var(--senti-brand-dark);
}

.senti-welcome {
  color: var(--senti-muted);
  font-size: 14px;
  line-height: 1.55;
}

.senti-suggestions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.senti-suggestions button {
  padding: 10px 12px;
  border: 1px solid rgba(0, 105, 178, .2);
  border-radius: 12px;
  background: #fff;
  color: var(--senti-brand-dark);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.senti-suggestions .senti-suggestion--daily {
  border-color: var(--senti-brand);
  background: var(--senti-brand);
  color: #fff;
  font-weight: 700;
}

.senti-help-options {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid rgba(21, 61, 94, .1);
}

.senti-help-options-title {
  display: block;
  margin-bottom: 9px;
  color: var(--senti-text);
  font-size: 12px;
}

.senti-help-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.senti-help-action {
  display: flex;
  min-width: 0;
  gap: 8px;
  padding: 11px;
  border: 1px solid rgba(0, 105, 178, .24);
  border-radius: 12px;
  background: rgba(0, 105, 178, .06);
  color: var(--senti-brand-dark);
  text-align: left;
  cursor: pointer;
}

.senti-help-action > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.senti-help-action strong {
  font-size: 12px;
  line-height: 1.25;
}

.senti-help-action small {
  color: var(--senti-muted);
  font-size: 10px;
  line-height: 1.35;
}

.senti-help-action-icon {
  display: grid;
  flex: 0 0 25px;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  background: var(--senti-brand);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.senti-help-action:hover,
.senti-help-action:focus-visible {
  border-color: var(--senti-brand);
  background: rgba(0, 105, 178, .11);
}

.senti-message {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 12px;
  padding: 10px 13px;
  border-radius: 15px 15px 15px 4px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(31, 51, 74, .07);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.senti-message--loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 52px;
  min-height: 38px;
}

.senti-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--senti-brand);
  animation: senti-typing-wave 1.1s ease-in-out infinite;
}

.senti-typing-dot:nth-child(2) {
  animation-delay: .14s;
}

.senti-typing-dot:nth-child(3) {
  animation-delay: .28s;
}

@keyframes senti-typing-wave {
  0%, 60%, 100% {
    opacity: .35;
    transform: translateY(0) scale(.9);
  }
  30% {
    opacity: 1;
    transform: translateY(-5px) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .senti-typing-dot {
    animation: none;
    opacity: .7;
  }
}

.senti-message--user {
  margin-left: auto;
  border-radius: 15px 15px 4px 15px;
  background: var(--senti-brand);
  color: #fff;
}

.senti-message-attachment {
  display: block;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(104, 112, 133, .2);
  font-size: 12px;
}

.senti-message--error {
  border: 1px solid #f3c7c7;
  background: #fff4f4;
  color: #9b2424;
}

.senti-message--loading {
  color: var(--senti-muted);
}

.senti-message-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  white-space: normal;
}

.senti-message-links a {
  padding: 5px 9px;
  border: 1px solid rgba(0, 105, 178, .22);
  border-radius: 999px;
  color: var(--senti-brand-dark);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.senti-message-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(21, 61, 94, .1);
  color: var(--senti-muted);
  font-size: 11px;
  white-space: normal;
}

.senti-message-sources summary {
  color: var(--senti-brand-dark);
  font-weight: 700;
  cursor: pointer;
}

.senti-message-source-list {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.senti-message-source {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid rgba(0, 105, 178, .16);
  border-radius: 8px;
  background: rgba(0, 105, 178, .04);
}

.senti-message-source strong {
  color: var(--senti-text);
  font-size: 11px;
}

.senti-action {
  display: grid;
  gap: 7px;
  min-width: min(290px, 72vw);
  margin-top: 11px;
  padding: 11px;
  border: 1px solid rgba(0, 105, 178, .25);
  border-radius: 12px;
  background: #f6fbff;
  white-space: normal;
}

.senti-action > span {
  color: var(--senti-muted);
  font-size: 12px;
}

.senti-action-controls {
  display: flex;
  gap: 7px;
}

.senti-action-controls button {
  padding: 6px 10px;
  border: 1px solid #d8e0e9;
  border-radius: 8px;
  background: #fff;
  color: var(--senti-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.senti-action-controls .senti-action-confirm {
  border-color: var(--senti-brand);
  background: var(--senti-brand);
  color: #fff;
}

.senti-action[data-status="executed"] {
  border-color: #78c29a;
  background: #effaf4;
}

.senti-action[data-status="canceled"],
.senti-action[data-status="expired"],
.senti-action[data-status="failed"] {
  opacity: .65;
}

.senti-feedback {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(21, 61, 94, .1);
  color: var(--senti-muted);
  font-size: 11px;
  white-space: normal;
}

.senti-feedback-controls,
.senti-feedback-detail-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.senti-feedback button {
  padding: 5px 8px;
  border: 1px solid rgba(0, 105, 178, .2);
  border-radius: 8px;
  background: #fff;
  color: var(--senti-brand-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.senti-feedback-details {
  display: grid;
  gap: 7px;
  min-width: min(290px, 70vw);
}

.senti-feedback select,
.senti-feedback textarea {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #d8e0e9;
  border-radius: 8px;
  background: #fff;
  color: var(--senti-text);
  font: inherit;
}

.senti-feedback textarea {
  resize: vertical;
}

.senti-feedback--saved {
  color: #28764a;
  font-weight: 700;
}

.senti-form {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 9px;
  padding: 12px 14px 8px;
  border-top: 1px solid #e6ebf1;
  background: #fff;
}

.senti-attachment-row {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.senti-draft-option {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 7px;
  color: var(--senti-brand-dark);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.senti-draft-option[hidden] { display: none; }
.senti-draft-option input { accent-color: var(--senti-brand); }

.senti-attachment-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--senti-brand-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.senti-attachment-name {
  overflow: hidden;
  color: var(--senti-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.senti-attachment-remove {
  flex: 0 0 auto;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #9b2424;
  cursor: pointer;
}

.senti-form textarea {
  width: 100%;
  max-height: 110px;
  resize: none;
  border: 1px solid #d8e0e9;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--senti-text);
  background: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
}

.senti-form textarea:focus {
  border-color: var(--senti-brand);
  outline: 3px solid rgba(0, 105, 178, .12);
}

.senti-form button {
  align-self: end;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--senti-brand);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.senti-form .senti-attachment-remove {
  align-self: center;
  width: auto;
  height: auto;
  padding: 0 4px;
  border-radius: 4px;
  background: transparent;
  color: #9b2424;
  font-size: 16px;
}

.senti-form button:disabled,
.senti-suggestions button:disabled,
.senti-help-action:disabled {
  cursor: wait;
  opacity: .55;
}

.senti-note {
  margin: 0;
  padding: 0 16px 12px;
  background: #fff;
  color: var(--senti-muted);
  font-size: 11px;
  line-height: 1.4;
}

html[data-bs-theme="dark"] .senti-widget--lector {
  --senti-text: #eef2f8;
  --senti-muted: #aab3c2;
  --senti-surface: #171b24;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-panel {
  border-color: rgba(255, 255, 255, .1);
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-messages {
  background: #10131a;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-threads,
html[data-bs-theme="dark"] .senti-widget--lector .senti-thread-card {
  background: #10131a;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-message,
html[data-bs-theme="dark"] .senti-widget--lector .senti-suggestions button,
html[data-bs-theme="dark"] .senti-widget--lector .senti-help-action,
html[data-bs-theme="dark"] .senti-widget--lector .senti-form,
html[data-bs-theme="dark"] .senti-widget--lector .senti-note,
html[data-bs-theme="dark"] .senti-widget--lector .senti-form textarea {
  border-color: rgba(255, 255, 255, .11);
  background: #1d222d;
  color: var(--senti-text);
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-suggestions .senti-suggestion--daily {
  border-color: #43a9ee;
  background: #176da6;
  color: #fff;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-feedback button,
html[data-bs-theme="dark"] .senti-widget--lector .senti-feedback select,
html[data-bs-theme="dark"] .senti-widget--lector .senti-feedback textarea {
  border-color: rgba(255, 255, 255, .14);
  background: #1d222d;
  color: var(--senti-text);
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-action {
  border-color: rgba(255, 255, 255, .16);
  background: #171d27;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-insight {
  border-color: rgba(67, 169, 238, .62);
  background: #152535;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-insight--warning {
  border-color: rgba(245, 166, 35, .7);
  background: #2b2418;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-center {
  background: #111720;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-center-metric,
html[data-bs-theme="dark"] .senti-widget--lector .senti-center-card {
  border-color: rgba(67, 169, 238, .5);
  background: #152535;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-center-card--warning {
  border-color: rgba(245, 166, 35, .7);
  background: #2b2418;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-center-action--secondary {
  border-color: rgba(255, 255, 255, .18);
  background: #1d222d;
  color: #7dc8ff;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-message-links a {
  color: #7dc8ff;
}

html[data-bs-theme="dark"] .senti-widget--lector .senti-message--user {
  background: var(--senti-brand);
  color: #fff;
}

@media (max-width: 560px) {
  .senti-widget {
    right: 14px;
    bottom: 14px;
  }

  .senti-panel {
    position: fixed;
    inset: 10px 10px max(10px, env(safe-area-inset-bottom));
    width: auto;
    height: auto;
  }

  body:has([data-content-editor]) .senti-widget--lector {
    bottom: max(78px, calc(78px + env(safe-area-inset-bottom)));
  }

  .senti-launcher > span:last-child {
    display: none;
  }

  .senti-launcher {
    padding: 8px;
  }

  .senti-help-actions {
    grid-template-columns: 1fr;
  }
}
