.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 color-mix(in srgb, var(--accent-gold, #a47a2b) 52%, var(--line-main, #ded7c8));
  border-radius: 14px;
  color: var(--text-main, #102a50);
  background: linear-gradient(145deg, var(--surface-page, #fffefa), color-mix(in srgb, var(--surface-muted, #f4f0e8) 44%, #fffefa));
  box-shadow: 0 16px 40px rgb(31 39 52 / 16%);
}

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

.atlas-search-panel__results {
  max-height: min(560px, calc(100vh - 180px));
  overflow-y: auto;
  padding: 8px;
  scrollbar-color: color-mix(in srgb, var(--accent-gold, #a47a2b) 58%, #8b8b86) transparent;
  scrollbar-width: thin;
}

.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(--accent-gold, #a47a2b);
  font: 750 10px/1.2 Inter, ui-sans-serif, sans-serif;
  letter-spacing: .18em;
  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, #efe6d2) 68%, transparent);
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent-gold, #a47a2b) 72%, 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: color-mix(in srgb, var(--surface-card, #fff) 76%, var(--surface-muted, #f4f0e8));
  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: 13px/1.4 Inter, ui-sans-serif, sans-serif;
}

.atlas-search-result__title-line strong {
  color: var(--text-heading, #102a50);
  font-family: var(--font-display, "Cormorant Garamond", Georgia, serif);
  font-size: 17px;
  font-weight: 500;
}
.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 Inter, ui-sans-serif, sans-serif;
}

.atlas-search-result__kind {
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent-gold, #a47a2b) 36%, transparent);
  color: color-mix(in srgb, var(--accent-gold, #a47a2b) 80%, var(--text-heading, #102a50));
  background: color-mix(in srgb, var(--surface-muted, #f4f0e8) 76%, transparent);
  font: 700 9px/1.2 Inter, ui-sans-serif, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.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) 72%, transparent);
  font: 11px/1.4 Inter, ui-sans-serif, sans-serif;
}

.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 color-mix(in srgb, var(--accent-gold, #a47a2b) 35%, var(--line-main, #ded7c8));
  border-radius: 10px;
  color: var(--text-muted, #687184);
  background: color-mix(in srgb, var(--surface-input, #fff) 82%, var(--surface-muted, #f4f0e8));
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.atlas-topbar__form:focus-within {
  border-color: color-mix(in srgb, var(--accent-gold, #a47a2b) 72%, var(--line-main, #ded7c8));
  background: var(--surface-input, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-gold, #a47a2b) 12%, transparent);
}

.atlas-topbar__form input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text-main, #102a50);
  background: transparent;
  font: 400 16px/1.3 var(--font-reading,"Source Sans 3",sans-serif);
  -webkit-appearance: none;
}

.atlas-topbar__form input::placeholder {
  font-family: var(--font-reading,"Source Sans 3",sans-serif);
  color: var(--text-muted, #687184);
  font-size: 16px;
  opacity: 1;
}

.atlas-topbar__form input::-webkit-search-cancel-button { display: none; }

.atlas-topbar__submit {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: 0;
  cursor: pointer;
}

.atlas-topbar__submit::before {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}

.atlas-topbar__submit::after {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
  transform: rotate(45deg);
  transform-origin: left center;
}

.atlas-topbar__clear {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  place-items: center;
  color: var(--accent-gold, #a47a2b);
  background: transparent;
  font: 500 21px/1 Georgia, serif;
  cursor: pointer;
}

.atlas-topbar__clear:hover,
.atlas-topbar__clear:focus-visible {
  background: color-mix(in srgb, var(--accent-gold, #a47a2b) 12%, transparent);
  outline: none;
}

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

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

.atlas-topbar__profile .atlas-account-avatar {
  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 .atlas-account-trigger__name { 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; }
}
.atlas-account-trigger { display: flex; align-items: center; gap: 10px; padding: 5px; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; border-radius: 8px; }
.atlas-account-trigger:focus-visible { outline: 2px solid var(--accent-gold, #a47a2b); outline-offset: 2px; }
.atlas-account-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 110; width: 248px; max-width: calc(100vw - 36px); overflow: hidden; border: 1px solid var(--line-main, #ded7c8); border-radius: 12px; color: var(--text-main, #102a50); background: var(--surface-elevated, #fff); box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.atlas-account-menu[hidden] { display: none; }
.atlas-account-menu__identity { display: flex; align-items: center; gap: 12px; padding: 18px; }
.atlas-account-menu__identity > div { min-width: 0; overflow-wrap: anywhere; }
.atlas-account-menu__identity strong { display: block; font-size: 14px; }
.atlas-account-menu__role { display: block; margin-top: 5px; color: var(--text-muted, #687184); font-size: 11px; letter-spacing: .08em; }
.atlas-account-menu .atlas-account-avatar { flex-shrink: 0; }
.atlas-account-menu form { margin: 0; }
.atlas-account-menu__signout { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 14px 18px; border: 0; border-top: 1px solid var(--line-main, #ded7c8); color: inherit; background: transparent; text-align: left; font: 13px system-ui; cursor: pointer; }
.atlas-account-menu__signout:hover { background: var(--surface-soft, #f7f3ea); }
