/* Public-only local FAQ panel. It intentionally uses the portal token set. */
.faq-chat-launcher,
.faq-chat-panel {
  --faq-bg: rgba(7, 16, 12, 0.96);
  --faq-surface: #0d1d15;
  --faq-surface-soft: #11261c;
  --faq-text: #edf8f2;
  --faq-muted: #91a69c;
  --faq-dim: #667970;
  --faq-line: rgba(127, 241, 179, 0.17);
  --faq-line-strong: rgba(127, 241, 179, 0.34);
  --faq-emerald: #56f2a4;
  --faq-gold: #d7b96b;
  --faq-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.faq-chat-launcher {
  position: fixed;
  z-index: 1080;
  right: 22px;
  bottom: 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 15px 8px 9px;
  border: 1px solid var(--faq-line-strong);
  border-radius: 14px 5px 14px 5px;
  background:
    linear-gradient(135deg, rgba(86, 242, 164, 0.14), transparent 48%),
    rgba(7, 16, 12, 0.92);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.32), inset 0 0 22px rgba(86, 242, 164, 0.035);
  color: var(--faq-text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.22s ease, background 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

.faq-chat-launcher::before {
  position: absolute;
  top: -1px;
  left: 17px;
  width: 36px;
  height: 2px;
  background: var(--faq-gold);
  content: "";
  opacity: 0.82;
}

.faq-chat-launcher:hover {
  border-color: var(--faq-emerald);
  background:
    linear-gradient(135deg, rgba(86, 242, 164, 0.2), transparent 52%),
    rgba(9, 26, 18, 0.96);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.42), 0 0 0 4px rgba(86, 242, 164, 0.06);
  transform: translateY(-3px);
}

.faq-chat-launcher[data-faq-hidden] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.92);
}

.faq-chat-launcher:focus-visible,
.faq-chat-panel button:focus-visible,
.faq-chat-panel input:focus-visible {
  outline: 2px solid var(--faq-gold);
  outline-offset: 3px;
}

.faq-chat-launcher-signal {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(86, 242, 164, 0.3);
  border-radius: 10px 3px 10px 3px;
  background: rgba(86, 242, 164, 0.08);
  color: var(--faq-emerald);
  font-size: 18px;
}

.faq-chat-launcher-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.faq-chat-launcher-copy strong {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.faq-chat-launcher-copy small {
  color: var(--faq-muted);
  font-size: 10px;
}

.faq-chat-launcher-pulse {
  width: 7px;
  height: 7px;
  margin-left: 3px;
  border-radius: 50%;
  background: var(--faq-emerald);
  box-shadow: 0 0 0 4px rgba(86, 242, 164, 0.1), 0 0 15px var(--faq-emerald);
}

.faq-chat-panel {
  position: fixed;
  z-index: 1079;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  max-height: min(700px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid var(--faq-line-strong);
  border-radius: 18px 5px 18px 5px;
  background:
    linear-gradient(145deg, rgba(86, 242, 164, 0.07), transparent 30%),
    var(--faq-bg);
  box-shadow: var(--faq-shadow), inset 0 0 42px rgba(86, 242, 164, 0.025);
  color: var(--faq-text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.32s cubic-bezier(0.2, 0.75, 0.15, 1), visibility 0s linear 0.32s;
  visibility: hidden;
}

.faq-chat-panel[data-faq-open] {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition-delay: 0s;
  visibility: visible;
}

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

.faq-chat-panel::before {
  position: absolute;
  top: 0;
  right: 20px;
  left: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--faq-gold), transparent);
  content: "";
  opacity: 0.85;
}

.faq-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 17px 14px;
  border-bottom: 1px solid var(--faq-line);
  background: rgba(3, 10, 7, 0.3);
}

.faq-chat-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.faq-chat-emblem {
  display: grid;
  width: 40px;
  height: 42px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid rgba(215, 185, 107, 0.42);
  border-radius: 9px 3px 9px 3px;
  background: rgba(215, 185, 107, 0.08);
}

.faq-chat-emblem img {
  width: 28px;
  height: 32px;
  object-fit: contain;
}

.faq-chat-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--faq-gold);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.faq-chat-header h2 {
  margin: 0;
  color: var(--faq-text);
  font-size: 15px;
  line-height: 1.1;
}

.faq-chat-header p {
  margin: 4px 0 0;
  color: var(--faq-muted);
  font-size: 10px;
}

.faq-chat-header-actions {
  display: flex;
  gap: 5px;
}

.faq-chat-icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--faq-line);
  border-radius: 7px;
  background: transparent;
  color: var(--faq-muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.faq-chat-icon-button:hover {
  border-color: var(--faq-emerald);
  background: rgba(86, 242, 164, 0.08);
  color: var(--faq-emerald);
}

.faq-chat-notice {
  display: flex;
  gap: 8px;
  margin: 12px 15px 0;
  padding: 9px 10px;
  border: 1px solid rgba(215, 185, 107, 0.2);
  border-radius: 8px 2px 8px 2px;
  background: rgba(215, 185, 107, 0.065);
  color: var(--faq-muted);
  font-size: 10px;
  line-height: 1.45;
}

.faq-chat-notice i {
  flex: 0 0 auto;
  color: var(--faq-gold);
  font-size: 13px;
}

.faq-chat-transcript {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 190px;
  max-height: 320px;
  overflow-y: auto;
  padding: 14px 15px 10px;
  scroll-behavior: smooth;
}

.faq-chat-transcript::-webkit-scrollbar {
  width: 6px;
}

.faq-chat-transcript::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(86, 242, 164, 0.28);
}

.faq-chat-message {
  display: grid;
  gap: 5px;
  max-width: 91%;
  animation: faq-chat-message-in 0.28s ease both;
}

.faq-chat-message--user {
  align-self: flex-end;
}

.faq-chat-message--assistant {
  align-self: flex-start;
}

.faq-chat-message-label {
  color: var(--faq-dim);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.faq-chat-message--user .faq-chat-message-label {
  text-align: right;
}

.faq-chat-bubble {
  padding: 10px 11px;
  border: 1px solid var(--faq-line);
  border-radius: 12px 3px 12px 3px;
  background: var(--faq-surface);
  color: var(--faq-text);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
}

.faq-chat-message--user .faq-chat-bubble {
  border-color: rgba(86, 242, 164, 0.35);
  background: rgba(39, 201, 121, 0.15);
}

.faq-chat-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  color: var(--faq-emerald);
  font-size: 10px;
  font-weight: 800;
}

.faq-chat-source:hover {
  color: var(--faq-gold-soft);
}

.faq-chat-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
  padding: 0 15px 5px;
  color: var(--faq-muted);
  font-size: 10px;
}

.faq-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faq-emerald);
  box-shadow: 0 0 0 3px rgba(86, 242, 164, 0.1);
  animation: faq-chat-status-pulse 1s ease-in-out infinite;
}

.faq-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 15px 10px;
}

.faq-chat-suggestions-label {
  width: 100%;
  color: var(--faq-dim);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.faq-chat-suggestion {
  padding: 6px 8px;
  border: 1px solid var(--faq-line);
  border-radius: 6px 2px 6px 2px;
  background: transparent;
  color: var(--faq-muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1.2;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.faq-chat-suggestion:hover {
  border-color: var(--faq-emerald);
  background: rgba(86, 242, 164, 0.08);
  color: var(--faq-text);
}

.faq-chat-form {
  padding: 11px 15px 13px;
  border-top: 1px solid var(--faq-line);
  background: rgba(3, 10, 7, 0.26);
}

.faq-chat-input-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
}

.faq-chat-input {
  min-width: 0;
  flex: 1 1 auto;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--faq-line-strong);
  border-radius: 8px 2px 8px 2px;
  outline: 0;
  background: var(--faq-surface);
  color: var(--faq-text);
  font: inherit;
  font-size: 12px;
}

.faq-chat-input::placeholder {
  color: var(--faq-dim);
}

.faq-chat-input:focus {
  border-color: var(--faq-emerald);
  box-shadow: 0 0 0 3px rgba(86, 242, 164, 0.08);
}

.faq-chat-send {
  display: grid;
  width: 43px;
  flex: 0 0 43px;
  place-items: center;
  border: 1px solid var(--faq-emerald);
  border-radius: 8px 2px 8px 2px;
  background: var(--faq-emerald);
  color: #04120a;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.faq-chat-send:hover {
  border-color: var(--faq-gold);
  background: var(--faq-gold);
  transform: translateY(-1px);
}

.faq-chat-form-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  color: var(--faq-dim);
  font-size: 9px;
}

.faq-chat-form-meta i {
  color: var(--faq-gold);
}

@keyframes faq-chat-message-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes faq-chat-status-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

html[data-theme="light"] .faq-chat-launcher,
html[data-theme="light"] .faq-chat-panel {
  --faq-bg: rgba(255, 253, 248, 0.98);
  --faq-surface: #faf6ed;
  --faq-surface-soft: #f1e8d8;
  --faq-text: #222920;
  --faq-muted: #657068;
  --faq-dim: #879087;
  --faq-line: rgba(128, 91, 24, 0.18);
  --faq-line-strong: rgba(128, 91, 24, 0.34);
  --faq-emerald: #1f6b49;
  --faq-gold: #a87922;
  --faq-shadow: 0 28px 80px rgba(78, 60, 24, 0.2);
}

html[data-theme="light"] .faq-chat-launcher {
  background:
    linear-gradient(135deg, rgba(31, 107, 73, 0.1), transparent 48%),
    rgba(255, 253, 248, 0.94);
}

html[data-theme="light"] .faq-chat-launcher:hover {
  background:
    linear-gradient(135deg, rgba(31, 107, 73, 0.15), transparent 52%),
    #fffdf8;
}

html[data-theme="light"] .faq-chat-header,
html[data-theme="light"] .faq-chat-form {
  background: rgba(234, 216, 170, 0.18);
}

html[data-theme="light"] .faq-chat-message--user .faq-chat-bubble {
  background: rgba(31, 107, 73, 0.1);
}

@media (max-width: 640px) {
  .faq-chat-launcher {
    right: 14px;
    bottom: 14px;
  }

  .faq-chat-panel {
    top: calc(var(--portal-nav-height) + 8px);
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: none;
    transform-origin: bottom center;
  }

  .faq-chat-transcript {
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .faq-chat-launcher,
  .faq-chat-panel,
  .faq-chat-message,
  .faq-chat-send {
    animation: none !important;
    transition-duration: 0.001ms !important;
  }
}
