/* ============================================================
   FLOATING CHAT WIDGET
   ============================================================ */

/* --- Animations --- */
@keyframes chatPanelIn {
  0%   { opacity: 0; transform: translateY(16px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chatBubbleFadeIn {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes chatChoiceIn {
  0%   { opacity: 0; transform: translateY(8px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chatDotBounce {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

@keyframes chatDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.7; }
}

@keyframes chatStatusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes chatTooltipIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(4px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes chatTooltipOut {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(4px); }
}

/* --- Bubble Button (no animation property — prevents shrink bug) --- */
.chat-widget-bubble {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 320;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--gradient-vibrant);
  color: #fff;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 16px rgba(59, 130, 246, 0.3),
    0 8px 32px rgba(59, 130, 246, 0.15);
  transition: box-shadow 0.3s var(--ease-soft, ease), transform 0.2s var(--ease-soft, ease);
}

.chat-widget-bubble:hover {
  box-shadow:
    0 6px 24px rgba(59, 130, 246, 0.4),
    0 12px 44px rgba(59, 130, 246, 0.2);
  transform: scale(1.08);
}

.chat-widget-bubble:active {
  transform: scale(0.95);
}

.chat-widget-bubble .chat-widget-close-icon {
  display: none;
}

.chat-widget.is-open .chat-widget-bubble .chat-widget-bubble-icon {
  display: none;
}

.chat-widget.is-open .chat-widget-bubble .chat-widget-close-icon {
  display: block;
  font-size: 1.2rem;
}

/* --- Tooltip ("Need help?") — sibling of bubble --- */
.chat-widget-tooltip {
  position: fixed;
  bottom: 146px;
  right: 16px;
  z-index: 320;
  background: var(--surface, #1e293b);
  color: var(--text, #f1f5f9);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.chat-widget-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--surface, #1e293b);
}

.chat-widget.tooltip-visible .chat-widget-tooltip {
  opacity: 1;
  visibility: visible;
  animation: chatTooltipIn 0.3s ease both;
}

.chat-widget.tooltip-hiding .chat-widget-tooltip {
  animation: chatTooltipOut 0.3s ease both;
}

.chat-widget.is-open .chat-widget-tooltip {
  display: none;
}

/* Notification dot */
.chat-widget-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  border: 2.5px solid #0e1525;
  pointer-events: none;
}

.chat-widget.dot-hidden .chat-widget-dot,
.chat-widget.is-open .chat-widget-dot {
  display: none;
}

/* --- Chat Panel (frosted glass) --- */
.chat-widget-panel {
  position: fixed;
  bottom: 148px;
  right: 16px;
  z-index: 300;
  width: 390px;
  max-height: 560px;
  border-radius: var(--radius-lg, 24px);
  border: 1px solid rgba(104, 154, 255, 0.15);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 24px 80px -12px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(59, 130, 246, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.chat-widget.is-open .chat-widget-panel {
  display: flex;
  animation: chatPanelIn 0.3s var(--ease-soft, ease) both;
}

/* --- Panel Header (refined) --- */
.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--gradient-vibrant);
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.chat-widget-header-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-widget-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.chat-widget-header-title i {
  font-size: 1.05rem;
  opacity: 0.9;
}

.chat-widget-step-label {
  font-size: 0.68rem;
  opacity: 0.7;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.chat-widget-header-close {
  background: rgba(220, 38, 38, 0.85);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, transform 0.15s;
}

.chat-widget-header-close:hover {
  background: rgba(220, 38, 38, 1);
  transform: scale(1.05);
}

/* Status dot in header */
.chat-widget-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
  animation: chatStatusPulse 3s ease-in-out infinite;
  flex-shrink: 0;
}

/* --- Progress Bar --- */
.chat-widget-progress {
  height: 2px;
  background: rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.chat-widget-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-vibrant);
  border-radius: 0 1px 1px 0;
  transition: width 0.4s var(--ease-soft, ease);
}

/* --- Ticket Assistant (inside panel) --- */
.ticket-assistant {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ticket-assistant-log {
  flex: 1;
  min-height: 180px;
  max-height: 300px;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.15) transparent;
}

.ticket-assistant-log::-webkit-scrollbar {
  width: 4px;
}

.ticket-assistant-log::-webkit-scrollbar-track {
  background: transparent;
}

.ticket-assistant-log::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.15);
  border-radius: 4px;
}

.ticket-assistant-log::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.3);
}

.ticket-assistant-row {
  display: flex;
}

.ticket-assistant-row--assistant,
.ticket-assistant-row--error {
  justify-content: flex-start;
}

.ticket-assistant-row--user {
  justify-content: flex-end;
}

/* --- Bubble enter animation for new messages --- */
.ticket-assistant-row.bubble-enter {
  animation: chatBubbleFadeIn 0.25s var(--ease-soft, ease) both;
}

/* --- Chat Bubbles (refined) --- */
.ticket-assistant-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.86rem;
  line-height: 1.55;
}

.ticket-assistant-bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: inherit;
}

.ticket-assistant-bubble--assistant {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.1);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ticket-assistant-bubble--user {
  background: var(--gradient-vibrant);
  border: none;
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.2);
}

.ticket-assistant-bubble--error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-bottom-left-radius: 4px;
}

/* --- Assistant avatar --- */
.ticket-assistant-row--assistant {
  gap: 8px;
  align-items: flex-end;
}

.ticket-assistant-avatar {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background: var(--gradient-vibrant);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 0.6rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

/* --- Typing indicator --- */
.ticket-assistant-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 2px;
}

.ticket-assistant-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-electric, #74a0ff);
  opacity: 0.5;
  animation: chatDotBounce 1.4s ease-in-out infinite;
}

.ticket-assistant-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ticket-assistant-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

/* --- Composer (hybrid layout) --- */
.ticket-assistant-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

/* Choices sit above input */
.ticket-assistant-choices {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.12) transparent;
}

.ticket-assistant-choices::-webkit-scrollbar {
  width: 3px;
}

.ticket-assistant-choices::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.12);
  border-radius: 3px;
}

.ticket-assistant-choices:empty {
  display: none;
}

.ticket-assistant-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* --- Choice buttons (elegant cards with icons) --- */
.ticket-assistant-choice {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s var(--ease-soft, ease);
  position: relative;
  overflow: hidden;
  animation: chatChoiceIn 0.2s var(--ease-soft, ease) both;
}

/* Stagger animation for choices */
.ticket-assistant-choice:nth-child(1)  { animation-delay: 0s; }
.ticket-assistant-choice:nth-child(2)  { animation-delay: 0.03s; }
.ticket-assistant-choice:nth-child(3)  { animation-delay: 0.06s; }
.ticket-assistant-choice:nth-child(4)  { animation-delay: 0.09s; }
.ticket-assistant-choice:nth-child(5)  { animation-delay: 0.12s; }
.ticket-assistant-choice:nth-child(6)  { animation-delay: 0.15s; }
.ticket-assistant-choice:nth-child(7)  { animation-delay: 0.18s; }
.ticket-assistant-choice:nth-child(8)  { animation-delay: 0.21s; }
.ticket-assistant-choice:nth-child(9)  { animation-delay: 0.24s; }
.ticket-assistant-choice:nth-child(10) { animation-delay: 0.27s; }

.ticket-assistant-choice::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.ticket-assistant-choice:hover::before,
.ticket-assistant-choice:focus-visible::before {
  opacity: 1;
}

.ticket-assistant-choice:hover,
.ticket-assistant-choice:focus-visible {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
  outline: none;
}

.ticket-assistant-choice-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--accent-electric, #74a0ff);
  transition: background 0.2s;
}

.ticket-assistant-choice:hover .ticket-assistant-choice-icon {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.1));
}

.ticket-assistant-choice-content {
  flex: 1;
  min-width: 0;
}

.ticket-assistant-choice-label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

.ticket-assistant-choice-hint {
  display: block;
  margin-top: 1px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.ticket-assistant-choice-arrow {
  color: var(--text-muted);
  font-size: 0.65rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.ticket-assistant-choice:hover .ticket-assistant-choice-arrow {
  opacity: 0.7;
  transform: translateX(0);
}

/* --- Input row (pill shape with embedded send) --- */
.ticket-assistant-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0;
  background: var(--surface-alt, #131d2d);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ticket-assistant-input-row:focus-within {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.ticket-assistant-input,
.ticket-assistant-textarea {
  flex: 1;
  font-size: 0.86rem;
  min-width: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 8px 0 !important;
  color: var(--text);
}

.ticket-assistant-input::placeholder,
.ticket-assistant-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.ticket-assistant-textarea {
  resize: none;
  border-radius: 0 !important;
}

/* Textarea mode: switch to non-pill layout */
.ticket-assistant-input-row:has(.ticket-assistant-textarea:not([hidden])) {
  border-radius: 16px;
  padding: 8px 4px 4px 14px;
  align-items: flex-end;
}

.ticket-assistant-send {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--gradient-vibrant);
  color: #fff;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s var(--ease-soft, ease), transform 0.15s var(--ease-soft, ease), opacity 0.2s;
  flex-shrink: 0;
}

.ticket-assistant-send:hover {
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  transform: scale(1.08);
}

.ticket-assistant-send:active {
  transform: scale(0.93);
}

.ticket-assistant-send:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* --- Action buttons (skip, start over) --- */
.ticket-assistant-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 4px;
}

.ticket-assistant-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.2s;
  letter-spacing: 0.01em;
}

.ticket-assistant-actions button:hover {
  color: var(--text);
}

/* --- Submit spinner (on send button) --- */
.ticket-assistant-send .fa-spinner {
  animation: fa-spin 1s linear infinite;
}

/* --- Review mode: log hidden, summary + buttons fill the panel --- */

/* Force the panel to its max height so flex children can expand */
.chat-widget.is-review .chat-widget-panel {
  height: 560px;
}

.ticket-assistant--review .ticket-assistant-log {
  display: none !important;
}

.ticket-assistant--review .ticket-assistant-composer {
  flex: 1 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ticket-assistant--review .ticket-assistant-choices {
  max-height: none !important;
  overflow-y: auto;
  flex: 1;
}

.ticket-assistant--review .ticket-assistant-input-row,
.ticket-assistant--review .ticket-assistant-actions {
  display: none !important;
}

/* --- Result container (hidden by default, only used as fallback) --- */
.ticket-assistant-result {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.12) transparent;
}

/* --- Review action buttons (in choices area, top of composer) --- */
.ticket-assistant-review-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.ticket-assistant-review-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  background: var(--gradient-vibrant, linear-gradient(135deg, #3b82f6, #6366f1));
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.ticket-assistant-review-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.4);
  color: #fff;
}

.ticket-assistant-review-submit:active {
  transform: translateY(0);
}

.ticket-assistant-review-restart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.ticket-assistant-review-restart:hover {
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--text);
  background: rgba(59, 130, 246, 0.04);
}

/* --- In-log summary card --- */
.ticket-assistant-summary-card {
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 14px;
  padding: 14px;
}

.ticket-assistant-summary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
}

.ticket-assistant-summary-header i {
  color: #3b82f6;
}

.ticket-assistant-summary-card h3,
.ticket-assistant-success-card h3 {
  margin-bottom: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ticket-assistant-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.ticket-assistant-summary-item {
  background: rgba(59, 130, 246, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.ticket-assistant-summary-item--full {
  margin-bottom: 12px;
  grid-column: 1 / -1;
}

.ticket-assistant-summary-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 500;
}

.ticket-assistant-summary-item strong,
.ticket-assistant-summary-detail {
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.ticket-assistant-summary-empty {
  color: var(--text-muted);
  font-style: italic;
}

.ticket-assistant-review-actions,
.ticket-assistant-result-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-assistant-review-actions .btn,
.ticket-assistant-result-links .btn {
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 10px;
}

.ticket-assistant-success-card {
  text-align: left;
}

.ticket-assistant-success-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  margin-bottom: 10px;
}

.ticket-assistant-success-card h3 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.ticket-assistant-success-card p {
  color: var(--text-muted);
  margin-bottom: 14px;
  font-size: 0.82rem;
}

/* --- Tablet positioning (mobile-call button visible, stack chat above it) --- */
@media (min-width: 577px) and (max-width: 991px) {
  .chat-widget-bubble {
    top: auto;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    right: 18px;
    width: 54px;
    height: 54px;
  }

  .chat-widget-tooltip {
    top: auto;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    right: 18px;
  }

  .chat-widget-panel {
    bottom: 154px;
    right: 18px;
  }
}

/* --- Desktop positioning (mobile-call hidden) --- */
@media (min-width: 992px) {
  .chat-widget-bubble {
    bottom: 116px;
    right: 24px;
  }

  .chat-widget-tooltip {
    bottom: 182px;
    right: 24px;
  }

  .chat-widget-panel {
    bottom: 186px;
    right: 24px;
  }
}

/* --- Mobile (<576px) — full-screen bottom sheet --- */
@media (max-width: 576px) {

  /* Bubble: anchored to the safe area so it does not cover page headings. */
  .chat-widget-bubble {
    top: auto;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    width: 50px;
    height: 50px;
    font-size: 1.12rem;
  }

  /* Hide bubble when chat is open — header close button is used instead */
  .chat-widget.is-open .chat-widget-bubble {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
    transition: all 0.2s ease;
  }

  /* Tooltip */
  .chat-widget-tooltip {
    top: auto;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    font-size: 0.74rem;
    padding: 6px 12px;
  }

  /* Panel: full-screen, above navbar (z-index 1040) */
  .chat-widget-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    height: 100vh; /* fallback for older browsers */
    max-height: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 1050;
  }

  @supports (height: 100dvh) {
    .chat-widget-panel {
      height: 100dvh;
    }
  }

  /* Review mode: full-screen on mobile */
  .chat-widget.is-review .chat-widget-panel {
    height: 100dvh;
    height: 100vh;
  }

  @supports (height: 100dvh) {
    .chat-widget.is-review .chat-widget-panel {
      height: 100dvh;
    }
  }

  /* Header */
  .chat-widget-header {
    padding: 10px 14px;
    padding-top: calc(max(10px, env(safe-area-inset-top, 0px)) + 2px);
  }

  .chat-widget-header-title {
    font-size: 0.88rem;
    gap: 8px;
  }

  .chat-widget-header-title i {
    font-size: 0.95rem;
  }

  .chat-widget-step-label {
    font-size: 0.64rem;
  }

  .chat-widget-header-close {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 1rem;
  }

  /* Root */
  .ticket-assistant {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Log */
  .ticket-assistant-log {
    flex: 1;
    min-height: 0;
    max-height: none;
    padding: 12px;
    gap: 8px;
  }

  /* Bubbles: wider on mobile for more content room */
  .ticket-assistant-bubble {
    max-width: 94%;
    padding: 9px 12px;
    font-size: 0.84rem;
    border-radius: 14px;
  }

  .ticket-assistant-bubble--assistant { border-bottom-left-radius: 4px; }
  .ticket-assistant-bubble--user { border-bottom-right-radius: 4px; }
  .ticket-assistant-bubble--error { border-bottom-left-radius: 4px; }

  /* Avatar slightly smaller */
  .ticket-assistant-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.52rem;
    border-radius: 8px;
  }

  .ticket-assistant-row--assistant {
    gap: 6px;
  }

  /* Composer: safe area bottom + compact */
  .ticket-assistant-composer {
    padding: 8px 10px;
    padding-bottom: calc(max(10px, env(safe-area-inset-bottom, 0px)) + 2px);
    gap: 6px;
    border-top: 1px solid var(--border);
  }

  /* Choices area: limit to 40% of viewport so log stays visible */
  .ticket-assistant-choices {
    max-height: 40vh;
    gap: 4px;
  }

  /* Choice buttons: 44px touch targets, tighter spacing */
  .ticket-assistant-choice {
    min-height: 44px;
    padding: 8px 10px;
    gap: 10px;
    border-radius: 10px;
  }

  .ticket-assistant-choice-grid {
    gap: 3px;
  }

  .ticket-assistant-choice-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 0.72rem;
    border-radius: 7px;
  }

  .ticket-assistant-choice-label {
    font-size: 0.8rem;
  }

  .ticket-assistant-choice-hint {
    font-size: 0.68rem;
    line-height: 1.3;
  }

  .ticket-assistant-choice-arrow {
    display: none; /* save space on mobile */
  }

  /* Input row: compact */
  .ticket-assistant-input-row {
    padding: 3px 3px 3px 12px;
  }

  .ticket-assistant-input,
  .ticket-assistant-textarea {
    font-size: 16px !important; /* prevents iOS zoom on focus */
    padding: 7px 0 !important;
  }

  .ticket-assistant-send {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 0.76rem;
  }

  /* Actions row */
  .ticket-assistant-actions {
    padding: 0 2px;
    gap: 12px;
  }

  .ticket-assistant-actions button {
    font-size: 0.7rem;
    padding: 4px 0;
    min-height: 32px; /* tap target */
  }

  /* ---- Summary card: properly spaced, not cramped ---- */
  .ticket-assistant-summary-card {
    padding: 10px;
    border-radius: 12px;
  }

  .ticket-assistant-summary-header {
    font-size: 0.8rem;
    margin-bottom: 8px;
    padding-bottom: 6px;
    gap: 6px;
  }

  .ticket-assistant-summary-header i {
    font-size: 0.85rem;
  }

  .ticket-assistant-summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .ticket-assistant-summary-item {
    padding: 6px 8px;
    border-radius: 8px;
  }

  .ticket-assistant-summary-item--full {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .ticket-assistant-summary-label {
    font-size: 0.58rem;
    margin-bottom: 1px;
    letter-spacing: 0.05em;
  }

  .ticket-assistant-summary-item strong,
  .ticket-assistant-summary-detail {
    font-size: 0.76rem;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .ticket-assistant-summary-empty {
    font-size: 0.76rem;
  }

  /* ---- Review buttons: prominent, easy to tap ---- */
  .ticket-assistant-review-buttons {
    gap: 6px;
    padding: 2px 0;
  }

  .ticket-assistant-review-submit {
    padding: 13px 16px;
    font-size: 0.88rem;
    border-radius: 12px;
    min-height: 48px;
  }

  .ticket-assistant-review-restart {
    padding: 10px 14px;
    font-size: 0.8rem;
    border-radius: 10px;
    min-height: 44px;
  }

  /* Success card */
  .ticket-assistant-success-kicker {
    font-size: 0.62rem;
    padding: 4px 10px;
  }

  .ticket-assistant-success-card h3 {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .ticket-assistant-success-card p {
    font-size: 0.8rem;
    margin-bottom: 10px;
  }

  /* Result area */
  .ticket-assistant-result {
    padding: 12px;
  }
}

/* Extra-small screens */
@media (max-width: 374px) {
  .ticket-assistant-summary-grid {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .ticket-assistant-choice-hint {
    display: none;
  }

  .ticket-assistant-bubble {
    max-width: 96%;
    padding: 8px 10px;
  }
}

/* Final public positioning: avoid overlap with sticky mobile call CTA. */
@media (max-width: 991.98px) {
  .chat-widget-bubble {
    right: 18px !important;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 575.98px) {
  .chat-widget-bubble {
    right: 14px !important;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .public-site-shell.home-page-clean .chat-widget-bubble {
    display: none !important;
  }
}
