/*
 * Learny ports of components from ui-lab (https://lab.xevrion.dev),
 * MIT License, Copyright (c) 2026 Yash Bavadiya. See lab-ui.js.
 *
 * The lab's dark theme tokens, then one block per component. Shared by
 * Learny AI and Learny Code; selectors that don't exist in an app are inert.
 */
:root {
  --lab-background: #0a0a0a;
  --lab-foreground: #ededed;
  --lab-surface: #161616;
  --lab-border: #262626;
  --lab-muted: #8f8f8f;
  --lab-danger: #e5484d;
  --lab-focus: oklch(0.95 0 0 / 0.45);
  --lab-shadow-raised:
    0 0 0 1px oklch(1 0 0 / 0.08),
    0 1px 2px oklch(0 0 0 / 0.4),
    0 6px 16px -6px oklch(0 0 0 / 0.6);
  --lab-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --lab-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

.lab-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.lab-grid {
  display: grid;
}

.lab-grid > * {
  grid-column: 1;
  grid-row: 1;
}

/* ------------------------------------------------------------------ Send button */
html body .send-button.lab-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: var(--lab-surface);
  color: var(--lab-foreground);
  box-shadow: var(--lab-shadow-raised);
  outline: none;
  touch-action: manipulation;
  user-select: none;
  transition: scale 150ms ease-out, background-color 150ms ease-out, opacity 150ms ease-out, color 150ms ease-out;
  transform: none;
}

html body .send-button.lab-send:hover {
  background: var(--lab-background);
}

html body .send-button.lab-send.has-message:not(.pause-mode) {
  background: var(--lab-foreground);
  color: var(--lab-background);
  box-shadow: none;
}

html body .send-button.lab-send.has-message:not(.pause-mode):hover {
  background: color-mix(in oklab, var(--lab-foreground) 90%, transparent);
}

html body .send-button.lab-send:active {
  scale: 0.96;
  transform: none;
}

html body .send-button.lab-send[data-lab-status]:not([data-lab-status="idle"]) {
  cursor: default;
}

html body .send-button.lab-send:disabled {
  opacity: 0.55;
}

html body .send-button.lab-send:focus-visible {
  outline: 2px solid var(--lab-foreground);
  outline-offset: 2px;
}

.send-button.lab-send > img {
  display: none;
}

.lab-send-icons {
  display: grid;
  translate: 1px 0;
}

.lab-send-icons > * {
  grid-column: 1;
  grid-row: 1;
  width: 20px;
  height: 20px;
}

.lab-send-plane-slot {
  display: flex;
}

.lab-send-plane {
  overflow: visible;
  transform-box: fill-box;
  transform-origin: center;
}

@media (prefers-reduced-motion: reduce) {
  html body .send-button.lab-send {
    transition: background-color 150ms ease-out, opacity 150ms ease-out;
  }
}

/* ------------------------------------------------------------------ Copy button */
.lab-copy {
  position: relative;
}

.lab-copy > img.message-copy-icon,
.lab-copy > img.message-action-icon {
  display: none;
}

.lab-copy-glyphs {
  display: grid;
}

.lab-copy-glyphs > svg {
  grid-column: 1;
  grid-row: 1;
  width: 16px;
  height: 16px;
  overflow: visible;
}

.lab-copy-tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  z-index: 5;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 9999px;
  background: var(--lab-foreground);
  color: var(--lab-background);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: bottom;
  translate: -50% 4px;
  scale: 0.97;
  opacity: 0;
  transition: opacity 100ms var(--lab-ease-out), translate 100ms var(--lab-ease-out), scale 100ms var(--lab-ease-out);
}

.lab-copy[data-lab-copy-tip="true"] .lab-copy-tip {
  translate: -50% 0;
  scale: 1;
  opacity: 1;
  transition-duration: 150ms;
}

@media (prefers-reduced-motion: reduce) {
  .lab-copy-tip {
    translate: -50% 0;
    scale: 1;
    transition-property: opacity;
  }
}

/* ------------------------------------------------------------------ Eye toggle */
html body .lab-eye {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--lab-muted);
  outline: none;
  touch-action: manipulation;
  transition: scale 150ms ease-out, color 150ms ease-out, background-color 150ms ease-out;
}

html body .lab-eye:hover {
  background: var(--lab-surface);
  color: var(--lab-foreground);
}

html body .lab-eye[aria-pressed="true"] {
  color: var(--lab-foreground);
}

html body .lab-eye:active {
  scale: 0.96;
}

html body .lab-eye:focus-visible {
  outline: 2px solid var(--lab-foreground);
}

.lab-eye > :not(.lab-eye-svg):not(.sr-only) {
  display: none !important;
}

.lab-eye-svg {
  width: 20px;
  height: 20px;
  overflow: visible;
}

/* ------------------------------------------------------------------ Toggle switch */
.lab-switch-host > input[type="checkbox"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.lab-switch-host > .lab-switch-legacy {
  display: none !important;
}

.lab-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  border-radius: 9999px;
  background: color-mix(in oklab, var(--lab-foreground) 25%, transparent);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

/* Grows the hit area to 56x44 without growing the track. */
.lab-switch::after {
  content: "";
  position: absolute;
  inset: -8px -4px;
}

.lab-switch-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lab-foreground);
  opacity: 0;
}

.lab-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: var(--lab-background);
  box-shadow: var(--lab-shadow-raised);
}

.lab-switch-host:has(> input:focus-visible) .lab-switch {
  outline: 2px solid var(--lab-foreground);
  outline-offset: 2px;
}

.lab-switch-host:has(> input:disabled) .lab-switch {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ------------------------------------------------------------------ Segmented control */
html body .lab-segmented {
  position: relative;
  display: inline-flex;
  width: auto;
  height: auto;
  padding: 4px;
  gap: 0;
  border: 0;
  border-radius: 9999px;
  background: var(--lab-surface);
  box-shadow: var(--lab-shadow-raised);
  overflow: visible;
}

html body .lab-segmented:has(:focus-visible) {
  outline: 2px solid var(--lab-foreground);
  outline-offset: 2px;
}

.lab-segmented > [class$="-slider-fill"] {
  display: none !important;
}

html body .lab-segmented > [role="radio"] {
  position: static;
  z-index: auto;
  display: flex;
  align-items: center;
  flex: none;
  width: auto;
  min-width: 0;
  height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: var(--lab-muted);
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
  outline: none;
  transition: color 150ms ease-out;
}

html body .lab-segmented > [role="radio"]:hover {
  color: var(--lab-foreground);
  background: transparent;
}

.lab-segmented-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 4px;
  border-radius: 9999px;
  background: var(--lab-foreground);
  color: var(--lab-background);
  pointer-events: none;
  visibility: hidden;
}

.lab-segmented-overlay > span {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ Dropdown menu */
html body .lab-menu {
  border: 0;
  border-radius: 12px;
  background: var(--lab-surface);
  box-shadow: var(--lab-shadow-raised);
  padding: 4px;
  outline: none;
}

html body .lab-menu :is([role="menuitem"], [role="menuitemradio"], .model-option, .permission-option, .desktop-menu-item) {
  border: 0;
  border-radius: 8px;
  background: transparent;
  transition: none;
}

html body .lab-menu :is([role="menuitem"], [role="menuitemradio"], .model-option, .permission-option, .desktop-menu-item):is(:hover, :focus-visible) {
  background: color-mix(in oklab, var(--lab-foreground) 6%, transparent);
  outline: none;
}

/* Class-driven menus (the Code permission menus) open and close in CSS. */
html body .permissions-menu.lab-menu {
  opacity: 0;
  scale: 0.95;
  transition: opacity 100ms var(--lab-ease-out), scale 100ms var(--lab-ease-out);
}

html body .permissions-menu.lab-menu.is-open {
  opacity: 1;
  scale: 1;
  transition-duration: 180ms;
}

html body .permissions-menu.lab-menu:not(.is-open) {
  scale: 0.97;
  pointer-events: none;
}

/* ------------------------------------------------------------------ Select menu */
html body .settings-select.lab-select {
  position: relative;
}

html body .settings-select.lab-select .settings-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--lab-surface);
  color: var(--lab-foreground);
  font-size: 14px;
  text-align: left;
  box-shadow: var(--lab-shadow-raised);
  outline: none;
  transition: scale 150ms ease-out;
}

html body .settings-select.lab-select .settings-select-trigger:active {
  scale: 0.96;
}

html body .settings-select.lab-select .settings-select-trigger:focus-visible {
  outline: 2px solid var(--lab-foreground);
  outline-offset: 2px;
}

html body .settings-select.lab-select .settings-select-trigger > svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--lab-muted);
}

html body .settings-select.lab-select .settings-select-menu {
  position: absolute;
  right: auto;
  bottom: auto;
  z-index: 50;
  max-height: none;
  margin: 0;
  padding: 4px;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: var(--lab-surface);
  box-shadow: var(--lab-shadow-raised);
}

html body .settings-select.lab-select .settings-select-menu [role="option"] {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--lab-foreground);
  font-size: 14px;
  cursor: default;
  transition: none;
}

html body .settings-select.lab-select .settings-select-menu [role="option"][data-lab-active] {
  background: color-mix(in oklab, var(--lab-foreground) 6%, transparent);
}

html body .settings-select.lab-select .settings-select-menu [role="option"] > span:not(.settings-option-check) {
  flex: 1;
  order: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .settings-select.lab-select .settings-option-check {
  order: 1;
  display: grid;
  width: 16px;
  height: 16px;
  font-size: 0;
  opacity: 1;
  visibility: visible;
}

.lab-check-svg {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------------ Dialog */
.lab-dialog-backdrop {
  background: color-mix(in oklab, var(--lab-background) 70%, transparent) !important;
  backdrop-filter: none !important;
}

html body .lab-dialog-panel {
  border: 0;
  border-radius: 16px;
  background: var(--lab-background);
  box-shadow: var(--lab-shadow-raised);
  outline: none;
}

/* Motion drives the hidden-toggled dialogs, so their own keyframes step aside. */
html body .lab-dialog-backdrop,
html body .lab-dialog-panel {
  animation: none !important;
}

/* Dialogs toggled with is-open: the same motion, as transitions. Opens over
   200ms from 96%, closes over 150ms to 98%. */
html body .lab-dialog-io .lab-dialog-panel,
html body .lab-dialog-io.lab-dialog-panel {
  filter: none !important;
}

html body .lab-dialog-io > .lab-dialog-backdrop,
html body .lab-dialog-io.lab-dialog-backdrop {
  transition: opacity 150ms cubic-bezier(0.23, 1, 0.32, 1) !important;
}

html body .lab-dialog-io .lab-dialog-panel {
  transform: scale(0.96) !important;
  transition:
    opacity 150ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 150ms cubic-bezier(0.23, 1, 0.32, 1) !important;
}

html body .lab-dialog-io.lab-closing .lab-dialog-panel {
  transform: scale(0.98) !important;
}

html body .lab-dialog-io.is-open > .lab-dialog-backdrop,
html body .lab-dialog-io.is-open.lab-dialog-backdrop,
html body .lab-dialog-io.is-open .lab-dialog-panel {
  transition-duration: 200ms !important;
}

html body .lab-dialog-io.is-open .lab-dialog-panel {
  transform: scale(1) !important;
}

@media (prefers-reduced-motion: reduce) {
  html body .lab-dialog-io .lab-dialog-panel,
  html body .lab-dialog-io.lab-closing .lab-dialog-panel {
    transform: none !important;
  }
}

/* The small single-purpose dialogs take the lab's full shape. */
html body .lab-dialog-panel.lab-dialog-simple {
  width: 440px;
  max-width: calc(100vw - 32px);
  padding: 24px;
  color: var(--lab-foreground);
}

html body .lab-dialog-panel.lab-dialog-simple :is(h2, h3) {
  margin: 0;
  color: var(--lab-foreground);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

html body .lab-dialog-panel.lab-dialog-simple p {
  color: var(--lab-muted);
  font-size: 14px;
}

html body .lab-dialog-panel.lab-dialog-simple button:not([class*="close"]):not([class*="toggle"]):not(.lab-eye) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 9999px;
  background: var(--lab-surface);
  color: var(--lab-foreground);
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
  touch-action: manipulation;
  transition: scale 150ms ease-out, background-color 150ms ease-out;
}

html body .lab-dialog-panel.lab-dialog-simple button:not([class*="close"]):not([class*="toggle"]):not(.lab-eye):hover {
  background: var(--lab-border);
}

html body .lab-dialog-panel.lab-dialog-simple button:is([class$="-ok"], [class$="-settings"], [class*="primary"], [type="submit"]) {
  background: var(--lab-foreground);
  color: var(--lab-background);
}

html body .lab-dialog-panel.lab-dialog-simple button:is([class$="-ok"], [class$="-settings"], [class*="primary"], [type="submit"]):hover {
  background: color-mix(in oklab, var(--lab-foreground) 85%, transparent);
}

html body .lab-dialog-panel.lab-dialog-simple button:not([class*="close"]):active {
  scale: 0.96;
}

html body .lab-dialog-panel.lab-dialog-simple button:focus-visible {
  outline: 2px solid var(--lab-foreground);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ Confirm popover */
.lab-confirm-anchor {
  position: relative;
}

html body .lab-confirm {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  display: block;
  width: min(272px, calc(100vw - 32px));
  margin-top: 12px;
  padding: 12px;
  border: 0;
  border-radius: 22px;
  background: var(--lab-background);
  color: var(--lab-foreground);
  box-shadow: var(--lab-shadow-raised);
  text-align: left;
  transform-origin: calc(100% - var(--lab-anchor, 50%)) -6px;
  animation: lab-pop-in 200ms var(--lab-ease-out) both;
}

.lab-confirm::before {
  content: "";
  position: absolute;
  top: -5px;
  right: calc(var(--lab-anchor, 50%) - 5px);
  width: 10px;
  height: 10px;
  border-radius: 2px 0 0 0;
  background: var(--lab-background);
  box-shadow: -1px -1px 0 0 color-mix(in oklab, var(--lab-foreground) 8%, transparent);
  rotate: 45deg;
}

html body .lab-confirm > div:first-child,
html body .lab-confirm .lab-confirm-copy {
  display: block;
  padding: 6px 6px 12px;
}

html body .lab-confirm strong,
html body .lab-confirm .lab-confirm-title {
  display: block;
  margin: 0;
  color: var(--lab-foreground);
  font-size: 15px;
  font-weight: 500;
}

html body .lab-confirm span,
html body .lab-confirm .lab-confirm-description {
  display: block;
  margin: 4px 0 0;
  color: var(--lab-muted);
  font-size: 14px;
  font-weight: 400;
}

html body .lab-confirm > div:last-child,
html body .lab-confirm .lab-confirm-actions {
  display: flex;
  gap: 8px;
  padding: 0;
}

html body .lab-confirm button {
  flex: 1;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: var(--lab-surface);
  color: var(--lab-foreground);
  font-size: 14px;
  font-weight: 500;
  touch-action: manipulation;
  transition: scale 150ms ease-out, background-color 150ms ease-out, opacity 150ms ease-out;
}

html body .lab-confirm button:hover {
  background: var(--lab-border);
}

html body .lab-confirm button.is-danger,
html body .lab-confirm button[data-lab-confirm] {
  background: var(--lab-danger);
  color: #fff;
}

html body .lab-confirm button.is-danger:hover,
html body .lab-confirm button[data-lab-confirm]:hover {
  background: var(--lab-danger);
  opacity: 0.9;
}

html body .lab-confirm button:active {
  scale: 0.96;
}

/* Floats over the page (the sidebar list clips its children), placed from
   JS under the button that asked; flips above it near the bottom edge. */
html body .lab-confirm.is-floating {
  position: fixed;
  right: auto;
  z-index: 10050;
  margin-top: 0;
}

html body .lab-confirm.is-floating.is-above {
  transform-origin: calc(100% - var(--lab-anchor, 50%)) calc(100% + 6px);
}

.lab-confirm.is-floating.is-above::before {
  top: auto;
  bottom: -5px;
  rotate: 225deg;
}

@keyframes lab-pop-in {
  from {
    opacity: 0;
    scale: 0.96;
  }
}

@keyframes lab-pop-out {
  to {
    opacity: 0;
    scale: 0.96;
  }
}

.lab-confirm.is-closing {
  animation: lab-pop-out 150ms var(--lab-ease-out) both;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .lab-confirm,
  .lab-confirm.is-closing {
    animation-name: lab-fade;
  }
}

@keyframes lab-fade {
  from {
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ Inline edit */
html body .chat-rename-input.lab-inline-input {
  width: 100%;
  min-width: 0;
  height: auto;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: var(--lab-background);
  color: var(--lab-foreground);
  font: inherit;
  box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--lab-foreground) 25%, transparent);
  outline: none;
}

html body .chat-rename-input.lab-inline-input::placeholder {
  color: var(--lab-muted);
}

html body .lab-inline-form :is(.rename-chat-save-button, .rename-chat-cancel-button) {
  display: none !important;
}

.lab-inline-saved {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--lab-foreground);
  pointer-events: none;
}

/* ------------------------------------------------------------------ Skeleton loader */
html body .settings-deleted-skeleton :is(i, span) {
  position: relative;
  overflow: hidden;
  background: color-mix(in oklab, var(--lab-foreground) 7%, transparent);
  animation: none;
}

html body .settings-deleted-skeleton :is(i, span)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--lab-foreground) 6%, transparent), transparent);
  translate: -100% 0;
  animation: lab-shimmer 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes lab-shimmer {
  70%,
  100% {
    translate: 100% 0;
  }
}

/* Loaded rows arrive on the skeleton's stagger: 40ms apart. */
.settings-deleted-chat-card,
.settings-deleted-toolbar {
  transition: opacity 250ms var(--lab-ease-out), filter 250ms var(--lab-ease-out), translate 250ms var(--lab-ease-out);
}

@starting-style {
  .settings-deleted-chat-card,
  .settings-deleted-toolbar {
    opacity: 0;
    filter: blur(4px);
    translate: 0 2px;
  }
}

.settings-deleted-chat-card:nth-of-type(2) { transition-delay: 40ms; }
.settings-deleted-chat-card:nth-of-type(3) { transition-delay: 80ms; }
.settings-deleted-chat-card:nth-of-type(n + 4) { transition-delay: 120ms; }

@media (prefers-reduced-motion: reduce) {
  html body .settings-deleted-skeleton :is(i, span)::after {
    display: none;
  }
}

/* ------------------------------------------------------------------ Accordion */
.lab-accordion-chevron {
  transition: rotate 250ms var(--lab-ease-out), color 250ms var(--lab-ease-out);
}

[aria-expanded="true"] > .lab-accordion-chevron,
[aria-expanded="true"] .lab-accordion-chevron {
  rotate: 180deg;
}

.lab-accordion-panel {
  transform-origin: top;
}

@media (prefers-reduced-motion: reduce) {
  .lab-accordion-chevron {
    transition: color 250ms var(--lab-ease-out);
  }
}

/* ------------------------------------------------------------------ Pulse dots */
html body .message.typing .bubble:has(> .typing-dot) {
  position: relative;
  display: block;
  width: 38px;
  min-width: 38px;
  height: 10px;
  min-height: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

html body .message.typing .typing-dot {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 10px;
  height: 10px;
  margin: 0;
  background: none;
  opacity: 1;
  animation: lab-hop-x 1.5s infinite;
}

html body .message.typing .typing-dot::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: var(--lab-foreground);
  animation: lab-hop-y 1.5s infinite;
  animation-delay: inherit;
}

html body .message.typing .typing-dot:nth-child(2) {
  translate: 14px 0;
  animation-delay: -0.5s;
}

html body .message.typing .typing-dot:nth-child(3) {
  translate: 28px 0;
  animation-delay: -1s;
}

@keyframes lab-hop-x {
  0% { translate: 0 0; animation-timing-function: cubic-bezier(0.77, 0, 0.175, 1); }
  20%, 33.3% { translate: 14px 0; animation-timing-function: cubic-bezier(0.77, 0, 0.175, 1); }
  53.3%, 66.7% { translate: 28px 0; animation-timing-function: cubic-bezier(0.77, 0, 0.175, 1); }
  86.7%, 100% { translate: 0 0; }
}

@keyframes lab-hop-y {
  0%, 66.7% { translate: 0 0; animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1); }
  76.7% { translate: 0 -9px; animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  86.7%, 100% { translate: 0 0; }
}

@keyframes lab-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  html body .message.typing .typing-dot {
    animation: lab-pulse 1.6s ease-in-out infinite;
  }
  html body .message.typing .typing-dot::before {
    animation: none;
  }
}

/* ------------------------------------------------------------------ Announcement banner */
html body .site-update-banner.lab-banner {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  width: auto;
  max-width: none;
  height: 44px;
  margin: 0;
  padding: 0 6px 0 16px;
  border: 0;
  border-radius: 0;
  background: var(--lab-foreground);
  color: var(--lab-background);
  font-size: 14px;
  box-shadow: none;
  transform: none;
  animation: lab-banner-in 280ms var(--lab-drawer) both;
}

html body .site-update-banner.lab-banner[hidden] {
  display: none;
}

html body .site-update-banner.lab-banner .site-update-copy {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}

html body .site-update-banner.lab-banner .site-update-copy :is(strong, span) {
  overflow: hidden;
  color: inherit;
  font-size: 14px;
  text-overflow: ellipsis;
}

html body .site-update-banner.lab-banner .site-update-copy strong {
  font-weight: 500;
}

html body .site-update-banner.lab-banner button {
  flex-shrink: 0;
  height: auto;
  margin-left: auto;
  margin-right: 10px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: none;
  color: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--lab-background) 40%, transparent);
  text-underline-offset: 3px;
  box-shadow: none;
  transition: text-decoration-color 150ms ease-out;
}

html body .site-update-banner.lab-banner button:hover {
  text-decoration-color: var(--lab-background);
}

@keyframes lab-banner-in {
  from {
    opacity: 0;
    filter: blur(2px);
    translate: 0 -100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .site-update-banner.lab-banner {
    animation-name: lab-fade;
  }
}

/* ------------------------------------------------------------------ Sliding tabs (vertical) */
html body .settings-nav.lab-tabs {
  position: relative;
}

html body .settings-nav.lab-tabs .settings-nav-button {
  position: relative;
  z-index: 1;
  background: transparent;
  color: var(--lab-muted);
  box-shadow: none;
  transition: color 150ms ease-out;
}

html body .settings-nav.lab-tabs .settings-nav-button:hover,
html body .settings-nav.lab-tabs .settings-nav-button.is-active,
html body .settings-nav.lab-tabs .settings-nav-button[aria-selected="true"] {
  background: transparent;
  color: var(--lab-foreground);
}

html body .settings-nav.lab-tabs .settings-nav-button > span:last-child {
  transition: scale 150ms ease-out;
}

html body .settings-nav.lab-tabs .settings-nav-button:active > span:last-child {
  scale: 0.96;
}

.lab-tabs-hover {
  position: absolute;
  right: 0;
  left: 0;
  z-index: 0;
  border-radius: 6px;
  background: var(--lab-surface);
  pointer-events: none;
  opacity: 0;
}

.lab-tabs-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 2px;
  border-radius: 1px;
  background: var(--lab-foreground);
  pointer-events: none;
}

/* ------------------------------------------------------------------ Upload button */
html body .settings-upload-button.lab-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 9999px;
  background: var(--lab-surface);
  color: var(--lab-foreground);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--lab-shadow-raised);
  transition: background-color 200ms ease-out, color 200ms ease-out, scale 150ms ease-out;
}

html body .settings-upload-button.lab-upload:active {
  scale: 0.96;
}

html body .settings-upload-button.lab-upload[data-lab-upload="checked"] {
  background: var(--lab-foreground);
  color: var(--lab-background);
}

html body .settings-upload-button.lab-upload:disabled {
  opacity: 1;
  cursor: default;
}

.settings-upload-button.lab-upload > :not(.lab-upload-layers):not(.lab-upload-ring) {
  display: none !important;
}

.lab-upload-layers {
  display: grid;
}

.lab-upload-layer {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  filter: blur(4px);
  translate: 0 2px;
  transition: opacity 100ms var(--lab-ease-out), filter 100ms var(--lab-ease-out), translate 100ms var(--lab-ease-out);
}

.lab-upload-layer.is-visible {
  opacity: 1;
  filter: blur(0);
  translate: 0 0;
  transition-duration: 200ms;
}

.lab-upload-layer.is-label {
  gap: 8px;
  padding: 0 16px 0 14px;
  white-space: nowrap;
}

.lab-upload-layer.is-label.is-visible {
  transition-delay: 100ms;
}

.lab-upload-layer.is-percent {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.lab-upload-ring {
  position: absolute;
  top: 0;
  left: 50%;
  width: 40px;
  height: 40px;
  translate: -50% 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.lab-upload-ring.is-visible {
  opacity: 1;
  transition-duration: 150ms;
}

/* ------------------------------------------------------------------ File dropzone */
html body .page-drop-overlay.lab-dropzone {
  background: color-mix(in oklab, var(--lab-background) 70%, transparent);
  backdrop-filter: none;
}

html body .page-drop-overlay.lab-dropzone .page-drop-overlay-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: min(440px, calc(100vw - 32px));
  height: 300px;
  padding: 0 24px;
  border: 0;
  border-radius: 24px;
  background: color-mix(in oklab, var(--lab-foreground) 2%, var(--lab-background));
  box-shadow: none;
  text-align: center;
  transition: background-color 150ms ease-out;
}

html body .page-drop-overlay.lab-dropzone .page-drop-overlay-card[data-lab-over] {
  background: color-mix(in oklab, var(--lab-foreground) 5%, var(--lab-background));
}

.lab-dz-edge-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: color-mix(in oklab, var(--lab-foreground) 45%, transparent);
  pointer-events: none;
}

[data-lab-over] > .lab-dz-edge-svg {
  color: var(--lab-foreground);
}

.lab-dz-edge {
  stroke-dasharray: 0.5 0.5;
  animation: lab-dz-march 0.6s linear infinite;
  transition: stroke-dasharray 240ms var(--lab-ease-out), color 150ms ease-out;
}

[data-lab-over] .lab-dz-edge {
  stroke-dasharray: 1 0;
}

@keyframes lab-dz-march {
  to {
    stroke-dashoffset: -1;
  }
}

.lab-dz-icon {
  width: 32px;
  height: 32px;
  color: var(--lab-foreground);
  transition: translate 200ms var(--lab-ease-out);
}

[data-lab-over] > .lab-dz-icon {
  translate: 0 -6px;
}

html body .page-drop-overlay.lab-dropzone .page-drop-overlay-card strong {
  color: var(--lab-foreground);
  font-size: 16px;
  font-weight: 500;
}

html body .page-drop-overlay.lab-dropzone .page-drop-overlay-card .lab-dz-labels > * {
  transition: opacity 150ms ease-out, filter 150ms ease-out;
}

[data-lab-over] .lab-dz-labels > :first-child,
.page-drop-overlay-card:not([data-lab-over]) .lab-dz-labels > :last-child {
  opacity: 0;
  filter: blur(4px);
}

html body .page-drop-overlay.lab-dropzone .page-drop-overlay-card > span {
  color: var(--lab-muted);
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .lab-dz-edge {
    animation: none !important;
  }
  [data-lab-over] > .lab-dz-icon {
    translate: none;
  }
}
