/* Valley deep-history page — scoped for culture/nepal-history shell */
.valley-shell {
  --ink: var(--site-ink, #2c221a);
  --muted: var(--site-muted, #6e5e50);
  --faint: var(--site-muted, #8a7d72);
  --paper: var(--site-bg, #fdf6e9);
  --panel: var(--site-panel, #fffaf0);
  --line: var(--site-line, #e7d8bf);
  --crimson: #9b1b2e;
  --serif: var(--site-font-display, "Literata", "Noto Serif Devanagari", Georgia, serif);
  --sans: var(--site-font-sans, "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}
html.valley-html,
html.valley-html body.valley-page {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--paper, #f3ece1);
}
html.valley-html body.valley-page {
  display: flex;
  flex-direction: column;
  margin: 0;
}
.valley-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
  max-width: none;
  padding: 0;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}
.valley-shell > .top {
  flex: 0 0 auto;
}
.valley-shell > .lib-pager {
  flex: 0 0 auto;
}
.valley-back-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 6px;
}
.valley-back-sep {
  color: var(--faint);
}
.valley-chrome {
  flex: 0 0 auto;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px 8px;
}

.valley-chrome .back {
  display: inline-block;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  color: var(--crimson);
  margin-bottom: 4px;
}

.valley-chrome-main h1 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 560;
  margin: 0 0 2px;
  letter-spacing: -0.02em;
}

.valley-chrome .lede {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.valley-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  overflow: hidden;
}

.valley-rail {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
}

.valley-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px 20px !important;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group + .nav-group {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.nav-label {
  margin: 0 10px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.valley-nav a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  padding: 8px 10px;
  border-left: 2px solid transparent;
}

.valley-nav a:hover {
  color: var(--ink);
  background: #f5efe6;
}

.valley-nav a.on {
  color: var(--ink);
  border-left-color: var(--crimson);
  background: #efe6d8;
  font-weight: 650;
}

.valley-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
}

.valley-reading {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.valley-reading-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 22px 28px;
}

.valley-inline-figure {
  margin: 14px 0 18px;
  max-width: min(100%, 520px);
}

.valley-inline-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  background: #d7d0c4;
  border: 1px solid var(--line);
}

.valley-inline-figure figcaption {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.valley-inline-figure .credit {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.85;
}

.valley-inline-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}

.valley-inline-figures .valley-inline-figure {
  margin: 0;
  max-width: none;
}

.valley-inline-figures .valley-inline-figure img {
  max-height: 200px;
}

.place-card .valley-inline-figure {
  margin: 8px 0 10px;
  max-width: none;
}

.place-card .valley-inline-figure img {
  max-height: 140px;
}

.valley-chapter > h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 560;
  margin: 0 0 6px;
}

.valley-chapter .chapter-sub {
  color: var(--muted);
  margin: 0 0 10px;
  font-size: 15px;
}

.valley-chapter .chapter-lede {
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.valley-section {
  margin: 0 0 18px;
}

.valley-section h3 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 560;
  margin: 0 0 8px;
}

.valley-section p {
  margin: 0 0 12px;
  line-height: 1.6;
  color: #2a211c;
}

.valley-panel h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 0 10px;
}

.panel-note {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.valley-timeline {
  margin: 0;
  padding-left: 18px;
}

.valley-timeline li {
  margin-bottom: 8px;
  line-height: 1.45;
}

.valley-timeline strong {
  color: var(--crimson);
  margin-right: 6px;
}

.lineage-tree {
  margin: 0 0 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.lineage-tree:last-child {
  border-bottom: 0;
}

.lineage-tree > h3 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 560;
  margin: 0 0 6px;
}

.lineage-tree > h4,
.tree-branch h4 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 560;
  margin: 0 0 10px;
  color: var(--crimson);
}

.tree-person {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #efe6d8;
  border: 1px solid var(--line);
  border-left: 3px solid var(--crimson);
  padding: 10px 12px;
}

.tree-person strong {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}

.tree-years {
  font-size: 12px;
  font-weight: 650;
  color: var(--crimson);
}

.tree-person em {
  font-style: normal;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.tree-chain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 52rem;
}

.tree-chain > li {
  position: relative;
  padding: 0 0 14px 22px;
}

.tree-chain > li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #c4b8a8;
}

.tree-chain > li::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--crimson);
  border: 2px solid #faf6ef;
  box-sizing: border-box;
}

.tree-chain > li:last-child {
  padding-bottom: 0;
}

.tree-chain > li:last-child::before {
  bottom: auto;
  height: 22px;
}

.tree-root {
  max-width: 28rem;
  margin: 0 0 16px;
}

.tree-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.tree-branch {
  min-width: 0;
}

.tree-branch ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kings-grid,
.places-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.king-card,
.place-card {
  background: #efe6d8;
  padding: 12px 14px;
  border: 1px solid var(--line);
}

.king-card h3,
.place-card h3 {
  font-family: var(--serif);
  font-size: 16px;
  margin: 0 0 8px;
}

.king-card li,
.place-card p {
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 6px;
  color: #2a211c;
}

.king-card ul {
  margin: 0;
  padding-left: 16px;
}

.place-card .where {
  color: var(--crimson);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 650;
}

.valley-footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.valley-footer h2 {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 8px;
}

@media (max-width: 860px) {
  html.valley-html,
  html.valley-html body.valley-page {
    height: auto !important;
    max-height: none !important;
    overflow: auto !important;
  }

  html.valley-html body.valley-page {
    display: block !important;
  }

  .valley-workspace {
    display: flex;
    flex-direction: column;
    flex: none;
    overflow: visible;
  }

  .valley-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    height: auto;
    max-height: 40vh;
    flex: none;
  }

  .valley-stage {
    display: flex;
    flex-direction: column;
    flex: none;
    overflow: visible;
  }

  .valley-reading-scroll {
    overflow: visible;
  }
}

html[data-theme="dark"] .valley-shell {
  --ink: var(--site-ink, #f3e6d4);
  --muted: var(--site-muted, #bdafa3);
  --faint: #9e9184;
  --paper: var(--site-bg, #1c1612);
  --panel: var(--site-panel, #2a221c);
  --line: var(--site-line, rgba(243, 230, 212, 0.18));
  --crimson: var(--site-accent, #f0b089);
}
html[data-theme="dark"].valley-html,
html[data-theme="dark"].valley-html body.valley-page {
  background: var(--site-bg);
  color: var(--site-ink);
}
html[data-theme="dark"] .valley-nav a:hover {
  background: #2f261f;
}
html[data-theme="dark"] .valley-nav a.on,
html[data-theme="dark"] .tree-person,
html[data-theme="dark"] .king-card,
html[data-theme="dark"] .place-card {
  background: #2a221c;
  color: var(--ink);
}
html[data-theme="dark"] .valley-article p,
html[data-theme="dark"] .valley-section p,
html[data-theme="dark"] .king-card li,
html[data-theme="dark"] .place-card p {
  color: var(--ink);
}
html[data-theme="dark"] .valley-figure img,
html[data-theme="dark"] .valley-inline-figure img {
  background: #18130f;
}
html[data-theme="dark"] .tree-chain > li::before {
  background: rgba(243, 230, 212, 0.25);
}
html[data-theme="dark"] .tree-chain > li::after {
  border-color: #1c1612;
}
