:root {
  --ai-drawer-bg: rgba(15, 23, 42, 0.98);
  --ai-drawer-border: rgba(148, 163, 184, 0.24);
  --ai-drawer-text: #e2e8f0;
  --ai-drawer-muted: #94a3b8;
  --ai-drawer-accent: #67e8f9;
}

.ai-seo-help-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(103, 232, 249, 0.45);
  border-radius: 999px;
  color: #e0f2fe;
  background: rgba(15, 23, 42, 0.82);
  box-shadow: 0 12px 35px rgba(2, 6, 23, 0.28);
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  backdrop-filter: blur(14px);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.ai-seo-help-toggle:hover,
.ai-seo-help-toggle:focus-visible {
  background: rgba(8, 47, 73, 0.95);
  border-color: var(--ai-drawer-accent);
  outline: none;
  transform: translateY(-1px);
}

.ai-seo-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1240;
  background: rgba(2, 6, 23, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.ai-seo-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ai-seo-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1250;
  display: flex;
  flex-direction: column;
  width: min(30rem, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  color: var(--ai-drawer-text);
  background: var(--ai-drawer-bg);
  border-left: 1px solid var(--ai-drawer-border);
  box-shadow: -24px 0 60px rgba(2, 6, 23, 0.36);
  transform: translateX(102%);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  visibility: hidden;
  pointer-events: none;
}

.ai-seo-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.ai-seo-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: 0 0 auto;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--ai-drawer-border);
}

.ai-seo-drawer__title {
  margin: 0;
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 800;
}

.ai-seo-drawer__close {
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid var(--ai-drawer-border);
  border-radius: 0.7rem;
  color: var(--ai-drawer-text);
  background: rgba(51, 65, 85, 0.45);
  cursor: pointer;
  font-size: 1.1rem;
}

.ai-seo-drawer__close:hover,
.ai-seo-drawer__close:focus-visible {
  color: #fff;
  border-color: var(--ai-drawer-accent);
  outline: none;
}

.ai-seo-drawer__body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.25rem 1.1rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.58) transparent;
}

.ai-seo-drawer__body::-webkit-scrollbar { width: 0.45rem; }
.ai-seo-drawer__body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.58);
}

.ai-seo-drawer .tool-seo-content {
  display: block;
  max-width: none;
  margin: 0;
  padding: 1rem 0 0;
  color: var(--ai-drawer-text);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.ai-seo-drawer .tool-seo-content h2,
.ai-seo-drawer .tool-seo-content h3,
.ai-seo-drawer .tool-seo-content summary {
  color: #f8fafc;
}

.ai-seo-drawer .tool-seo-content p,
.ai-seo-drawer .tool-seo-content li {
  color: var(--ai-drawer-muted);
  line-height: 1.7;
}

.ai-seo-drawer .tool-seo-content h2 {
  display: none;
}

.ai-seo-drawer .tool-seo-content h3 {
  margin-top: 1.1rem;
}

.ai-seo-drawer .tool-seo-content details {
  margin: 0.6rem 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--ai-drawer-border);
  border-radius: 0.75rem;
  background: rgba(30, 41, 59, 0.62);
}

.ai-seo-drawer .tool-seo-content details p {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
}

.ai-seo-drawer .tool-seo-content a {
  color: var(--ai-drawer-accent);
}

html.ai-seo-drawer-lock,
body.ai-seo-drawer-lock {
  overflow: hidden;
}

@media (max-width: 640px) {
  .ai-seo-help-toggle {
    top: 0.65rem;
    right: 0.65rem;
    min-height: 2.25rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.76rem;
  }

  .ai-seo-drawer__header { padding: 0.8rem 0.85rem; }
  .ai-seo-drawer__body { padding: 0 0.85rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-seo-drawer,
  .ai-seo-backdrop,
  .ai-seo-help-toggle { transition: none; }
}
