.site-head .brand-mark {
  width: 44px;
  height: 32px;
}

/* Sticky container: search + alphabet bar */
.glossary-sticky-head::before {
  content: '';
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  height: 50px;
  background: var(--card);
  display: none;
}

.glossary-sticky-head.is-stuck::before {
  display: block;
}

.glossary-sticky-head {
  position: sticky;
  top: 50px;
  z-index: 20;
  background: var(--card);
  margin: 0 -22px 16px;
  padding: 14px 22px 0;
  border-bottom: 1px solid #d2d9e3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.glossary-search {
  position: relative;
  margin: 0 0 0;
}

.glossary-search-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 54px 12px 16px;
  border: 1px solid #c9d5e4;
  border-radius: 999px;
  background: #f7fafc;
  color: var(--text);
  font: inherit;
}

.glossary-search-input::placeholder {
  color: #6a7890;
}

.glossary-search-input:focus {
  outline: none;
  border-color: #C02318;
  box-shadow: 0 0 0 3px rgba(192, 35, 24, 0.12);
  background: #ffffff;
}

.glossary-search-clear {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #9aabbe;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}

.glossary-search-clear:hover,
.glossary-search-clear:focus-visible {
  color: #C02318;
  background: rgba(192, 35, 24, 0.08);
  outline: none;
}

.glossary-search-count {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #9aabbe;
}

.glossary-search-empty {
  margin: 0 0 12px;
  color: #5b6980;
}

.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: #C02318;
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(192, 35, 24, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
}

.scroll-top-btn.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top-btn:hover {
  background: #a01d14;
}

.glossary-list {
  margin: 0;
}

.glossary-entry {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid #d2d9e3;
}

.glossary-entry[hidden] {
  display: none;
}

/* Hide native browser clear button on search inputs */
.glossary-search-input::-webkit-search-cancel-button {
  display: none;
  -webkit-appearance: none;
}

.glossary-entry:first-child {
  padding-top: 4px;
  border-top: 0;
}

.glossary-term {
  margin: 0;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: break-word;
  hyphens: auto;
}

.glossary-definition {
  margin: 0;
  color: var(--muted);
}

.glossary-link {
  position: relative;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 2px;
}

.glossary-link:hover,
.glossary-link:focus-visible {
  color: var(--text);
}

.glossary-link-tooltip {
  display: none;
}

#glossary-tooltip {
  position: fixed;
  z-index: 200;
  width: 220px;
  max-width: calc(100vw - 16px);
  padding: 8px 10px;
  background: #f0f1f3;
  color: #7a8599;
  font-size: 0.78rem;
  line-height: 1.45;
  border: 1px solid #d4d8e0;
  border-radius: 6px;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#glossary-tooltip.is-visible {
  opacity: 1;
}

.section-band.is-first-visible {
  padding-top: 4px;
  border-top: 0;
}

/* Alphabet navigation bar (inside .glossary-sticky-head) */
.toc {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0 8px;
  margin: 0;
}

.toc::-webkit-scrollbar {
  display: none;
}

.toc a {
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #52627d;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.toc a:hover,
.toc a:focus-visible {
  background: #e4e9f0;
  color: #24324b;
  border: none;
  outline: none;
}

.toc a.is-active {
  background: #C02318;
  color: #fff;
}

/* Offset anchor targets so they appear below the sticky bar */
.section-band[id],
.glossary-entry[id] {
  scroll-margin-top: 168px;
}

/* Spotlight: dim everything except the target entry */
.glossary-list.has-spotlight .glossary-entry,
.glossary-list.has-spotlight .section-letter {
  opacity: 0.12;
  transition: opacity 0.2s ease;
}

.glossary-entry.is-spotlight {
  opacity: 1 !important;
  background: rgba(192, 35, 24, 0.07);
  transition: opacity 0.2s ease, background 0.2s ease;
}

/* Fade back to normal when spotlight is removed */
.glossary-entry {
  transition: opacity 0.4s ease, background 0.5s ease;
}

.section-letter {
  margin: 6px 0 4px;
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  color: #C02318;
  letter-spacing: -0.02em;
}

@media (max-width: 720px) {
  .glossary-entry {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toc {
    margin: 0 -17px 16px;
    padding: 6px 17px;
  }
}
