.app-nav { display: grid; gap: .24rem; }
.app-nav a, .shelf-account {
  display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .52rem .72rem;
  border-radius: .55rem; color: var(--ink); text-decoration: none; font: 550 .95rem/1.22 var(--sans);
}
.app-nav i, .shelf-account i { font-size: 1.25rem; }
.app-nav a:hover, .shelf-account:hover { background: var(--pale); }
.app-nav a[aria-current=page] { background: var(--paper); color: var(--primary); font-weight: 700; }
.app-tabs { display: none; }
.shelf-page { height: 100vh; height: 100dvh; background: var(--paper); color: var(--ink); }
.shelf-shell { height: 100%; display: grid; grid-template-columns: clamp(12.5rem,18vw,16rem) minmax(0,1fr); }
.shelf-side { display: flex; flex-direction: column; padding: 1.5rem .85rem .8rem; background: var(--side) var(--prism-sidebar); border-right: 1px solid var(--side-line); }
.shelf-side .brand, .shelf-bar .brand { gap: .36em; color: var(--ink); text-decoration: none; letter-spacing: -.055em; }
.shelf-side .brand { font-size: clamp(1.65rem,2.8vw,2.3rem); padding: .2rem .55rem; margin-bottom: 2rem; }
.shelf-account { margin-top: auto; }
.shelf-main { min-width: 0; min-height: 0; overflow: auto; }
.shelf-bar { min-height: 52px; padding: .17rem clamp(1rem,3.6vw,3.25rem); display: flex; align-items: center; justify-content: space-between; gap: .65rem; border-bottom: 1px solid var(--line); }
.shelf-bar .brand { display: none; }
.shelf-location { color: var(--muted); font-size: .87rem; }
.shelf-import, .shelf-link { color: var(--primary); font: 650 .9rem var(--sans); display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; text-decoration: none; }
.shelf-import:hover, .shelf-link:hover { text-decoration: underline; }
.shelf-content { width: min(100%,66rem); margin-inline: auto; padding: clamp(1.6rem,4.4vw,4rem) clamp(1rem,3.6vw,3.25rem) 3rem; }
.shelf-heading, .shelf-section-head, .shelf-form-end, #page-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1.2rem; flex-wrap: wrap; }
.shelf-heading { margin-bottom: 1.5rem; }
.shelf-page h1, .shelf-page h2, .shelf-page h3 { margin: 0; font-family: var(--display); color: var(--ink); overflow-wrap: anywhere; }
.shelf-page h1 { font-size: clamp(2.3rem,4vw,3.45rem); line-height: 1.02; letter-spacing: -.045em; }
.shelf-page h2 { font-size: clamp(1.28rem,2vw,1.62rem); line-height: 1.18; letter-spacing: -.025em; }
.shelf-page h3 { font-size: 1rem; }
.shelf-button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .5rem .9rem; border: 1px solid var(--side-line); border-radius: .55rem; color: var(--primary); background: var(--paper); font: 650 .9rem/1.25 var(--sans); text-decoration: none; }
.shelf-button.primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.shelf-button:hover { background: var(--pale); }
.shelf-button.primary:hover { background: var(--primary-hover); }
.shelf-start { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: clamp(.6rem,1.7vw,1.25rem); }
.start-choice { display: flex; align-items: center; gap: 1rem; padding: clamp(.95rem,2vw,1.5rem); text-align: left; text-decoration: none; min-width: 0; color: var(--ink); background: var(--pale); border: 1px solid var(--side-line); border-radius: .85rem; }
.start-choice:hover { border-color: var(--primary); }
.start-choice.thought { background: color-mix(in srgb, var(--paper),var(--prism-note) 40%); }
.start-choice strong { display: block; font: 700 clamp(1.1rem,2vw,1.4rem)/1.2 var(--display); letter-spacing: -.025em; }
.start-choice small { display: block; color: var(--muted); font-size: .87rem; margin-top: .3rem; line-height: 1.4; }
.start-symbol {
  position: relative; display: block; flex: none; width: 3.1rem; height: 3.5rem;
  font-size: 1.55rem; forced-color-adjust: none;
}
.paper-art, .paper-art::before, .paper-art::after,
.start-symbol::before, .start-symbol::after { position: absolute; }
.book .paper-art {
  inset: 9% 12% 12% 14%; transform: rotate(-9deg);
  border-radius: 12% 13% 10% 11% / 7% 9% 8% 8%;
  background: linear-gradient(90deg, #314e88 0 13%, #7f9ad5 14% 17%, #5879bb 18%, #385990 100%);
  box-shadow: 0 .08em 0 #f9eed2, 0 .14em 0 #d9caba, 0 .19em 0 #36517d;
}
.book .paper-art::before {
  content: ""; left: 29%; top: 33%; width: 41%; height: 5%; border-radius: 1em;
  background: #fff0c7; box-shadow: 0 .22em 0 -.015em #efe3c7;
}
.book .paper-art::after {
  content: ""; right: 14%; top: 0; width: 14%; height: 32%;
  background: linear-gradient(90deg, #f9cead, #e5a6ac);
  clip-path: polygon(0 0,100% 0,100% 100%,50% 78%,0 100%);
}
.thought .start-symbol::before {
  content: ""; inset: 15% 16% 10% 13%; border-radius: 12%;
  transform: rotate(4deg); background: #b8abd2;
}
.thought .paper-art {
  inset: 10% 17% 14% 10%; transform: rotate(-8deg); border-radius: 10%;
  background: linear-gradient(225deg, transparent 0 16%, #dec7b5 16.5% 31%, transparent 31.5%) top right / 42% 39% no-repeat,
              linear-gradient(145deg, #fff5dd, #f2d5bd);
  clip-path: polygon(0 0,76% 0,100% 23%,100% 100%,0 100%);
}
.thought .paper-art::before, .thought .paper-art::after {
  content: ""; left: 17%; height: 6%; border-radius: 1em; background: #90726f;
}
.thought .paper-art::before { top: 37%; width: 46%; }
.thought .paper-art::after { top: 53%; width: 33%; }
.thought .start-symbol::after {
  content: ""; width: 72%; height: 14%; right: 0; bottom: 25%; transform: rotate(-48deg);
  background: linear-gradient(90deg, #353957 0 8%, #e2b58e 9% 23%, transparent 24% 79%, #d3c9df 80% 86%, #996f91 87%),
              linear-gradient(#5c70ab 0 48%, #3c4d80 49%);
  clip-path: polygon(0 50%,22% 0,97% 0,100% 18%,100% 82%,97% 100%,22% 100%);
}
.app-nav .ph, .row-symbol .ph { color: var(--primary); }
.app-nav .ph-books, .row-symbol .ph-files { --symbol-wash: #a49bd3; }
.app-nav .ph-book-open-text, .row-symbol .ph-book-open-text { --symbol-wash: #76a8d1; }
.app-nav .ph-lightbulb-filament, .row-symbol .ph-lightbulb-filament { --symbol-wash: #e4ad76; }
.app-nav .ph-gear-six, .row-symbol .ph-shield-check { --symbol-wash: #79aaa9; }
.app-nav a[aria-current=page] .ph { --wash-opacity: .86; }
.shelf-section { margin-top: clamp(1.45rem,3vw,2.5rem); }
.shelf-section-head { margin-bottom: .35rem; }
.shelf-list { border-block: 1px solid var(--line); }
.shelf-row { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.shelf-row + .shelf-row { border-top: 1px solid var(--line); }
.shelf-row > a:first-child, .shelf-row > button:first-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: .85rem; padding: .75rem .15rem; min-height: 3.6rem; color: var(--ink); text-decoration: none; text-align: left; }
.shelf-row > :first-child:hover strong { text-decoration: underline; text-underline-offset: .18rem; }
.shelf-row .row-symbol { flex: none; color: var(--primary); display: grid; place-items: center; font-size: 1.25rem; width: 2.3rem; height: 2.55rem; border-radius: .4rem; background: var(--pale); }
.shelf-row .row-text { min-width: 0; flex: 1; }
.shelf-row strong, .shelf-row small { display: block; overflow-wrap: anywhere; }
.shelf-row strong { font: 650 1rem/1.3 var(--sans); }
.shelf-row small, .shelf-empty, #shelf-status { color: var(--muted); font: .87rem/1.45 var(--sans); }
.shelf-row small { margin-top: .16rem; }
.shelf-empty { padding: .85rem 0; margin: 0; }
.shelf-row .trailing { color: var(--muted); }
.row-tools { flex: none; position: relative; }
.row-tools summary { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; gap: .2rem; color: var(--primary); font: 600 .84rem var(--sans); }
.row-tools .menu { z-index: 5; }
.row-tools .menu a { display: block; min-height: 44px; padding: .65rem; font-size: .9rem; text-decoration: none; color: var(--ink); }
.shelf-form { display: grid; gap: .85rem; }
.shelf-form label { display: grid; gap: .28rem; font-weight: 600; }
.shelf-form input, .shelf-form textarea, .shelf-form select { font: inherit; padding: .55rem; width: 100%; min-height: 44px; border: 1px solid var(--control-line); border-radius: .4rem; color: var(--ink); background: var(--paper); }
.shelf-form textarea { resize: vertical; }
.shelf-form-end { justify-content: flex-end; }
.form-error { margin: 0; color: var(--error); }
.form-error:empty { display: none; }
.collection-list { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.collection-list a { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .45rem .72rem; border: 1px solid var(--side-line); border-radius: .55rem; text-decoration:none; color: var(--ink); }
.collection-list a[aria-current=page] { border-color: var(--primary); color: var(--primary); background: var(--pale); }
#shelf-status { margin: .7rem 0 0; }
.shelf-page { --prism-note: var(--sun); }
@media (max-width: 760px) {
  .shelf-shell { grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; }
  .shelf-side, .shelf-location { display: none; }
  .shelf-bar { background: var(--side) var(--prism-toolbar); }
  .shelf-bar .brand { display: inline-flex; font-size: 1.55rem; }
  .app-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); align-items: stretch; padding: .2rem .28rem max(.2rem,env(safe-area-inset-bottom)); border-top: 1px solid var(--side-line); background: var(--chrome); }
  .app-tabs a { justify-content: center; flex-direction: column; gap: .18rem; min-height: 48px; padding: .18rem; font-size: .74rem; }
  .app-tabs a[aria-current=page] { color: var(--primary); background: var(--pale); }
  .shelf-content { padding-top: 1.5rem; }
}
@media (max-width: 525px) {
  .start-choice { flex-direction: column; align-items: flex-start; gap: .65rem; }
  .start-symbol { width: 2.2rem; height: 2.45rem; font-size: 1.2rem; }
  .shelf-heading { margin-bottom: 1rem; }
  .shelf-row > :first-child { gap: .55rem; }
}

.shelf-side { padding: 1.18rem .7rem .8rem; min-height: 0; overflow: auto; }
.shelf-shell { grid-template-columns: 12.5rem minmax(0,1fr); }
.shelf-side .brand, .shelf-bar .brand { font-family: Spectral,Georgia,serif; font-weight: 600; }
.shelf-side .brand { font-size: 1.82rem; margin-bottom: 1.5rem; }
.app-nav a, .shelf-account { border-radius: .42rem; font-size: .91rem; }
.shelf-side .app-nav a[aria-current=page], #sidebar .app-nav a[aria-current=page] { background: color-mix(in srgb,var(--paper) 74%,transparent); }
.rail-books { margin: 1.35rem 0 .7rem; }
.rail-books h2.side-label, .rail-tools summary { color: var(--side-muted); font: 650 .75rem/1.4 var(--sans); letter-spacing: .025em; text-transform: none; }
.rail-books h2.side-label { margin: 0 0 .32rem; }
.rail-books nav { display: grid; }
.rail-books a { display: flex; align-items: center; min-height: 36px; gap: .55rem; padding: .35rem .66rem; border-radius: .35rem; color: var(--ink); text-decoration: none; font: 520 .88rem/1.35 var(--sans); }
.rail-books a span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rail-books a i { flex: none; color: var(--primary); }
.rail-books a:hover, .rail-books a[aria-current] { background: color-mix(in srgb,var(--paper) 61%,transparent); }
.shelf-content { max-width: 66rem; padding-top: clamp(1.65rem,4.6vh,3.4rem); }
.shelf-page h1, .shelf-page h2, .project-shell #project-title { font-family: Spectral,Georgia,serif; font-weight: 600; letter-spacing: -.042em; }
.shelf-page h1 { font-size: clamp(2.45rem,4vw,3.3rem); }
.shelf-page .shelf-heading { margin-bottom: 1.45rem; }
.shelf-start { gap: 0; border-block: 1px solid var(--side-line); }
.shelf-start .start-choice { border: 0; border-radius: 0; background: transparent; padding: 1.05rem .55rem; gap: .85rem; }
.shelf-start .start-choice + .start-choice { border-left: 1px solid var(--line); padding-inline-start: clamp(.65rem,2vw,1.55rem); }
.shelf-start .start-choice:hover { background: var(--pale); }
.start-choice strong { font: 650 1.03rem/1.3 var(--sans); letter-spacing: -.015em; }
.start-choice small { font-size: .84rem; margin-top: .12rem; }
.shelf-start .start-symbol { width: 2.5rem; height: 2.9rem; }
.library-columns { display: grid; grid-template-columns: minmax(0,1.52fr) minmax(0,1fr); column-gap: clamp(1.2rem,4vw,3.6rem); }
.library-columns .shelf-section-head { min-height: 44px; }
.shelf-row .row-symbol { background: transparent; width: 1.8rem; }
@media(max-width:760px) {
  .shelf-shell { grid-template-columns: 1fr; }
  .library-columns { display: block; }
  .shelf-start .start-choice { flex-direction: row; align-items: center; }
  .shelf-start .start-symbol { width: 2rem; height: 2.35rem; }
}
@media(max-width:440px) {
  .shelf-start .start-choice { align-items: flex-start; flex-direction: column; gap: .4rem; }
}
.shelf-shell, .project-shell { container: library-layout / inline-size; }
.shelf-form, .shelf-form label, .shelf-form select { min-width: 0; }
#discard-thought { margin-inline-end: auto; }
@container library-layout (max-width: 18em) {
  .app-tabs { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 2px; padding: 3px 4px max(3px,env(safe-area-inset-bottom)); }
  .app-tabs a { flex-direction: row; min-height: 44px; padding: .15em .12em; gap: .28em; font-size: .82rem; }
  .app-tabs i { font-size: 1em; }
  .shelf-bar { flex-wrap: wrap; gap: 0 .6em; padding: .15em min(5vw,1rem); }
  .shelf-import { margin-inline-start: auto; }
  .shelf-content { padding-inline: min(5vw,1rem); }
  .shelf-start { grid-template-columns: minmax(0,1fr); }
  .shelf-start .start-choice { flex-direction: row; align-items: center; padding: .55rem .12rem; gap: .45rem; }
  .shelf-start .start-choice + .start-choice { border-left: 0; border-top: 1px solid var(--line); padding-inline-start: .12rem; }
  .shelf-start .start-symbol { width: 1.45rem; height: 1.7rem; }
  .shelf-row { flex-wrap: wrap; gap: 0 .35rem; }
  .shelf-row > :first-child { flex-basis: 75%; }
  .shelf-row > :nth-child(2) { margin-inline-start: auto; }
  .project-shell .library-heading { flex-wrap: wrap; }
  .project-shell .library-new { white-space: normal; }
  .project-shell .section-row { flex-wrap: wrap; }
}
@container library-layout (max-width: 13em) {
  .app-tabs a i { display: none; }
  .app-tabs a { overflow-wrap: anywhere; }
  .shelf-bar .brand { font-size: 1.2rem; }
  .shelf-bar .shelf-import { font-size: .82rem; }
}
