/* Shared Research shell: one persistent reader for every session. */
html { scroll-behavior: smooth; }

body[data-research-shell] { min-height: 100vh; }

body[data-research-shell] .research-reader-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

body[data-research-shell] .research-rail {
  position: sticky;
  inset: 0 auto auto 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-self: start;
  width: 292px;
  height: 100vh;
  padding: 22px 18px 28px;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}

.research-rail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.research-brand {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.research-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--ink);
  border-radius: 7px;
  font: 400 20px/1 var(--display);
}

.research-brand strong,
.research-brand small { display: block; }

.research-brand strong {
  overflow: hidden;
  font: 750 12px/1.2 var(--sans);
  letter-spacing: .03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-brand small {
  margin-top: 3px;
  color: var(--muted);
  font: 500 9px/1.25 var(--sans);
  letter-spacing: .04em;
}

.research-rail-close,
.research-menu-button {
  display: none;
  place-items: center;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  cursor: pointer;
}

.research-track-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 24px;
}

.research-track-links a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 650 10px/1.25 var(--sans);
  text-decoration: none;
}

.research-track-links a:hover,
.research-track-links a[aria-current="page"] {
  color: var(--ink);
  background: #f3f3f1;
  border-color: var(--line-strong);
}

.research-nav-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font: 700 9px/1.3 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.research-session-nav {
  display: grid;
  flex: 0 1 480px;
  gap: 2px;
  min-height: 152px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.research-session-link {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 6px 8px;
  color: var(--muted);
  border-radius: 6px;
  font-family: var(--sans);
  text-decoration: none;
}

.research-session-link:hover { color: var(--ink); background: #f5f5f3; }

.research-session-link[aria-current="page"] {
  color: var(--ink);
  background: #f1f1ef;
  box-shadow: inset 2px 0 var(--ink);
}

.research-session-number {
  color: var(--orange);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .06em;
}

.research-session-title {
  overflow: hidden;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-section-nav {
  flex: 1 1 180px;
  min-height: 120px;
  margin-top: 24px;
  padding: 20px 8px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
}

.research-section-nav[hidden] { display: none; }

body[data-research-shell] .reader-sidebar-title {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 9px;
}

body[data-research-shell] .reader-toc { gap: 1px; }

body[data-research-shell] .reader-toc a {
  padding: 5px 7px;
  font-size: 10px;
  line-height: 1.3;
}

.research-workspace { min-width: 0; }

body[data-research-shell] .reader-top {
  position: sticky;
  top: 0;
  z-index: 120;
  min-height: 58px;
  padding: 9px 20px;
}

.research-crumb {
  min-width: 0;
  color: var(--muted);
  font: 500 11px/1.4 var(--sans);
}

.research-crumb strong { color: var(--ink); font-weight: 700; }

body[data-research-shell] .reader-main {
  min-height: calc(100vh - 58px);
  opacity: .72;
  transition: opacity .16s ease;
}

body[data-research-shell] .reader-main.is-ready { opacity: 1; }

.reader-status {
  max-width: 680px;
  margin: 0 auto;
  padding: 72px 28px;
  color: var(--muted);
  font: 600 13px/1.5 var(--sans);
}

body[data-research-shell] .reader-nav {
  max-width: 900px;
  padding-top: 12px;
}

body[data-research-shell] .reader-nav[hidden] { display: none; }

body[data-research-shell] .reader-nav a {
  min-width: 0;
  line-height: 1.35;
}

body[data-research-shell] .reader-nav small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.research-shell-library { min-height: calc(100vh - 58px); }

.research-nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: none;
  padding: 0;
  background: rgb(23 23 23 / .26);
  border: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

@media (min-width: 901px) {
  html,
  body[data-research-shell] {
    height: 100%;
    overflow: hidden;
  }

  body[data-research-shell] .research-reader-layout {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
  }

  body[data-research-shell] .research-rail {
    position: relative;
    inset: auto;
    height: 100vh;
  }

  body[data-research-shell] .research-workspace {
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  body[data-research-shell] .research-session-nav {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
  }

  body[data-research-shell] .research-session-link {
    min-height: 32px;
    padding-block: 4px;
  }

  body[data-research-shell] .research-section-nav {
    min-height: 72px;
  }
}

@media (max-width: 900px) {
  body[data-research-shell] .research-reader-layout { grid-template-columns: 1fr; }

  body[data-research-shell] .research-rail {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    width: min(340px, 90vw);
    height: 100dvh;
    transform: translateX(-102%);
    transition: transform .2s cubic-bezier(.22, 1, .36, 1);
  }

  .research-rail-close,
  .research-menu-button { display: grid; }

  .research-menu-button { flex: 0 0 auto; }

  .research-nav-scrim { display: block; }

  body.research-menu-open { overflow: hidden; }

  body.research-menu-open .research-rail { transform: translateX(0); }

  body.research-menu-open .research-nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .research-crumb { flex: 1; }
}

@media (max-width: 560px) {
  body[data-research-shell] .reader-top { padding-inline: 12px; }
  .research-crumb { font-size: 10px; }
  body[data-research-shell] .reader-actions a { padding-inline: 9px; }
  body[data-research-shell] .reader-nav { grid-template-columns: 1fr 1fr; }
  body[data-research-shell] .reader-home { grid-column: 1 / -1; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body[data-research-shell] .reader-main,
  body[data-research-shell] .research-rail,
  .research-nav-scrim { transition: none; }
}
