/* ── FAB button ── */
.ai-sidekick-fab {
  position: fixed;
  bottom: 1.5rem;
  inset-inline-end: 1.5rem;
  inset-inline-start: auto;
  z-index: 99999;
  display: inline-flex;
  height: 3.5rem;
  width: 3.5rem;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ai-sidekick-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.55);
}

/* ── Fit Sidekick to the viewport (no outer panel scrollbar) ── */
.dialog:has(.ai-sidekick-chat) .overflow-y-scroll {
  overflow: hidden !important;
}

.dialog:has(.ai-sidekick-chat) .relative.mt-6.flex-1 {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin-top: 0.75rem;
  padding-bottom: 0.5rem;
}

.ai-sidekick-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.ai-sidekick-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.ai-sidekick-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0 !important;
  height: auto !important;
  max-height: none;
  overflow: hidden;
}

.ai-sidekick-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
}

.ai-sidekick-footer {
  flex-shrink: 0;
}

/* ── Message bubbles ── */
.ai-sidekick-bubble {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ai-sidekick-bubble--user {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  border-radius: 1rem;
  border-end-end-radius: 0.25rem;
}

.ai-sidekick-bubble--assistant {
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  border-end-start-radius: 0.25rem;
}

.dark .ai-sidekick-bubble--assistant {
  background: #1f2937;
  color: #f3f4f6;
  border-color: #374151;
}

.ai-sidekick-bubble--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 1rem;
}

.dark .ai-sidekick-bubble--error {
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
  border-color: #7f1d1d;
}

/* ── Example prompt chips ── */
.ai-sidekick-suggestions {
  padding: 0 0 0.625rem;
  margin-bottom: 0.625rem;
  border-bottom: 1px solid #f3f4f6;
}

.dark .ai-sidekick-suggestions {
  border-bottom-color: #374151;
}

.ai-sidekick-suggestions-label {
  margin-bottom: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #4b5563;
}

.dark .ai-sidekick-suggestions-label {
  color: #d1d5db;
}

.ai-sidekick-suggestions--starter {
  border: 1px solid #e0e7ff;
  border-radius: 0.75rem;
  background: linear-gradient(180deg, #f5f3ff 0%, #fff 100%);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.dark .ai-sidekick-suggestions--starter {
  border-color: rgba(99, 102, 241, 0.35);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.12) 0%, rgba(31, 41, 55, 0.5) 100%);
}

.ai-sidekick-suggestions-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.ai-sidekick-context-badge {
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #6366f1;
}

.dark .ai-sidekick-context-badge {
  color: #a5b4fc;
}

.ai-sidekick-context-prefix {
  color: #9ca3af;
  font-weight: 400;
}

.ai-sidekick-refresh-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.ai-sidekick-refresh-btn:hover {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
}

.ai-sidekick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-sidekick-chip {
  cursor: pointer;
  border: 1px solid #c7d2fe;
  border-radius: 0.625rem;
  background: #eef2ff;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: #4338ca;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  text-align: start;
  max-width: 100%;
}

.ai-sidekick-suggestions--starter .ai-sidekick-chip {
  padding: 0.5625rem 0.875rem;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.08);
}

.ai-sidekick-chip-icon {
  display: none;
}

.ai-sidekick-chip-label {
  min-width: 0;
  word-break: break-word;
}

.ai-sidekick-chip:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

.dark .ai-sidekick-chip {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
}

.dark .ai-sidekick-chip:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
}

.ai-sidekick-message-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-sidekick-message-wrap--user {
  align-items: flex-end;
}

.ai-sidekick-message-wrap--assistant {
  align-items: flex-start;
}

.ai-sidekick-reply-chips {
  width: 100%;
  max-width: 100%;
}

.ai-sidekick-chips-panel {
  width: 100%;
  max-width: 100%;
  margin-top: 0.375rem;
  border: 1px solid #e0e7ff;
  border-radius: 0.75rem;
  background: linear-gradient(180deg, #f5f3ff 0%, #fff 100%);
  padding: 0.75rem;
}

.dark .ai-sidekick-chips-panel {
  border-color: rgba(99, 102, 241, 0.35);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.12) 0%, rgba(31, 41, 55, 0.5) 100%);
}

.ai-sidekick-chips-panel .ai-sidekick-chip {
  padding: 0.5625rem 0.875rem;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.08);
}

.ai-sidekick-suggestions-inline {
  margin-top: 0.5rem;
}

.ai-sidekick-reply-chips__title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
}

.ai-sidekick-reply-chips__reason {
  margin: 0 0 0.625rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #4f46e5;
}

.ai-sidekick-reply-chips__reason strong,
.ai-sidekick-message-body strong {
  font-weight: 700;
  color: #312e81;
}

.dark .ai-sidekick-reply-chips__reason strong,
.dark .ai-sidekick-message-body strong {
  color: #e0e7ff;
}

.dark .ai-sidekick-reply-chips__reason {
  color: #a5b4fc;
}

.ai-sidekick-suggested-content {
  margin: 0 0 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.625rem;
  background: #f5f3ff;
  border: 1px solid #e0e7ff;
}

.ai-sidekick-suggested-content__title {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #312e81;
}

.ai-sidekick-suggested-content__description {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #4338ca;
  white-space: pre-line;
}

.dark .ai-sidekick-suggested-content {
  background: rgba(49, 46, 129, 0.25);
  border-color: #4338ca;
}

.dark .ai-sidekick-suggested-content__title {
  color: #e0e7ff;
}

.dark .ai-sidekick-suggested-content__description {
  color: #c7d2fe;
}

.ai-sidekick-chip--activity_title_with_description {
  border-color: #a5b4fc;
}

.dark .ai-sidekick-reply-chips__title {
  color: #d1d5db;
}

.ai-sidekick-chip-badge {
  flex-shrink: 0;
  border: none;
  border-radius: 9999px;
  background: #4f46e5;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.28rem 0.5rem;
  letter-spacing: 0.02em;
  box-shadow: none;
  outline: none;
}

.dark .ai-sidekick-chip-badge {
  background: #6366f1;
  border: none;
  box-shadow: none;
}

.ai-sidekick-chip--activity_type,
.ai-sidekick-chip--activity_date,
.ai-sidekick-chip--activity_time,
.ai-sidekick-chip--activity_title {
  border-color: #a5b4fc;
}

/* Badged chips stay visually equal to siblings — emphasis is the pill alone. */
.ai-sidekick-chip--recommended,
.ai-sidekick-chip--activity_type_recommend,
.ai-sidekick-chip:has(.ai-sidekick-chip-badge) {
  border-width: 1px;
}

.ai-sidekick-deal-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-sidekick-deal-picker__list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ai-sidekick-deal-picker__row {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 0.5625rem 0.75rem;
  border: 1px solid #e0e7ff;
  border-radius: 0.625rem;
  background: #fff;
  color: #312e81;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ai-sidekick-deal-picker__row:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.ai-sidekick-deal-picker__row:active:not(:disabled) {
  background: #e0e7ff;
}

.ai-sidekick-deal-picker__row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dark .ai-sidekick-deal-picker__row {
  background: rgba(31, 41, 55, 0.65);
  border-color: rgba(99, 102, 241, 0.35);
  color: #e0e7ff;
}

.dark .ai-sidekick-deal-picker__row:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(165, 180, 252, 0.55);
}

.ai-sidekick-deal-picker__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-sidekick-deal-picker__pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.125rem;
}

.ai-sidekick-list-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0.15rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.625rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.dark .ai-sidekick-list-pager {
  background: rgba(15, 23, 42, 0.55);
  border-color: #334155;
}

.ai-sidekick-list-pager__page {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

.dark .ai-sidekick-list-pager__page {
  color: #cbd5e1;
}

.ai-sidekick-list-pager__nav {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 0.5rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.ai-sidekick-list-pager__nav:hover:not(:disabled) {
  background: #f1f5f9;
}

.ai-sidekick-list-pager__nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dark .ai-sidekick-list-pager__nav {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

.ai-sidekick-deal-picker__nav {
  margin: 0;
  padding: 0.3125rem 0.625rem;
  border: 1px solid #e0e7ff;
  border-radius: 0.5rem;
  background: #fff;
  color: #4f46e5;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.ai-sidekick-deal-picker__nav:hover:not(:disabled) {
  background: #eef2ff;
}

.ai-sidekick-deal-picker__nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dark .ai-sidekick-deal-picker__nav {
  background: rgba(31, 41, 55, 0.65);
  border-color: rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}

.ai-sidekick-deal-picker__page {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.dark .ai-sidekick-deal-picker__page {
  color: #9ca3af;
}

.ai-sidekick-chip--activity_date_skip,
.ai-sidekick-chip--activity_time_skip,
.ai-sidekick-chip--activity_title_skip {
  border-style: dashed;
  background: #fff;
  color: #6b7280;
  border-color: #d1d5db;
}

.dark .ai-sidekick-chip--activity_date_skip,
.dark .ai-sidekick-chip--activity_time_skip,
.dark .ai-sidekick-chip--activity_title_skip {
  background: rgba(31, 41, 55, 0.5);
  color: #d1d5db;
  border-color: #4b5563;
}

.ai-sidekick-chip--activity_date_custom {
  border-color: #a5b4fc;
}

.ai-sidekick-date-picker {
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px dashed #e5e7eb;
}

.dark .ai-sidekick-date-picker {
  border-top-color: #374151;
}

.ai-sidekick-date-picker__label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
}

.dark .ai-sidekick-date-picker__label {
  color: #d1d5db;
}

.ai-sidekick-date-picker__row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-sidekick-date-picker__control {
  flex: 1;
  min-width: 0;
}

.ai-sidekick-date-picker__control .relative {
  width: 100%;
}

.ai-sidekick-date-picker__control input {
  width: 100%;
  cursor: pointer;
  border-radius: 0.5rem;
  border-color: #c7d2fe;
}

.ai-sidekick-date-picker__control input:focus {
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.55);
}

.ai-sidekick-date-picker__btn {
  flex-shrink: 0;
  border: none;
  border-radius: 0.5rem;
  background: #4f46e5;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.ai-sidekick-date-picker__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-sidekick-date-picker__btn:not(:disabled):hover {
  background: #4338ca;
}

.ai-sidekick-time-picker__input {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0.5rem;
  border: 1px solid #c7d2fe;
  background: #fff;
  color: #111827;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.ai-sidekick-time-picker__input:focus {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.55);
}

.ai-sidekick-time-picker__input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dark .ai-sidekick-time-picker__input {
  background: #111827;
  border-color: #4b5563;
  color: #f9fafb;
}

@media (max-width: 640px) {
  .ai-sidekick-time-picker .ai-sidekick-date-picker__row {
    flex-direction: column;
    align-items: stretch;
  }

  .ai-sidekick-time-picker__input {
    min-height: 3rem;
    font-size: 1.125rem;
  }

  .ai-sidekick-time-picker .ai-sidekick-date-picker__btn {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.625rem 0.75rem;
  }
}

/* ── Typing indicator ── */
.ai-sidekick-typing {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.ai-sidekick-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 1rem;
  border-end-start-radius: 0.25rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 0.625rem 0.875rem;
}

.dark .ai-sidekick-typing-bubble {
  background: #1f2937;
  border-color: #374151;
}

.ai-sidekick-typing-dot {
  display: inline-block;
  height: 0.375rem;
  width: 0.375rem;
  border-radius: 9999px;
  background: #a5b4fc;
  animation: ai-sidekick-typing-bounce 1.4s infinite ease-in-out;
}

.ai-sidekick-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-sidekick-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ai-sidekick-typing-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.ai-sidekick-typing-label {
  font-size: 0.75rem;
  color: #9ca3af;
}

/* ── Input footer ── */
.ai-sidekick-footer {
  padding-top: 0.75rem;
}

.ai-sidekick-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-sidekick-input-wrap {
  flex: 1;
  min-width: 0;
}

.ai-sidekick-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: 0.75rem;
  background: #f5f3ff;
  border: 1px solid #e0e7ff;
  overflow: hidden;
}

.ai-sidekick-wave__bar {
  width: 3px;
  min-height: 4px;
  border-radius: 9999px;
  background: #6366f1;
  transition: height 0.05s linear;
  align-self: center;
}

.dark .ai-sidekick-wave {
  background: #1e1b4b;
  border-color: #3730a3;
}

.dark .ai-sidekick-wave__bar {
  background: #818cf8;
}

.ai-sidekick-input-wrap textarea {
  resize: none;
  border-radius: 0.75rem;
  min-height: 2.5rem !important;
  max-height: 2.5rem;
  height: 2.5rem !important;
  padding-block: calc((2.5rem - 1.5rem) / 2) !important;
  line-height: 1.5rem !important;
  overflow-y: hidden;
}

.ai-sidekick-send-btn {
  flex-shrink: 0;
  min-width: 5.5rem;
  height: 2.5rem;
  padding-inline: 1rem;
  padding-block: 0;
}

.ai-sidekick-mic-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #6366f1;
  cursor: pointer;
  box-shadow: none;
  transition: color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.ai-sidekick-mic-btn:hover:not(:disabled) {
  color: #4f46e5;
  transform: scale(1.08);
  background: transparent;
  box-shadow: none;
  filter: none;
}

.ai-sidekick-mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.ai-sidekick-mic-btn--recording {
  color: #dc2626;
  background: transparent;
  box-shadow: none;
  animation: ai-sidekick-mic-pulse 1.1s ease-in-out infinite;
}

.ai-sidekick-mic-btn--busy {
  color: #6366f1;
  background: transparent;
  box-shadow: none;
}

.ai-sidekick-mic-btn__icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  fill: currentColor;
}

.ai-sidekick-mic-btn__spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  border: 2px solid rgba(99, 102, 241, 0.25);
  border-top-color: #6366f1;
  animation: ai-sidekick-mic-spin 0.7s linear infinite;
}

@keyframes ai-sidekick-mic-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

@keyframes ai-sidekick-mic-spin {
  to {
    transform: rotate(360deg);
  }
}

.dark .ai-sidekick-mic-btn {
  background: transparent;
  color: #818cf8;
  box-shadow: none;
}

.dark .ai-sidekick-mic-btn:hover:not(:disabled) {
  color: #a5b4fc;
  background: transparent;
  box-shadow: none;
}

.dark .ai-sidekick-mic-btn--recording {
  color: #f87171;
  background: transparent;
}

.dark .ai-sidekick-mic-btn__spinner {
  border-color: rgba(129, 140, 248, 0.25);
  border-top-color: #818cf8;
}

.ai-sidekick-send-btn__content {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.ai-sidekick-send-btn__label {
  line-height: 1;
}

.ai-sidekick-send-btn__icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.92;
}

.ai-sidekick-keyboard-hint {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.6875rem;
  color: #9ca3af;
  line-height: 1.4;
}

.ai-sidekick-usage {
  margin-top: 0.375rem;
  text-align: center;
  font-size: 0.6875rem;
  color: #d1d5db;
}

/* ── Formatted assistant message body ── */
.ai-sidekick-message-body {
  word-break: break-word;
}

.ai-sidekick-message-body p {
  margin: 0 0 0.5rem;
}

.ai-sidekick-message-body p:last-child {
  margin-bottom: 0;
}

.ai-sidekick-message-body strong {
  font-weight: 600;
}

.ai-sidekick-message-body .sidekick-record-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.ai-sidekick-message-body .sidekick-record-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-sidekick-message-body .sidekick-record-link:hover {
  text-decoration: underline;
}

.ai-sidekick-message-body .sidekick-record-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.ai-sidekick-message-body .sidekick-record-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  padding: 0;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.ai-sidekick-message-body .sidekick-record-action svg {
  width: 1rem;
  height: 1rem;
}

.ai-sidekick-message-body .sidekick-record-action:hover {
  color: #6366f1;
  background-color: rgba(99, 102, 241, 0.08);
}

.dark .ai-sidekick-message-body .sidekick-record-action {
  color: #9ca3af;
}

.dark .ai-sidekick-message-body .sidekick-record-action:hover {
  color: #a5b4fc;
  background-color: rgba(99, 102, 241, 0.18);
}

.ai-sidekick-table td:last-child {
  width: 22%;
}

.ai-sidekick-message-body h4.ai-sidekick-heading {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.ai-sidekick-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0;
  max-width: 100%;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.ai-sidekick-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  table-layout: fixed;
}

.ai-sidekick-table th,
.ai-sidekick-table td {
  padding: 0.375rem 0.5rem;
  text-align: start;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  /* with table-layout:fixed, max-width:0 lets cells shrink + ellipsize */
  max-width: 0;
}

/* Name (first col) gets most space; score/amount/date stay compact */
.ai-sidekick-table th:first-child,
.ai-sidekick-table td:first-child {
  width: 42%;
}

.ai-sidekick-table th:nth-child(2),
.ai-sidekick-table td:nth-child(2) {
  width: 14%;
}

.ai-sidekick-table th:nth-child(3),
.ai-sidekick-table td:nth-child(3) {
  width: 22%;
}

.ai-sidekick-table th:nth-child(n + 4),
.ai-sidekick-table td:nth-child(n + 4) {
  width: 22%;
}

.ai-sidekick-table .sidekick-record-cell {
  display: flex;
  width: 100%;
  min-width: 0;
}

.ai-sidekick-table .sidekick-record-link {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-sidekick-table th {
  font-weight: 600;
  background: #f9fafb;
  white-space: nowrap;
  position: relative;
}

.ai-sidekick-table-th--sortable {
  cursor: pointer;
  user-select: none;
  /* keep table-cell display — flex on <th> breaks column widths */
}

.ai-sidekick-table-th--sortable:hover {
  color: #4f46e5;
}

.ai-sidekick-table-th--sortable:hover .ai-sidekick-table-th__sort {
  opacity: 0.85;
}

.ai-sidekick-table-th__label {
  margin-inline-end: 0.2rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: calc(100% - 1rem);
  vertical-align: middle;
}

.ai-sidekick-table-th__sort {
  display: inline-block;
  width: 0.55rem;
  height: 0.7rem;
  position: relative;
  vertical-align: -0.05em;
  opacity: 0.55;
  flex-shrink: 0;
  pointer-events: none;
}

.ai-sidekick-table-th__resize {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  width: 0.28rem;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  z-index: 1;
}

.ai-sidekick-table-th__resize:hover,
.ai-sidekick-table-th__resize.is-dragging {
  background: rgba(79, 70, 229, 0.35);
}

.ai-sidekick-table-th__sort::before,
.ai-sidekick-table-th__sort::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-left: 0.22rem solid transparent;
  border-right: 0.22rem solid transparent;
}

.ai-sidekick-table-th__sort::before {
  top: 0;
  border-bottom: 0.26rem solid currentColor;
}

.ai-sidekick-table-th__sort::after {
  bottom: 0;
  border-top: 0.26rem solid currentColor;
}

.ai-sidekick-table-th--asc,
.ai-sidekick-table-th--desc {
  color: #312e81;
  background: #eef2ff;
}

.ai-sidekick-table-th--asc .ai-sidekick-table-th__label,
.ai-sidekick-table-th--desc .ai-sidekick-table-th__label {
  font-weight: 700;
}

.ai-sidekick-table-th--asc .ai-sidekick-table-th__sort,
.ai-sidekick-table-th--desc .ai-sidekick-table-th__sort {
  opacity: 0.9;
  color: #4f46e5;
}

.ai-sidekick-table-th--asc .ai-sidekick-table-th__sort::after {
  opacity: 0.25;
}

.ai-sidekick-table-th--desc .ai-sidekick-table-th__sort::before {
  opacity: 0.25;
}

.dark .ai-sidekick-table th,
.dark .ai-sidekick-table td {
  border-bottom-color: #374151;
}

.dark .ai-sidekick-table th {
  background: #111827;
}

.ai-sidekick-table tbody tr.ai-sidekick-table-row {
  transition: background-color 0.12s ease;
}

.ai-sidekick-table tbody tr.ai-sidekick-table-row:hover {
  background-color: #f5f3ff;
}

.dark .ai-sidekick-table tbody tr.ai-sidekick-table-row:hover {
  background-color: rgba(99, 102, 241, 0.14);
}

/* Mobile: keep real columns (horizontal scroll) — card stacking hid headers. */
@media (max-width: 640px) {
  .ai-sidekick-table-wrap {
    overflow-x: auto;
    margin-inline: -0.25rem;
    padding-inline: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .ai-sidekick-table {
    min-width: 32rem;
    width: max-content;
    max-width: none;
    table-layout: auto;
  }

  .ai-sidekick-table th,
  .ai-sidekick-table td {
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ai-sidekick-table th:first-child,
  .ai-sidekick-table td:first-child {
    width: auto;
    min-width: 11rem;
    max-width: 16rem;
  }

  .ai-sidekick-table th:nth-child(n + 2),
  .ai-sidekick-table td:nth-child(n + 2) {
    width: auto;
    min-width: 4.5rem;
  }

  .ai-sidekick-table-th__resize {
    display: none;
  }

  .ai-sidekick-table .sidekick-record-action {
    width: 2.25rem;
    height: 2.25rem;
  }

  .ai-sidekick-table .sidekick-record-action svg {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* ── Action preview (draft table) ── */
.ai-sidekick-preview {
  border: 1px solid #e0e7ff;
  border-radius: 0.625rem;
  background: #f5f3ff;
  padding: 0.875rem;
}

.dark .ai-sidekick-preview {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.1);
}

.ai-sidekick-preview__title {
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4338ca;
}

.dark .ai-sidekick-preview__title {
  color: #c7d2fe;
}

.ai-sidekick-preview__message {
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #6366f1;
}

.dark .ai-sidekick-preview__message {
  color: #a5b4fc;
}

.ai-sidekick-preview__table-wrap {
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

.ai-sidekick-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.ai-sidekick-preview-table th,
.ai-sidekick-preview-table td {
  padding: 0.375rem 0.5rem;
  text-align: start;
  border-bottom: 1px solid #e0e7ff;
}

.ai-sidekick-preview-table th {
  font-weight: 500;
  color: #6b7280;
  background: #ede9fe;
}

.ai-sidekick-preview-table__required {
  font-weight: 600;
  color: #4338ca !important;
}

.ai-sidekick-preview-table__optional {
  font-weight: 400;
  color: #9ca3af;
}

.ai-sidekick-preview-table__row {
  transition: background-color 0.12s ease;
}

.ai-sidekick-preview-table__row:hover {
  background-color: #ede9fe;
}

.ai-sidekick-preview-table__row--invalid {
  background-color: #fef2f2;
}

.dark .ai-sidekick-preview-table th,
.dark .ai-sidekick-preview-table td {
  border-bottom-color: rgba(99, 102, 241, 0.25);
}

.dark .ai-sidekick-preview-table th {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.18);
}

.dark .ai-sidekick-preview-table__row:hover {
  background-color: rgba(99, 102, 241, 0.16);
}

.dark .ai-sidekick-preview-table__row--invalid {
  background-color: rgba(127, 29, 29, 0.15);
}

.ai-sidekick-preview-input {
  width: 100%;
  border: 1px solid #e0e7ff;
  border-radius: 0.375rem;
  background: #fff;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  color: #374151;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.ai-sidekick-preview-input--name {
  font-weight: 600;
}

.ai-sidekick-preview-input:focus {
  border-color: #a5b4fc;
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.dark .ai-sidekick-preview-input {
  border-color: rgba(99, 102, 241, 0.35);
  background: #1f2937;
  color: #f3f4f6;
}

.ai-sidekick-preview__count {
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  color: #6b7280;
}

.ai-sidekick-preview__error {
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  color: #dc2626;
}

.ai-sidekick-preview__actions {
  display: flex;
  gap: 0.5rem;
}

/* Activity preview — vertical editable fields (desktop hover + mobile tap) */
.ai-sidekick-preview-fields {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.ai-sidekick-preview-fields__hint {
  margin: 0 0 0.15rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: #6b7280;
}

.dark .ai-sidekick-preview-fields__hint {
  color: #9ca3af;
}

.ai-sidekick-preview-field {
  border: 1px solid #e0e7ff;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.45rem 0.55rem;
  transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.dark .ai-sidekick-preview-field {
  border-color: rgba(99, 102, 241, 0.28);
  background: rgba(17, 24, 39, 0.45);
}

.ai-sidekick-preview-field--editing {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.ai-sidekick-preview-field--invalid {
  border-color: #fca5a5;
  background: #fef2f2;
}

.dark .ai-sidekick-preview-field--invalid {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.18);
}

.ai-sidekick-preview-field__label {
  margin-bottom: 0.15rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #6b7280;
}

.dark .ai-sidekick-preview-field__label {
  color: #c7d2fe;
}

.ai-sidekick-preview-field__body {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 1.4rem;
}

.ai-sidekick-preview-field:not(.ai-sidekick-preview-field--readonly):not(.ai-sidekick-preview-field--editing) .ai-sidekick-preview-field__body {
  cursor: pointer;
}

.ai-sidekick-preview-field__value {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}

.dark .ai-sidekick-preview-field__value {
  color: #f3f4f6;
}

.ai-sidekick-preview-field__value--muted {
  color: #9ca3af;
}

.ai-sidekick-preview-field__edit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-inline-start: auto;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: #6366f1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, background-color 0.12s ease;
}

.ai-sidekick-preview-field:hover .ai-sidekick-preview-field__edit,
.ai-sidekick-preview-field:focus-within .ai-sidekick-preview-field__edit,
.ai-sidekick-preview-field__edit:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.ai-sidekick-preview-field__edit:hover,
.ai-sidekick-preview-field__edit:focus-visible {
  background: rgba(99, 102, 241, 0.12);
}

/* Touch / coarse pointers: always show the edit affordance */
@media (hover: none), (pointer: coarse) {
  .ai-sidekick-preview-field__edit {
    opacity: 0.85;
    pointer-events: auto;
  }

  .ai-sidekick-preview-field__body {
    min-height: 2rem;
    align-items: center;
  }

  .ai-sidekick-preview-field__edit {
    width: 2rem;
    height: 2rem;
  }

  .ai-sidekick-preview-fields__hint {
    font-size: 0.75rem;
  }
}

.ai-sidekick-preview-input--textarea {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.4;
}

/* Debug Replay */
.ai-sidekick-replay-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
}

.ai-sidekick-replay-modal {
  width: min(36rem, 100%);
  max-height: min(90vh, 40rem);
  overflow: auto;
  border-radius: 0.75rem;
  background: #fff;
  padding: 1rem 1.125rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.dark .ai-sidekick-replay-modal {
  background: #111827;
  color: #f3f4f6;
}

.ai-sidekick-replay-modal__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.ai-sidekick-replay-modal__help {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #6b7280;
}

.dark .ai-sidekick-replay-modal__help {
  color: #9ca3af;
}

.ai-sidekick-replay-modal__textarea {
  width: 100%;
  min-height: 10rem;
  margin: 0.5rem 0 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.35;
  resize: vertical;
  background: #f9fafb;
  color: inherit;
}

.dark .ai-sidekick-replay-modal__textarea {
  border-color: #374151;
  background: #0f172a;
}

.ai-sidekick-replay-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.ai-sidekick-replay-result {
  margin-bottom: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: #fafafa;
}

.dark .ai-sidekick-replay-result {
  border-color: #374151;
  background: #0f172a;
}

.ai-sidekick-replay-result__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ai-sidekick-replay-result__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
}

.ai-sidekick-replay-result__meta {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: #6b7280;
  white-space: pre-wrap;
}

.ai-sidekick-replay-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .ai-sidekick-replay-cols {
    grid-template-columns: 1fr 1fr;
  }
}

.ai-sidekick-replay-col {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.625rem;
  background: #fff;
}

.dark .ai-sidekick-replay-col {
  border-color: #374151;
  background: #111827;
}

.ai-sidekick-replay-col__label {
  margin: 0 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #6b7280;
}

.ai-sidekick-replay-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.ai-sidekick-replay-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
  font-size: 0.6875rem;
  background: #eef2ff;
  color: #3730a3;
}

.dark .ai-sidekick-replay-tag {
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
}

.ai-sidekick-replay-col__body {
  max-height: 12rem;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-sidekick-replay-checks {
  margin-top: 0.75rem;
}

.ai-sidekick-replay-checks__title {
  margin: 0 0 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.ai-sidekick-replay-check {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-bottom: 0.375rem;
  border-radius: 0.375rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.ai-sidekick-replay-check--pass {
  background: #ecfdf5;
  color: #065f46;
}

.ai-sidekick-replay-check--fail {
  background: #fef2f2;
  color: #991b1b;
}

.dark .ai-sidekick-replay-check--pass {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.dark .ai-sidekick-replay-check--fail {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.ai-sidekick-replay-check__status {
  font-weight: 700;
}

.ai-sidekick-replay-check__detail {
  opacity: 0.9;
}
