/* Left navigation owns its layout without changing the reading components. */
.reading-workspace {
  --sidebar-width: 188px;
  --sidebar-column: var(--sidebar-width);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: var(--sidebar-column) minmax(0, 1fr);
  align-items: start;
  gap: 26px;
  width: 100%;
  margin-top: 14px;
  padding-right: 20px;
}

.reading-workspace[data-sidebar-state="collapsed"] {
  --sidebar-column: 4px;
}

.reading-workspace > .app-shell {
  /* Keep sticky subnavigation and reading controls below the drawer layers. */
  position: relative;
  z-index: 0;
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  margin: 0 !important;
  padding-inline: 0 !important;
}

.reading-sidebar {
  position: sticky;
  top: 12px;
  z-index: 2;
  width: var(--sidebar-column);
  height: calc(100vh - 24px);
  height: calc(100dvh - 24px);
  min-height: 44px;
  background: #b5a17b;
  border-radius: 0 10px 10px 0;
}

.sidebar-panel {
  width: var(--sidebar-width);
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 20px 10px;
  border: 1px solid #d4c8b2;
  border-left: 0;
  border-radius: 0 10px 10px 0;
  background: #fbf9f4;
  box-shadow: 2px 2px 12px #4e412d0a;
}

.sidebar-heading {
  margin: 0 10px 16px;
  color: #71634c;
  font-family: var(--font-heading, serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .12em;
}

.sidebar-guide-note {
  margin:0 0 12px;
  padding:10px;
  border:1px solid #b5a17b;
  border-radius:8px;
  background:rgba(250,248,242,.35);
  color:#34463b;
  line-height:1.65;
}

.reading-sidebar .sidebar-tabs {
  display: flex !important;
  flex-direction: column;
  grid-template-columns: none !important;
  gap: 5px !important;
  overflow: visible !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.reading-sidebar .sidebar-tabs .tab {
  flex: 0 0 auto;
  justify-content: flex-start !important;
  gap: 12px;
  width: 100%;
  min-height: 46px !important;
  height: auto !important;
  padding: 10px 12px !important;
  border: 1px solid transparent !important;
  border-radius: 7px !important;
  background: transparent !important;
  text-align: left !important;
  transition: background .16s ease, color .16s ease !important;
}

.reading-sidebar .sidebar-tabs .tab:hover {
  border-color: #dfd5c4 !important;
  background: #f1eadc !important;
}

.reading-sidebar .sidebar-tabs .tab.active {
  border-color: #263d35 !important;
  background: #263d35 !important;
  color: #fffaf0 !important;
  box-shadow: 0 2px 5px #263d3514 !important;
}

.reading-sidebar .sidebar-tabs .sidebar-label {
  color: inherit;
  font-size: 14px !important;
  letter-spacing: .04em;
  line-height: 1.5;
}

.sidebar-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-toggle {
  position: absolute;
  top: 14px;
  left: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-height: 44px;
  margin: 0;
  padding: 6px;
  border: 1px solid #b5a17b;
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: #f7f3e9;
  color: #65502d;
  box-shadow: 2px 2px 5px #4e412d0a;
}

.sidebar-toggle:hover { background: #eadfc9; }
.sidebar-toggle svg { width: 12px; height: 16px; fill: currentColor; }
.sidebar-toggle[aria-expanded="false"] svg { transform: rotate(180deg); }
.sidebar-toggle:focus-visible, .reading-sidebar .tab:focus-visible {
  outline: 2px solid #65502d;
  outline-offset: 2px;
}
.sidebar-backdrop { display: none; }

@media (max-width: 760px) {
  .reading-workspace {
    --sidebar-column: 4px;
    gap: 26px;
    margin-top: 10px;
    padding-right: 10px;
  }

  .reading-sidebar { border-radius: 0; }
  .reading-workspace[data-sidebar-state="expanded"] .reading-sidebar {
    width: var(--sidebar-width);
    border-radius: 0 10px 10px 0;
  }

  .reading-workspace[data-sidebar-state="expanded"] .sidebar-backdrop:not([hidden]) {
    position: absolute;
    inset: 0 0 0 4px;
    z-index: 1;
    display: block;
    width: calc(100% - 4px);
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #263d3526;
    cursor: pointer;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reading-sidebar .sidebar-tabs .tab { transition: none !important; }
}

@media print {
  .reading-workspace { display: block; margin: 0; padding: 0; }
  .reading-sidebar, .sidebar-backdrop { display: none !important; }
}

/* Floating navigation: its rail never participates in the content width. */
.reading-workspace,
.reading-workspace[data-sidebar-state="collapsed"] {
  display:block;
  width:min(calc(100% - 36px),1060px);
  margin:14px auto 0;
  padding:0;
}
.reading-sidebar,
.reading-workspace[data-sidebar-state="expanded"] .reading-sidebar {
  position:fixed;
  inset:0 auto auto 0;
  width:0;
  height:0;
  min-height:0;
  background:transparent;
  border:0;
  border-radius:0;
  z-index:30;
}
.sidebar-panel {
  position:fixed;
  left:10px;
  top:50%;
  transform:translateY(-50%);
  width:188px;
  height:min(78dvh,680px);
  border:1px solid #d4c8b2;
  border-radius:12px;
  box-shadow:0 8px 32px #263d3526;
}
.sidebar-toggle {
  position:fixed;
  left:6px;
  top:50%;
  transform:translateY(-50%);
  width:28px;
  min-height:50px;
  border:1px solid #b5a17b;
  border-radius:9px;
  box-shadow:0 3px 14px #263d3529;
  z-index:31;
}
.reading-workspace[data-sidebar-state="expanded"] .sidebar-toggle { left:198px; }
@media(max-width:760px) {
  .reading-workspace,.reading-workspace[data-sidebar-state="collapsed"] { width:calc(100% - 24px); margin-top:10px; }
  .reading-workspace[data-sidebar-state="expanded"] .sidebar-backdrop:not([hidden]) { position:fixed; inset:0; width:100%; height:100dvh; z-index:20; }
}
@media print {
  .reading-workspace { width:100%; }
}
