.atlas-topbar {
  position: relative;
  z-index: 30;
  display: flex;
  width: 100%;
  height: 76px;
  min-height: 76px;
  flex: 0 0 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(24px, 4vw, 54px);
  background: color-mix(in srgb, var(--surface-page, #fffefa) 94%, transparent);
}

/* Settings content has its own 36px top rhythm; keep the global bar on the Atlas baseline. */
.atlas-topbar.atlas-topbar--settings {
  top: -36px;
}

/* Character sheets and forms use the same compact top rhythm as settings. */
.atlas-topbar.atlas-topbar--character-detail {
  top: -36px;
}

.atlas-search-panel {
  position: absolute;
  top: calc(50% + 26px);
  left: clamp(24px, 4vw, 54px);
  width: min(720px, calc(100vw - 48px));
  max-height: min(650px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid var(--line-main, #ded7c8);
  border-radius: 14px;
  color: var(--text-main, #102a50);
  background: var(--surface-page, #fffefa);
  box-shadow: 0 18px 52px rgb(31 39 52 / 20%);
}

.atlas-search-panel[hidden] { display: none; }

.atlas-search-panel__results {
  max-height: min(560px, calc(100vh - 180px));
  overflow-y: auto;
  padding: 8px;
}

.atlas-search-panel__status {
  padding: 28px 24px;
  color: var(--text-muted, #687184);
  text-align: center;
  font: 14px/1.5 system-ui;
}

.atlas-search-group + .atlas-search-group { margin-top: 6px; }

.atlas-search-group__heading {
  margin: 0;
  padding: 8px 10px 5px;
  color: var(--text-muted, #687184);
  font: 700 11px/1.2 system-ui;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.atlas-search-result {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: 9px;
  color: inherit;
  text-decoration: none;
}

.atlas-search-result:hover,
.atlas-search-result.is-selected {
  background: color-mix(in srgb, var(--accent-soft, #e8edf4) 78%, transparent);
}

.atlas-search-result__icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line-main, #ded7c8) 80%, transparent);
  border-radius: 8px;
  background: var(--surface-card, #fff);
  font-size: 21px;
}

.atlas-search-result__copy,
.atlas-search-result__title-line {
  display: block;
  min-width: 0;
}

.atlas-search-result__title-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 14px/1.4 system-ui;
}

.atlas-search-result__title-line strong { font-weight: 650; }
.atlas-search-result__location { margin-left: 6px; color: var(--text-muted, #687184); }

.atlas-search-result__description {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--text-muted, #687184);
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 12px/1.35 system-ui;
}

.atlas-search-result__kind {
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--text-muted, #687184);
  background: color-mix(in srgb, var(--surface-muted, #f4f0e8) 80%, transparent);
  font: 600 10px/1.2 system-ui;
  text-transform: capitalize;
}

.atlas-search-panel__footer {
  display: flex;
  gap: 18px;
  padding: 9px 16px;
  border-top: 1px solid var(--line-main, #ded7c8);
  color: var(--text-muted, #687184);
  background: color-mix(in srgb, var(--surface-muted, #f4f0e8) 55%, transparent);
  font: 11px/1.4 system-ui;
}

.atlas-search-panel__footer kbd {
  margin-right: 3px;
  padding: 1px 4px;
  border: 1px solid var(--line-main, #ded7c8);
  border-radius: 4px;
  background: var(--surface-card, #fff);
  font: inherit;
}

.atlas-topbar__form {
  display: flex;
  width: min(470px, 50vw);
  height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line-main, #ded7c8);
  border-radius: 10px;
  color: var(--text-muted, #687184);
  background: var(--surface-input, #fff);
}

.atlas-topbar__form input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text-main, #102a50);
  background: transparent;
  font: 13px system-ui;
}

.atlas-topbar__submit {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.atlas-topbar__profile {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted, #687184);
  font-size: 12px;
}

.atlas-topbar__profile strong {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #31547f;
  font-size: 11px;
}

/* Keep the persistent top bar outside the legacy Rule-screen content inset. */
.glossary-main:not(.has-collection-layout) > .atlas-topbar {
  width: calc(100% + 2 * clamp(28px, 5vw, 76px));
  margin-top: -46px;
  margin-right: calc(-1 * clamp(28px, 5vw, 76px));
  margin-left: calc(-1 * clamp(28px, 5vw, 76px));
}

@media (max-width: 760px) {
  .atlas-topbar { height: 64px; min-height: 64px; flex-basis: 64px; padding: 0 18px; }
  .atlas-topbar.atlas-topbar--settings { top: -24px; }
  .atlas-topbar.atlas-topbar--character-detail { top: -24px; }
  .atlas-topbar__form { width: 100%; }
  .atlas-topbar__profile span { display: none; }
  .atlas-search-panel { top: 58px; left: 12px; width: calc(100vw - 24px); }
  .atlas-search-result__kind { display: none; }
  .atlas-search-panel__footer { display: none; }
}
