.atlas-topbar-code span {
  color: #d2a9f2;
  font: 700 .78rem ui-monospace, monospace;
}

.atlas-code-library-dialog {
  position: fixed;
  inset: 0;
  width: min(860px, calc(100% - 32px));
  height: min(740px, calc(var(--atlas-viewport-height, 100dvh) - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  color: var(--text);
  background: #0e0b13;
}

.atlas-code-library-dialog:not([open]) {
  display: none;
}

.atlas-code-library-dialog[open] {
  display: flex;
  flex-direction: column;
}

.atlas-code-library-dialog::backdrop {
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(8px);
}

.atlas-code-library-dialog .modal-head {
  flex: 0 0 auto;
  align-items: center;
}

.code-library-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: 9px;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
}

.code-library-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code-library-controls input {
  flex: 1 1 230px;
  min-width: 0;
  width: auto;
}

.code-library-controls select {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  min-height: 40px;
}

.code-library-controls [hidden],
.code-library-pagination[hidden] {
  display: none;
}

.code-library-results {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  min-height: 0;
  gap: 7px;
  padding: 3px 4px 3px 3px;
  overflow: auto;
  overscroll-behavior: contain;
}

.code-library-results > button {
  justify-self: start;
}

.code-library-example {
  min-width: 0;
  border: 1px solid rgba(177, 76, 255, .14);
  border-radius: 10px;
  background: #14101a;
}

.code-library-example > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 9px 10px;
  border-radius: inherit;
  cursor: pointer;
  list-style: none;
}

.code-library-example > summary::-webkit-details-marker {
  display: none;
}

.code-library-example > summary::after {
  content: '';
  width: 6px;
  height: 6px;
  margin-right: 2px;
  border-right: 2px solid #c9a5e2;
  border-bottom: 2px solid #c9a5e2;
  transform: rotate(-45deg);
}

.code-library-example[open] > summary::after {
  transform: rotate(45deg) translateY(-2px);
}

.code-library-example > summary:hover,
.code-library-example[open] > summary {
  background: rgba(177, 76, 255, .08);
}

.code-library-result-title {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.code-library-result-title strong {
  color: #f3eef8;
  font-size: .9rem;
}

.code-library-result-title > span,
.code-library-action-status {
  color: #b8a9c2;
  font-size: .78rem;
}

.code-library-preview {
  min-width: 0;
  padding: 10px;
  border-top: 1px solid rgba(177, 76, 255, .14);
}

.code-library-preview .code-block-shell pre {
  max-height: min(45vh, 360px);
  overflow: auto;
}

.code-library-preview-actions,
.code-library-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.code-library-preview-actions {
  margin-top: 10px;
}

.code-library-pagination {
  justify-content: flex-end;
}

.atlas-code-library-dialog :is(summary, button, select, pre):focus-visible {
  outline: 2px solid #d49aff;
  outline-offset: 1px;
}

@media (max-width: 600px) {
  .topbar #topbarCodeLibraryBtn {
    display: none;
  }

  .atlas-code-library-dialog {
    width: 100%;
    height: var(--atlas-viewport-height, 100dvh);
    border: 0;
    border-radius: 0;
  }

  .code-library-body {
    padding-inline: 9px;
  }

  .code-library-controls input {
    flex-basis: 100%;
    font-size: 16px;
  }

  .code-library-controls select {
    flex: 1 1 100px;
  }
}
