html {
  height: auto !important;
  min-height: 100%;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scroll-behavior: smooth;
}

body.ls-page-reference {
  height: auto !important;
  min-height: 100svh;
  padding-top: 68px;
  padding-bottom: 28px;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  background:
    linear-gradient(180deg, rgba(22, 16, 24, .94), rgba(8, 7, 11, .98)),
    url("../img/splash-bg.jpg") center / cover fixed no-repeat;
  color: var(--text, #f7eef7);
}

body.ls-page-reference::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(11, 21, 27, .58), rgba(27, 18, 22, .52)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.028) 0 1px, transparent 1px 72px);
}

.ref-main {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 20px));
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.ref-hero,
.ref-section {
  background: rgba(16, 13, 20, .78);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}

.ref-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, .65fr);
  gap: 14px;
  padding: clamp(14px, 2.4vw, 24px);
  min-height: clamp(240px, 42vh, 330px);
  align-items: center;
}

.ref-kicker,
.ref-card-label {
  margin: 0 0 8px;
  color: #8fe4d7;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ref-hero h1,
.ref-section h2 {
  margin: 0;
  color: #fff;
  letter-spacing: 0;
}

.ref-hero h1 {
  max-width: 760px;
  font-size: clamp(2rem, 4.5vw, 4rem);
  line-height: 1;
}

.ref-hero p,
.ref-section p {
  max-width: 760px;
  color: rgba(247, 238, 247, .82);
  line-height: 1.42;
  margin-top: 8px;
  margin-bottom: 10px;
}

.ref-hero-actions,
.ref-schema-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ref-btn,
.ref-schema-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.16);
  color: #fff;
  background: rgba(255,255,255,.08);
  text-decoration: none;
  font-weight: 800;
}

.ref-btn.primary {
  background: linear-gradient(135deg, #f6b354, #7be0c4);
  color: #171017;
  border-color: transparent;
}

.ref-hero-panel {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
}

.ref-hero-panel h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(1.2rem, 2.4vw, 1.75rem);
}

.ref-mini-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.ref-mini-list div {
  display: grid;
  gap: 4px;
}

.ref-mini-list dt {
  color: #f6b354;
  font-weight: 800;
}

.ref-mini-list dd {
  margin: 0;
  color: rgba(255,255,255,.84);
}

.ref-jumpbar {
  position: sticky;
  top: 72px;
  z-index: 5;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(12, 9, 15, .88);
  box-shadow: 0 14px 36px rgba(0,0,0,.32);
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.ref-jumpbar::-webkit-scrollbar { display: none; }

.ref-jumpbar a {
  flex: 0 0 auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.86);
  background: rgba(255,255,255,.06);
  text-decoration: none;
  font-size: .84rem;
  font-weight: 850;
  scroll-snap-align: start;
}

.ref-section {
  padding: clamp(12px, 2vw, 20px);
  scroll-margin-top: 90px;
}

.ref-section-head {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.ref-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.ref-stats span,
.ref-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.82);
  font-size: .78rem;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.ref-card {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
}

.ref-card[data-risk="High"] { border-left: 4px solid #f16f7d; }
.ref-card[data-risk="Medium"] { border-left: 4px solid #f6b354; }
.ref-card[data-risk="Low"] { border-left: 4px solid #7be0c4; }

.ref-card h3 {
  margin: 0;
  color: #fff;
  font-size: .98rem;
  letter-spacing: 0;
}

.ref-card p {
  margin: 0;
  color: rgba(247,238,247,.80);
  font-size: .88rem;
}

.ref-card ul {
  margin: 0;
  padding-left: 18px;
  color: rgba(247,238,247,.82);
  font-size: .86rem;
  line-height: 1.32;
}

.ref-card strong {
  color: #f6b354;
}

.ref-guide-card {
  gap: 6px;
}

.ref-guide-card .ref-stats {
  margin: 2px 0;
}

.ref-card-link,
.ref-back {
  width: fit-content;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(123, 224, 196, .14);
  border: 1px solid rgba(123, 224, 196, .32);
  color: #b8fff1;
  text-decoration: none;
  font-weight: 900;
}

.ref-back {
  margin-bottom: 10px;
}

.ref-guide-page .ref-guide-hero {
  min-height: clamp(210px, 34vh, 280px);
}

.ref-detail-list {
  margin: 0;
  padding-left: 20px;
  color: rgba(247,238,247,.82);
  line-height: 1.48;
}

.ref-two-col {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(260px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.ref-quick-tools {
  display: grid;
  grid-template-columns: minmax(210px, .62fr) minmax(260px, .9fr) minmax(300px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.ref-quick-copy {
  align-self: center;
}

.ref-quick-panel {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.11);
}

.ref-quick-panel h3 {
  margin: 0 0 9px;
  color: #fff;
  font-size: 1.02rem;
}

.source-ladder {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  counter-reset: source-rank;
  list-style: none;
}

.source-ladder li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.86);
}

.source-ladder li::before {
  counter-increment: source-rank;
  content: counter(source-rank);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #7be0c4;
  color: #081011;
  font-weight: 900;
}

.ref-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.ref-tool-grid article {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
}

.ref-tool-grid h3,
.ref-tool-grid h4 {
  margin: 0 0 6px;
  color: #fff;
  font-size: .94rem;
}

.ref-tool-grid p {
  margin: 0;
  font-size: .84rem;
}

.ref-search {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  max-width: 560px;
  color: rgba(255,255,255,.76);
  font-weight: 800;
}

.ref-search input {
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(5,5,8,.72);
  color: #fff;
}

.ref-library {
  display: grid;
  gap: 8px;
}

.ref-library-group {
  overflow: hidden;
  scroll-margin-top: 90px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}

.ref-library-group summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  color: #fff;
  font-weight: 900;
  list-style: none;
}

.ref-library-group summary::-webkit-details-marker {
  display: none;
}

.ref-library-group summary::before {
  content: "+";
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(123, 224, 196, .18);
  color: #b8fff1;
}

.ref-library-group[open] summary::before {
  content: "-";
}

.ref-library-group summary span {
  flex: 1;
  min-width: 0;
}

.ref-library-group summary em {
  flex: 0 0 auto;
  color: rgba(255,255,255,.64);
  font-size: .78rem;
  font-style: normal;
}

.ref-library-group .ref-grid {
  padding: 0 10px 10px;
}

.ref-empty {
  padding: 14px;
  border-radius: 8px;
  border: 1px dashed rgba(255,255,255,.24);
  color: rgba(255,255,255,.74);
}

@media (max-width: 820px) {
  body.ls-page-reference {
    padding-top: 64px;
  }

  .ref-main {
    width: min(100% - 20px, 1180px);
  }

  .ref-jumpbar {
    top: 64px;
  }

  .ref-hero,
  .ref-two-col,
  .ref-quick-tools {
    grid-template-columns: 1fr;
  }

  .ref-hero {
    min-height: 0;
  }

  .ref-hero-panel {
    display: none;
  }
}

body.vr-mode.ls-page-reference {
  font-size: 1.16rem;
}

body.vr-mode .ref-btn,
body.vr-mode .ref-schema-links a,
body.vr-mode .ref-search input {
  min-height: 58px;
}
