
:root {
  --sf-topbar-height: 76px;
}

.ai-workspace-tabs,
.overlay-ai-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.ai-workspace-tab,
.overlay-ai-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.7);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(18px);
}
body.dark .ai-workspace-tab,
body.dark .overlay-ai-tab {
  background: rgba(34,36,31,0.84);
}
.ai-workspace-tab.is-active,
.overlay-ai-tab.is-active {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}

.ai-workspace-pane,
.overlay-ai-pane {
  display: none;
  gap: 14px;
}
.ai-workspace-pane.is-active,
.overlay-ai-pane.is-active {
  display: grid;
}
.ai-stack {
  display: grid;
  gap: 14px;
}
.ai-card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ai-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ai-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 11px;
  color: var(--text-soft);
  background: rgba(255,255,255,0.62);
}
body.dark .ai-chip {
  background: rgba(34,36,31,0.72);
}
.ai-note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}
.ai-output-panel {
  min-height: 168px;
}
.ai-output-panel .comment-body {
  line-height: 1.72;
}
.coverage-grid {
  display: grid;
  gap: 12px;
}
.coverage-list {
  display: grid;
  gap: 10px;
}
.coverage-item {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.72);
  border-radius: var(--radius-md);
  padding: 12px 13px;
}
body.dark .coverage-item {
  background: rgba(33,35,30,0.86);
}
.coverage-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.coverage-copy {
  font-size: 13px;
  line-height: 1.6;
}
.ai-research-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copilot-overlay {
  z-index: 108;
}
.copilot-backdrop {
  z-index: 107;
}
body.tablet-landscape .copilot-overlay,
body.tablet-portrait .copilot-overlay,
body.phone-portrait .copilot-overlay,
body.phone-landscape .copilot-overlay {
  top: var(--sf-topbar-height);
  height: calc(100dvh - var(--sf-topbar-height));
}
body.tablet-landscape .copilot-backdrop,
body.tablet-portrait .copilot-backdrop,
body.phone-portrait .copilot-backdrop,
body.phone-landscape .copilot-backdrop {
  top: var(--sf-topbar-height);
  height: calc(100dvh - var(--sf-topbar-height));
}
body.phone-portrait .copilot-overlay,
body.phone-landscape .copilot-overlay,
body.tablet-portrait .copilot-overlay {
  width: 100vw;
  max-width: 100vw;
}
.copilot-overlay-body {
  padding-top: 14px;
}
.overlay-ai-pane .ai-card-grid {
  grid-template-columns: 1fr;
}
.overlay-ai-pane .ai-output-panel {
  min-height: 0;
}

@media (max-width: 1100px) {
  .ai-card-grid {
    grid-template-columns: 1fr;
  }
}


/* Independent Copilot overlay scrolling + body scroll lock */
.copilot-overlay {
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.copilot-overlay-body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
body.copilot-open,
html.copilot-open {
  overflow: hidden;
}
body.copilot-scroll-lock {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  top: calc(var(--sf-copilot-scroll-y, 0px) * -1);
}


/* Real mobile/iPad Copilot sheet scroll containment fix */
.copilot-overlay {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.copilot-overlay-body {
  min-height: 0;
  max-height: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
html.copilot-open,
body.copilot-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}
body.copilot-scroll-lock {
  position: fixed;
  inset: 0;
  width: 100%;
  top: calc(var(--sf-copilot-scroll-y, 0px) * -1);
}


/* Reach true end of Copilot sheet content on phone/iPad portrait */
.copilot-overlay-body {
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  scroll-padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}
.copilot-overlay-body > :last-child {
  margin-bottom: 0;
}
body.tablet-landscape .copilot-overlay-body,
body.tablet-portrait .copilot-overlay-body,
body.phone-portrait .copilot-overlay-body,
body.phone-landscape .copilot-overlay-body {
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}
