@layer components {
/* Reserve the actual reader geometry, not a blank page or a second note list. */
.shelf-loading-label { font: .7rem var(--mono); color: var(--ink-soft); }
.shelf-loading-card {
  min-height: var(--reader-min-card-height); border: 1px solid var(--rule-faint);
  border-top: 3px solid var(--moss); background: var(--card-surface);
  opacity: .4; padding: 1rem;
}
.shelf-loading-card::before, .shelf-loading-card::after {
  content: ""; display: block; height: .6rem; width: 65%;
  background: var(--rule-faint); opacity: .35; margin-block: .7rem;
}
.shelf-loading-card::after { width: 85%; }
.shelf[data-boot] .timeline-viewport { overflow: hidden; }
.shelf[data-boot] :is(.shelf-tools, .shelf-index, .timeline-footer, .timeline-rail) { pointer-events: none; }
.shelf[data-boot] .shelf-end { display: none; }
:root:not([data-js]) :is([data-enhanced], .shelf-timeline) { display: none; }
/* Stationary reading slots shared by Timeline and Threads. */
.shelf-timeline { border-top: 0; }
.shelf-results-bar { margin-bottom: 0; }
.timeline-heading { height: 52px; }
.timeline-stage { height: min(74dvh, 760px); }
.timeline-stage::after { display: none; }
.stepped-reader { overflow-x: hidden !important; overflow-y: auto !important; overscroll-behavior: contain; scroll-behavior: auto !important; scrollbar-width: none; transition: none; touch-action: pan-y pinch-zoom; min-height: 0; }
.stepped-reader::-webkit-scrollbar { display: none; }
.timeline-viewport { padding: 2px 5px 5px 2px; }
.reader-frame { position: sticky; top: 0; z-index: 1; display: grid; width: 100%; height: 100%; min-height: 0; overflow: hidden; grid-auto-rows: max-content; align-content: start; gap: var(--reader-gap); background: transparent; }
.reader-scroll-space { width: 1px; pointer-events: none; }
/* Presentation recipes adapt to the actual card column, including Threads. */
.reader-frame { container: note-list / inline-size; }
[data-thread-notes].stepped-reader { padding-right: 18px; }
.thread-column--notes > [data-thread-notes] { flex: 1; }
.reader-scrollbar { position: absolute; right: -1px; width: 12px; overflow: hidden; overscroll-behavior: contain; background: transparent; cursor: var(--cursor-vertical-resize, ns-resize); opacity: 0; transition: opacity .15s; }
.reader-scrollbar.is-active { opacity: .72; }
.reader-scrollbar:focus-visible, .reader-scrollbar:active, .reader-scrollbar[data-dragging="true"] { opacity: 1; }
.reader-scrollbar[data-dragging="true"] { cursor: var(--cursor-grabbing, grabbing); }
.reader-scrollbar:focus-visible { outline: 1px solid var(--rust); outline-offset: 2px; }
.reader-scrollbar__native { position: absolute; inset: 0; overflow-y: scroll; overscroll-behavior: contain; scrollbar-width: none; }
.reader-scrollbar__native::-webkit-scrollbar { display: none; }
.reader-scrollbar__space { width: 1px; pointer-events: none; }
.reader-scrollbar__track { position: absolute; inset: 0 0 0 auto; width: 8px; border-left: 1px solid color-mix(in srgb, var(--rule-faint) 70%, transparent); background: transparent; touch-action: none; }
.reader-scrollbar__thumb { display: block; width: 5px; margin-left: 1px; border-radius: 4px; background: var(--moss); box-shadow: 0 0 0 1px color-mix(in srgb, var(--paper-bright) 70%, transparent); will-change: transform; }
.shelf[data-view="timeline"] .timeline-viewport .shelf-cards { border: 0; padding: 0; margin: 0; }
.stepped-reader .note-card { margin: 0; min-height: var(--reader-min-card-height); overflow: visible; box-shadow: none; transition: none; padding: .75rem; display: flex; flex-direction: column; }
.stepped-reader .note-card h2 { font-size: clamp(1.3rem, 2vw, 1.65rem); line-height: 1.1; margin: .35rem 0; flex-shrink: 0; }
.stepped-reader .note-card__summary { margin-bottom: .6rem; font-size: .82rem; }
.stepped-reader[data-reader-density="compact"] .note-card { padding: .65rem .75rem; }
.stepped-reader[data-reader-density="compact"] .note-card h2 { margin-block: .25rem; font-size: clamp(1.18rem, 4.5vw, 1.5rem); }
.stepped-reader[data-reader-density="compact"] .note-card__summary { margin-bottom: .3rem; }
.stepped-reader[data-reader-density="compact"] .note-card__meta { margin-bottom: .15rem; }
.stepped-reader[data-reader-density="compact"] .note-card__bottom { padding-top: .25rem; }
.stepped-reader .note-card__match:not([hidden]) { display: block; margin: .3rem 0; }
.stepped-reader .note-card__bottom { flex-wrap: nowrap; padding-top: .4rem; gap: .5rem; }
.stepped-reader .note-card__tags { overflow: visible; max-height: none; }
.timeline-footer { min-height: 44px; padding: .4rem 0; }
.shelf-lucky { border: 1px solid var(--rule-faint); padding: .4rem .65rem; background: var(--paper-bright); font: .65rem var(--mono); }
.shelf-results-actions { display: flex; align-items: center; gap: .7rem; }
.reader-step-controls { display: inline-flex; flex: none; align-items: center; gap: .25rem; }
.thread-status-bar { display: flex; align-items: center; border-top: 1px solid var(--rule-faint); gap: .6rem; padding: .5rem .8rem; }
.thread-status-bar .thread-status { padding: 0; border: 0; flex: 1; }
.thread-status-bar button { min-width: 76px; border: 1px solid var(--rule-faint); background: var(--paper-bright); padding: .5rem .65rem; font: .62rem var(--mono); }
.thread-status-bar button:disabled { opacity: .38; }
.graph-canvas { width: 100%; height: 100%; }
[data-graph] { height: min(78dvh, 880px); min-height: 400px; }
.graph-inspector { max-height: min(60%, 400px); background: var(--map-inspector-background); z-index: 5; }
.shelf-index { scrollbar-width: none; }
.shelf-index::-webkit-scrollbar { display: none; }
.sidebar-scroll-hint { position: fixed; z-index: 4; width: 3px; border-radius: 3px; background: var(--moss); opacity: 0; pointer-events: none; transition: opacity .15s; }
.sidebar-scroll-hint.is-active { opacity: .7; }
.shelf-reading [data-reading-count] { font-size: .65rem; }
@media (max-width: 700px) {
  .shelf-page main { padding: 1.2rem .75rem; }
  .shelf-hero { gap: .5rem; padding-bottom: 1rem; }
  .shelf-hero h1 { font-size: 3.7rem; }
  .shelf-hero .eyebrow { margin-bottom: .6rem; }
  .shelf-tools { padding: .5rem 0; gap: .4rem; }
  .shelf-search { padding: .55rem; }
  .shelf-results-bar { min-height: 36px; }
  .timeline-heading { height: 42px; }
  .timeline-stage { height: max(260px, calc(100dvh - 250px)); grid-template-columns: minmax(0, 1fr) 34px; gap: .55rem; }
  .timeline-footer { padding-bottom: max(.4rem, env(safe-area-inset-bottom)); }
  .thread-toolbar { padding: .6rem .7rem; flex-wrap: nowrap; }
  .thread-toolbar h2 { font-size: 1.35rem; }
  .thread-toolbar .eyebrow { display: none; }
  .thread-toolbar > div:first-child { width: auto; }
  .thread-trail { padding: 0 .7rem .5rem; }
  .thread-board { display: flex; height: auto; padding: 0 .65rem .7rem; flex-direction: column; gap: .55rem; }
  .thread-connections { display: none; }
  .thread-column { display: block; width: 100%; }
  .thread-column--categories, .thread-column--tags { border-top: 1px solid var(--rule-faint); }
  .thread-column > header { height: 35px; padding-top: .25rem; }
  .thread-column > header > span, .thread-column > header p { display: none; }
  .thread-column > header h3 { margin: .25rem 0; font-size: 1.1rem; }
  .thread-column--categories > header, .thread-column--tags > header { height: auto; padding: 0; border: 0; }
  .thread-column--categories > header > h3, .thread-column--tags > header > h3 { display: none; }
  .thread-mobile-section { display: grid; width: 100%; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .75rem; border: 0; padding: .7rem .2rem; background: transparent; text-align: left; }
  .thread-mobile-section > span { font: 500 1.1rem var(--display); }
  .thread-mobile-section > small { overflow: hidden; color: var(--rust-dark); font: .61rem var(--mono); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
  .thread-mobile-section > b { color: var(--moss-dark); font: 400 .8rem var(--mono); }
  .thread-mobile-section[aria-expanded="true"] > b { transform: rotate(45deg); }
  .thread-column--categories .thread-scroll, .thread-column--tags .thread-scroll { height: auto; max-height: none; overflow: visible; padding: .2rem 0 .6rem; }
  .thread-column--categories .thread-choice, .thread-column--tags .thread-choice { min-height: 40px; margin-bottom: .35rem; padding: .55rem .65rem; }
  .thread-column--notes { grid-column: auto; border-top: 1px solid var(--rule-faint); }
  .thread-column--notes > header { display: flex; justify-content: space-between; align-items: center; }
  .thread-column--notes > header p { display: block; font-size: .67rem; }
  [data-thread-notes].stepped-reader { height: clamp(285px, 50dvh, 430px); padding: .25rem 18px .25rem 0; }
  .thread-choice { min-height: 42px; padding: .55rem; font-size: .65rem; }
  .thread-choice > span { width: auto; }
  .thread-status-bar { padding: .3rem .6rem; }
  .thread-status { font-size: .65rem; }
  .thread-actions { margin: 0; }
  .thread-scroll-hint { display: none; }
  .thread-status-bar { position: sticky; bottom: calc(3.55rem + env(safe-area-inset-bottom)); z-index: 6; gap: .35rem; background: var(--paper-bright); }
  .thread-status-bar .reader-step-controls { gap: .2rem; }
  .thread-status-bar button { min-width: 70px; padding: .55rem .4rem; font-size: .65rem; }
  .thread-status-bar .thread-status { display: block; text-align: center; }
  /* Keep one viewport-sized map region. Details borrow space from the canvas;
     collapsing them gives that space back instead of shrinking the whole map. */
  [data-graph] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(200px, 1fr) auto auto; height: max(440px, calc(100dvh - 260px)); min-height: 0; }
  .graph-canvas { grid-area: 1 / 1; width: 100%; height: 100%; min-width: 0; min-height: 0; }
  .graph-inspector { grid-area: 2 / 1; position: relative; inset: auto; width: auto; max-height: 220px; margin: .5rem .6rem; }
  .graph-minimap { grid-area: 1 / 1; position: relative; inset: auto; align-self: end; justify-self: start; margin: 0 0 10px 10px; width: 90px; height: 56px; }
  .graph-status { grid-area: 3 / 1; position: relative; inset: auto; margin: .2rem .6rem; font-size: .55rem; }
  .graph-inspector.is-minimized { left: auto; }
}
@media (orientation: landscape) and (min-width: 701px) and (max-height: 700px) {
  .shelf-page main { padding-top: 1rem; }
  .shelf-tools { padding-block: .3rem; }
  .timeline-stage { height: max(230px, calc(100dvh - 190px)); }
  .thread-toolbar { padding: .4rem .7rem; }
  .thread-toolbar h2 { font-size: 1.2rem; }
  .thread-toolbar .eyebrow { display: none; }
  .thread-trail { padding-block: .2rem; }
  .thread-column > header { height: 40px; padding-top: .3rem; }
  .thread-column > header > span, .thread-column > header p { display: none; }
  .thread-board { height: max(300px, calc(100dvh - 190px)); }
  .thread-column--categories > header, .thread-column--tags > header { height: auto; }
  .thread-column--notes { grid-column: auto; }
  .thread-column--notes > header { height: 40px; }
  [data-graph] { min-height: 240px; height: max(240px, calc(100dvh - 140px)); }
}
@media (prefers-reduced-motion: reduce) { .sidebar-scroll-hint, .reader-scrollbar { transition: none; } }

}
