:root{--rail-width:104px;--window-inset:clamp(24px,6svh,56px)}
html:has(>body.route-mode),html:has(>body.section-mode){background:#2a2e2d}

body:is(.route-mode,.section-mode){
  position:relative;
  width:min(calc(100% - 32px),calc((100svh - 2*var(--window-inset))*1.4 + var(--rail-width)));
  height:calc(100svh - 2*var(--window-inset));min-height:0;margin:var(--window-inset) auto;padding:0;
  display:grid;grid-template-columns:var(--rail-width) minmax(0,1fr);overflow:hidden;
  background:#f5f2e8;border:1px solid #d2d4c4;box-shadow:0 9px 35px #12202433;
}
.overview-backdrop{position:fixed;inset:0;z-index:-1;overflow:hidden;pointer-events:none;background:linear-gradient(#adbcb526,#cad2cc40),url('/assets/chapters/train-mist.jpg') center/cover}
.backdrop-home{position:absolute;inset:0;background:transparent}
.backdrop-paper{--paper-icon-space:clamp(52px,7.5svh,84px);--poster-height:min(calc(100svh - 24px),calc((100vw - 64px)*1.44 + 8px + var(--paper-icon-space)));width:calc((var(--poster-height) - var(--paper-icon-space) - 8px)*.694444 + 36px);height:var(--poster-height);padding:4px 18px calc(var(--paper-icon-space) + 4px);margin:calc((100svh - var(--poster-height))/2) auto;background:#e4d9c4;-webkit-mask:url('/assets/paper-edge.svg') 0 0/100% 100% no-repeat;mask:url('/assets/paper-edge.svg') 0 0/100% 100% no-repeat}
.overview-dimmer{position:absolute;inset:0;background:#19352c55;backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)}
body:is(.route-mode,.section-mode) .sidebar{
  position:relative;inset:auto;display:flex;flex-direction:column;align-items:center;
  width:100%;height:100%;min-height:0;padding:12px 8px 16px;overflow:visible;
  border:0;border-right:1px solid #cdd2c4;background:#f0eddf;
}
body:is(.route-mode,.section-mode) #navigation{
  display:flex;flex-direction:column;align-items:center;justify-content:flex-start;
  gap:6px;width:100%;margin:0;padding:0;overflow:visible;flex-shrink:0;
}
#navigation .nav-link{
  position:relative;display:flex;align-items:center;justify-content:center;
  width:52px;height:44px;flex-shrink:0;margin:0;padding:0;border:0;border-radius:4px;
  color:#527887;background:transparent;transition:background .18s;
}
#navigation .nav-link svg{display:block;width:40px;height:32px;overflow:visible;transition:transform .18s}
#navigation .nav-link:hover{background:#e1e8dd}
#navigation .nav-link:hover svg{transform:translateY(-1px)}
#navigation .nav-link.active{background:#d9e5de}
#navigation .nav-link.active:after{content:'';position:absolute;left:3px;top:50%;transform:translateY(-50%);width:2px;height:15px;margin:0;border-radius:2px;background:#ac6c60}
#navigation .nav-link:focus-visible{outline:1px dashed #557b83;outline-offset:2px}
#navigation .nav-link .nav-tooltip{
  position:absolute;left:calc(100% + 12px);top:50%;z-index:40;
  transform:translate(-4px,-50%);padding:8px 12px;border:1px solid #a3b9b0;
  border-radius:3px;background:#31565c;color:#faf4e3;box-shadow:0 4px 12px #173c3526;
  font-family:'Neucha',sans-serif;font-size:17px;font-weight:400;line-height:1.2;
  letter-spacing:.02em;white-space:nowrap;pointer-events:none;opacity:0;visibility:hidden;
  transition:opacity .15s ease,transform .15s ease,visibility .15s;
}
#navigation .nav-tooltip:before{content:'';position:absolute;right:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-right-color:#31565c}
#navigation .nav-link:hover .nav-tooltip,#navigation .nav-link:focus-visible .nav-tooltip{opacity:1;visibility:visible;transform:translate(0,-50%)}
body:is(.route-mode,.section-mode) .sidebar-bottom{
  display:flex;flex-direction:column;align-items:center;width:100%;max-width:86px;
  margin-top:auto;padding-top:24px;flex-shrink:0;
}
body:is(.route-mode,.section-mode) .side-sketch{width:82px;max-width:100%;margin:0;color:#7c8b72}
.sidebar-bottom .side-sketch svg{display:block;width:100%;height:auto}
body:is(.route-mode,.section-mode) .sidebar-bottom p{
  font-family:Georgia,serif;font-size:12px;font-style:italic;font-weight:400;
  line-height:1.55;letter-spacing:0;text-align:center;color:#788171;margin:10px 0 0;
}
.sidebar .local-badge{display:none}
.route-mode main{margin:0;padding:0;width:100%;height:100%;min-height:0;max-width:none;overflow:hidden}
.route-mode .atlas-back{display:none}
.section-mode main{height:100%}
.sidebar-close-row{display:flex;justify-content:center;flex-shrink:0;width:52px;max-width:100%;padding-bottom:5px;margin-bottom:6px;border-bottom:1px solid #cdd2c4}
.window-close{position:static;width:44px;height:32px;padding:0;background:transparent;border:0;color:#648179;border-radius:3px}
.window-close svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round}
.window-close:hover{background:#e1e9df;color:#355c57}
body:has(#chapter-dialog[open]) .window-close{visibility:hidden}
body:has(#chapter-dialog[open]) .sidebar{visibility:hidden}
@media(max-width:800px){
  :root{--rail-width:64px}
  body:is(.route-mode,.section-mode){width:calc(100% - 16px);height:calc(100svh - 48px);margin:24px auto;display:grid;grid-template-columns:var(--rail-width) minmax(0,1fr)}
  .backdrop-paper{width:100%;height:auto;min-height:100svh;margin:0;padding:22px 31.5px 64px;-webkit-mask:none;mask:none}
  body:is(.route-mode,.section-mode) .sidebar{display:flex;height:100%;padding:8px 4px 12px;border-bottom:0;border-right:1px solid #cdd2c4;overflow:visible}
  body:is(.route-mode,.section-mode) #navigation{flex-direction:column;gap:4px;margin:0;padding:0;overflow:visible}
  #navigation .nav-link{width:44px;height:40px;padding:0;gap:0}
  #navigation .nav-link svg{width:34px;height:28px}
  .sidebar-close-row{width:44px;padding-bottom:4px;margin-bottom:5px}
  body:is(.route-mode,.section-mode) .sidebar-bottom{display:flex;max-width:52px;padding-top:18px}
  body:is(.route-mode,.section-mode) .sidebar-bottom p{font-size:9.5px;line-height:1.5;margin-top:7px;overflow-wrap:normal}
  .section-mode main{height:100%;padding:0 14px}
  .section-mode .page-heading h1{font-size:27px}
  .section-mode .page-heading{padding:18px 0}
  .section-mode .topbar{height:34px;min-height:34px}
  .route-mode main{height:100%;padding:0}
}
@media(prefers-reduced-motion:reduce){#navigation .nav-link,#navigation .nav-link svg{transition:none}#navigation .nav-link:hover svg{transform:none}}
