/* Use the site's palette, with an inset frame and glass controls only in web chat. */
#glassChatCommands,
#chatEarth,
#chatEarthSetting {
  display: none;
}

html[data-chat-glass="true"][data-site-view="workspace"] body {
  --chat-glass-line: color-mix(in srgb, var(--work-ink) 22%, var(--work-line));
  --chat-glass-panel: color-mix(in srgb, var(--work-surface) 93%, transparent);
  --chat-glass-control: color-mix(in srgb, var(--chat-entry) 94%, transparent);
}

html[data-chat-glass="true"] #chatEarthSetting {
  display: flex;
}

#chatEarthDescription {
  margin: 0;
}

#chatEarthDescription a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #glassChatCommands {
  display: flex;
  flex: none;
}

#glassChatCommands .glass-command-trigger,
#glassChatCommands .glass-command-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--chat-glass-line);
  border-radius: 999px;
  background: var(--chat-glass-control);
  color: var(--work-ink);
  box-shadow: inset 0 1px 0 #ffffff0b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

#glassChatCommands .glass-command-trigger:hover,
#glassChatCommands .glass-command-close:hover {
  background: var(--work-selected);
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active .app-header {
  background: transparent !important;
  border: 0 !important;
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active .app-header .header-shell {
  width: min(100%, 1260px) !important;
  min-height: 52px;
  height: auto !important;
  padding: 4px 9px !important;
  border: 1px solid var(--work-line) !important;
  border-radius: 17px !important;
  background: var(--chat-glass-panel) !important;
  box-shadow: inset 0 1px 0 #ffffff10, 0 6px 18px #0002;
  backdrop-filter: blur(10px);
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card {
  position: relative;
  isolation: isolate;
  border-color: var(--chat-glass-line) !important;
  border-radius: 22px !important;
  background: var(--work-surface) !important;
  box-shadow: inset 0 1px 0 #ffffff0a, 0 14px 36px #0003;
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card:has(#chatMessages[data-studio-empty="true"]) #chatEarth {
  display: block;
  position: absolute;
  inset: auto 1% -6% auto;
  z-index: -1;
  inline-size: min(58%, 620px);
  aspect-ratio: 1;
  opacity: .37;
  mix-blend-mode: screen;
  pointer-events: none;
  visibility: hidden;
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card:has(#chatMessages[data-studio-empty="true"]) #chatEarth[data-ready="true"] {
  visibility: visible;
}

html[data-chat-glass="true"][data-site-view="workspace"][data-palette="light"] body.tab-chat-active #panel-chat .chat-window-card:has(#chatMessages[data-studio-empty="true"]) #chatEarth[data-ready] {
  mix-blend-mode: multiply;
  opacity: .13;
  clip-path: circle(40%);
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card #chatForm.flux-v0 {
  background: var(--chat-glass-control) !important;
  border-color: var(--chat-glass-line) !important;
  border-radius: 17px !important;
  box-shadow: inset 0 1px 0 #ffffff0d, 0 10px 21px #0003 !important;
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat :has(#chatEarth[data-ready="true"]) #chatForm.flux-v0 {
  backdrop-filter: blur(8px);
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .studio-welcome h1 {
  font-weight: 620 !important;
}

html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card .flux-v0-actions .v0-action {
  border-radius: 12px;
  box-shadow: inset 0 1px 0 #ffffff0b;
  font-size: 12px;
}

#glassChatCommands .glass-command-dialog {
  inline-size: min(460px, calc(100% - 24px));
  margin: min(14vh, 100px) auto auto;
  padding: 0;
  border: 1px solid var(--chat-glass-line);
  border-radius: 19px;
  background: var(--work-surface);
  color: var(--work-ink);
  box-shadow: 0 22px 65px #0006, inset 0 1px 0 #ffffff12;
  max-height: min(66dvh, 520px);
  overflow: auto;
  overscroll-behavior: contain;
  animation: chat-command-in .17s ease-out;
}

#glassChatCommands .glass-command-dialog::backdrop {
  background: #080808b5;
  backdrop-filter: blur(3px);
}

#glassChatCommands .glass-command-sheet {
  padding: 16px;
}

#glassChatCommands .glass-command-heading {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#glassChatCommands .glass-command-heading h2 {
  font-size: 19px;
  margin: 0;
  line-height: 1.3;
}

#glassChatCommands .glass-command-close {
  inline-size: 40px;
  padding: 0;
}

#glassChatCommands .glass-command-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--chat-glass-line);
  border-radius: 10px;
  background: var(--chat-entry);
  padding: 4px 10px;
  color: var(--work-ink);
}

#glassChatCommands .glass-command-search:focus-within {
  border-color: currentColor;
}

#glassChatCommands .glass-command-search input {
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 40px;
  padding: 0;
  border: 0 !important;
  color: var(--work-ink);
  background: transparent !important;
  box-shadow: none !important;
  outline: 0;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
}

#glassChatCommands .glass-command-search input::placeholder {
  color: var(--work-secondary);
}

#glassChatCommands .glass-command-actions {
  list-style: none;
  margin: 9px 0 0;
  padding: 0;
}

#glassChatCommands .glass-command-actions button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  text-align: start;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--work-ink);
  font-size: 14px;
  cursor: pointer;
}

#glassChatCommands .glass-command-actions button:hover,
#glassChatCommands .glass-command-actions button:focus-visible {
  background: var(--work-selected);
}

#glassChatCommands .glass-command-empty {
  color: var(--work-secondary);
  margin: 12px 0 2px;
}

@keyframes chat-command-in {
  from { opacity: .5; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1139px) {
  #glassChatCommands .glass-command-trigger {
    inline-size: 40px;
    padding: 0;
  }

  #glassChatCommands .glass-command-trigger span {
    display: none;
  }
}

@media (max-width: 959px) {
  html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active .app-header .header-shell {
    min-height: 48px;
    gap: 4px !important;
    padding: 3px 4px !important;
    border-radius: 13px !important;
  }

  html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card {
    border-radius: 15px !important;
  }

  html[data-chat-glass="true"][data-site-view="workspace"] body.tab-chat-active #panel-chat .chat-window-card:has(#chatMessages[data-studio-empty="true"]) #chatEarth {
    inline-size: min(95%, 500px);
    inset: auto -15% 1% auto;
    opacity: .25;
  }

  #glassChatCommands .glass-command-trigger {
    inline-size: 36px;
    min-height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #glassChatCommands .glass-command-dialog {
    animation: none;
  }
}
