#synopai-chat-widget {
  position: fixed;
  z-index: 99999;
  --synopai-accent: #d4af37;
  --synopai-panel-bg: rgba(255, 255, 255, 0.96);
  --synopai-blur: 10px;
  --synopai-border: rgba(20, 20, 20, 0.08);
  --synopai-text: #262626;
  --synopai-muted: #70757a;
  --synopai-user-bg: rgba(37, 99, 235, 0.12);
  --synopai-bot-bg: rgba(20, 20, 20, 0.05);
  --synopai-header-bg: #f3f4f6;
}

#synopai-chat-widget.synopai-expanded:not(.synopai-floating) {
  left: auto !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
}

body.synopai-chat-split {
  margin-right: 33.3333vw;
  transition: margin-right 180ms ease;
}

#synopai-chat-window {
  position: relative;
  margin-top: 0;
  width: min(92vw, 560px);
  height: 58px;
  overflow: hidden;
  border-radius: 999px;
  border: 0;
  background: var(--synopai-panel-bg);
  backdrop-filter: blur(var(--synopai-blur));
  color: var(--synopai-text);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.16);
  transition: height 220ms ease, width 220ms ease, border-radius 220ms ease;
}

#synopai-chat-window.synopai-compact {
  width: min(86vw, 460px);
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.98), rgba(226, 232, 240, 0.98)) !important;
  box-shadow: 0 -8px 16px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.08) !important;
}

#synopai-chat-widget.synopai-closed #synopai-chat-window {
  display: none !important;
}

.synopai-chat-launcher {
  border: 0;
  height: 46px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1f2937, #111827);
  color: #fff;
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.3);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

#synopai-chat-widget.synopai-closed .synopai-chat-launcher {
  display: inline-flex;
}

.synopai-chat-launcher[hidden] {
  display: none !important;
}

#synopai-chat-compact-close {
  display: none;
  border: 0;
  position: absolute;
  top: -22px;
  right: 10px;
  width: 20px;
  height: 20px;
  border-radius: 0;
  background: transparent;
  color: #334155;
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 3;
}

#synopai-chat-compact-close:hover {
  color: #1e293b;
}

.synopai-chat-launcher:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.34);
}

.synopai-chat-launcher:active {
  transform: translateY(0);
}

#synopai-chat-window.synopai-expanded {
  width: 33.3333vw;
  min-width: 360px;
  max-width: 560px;
  height: 100vh;
  border-radius: 0;
}

#synopai-chat-widget.synopai-floating {
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
}

#synopai-chat-widget.synopai-floating #synopai-chat-window.synopai-expanded {
  width: min(92vw, 520px);
  height: min(90vh, 760px);
  border-radius: 14px;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.2);
}

.synopai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(20, 20, 20, 0.1);
  background: var(--synopai-header-bg);
}

.synopai-chat-title {
  font-size: 13px;
  font-weight: 700;
  color: #2b2b2b;
  letter-spacing: 0.15px;
}

#synopai-chat-close {
  border: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#synopai-chat-close:hover {
  background: rgba(20, 20, 20, 0.08);
  color: #1f2937;
}

.synopai-chat-header {
  cursor: default;
}

.synopai-chat-title {
  cursor: move;
}

#synopai-chat-log {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  background: rgba(255, 255, 255, 0.78);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#synopai-chat-window.synopai-compact #synopai-chat-log,
#synopai-chat-window.synopai-compact .synopai-status-bar,
#synopai-chat-window.synopai-compact .synopai-crawl-note,
#synopai-chat-window.synopai-compact .synopai-chat-header {
  display: none !important;
}

#synopai-chat-window.synopai-compact #synopai-chat-form {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(226, 232, 240, 0.98)) !important;
  border-top: 0 !important;
  padding: 6px 8px;
  height: 100%;
  box-sizing: border-box;
  align-items: center;
}

#synopai-chat-window.synopai-compact #synopai-chat-input {
  flex: 0 1 75%;
  width: 75%;
  max-width: 75%;
}

#synopai-chat-window.synopai-compact #synopai-chat-form button[type='submit'] {
  flex: 0 0 25%;
  width: 25%;
  min-width: 81px;
  justify-content: center;
}

#synopai-chat-widget:not(.synopai-expanded):not(.synopai-closed) #synopai-chat-compact-close {
  display: block;
}

#synopai-chat-widget.synopai-expanded #synopai-chat-compact-close,
#synopai-chat-widget.synopai-closed #synopai-chat-compact-close {
  display: none !important;
}

#synopai-chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.96));
  overflow: hidden;
  border-radius: 999px;
}

#synopai-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 112px);
  height: 40px;
  border: 1px solid rgba(20, 20, 20, 0.12);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  color: #111;
  background: #fff;
}

#synopai-chat-form button[type='submit'] {
  border: 0;
  height: 40px;
  min-width: 96px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1f2937, #111827);
  color: #fff;
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(17, 24, 39, 0.25);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

#synopai-chat-form button[type='submit']:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 14px rgba(17, 24, 39, 0.28);
}

#synopai-chat-form button[type='submit']:active {
  transform: translateY(0);
}

#synopai-chat-form button[type='submit']:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.synopai-send-icon {
  font-size: 13px;
  line-height: 1;
  color: #fcd34d;
}

.synopai-send-text {
  letter-spacing: 0.2px;
}

.synopai-chat-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#synopai-chat-dock-toggle,
#synopai-chat-close {
  border: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#synopai-chat-dock-toggle:hover,
#synopai-chat-close:hover {
  background: rgba(20, 20, 20, 0.08);
  color: #1f2937;
}

.synopai-line {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #222;
  max-width: 82%;
}

.synopai-user {
  align-self: flex-end;
  color: #0b3d67;
  background: var(--synopai-user-bg);
  border-radius: 12px 12px 4px 12px;
  padding: 8px 10px;
  margin-left: auto;
}

.synopai-bot {
  align-self: flex-start;
  color: #1f1f1f;
  background: var(--synopai-bot-bg);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 10px;
  margin-right: auto;
}

.synopai-line-warn {
  color: #7a4a00;
  font-style: italic;
  font-size: 12px;
}

.synopai-sources {
  margin-top: 6px;
  border-top: 1px dashed rgba(20, 20, 20, 0.15);
  padding-top: 6px;
}

.synopai-sources-summary {
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.synopai-sources-summary::-webkit-details-marker {
  display: none;
}

.synopai-sources-summary::after {
  content: '▾';
  font-size: 10px;
  line-height: 1;
  transition: transform 150ms ease;
}

.synopai-sources[open] .synopai-sources-summary::after {
  transform: rotate(180deg);
}

.synopai-sources-list {
  margin: 6px 0 0;
  padding: 0 0 0 14px;
}

.synopai-sources-item {
  margin: 0 0 4px;
  font-size: 11px;
  line-height: 1.35;
  color: #374151;
}

.synopai-sources-item a {
  color: #1d4ed8;
  text-decoration: none;
}

.synopai-sources-item a:hover {
  text-decoration: underline;
}

.synopai-debug {
  margin-top: 6px;
  border-top: 1px dashed rgba(100, 116, 139, 0.35);
  padding-top: 6px;
}

.synopai-debug-summary {
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.synopai-debug-summary::-webkit-details-marker {
  display: none;
}

.synopai-debug-summary::after {
  content: '▾';
  font-size: 10px;
  transition: transform 150ms ease;
}

.synopai-debug[open] .synopai-debug-summary::after {
  transform: rotate(180deg);
}

.synopai-debug-meta {
  margin-top: 4px;
  font-size: 10px;
  color: #64748b;
}

.synopai-debug-controls {
  margin-top: 6px;
}

.synopai-debug-copy {
  border: 1px solid rgba(100, 116, 139, 0.35);
  background: #f8fafc;
  color: #334155;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

.synopai-debug-copy:hover {
  background: #eef2ff;
  border-color: rgba(79, 70, 229, 0.35);
  color: #312e81;
}

.synopai-debug-copy:disabled {
  opacity: 0.8;
  cursor: default;
}

.synopai-debug-copy.is-error {
  border-color: rgba(185, 28, 28, 0.45);
  color: #7f1d1d;
  background: #fef2f2;
}

.synopai-debug-list {
  margin: 6px 0 0;
  padding-left: 16px;
}

.synopai-debug-head {
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}

.synopai-debug-excerpt {
  font-size: 10px;
  color: #64748b;
  margin: 2px 0 4px;
}

.synopai-debug a {
  font-size: 10px;
  color: #1d4ed8;
  text-decoration: none;
}

.synopai-debug a:hover {
  text-decoration: underline;
}

/* Fallback quota status bar */
.synopai-status-bar {
  padding: 6px 12px;
  font-size: 11px;
  text-align: center;
  border-bottom: 1px solid rgba(20, 20, 20, 0.08);
}

.synopai-status-warning {
  background: rgba(245, 166, 35, 0.18);
  color: #7a4a00;
}

.synopai-status-error {
  background: rgba(220, 38, 38, 0.16);
  color: #7f1d1d;
}

.synopai-crawl-note {
  padding: 6px 12px;
  font-size: 11px;
  color: #3f3f46;
  background: rgba(99, 102, 241, 0.1);
  border-bottom: 1px solid rgba(20, 20, 20, 0.05);
}

@media (max-width: 1024px) {
  body.synopai-chat-split {
    margin-right: 0;
  }

  #synopai-chat-window.synopai-expanded,
  #synopai-chat-widget.synopai-floating #synopai-chat-window.synopai-expanded {
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    height: 100vh;
    border-radius: 0;
  }
}

.synopai-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.synopai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6b7280;
  animation: synopaiTyping 1s infinite ease-in-out;
}

.synopai-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.synopai-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes synopaiTyping {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
