/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  flex-shrink: 0;
  position: relative;
  z-index: 11;
  background: var(--chat-bg);
  transition: background 0.2s;
}

/* Design system page sits flush against its own top nav — drop header bottom padding */
body[data-page-slug="/design-system/ui-kit"] .chat-header {
  padding-bottom: 0;
}

/* Search shortcut — only visible while the design system page is open.
   Selector uses both classes to win against .ui-tooltip-wrap { display: inline-flex }
   declared in chat-responsive.css (same specificity but loaded later).
   Collapse animation mirrors .header-newchat-wrap (width/opacity/margin). */
.ui-tooltip-wrap.header-ds-search-wrap {
  display: none;
  transition:
    width 0.25s ease,
    opacity 0.25s ease,
    margin 0.25s ease;
  width: 34px;
  opacity: 1;
  overflow: hidden;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  body[data-page-slug="/design-system/ui-kit"] .ui-tooltip-wrap.header-ds-search-wrap {
    display: inline-flex;
  }
}
body.ds-search-active .ui-tooltip-wrap.header-ds-search-wrap {
  width: 0;
  opacity: 0;
  margin: 0 !important;
  pointer-events: none;
}
.header-ds-search-btn .icon {
  width: 16px;
  height: 16px;
  background-color: currentColor;
}

/* While the connect pill is morphing/open, drop the header's stacking
   context so the pill (position:fixed, z:201) escapes and renders above
   the backdrop (z:200). The rest of the header content stays underneath
   the blur. */
.chat-header:has(.connect-pinning) {
  z-index: auto;
}

.chat-header-toggle {
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-text-muted);
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.chat-header-toggle:hover {
  background: var(--chat-surface-hover-dark);
  color: var(--chat-text);
  cursor: e-resize;
}

.chat-header-toggle svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.chat-header-label {
  display: none;
}

/* Right-side header actions pill (share + theme) */
/* ── Resume page header actions ── */
.resume-header-actions {
  display: none;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.resume-header-actions.visible { display: flex; }
.resume-header-actions .ui-btn--lg {
  padding: 0.5625rem 1.375rem;
  font-size: 0.9375rem;
}
#resumePrintBtn img { filter: brightness(0) invert(0.45); }
#resumeDownloadBtn img { filter: brightness(0) invert(0.1); }
html[data-theme="light"] #resumePrintBtn img { filter: brightness(0) invert(0.35); }
html[data-theme="light"] #resumeDownloadBtn img { filter: brightness(0) invert(1); }
@media (max-width: 768px) {
  .resume-btn-label { display: none; }
  .resume-header-actions { margin-left: 0; order: 1; }
  .header-right-actions { order: 0; }
  #resumePrintBtn { display: none; }
  #resumeDownloadBtn { padding: 0.5625rem; aspect-ratio: 1; justify-content: center; }
}

.header-right-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: auto;
  background: var(--chat-surface-hover);
  border-radius: var(--radius-full);
  border: var(--border-width-1) solid var(--chat-border);
  padding: 0.2rem;
  width: auto;
  transition:
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.2s,
    top 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="light"] .header-right-actions {
  background: var(--color-white);
  border: var(--border-width-1) solid var(--chat-border);
}

/* While transitioning: pill is fixed-positioned at its captured rect */
.header-right-actions.connect-pinning {
  position: fixed;
  z-index: 215;
}

.header-actions-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-content: flex-end;
  flex-shrink: 0;
}

/* expanded state: pill anchors top-right of viewport (uses .connect-pinning's position:fixed) */
.header-right-actions.connect-open {
  top: 1rem;
  right: 1rem;
  width: 340px;
  border-radius: 24px;
  padding: 0.2rem 0.2rem var(--space-4);
  background: var(--chat-sidebar-bg);
  box-shadow: var(--shadow-lg);
  align-items: stretch;
}

html[data-theme="light"] .header-right-actions.connect-open {
  background: var(--color-white);
}

/* Suppress button tooltips while pill is expanded */
.header-right-actions.connect-open .header-actions-row .ui-tooltip {
  display: none;
}

/* Mobile: pill stays anchored top-right but width fits viewport with equal-ish margins */
@media (max-width: 480px) {
  .header-right-actions.connect-open {
    width: calc(100vw - 2rem);
    max-width: 340px;
  }
}

/* connect body — display:none until JS toggles `.connect-body-visible` after
   the pill finishes morphing open. Removed from layout entirely while the
   pill animates, so no text ever shows during the morph. */
.connect-body {
  display: none;
  width: 100%;
  opacity: 0;
  transform: translateY(-4px);
  padding: var(--space-2) var(--space-4) 0;
  transition:
    opacity 0.28s ease,
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.connect-body.connect-body-visible {
  opacity: 1;
  transform: translateY(0);
}

.connect-body-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--chat-text);
  margin: var(--space-2) 0 var(--space-1);
  line-height: 1.3;
}

.connect-body-subtitle {
  font-size: 0.9375rem;
  color: var(--chat-text-muted);
  margin: 0 0 var(--space-4);
  line-height: 1.5;
}

.connect-body-links {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.connect-body-links .ui-tooltip-wrap {
  flex: 1;
  display: flex;
  overflow: visible;
}

.connect-body-links .ui-tooltip {
  z-index: 220;
}

/* circular icon buttons */
.connect-link {
  flex: 1;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--chat-surface);
  border: var(--border-width-1) solid var(--chat-border);
  text-decoration: none;
  color: var(--chat-link);
  cursor: pointer;
  padding: 0;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}

.connect-link:hover {
  background: var(--chat-surface-hover-dark);
  color: var(--color-white);
}

html[data-theme="light"] .connect-link {
  background: var(--chat-bg);
  color: var(--chat-text-muted);
}

html[data-theme="light"] .connect-link:hover {
  background: var(--chat-surface);
  color: var(--chat-text);
}

/* copy-link button: swap icons on success */
.connect-link .connect-copy-success {
  display: none;
}
.connect-link.copied .connect-copy-default {
  display: none;
}
.connect-link.copied .connect-copy-success {
  display: block;
  color: var(--color-success);
}

/* connect backdrop */
.connect-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 205;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.connect-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.header-share-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-text-muted);
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.header-share-btn:hover {
  background: var(--chat-surface-hover-dark);
  color: var(--chat-text);
}

/* Face icon eye animations */
@keyframes face-blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95%,
  97% {
    transform: scaleY(0.08);
  }
}

@keyframes face-wink-left {
  0%,
  100% {
    transform: scaleY(1);
  }
  30%,
  70% {
    transform: scaleY(0.08);
  }
}

.face-eye {
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform;
}

.face-eyebrow {
  transform-box: fill-box;
  transform-origin: bottom center;
}

@keyframes face-eyebrow-raise {
  0%,
  100% {
    transform: translateY(0);
  }
  30%,
  70% {
    transform: translateY(-0.7px);
  }
}

#headerShareBtn.winking .face-eye--left {
  animation: face-wink-left 0.5s ease-in-out forwards;
}

#headerShareBtn.winking .face-eyebrow {
  animation: face-eyebrow-raise 0.5s ease-in-out forwards;
}

#headerShareBtn.winking .face-eye--right {
  animation: face-roam 9s ease-in-out infinite;
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-text-muted);
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: var(--chat-surface-hover-dark);
  color: var(--chat-text);
}

.theme-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* App panel mode: ensure no page-back row or duplicate action pill leaks.
   Triggered via body class set by openAppPanel, or via the panel's own state. */
body.app-panel-open .chat-page-back,
body:has(.shop-panel--app.open) .chat-page-back {
  display: none !important;
}




