.mode-nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 15px;
  border: 1px solid rgba(224, 215, 202, 0.88);
  border-radius: var(--v2-radius-pill);
  background: rgba(255, 253, 248, 0.54);
  color: var(--v2-muted);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.mode-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(138, 101, 63, 0.48);
  background: rgba(255, 253, 248, 0.82);
  color: var(--v2-ink);
}

.mode-btn.active {
  background: var(--v2-ink);
  border-color: var(--v2-ink);
  color: var(--v2-bg);
}

.search-form {
  width: 100%;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 0 0.35rem;
  border: 0;
  border-bottom: 1px solid rgba(216, 205, 190, 0.9);
  background: transparent;
  color: var(--v2-ink);
  outline: none;
}

.search-input::placeholder {
  color: var(--v2-soft);
}

.search-input:focus {
  border-bottom-color: var(--v2-accent);
}

.search-input--shell {
  max-width: 380px;
  justify-self: end;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 2;
  background: var(--v2-insights-canvas-bg);
  color: var(--v2-muted);
  font-size: 0.93rem;
  border-top: 1px solid var(--v2-rule-soft);
  padding-top: var(--v2-workspace-content-start);
}

.rail-panel {
  display: grid;
  gap: 1rem;
  padding: 0;
  border-top: 0;
}

.rail-panel > :first-child {
  margin-top: 0;
}

.rail-title {
  margin-top: 0;
  margin-block-start: 0;
  margin-bottom: 0.05rem;
  color: var(--v2-ink);
  font-family: var(--v2-font-body);
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.rail-intro {
  margin-top: 0;
  color: var(--v2-muted);
  font-size: 0.91rem;
}

.rail-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rail-list--dense {
  gap: 0.38rem;
}

.rail a {
  display: inline-block;
  color: var(--v2-muted);
  text-align: left;
  line-height: 1.42;
  padding: 0.15rem 0 0.15rem 0.95rem;
  border-left: 1px solid transparent;
  text-decoration: none;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.rail a:hover {
  color: var(--v2-ink);
}

.rail a.active {
  color: var(--v2-ink);
  font-weight: 600;
  border-left-color: rgba(138, 101, 63, 0.68);
}

.rail-subsection {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(216, 205, 190, 0.5);
}

.rail-subtitle {
  color: var(--v2-soft);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.rail-meta {
  margin-top: 0;
  color: var(--v2-muted);
  font-size: 0.92rem;
}

.rail-backlink {
  position: relative;
  padding: 0;
  color: var(--v2-ink);
  text-decoration: none;
}

@media (min-width: 1021px) {
  .rail {
    top: calc(
      var(--site-header-height, 58px) +
      var(--insights-sticky-gap) +
      var(--insights-controls-height, 0px) +
      var(--v2-interface-spacer-height)
    );
  }
}

@media (max-width: 1020px) {
  .rail {
    position: static;
    top: auto;
  }
}

@media (max-width: 850px) {
  .search-input--shell {
    max-width: none;
  }

  .rail {
    position: static;
    border-top: 0;
    border-bottom: 1px solid var(--v2-rule-soft);
    padding-bottom: 1rem;
    padding-top: 0;
  }

  .rail-panel {
    padding-top: 0;
    border-top: 0;
  }

  .rail-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.7rem 1rem;
  }

  .rail a {
    padding-left: 0;
    border-left: 0;
    border-bottom: 1px solid transparent;
  }

  .rail a.active {
    border-bottom-color: rgba(138, 101, 63, 0.68);
  }
}
