.assistant-widget-root {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 80;
  font-family: inherit;
}

.assistant-widget-root.is-hidden,
.share-widget-root.is-hidden {
  display: none;
}

.assistant-fab,
.share-fab {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid rgba(83, 217, 255, 0.55);
  background: linear-gradient(145deg, rgba(9, 42, 54, 0.96), rgba(3, 16, 26, 0.96));
  color: #e9fbff;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  cursor: pointer;
  font-size: 25px;
}

.assistant-panel,
.share-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto auto;
  width: min(380px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 120px));
  border: 1px solid rgba(83, 217, 255, 0.32);
  border-radius: 24px;
  overflow: hidden;
  background: rgba(4, 12, 18, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.44);
  color: var(--text);
}

.assistant-panel.is-hidden,
.share-panel.is-hidden {
  display: none;
}

.assistant-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(83, 217, 255, 0.18);
  background: rgba(8, 35, 45, 0.86);
}

.assistant-header strong {
  display: block;
  font-size: 16px;
}

.assistant-header p,
.assistant-boundary {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.assistant-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(139, 167, 188, 0.32);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  cursor: pointer;
  font-size: 20px;
}

.assistant-messages {
  display: flex;
  min-height: 150px;
  max-height: 280px;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 16px;
}

.assistant-message {
  max-width: 88%;
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.assistant-message-bot {
  align-self: flex-start;
  border: 1px solid rgba(83, 217, 255, 0.18);
  background: rgba(83, 217, 255, 0.08);
}

.assistant-message-user {
  align-self: flex-end;
  background: rgba(255, 195, 74, 0.16);
  border: 1px solid rgba(255, 195, 74, 0.32);
}

.assistant-faq-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.assistant-faq-chip {
  border: 1px solid rgba(83, 217, 255, 0.28);
  border-radius: 999px;
  background: rgba(83, 217, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 7px 10px;
}

.assistant-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 0 16px 12px;
}

.assistant-input,
.assistant-send {
  border-radius: 14px;
  min-height: 42px;
}

.assistant-input {
  border: 1px solid rgba(139, 167, 188, 0.28);
  background: rgba(2, 10, 16, 0.92);
  color: var(--text);
  padding: 0 12px;
}

.assistant-send {
  border: 1px solid rgba(83, 217, 255, 0.42);
  background: rgba(11, 75, 88, 0.72);
  color: #e9fbff;
  cursor: pointer;
  padding: 0 14px;
}

.assistant-boundary {
  padding: 0 16px 16px;
}

.settings-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: rgba(139, 167, 188, 0.28);
  border: 1px solid rgba(139, 167, 188, 0.32);
  transition: background 0.18s ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e9fbff;
  transition: transform 0.18s ease;
}

.switch-control input:checked + .switch-track {
  background: rgba(35, 197, 122, 0.42);
  border-color: rgba(35, 197, 122, 0.58);
}

.switch-control input:checked + .switch-track .switch-thumb {
  transform: translateX(26px);
}

.switch-control input:disabled + .switch-track {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-control input:disabled + .switch-track .switch-thumb {
  opacity: 0.75;
}

[data-theme="light"] .assistant-fab {
  background: linear-gradient(145deg, #ffffff, #dff0fb);
  color: #0b2638;
  border-color: rgba(30, 112, 148, 0.28);
  box-shadow: 0 18px 42px rgba(45, 83, 110, 0.20);
}

[data-theme="light"] .assistant-panel {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(84, 123, 151, 0.24);
  box-shadow: 0 24px 60px rgba(75, 112, 140, 0.22);
}

[data-theme="light"] .assistant-header {
  background: rgba(231, 243, 251, 0.92);
}

[data-theme="light"] .assistant-input {
  background: rgba(255, 255, 255, 0.96);
}

@media (max-width: 640px) {
  .assistant-widget-root {
    right: 14px;
    bottom: 14px;
  }
  .assistant-panel {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 96px);
  }

  .ai-diagnosis-subtabs {
    width: 100%;
    gap: 6px;
    padding: 5px;
  }

  .ai-diagnosis-subtab {
    min-height: 44px;
    min-width: 0;
    padding: 8px 6px;
    letter-spacing: 0;
    white-space: normal;
  }

  .assistant-form {
    grid-template-columns: 1fr;
  }
}

/* Keep floating widgets above the sticky header while product modals remain higher. */
.assistant-widget-root {
  z-index: 90;
}

.switch-track,
.switch-thumb {
  pointer-events: none;
}
