/* Central Synthesis: the room rail and the paged reading surface. Drawn from the
   vault's theme tokens so all twenty palettes style it without a fork. */

.sy-body {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}

/* the rail borrows .toc-inline for heading-tracking highlights, which is hidden
   by default as a collapsed <details>; here it is a permanent column */
.sy-rail {
  display: block;
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  max-height: calc(100vh - var(--topbar-h) - 40px);
  overflow: auto;
  margin: 0;
  padding: 4px 0 10px;
  border: none;
  border-radius: 0;
  background: none;
  scrollbar-width: thin;
}

.sy-rail nav {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sy-rail-label {
  margin: 14px 0 7px;
  padding-left: 2px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sy-rail-label:first-child {
  margin-top: 0;
}

.sy-rail .toc a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-left-width: 2px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-dim);
  font-size: 12.6px;
  line-height: 1.34;
}

.sy-rail-item.is-active {
  border-left-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  color: var(--accent);
}

.sy-no {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 700;
}

.sy-rail-item.is-active .sy-no {
  border-color: var(--accent);
  color: var(--accent);
}

.sy-no-plain {
  width: 18px;
  height: 18px;
  border: none;
  background: none;
}

.sy-no-plain .i {
  width: 13px;
  height: 13px;
}

.sy-rail-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sy-count {
  flex: none;
  color: var(--text-faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.sy-subs {
  margin-bottom: 6px;
}

.sy-subs a {
  display: block;
  padding: 4px 9px 4px 21px;
  color: var(--text-faint);
  font-size: 11.9px;
  line-height: 1.4;
}

.sy-main {
  min-width: 0;
}

.sy-main .prose {
  max-width: var(--sy-measure, 72ch);
}

.sy-section + .sy-section {
  margin-top: 46px;
  padding-top: 34px;
  border-top: 1px solid var(--border-soft);
}

.sy-section .prose {
  max-width: var(--sy-measure, 72ch);
}

.sy-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 24px;
}

.sy-open-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--text-dim);
  font-size: 12.6px;
  white-space: nowrap;
}

.sy-open-note:hover {
  color: var(--accent);
  text-decoration: none;
}

.sy-open-note .i,
.sy-tools .chip .i {
  width: 14px;
  height: 14px;
}

/* rail off ---------------------------------------------------------------- */

.sy-page.no-rail .sy-body {
  grid-template-columns: minmax(0, 1fr);
}

.sy-page.no-rail .sy-rail {
  display: none;
}

/* narrow screens stack, rail first, and stop sticking ---------------------- */

@media (max-width: 1040px) {
  .sy-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .sy-rail {
    position: static;
    top: auto;
    max-height: 260px;
    order: -1;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-soft);
  }

  .sy-page.no-rail .sy-rail {
    display: none;
  }

  .sy-open-note {
    margin-left: 0;
  }
}
