.composer-quick-options {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(100% + 1px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  width: auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.composer-quick-options::-webkit-scrollbar {
  display: none;
}

.composer-quick-options:has(.composer-menu[open]) {
  overflow: visible;
}

.composer-menu {
  --composer-menu-row: 5vh;
  --composer-menu-bg: #202020;
  --composer-menu-border: #454545;
  --composer-menu-muted: #a7a7a7;
  position: relative;
  min-width: 0;
}

.composer-menu,
.composer-active-chip {
  flex: 0 0 auto;
}

.composer-menu > summary {
  list-style: none;
}

.composer-menu > summary::-webkit-details-marker {
  display: none;
}

.composer-menu > summary::marker {
  content: "";
}

.composer-pill {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f1f1f1;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.composer-pill > span {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  white-space: nowrap;
}

.composer-menu > .composer-pill > span,
.composer-active-chip > span {
  border: 1px solid #343841;
  background: #202329;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04);
}

.composer-menu[open] > .composer-pill > span {
  border-color: #596273;
  background: #292d34;
}

.composer-menu-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-check-icon {
  color: #9fb2ff;
}

.composer-menu.full-access .composer-pill > span {
  border-color: #6d4a1f;
  background: #3a2814;
  color: #ffd18a;
}

.composer-active-chip {
  align-items: center;
  min-height: 56px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.composer-active-chip > span {
  gap: 6px;
}

.composer-active-chip .composer-close-icon {
  width: 14px;
  height: 14px;
  margin-left: 2px;
  color: #a7a7a7;
}

.composer-popover,
.composer-tools-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  display: grid;
  padding: 8px;
  border: 1px solid var(--composer-menu-border);
  border-radius: 24px;
  background: var(--composer-menu-bg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .48);
  z-index: 30;
}

.composer-popover {
  left: 0;
  max-height: min(520px, 62dvh);
  overflow: auto;
}

.model-popover.compact-menu,
.permission-popover.compact-menu,
.model-picker-popover.compact-menu {
  width: 20vw;
}

.model-picker-popover {
  left: 0;
  bottom: 0;
  z-index: 40;
}

.permission-popover .menu-option small {
  line-height: 1.4;
  white-space: normal;
}

.permission-popover .menu-option.full-access.selected {
  background: #3a2814;
  color: #ffd18a;
}

.wide-menu { width: min(490px, calc(100vw - 32px)); }

.composer-menu:not([open]) > .composer-popover,
.composer-menu:not([open]) > .composer-tools-panel {
  display: none;
}

.popover-title {
  padding: 6px 8px 4px;
  color: var(--composer-menu-muted);
  font-size: 13px;
  font-weight: 600;
}

.menu-divider {
  height: 1px;
  margin: 6px;
  background: #383838;
}

.menu-option,
.tool-menu-row {
  width: 100%;
  min-height: var(--composer-menu-row);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #f4f4f4;
  font-size: 15px;
  text-align: left;
}

.menu-option:hover,
.tool-menu-row:hover {
  background: #353535;
}

.menu-option.selected {
  background: #303030;
}

.tool-menu-row.selected {
  background: #303030;
}

.menu-option > span:first-child,
.tool-menu-row > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.menu-option small,
.tool-menu-row small {
  display: block;
  overflow: hidden;
  color: var(--composer-menu-muted);
  font-size: 13px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-options {
  display: grid;
  padding-top: 4px;
}

.model-picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 8px;
}

.model-picker-heading .popover-title {
  padding-left: 0;
}

.model-picker-dismiss {
  display: grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--composer-menu-muted);
}

.model-picker-dismiss:hover {
  background: #353535;
  color: #f4f4f4;
}

.composer-tools-panel {
  left: 0;
  right: auto;
  max-height: min(560px, 68dvh);
  overflow: auto;
}

.tool-menu-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  justify-content: initial;
}

.tool-menu-row > span:nth-child(2) {
  justify-self: start;
  width: 100%;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 0;
  background: transparent;
  color: #f2f2f2;
  font-size: 19px;
}

.tool-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-menu-section {
  display: grid;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #383838;
}

.composer-icon-button {
  display: grid;
  place-items: center;
  border: 1px solid #3b3d42;
  border-radius: 50%;
  background: #1b1d22;
}

.composer-popover,
.composer-tools-panel {
  opacity: 1;
  scale: 1;
  transform-origin: left bottom;
  transition: opacity var(--motion-popup) ease, scale var(--motion-popup) var(--motion-ease-out), display var(--motion-popup) allow-discrete;
  transition-behavior: allow-discrete;
}

.model-popover.compact-menu,
.permission-popover.compact-menu,
.model-picker-popover.compact-menu {
  transform-origin: center bottom;
}

.composer-menu:not([open]) > .composer-popover,
.composer-menu:not([open]) > .composer-tools-panel {
  opacity: 0;
  scale: .94;
}

@starting-style {
  .composer-menu[open] > .composer-popover,
  .composer-menu[open] > .composer-tools-panel {
    opacity: 0;
    scale: .94;
  }
}

@media (max-width: 640px) {
  .composer-quick-options {
    padding: 0 2px;
    left: 14px;
    right: 14px;
    height: 48px;
  }

  .composer-pill {
    min-height: 48px;
    padding: 0;
    border: 0;
    font-size: 12px;
  }

  .composer-active-chip {
    min-height: 56px;
    font-size: 12px;
  }

  .composer-popover,
  .composer-tools-panel {
    position: fixed;
  }

  .model-popover.compact-menu,
  .permission-popover.compact-menu,
  .model-picker-popover.compact-menu {
    left: 50%;
    right: auto;
    bottom: calc(124px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: 72vw;
    max-height: 64dvh;
  }

  .composer-popover.compact-menu .menu-option {
    min-height: 6dvh;
    padding: .45dvh 2.2vw;
    border-radius: 2.2dvh;
    font-size: 1.8dvh;
  }

  .model-picker-popover.compact-menu {
    bottom: calc(108px + env(safe-area-inset-bottom));
  }

  .composer-tools-panel.wide-menu {
    left: 16px;
    right: auto;
    bottom: calc(68px + env(safe-area-inset-bottom));
    max-height: 66dvh;
  }

  .menu-option,
  .tool-menu-row {
    min-height: var(--composer-menu-row);
  }

}
