/*
 * The Library (docs/design/2026-08-12-library-design.md), master-detail
 * (owner: "I think the library needs a master/detail view") — the Notebook
 * shell's grammar in the same tokens: one elevated viewport-fit card split
 * into a master rail and a detail pane, each owning its own scroll. The rail
 * sits a tonal step below the pane so the selected row's lift off its 3px
 * teal edge reads. Rows are list grammar (one line, may ellipsize); the
 * pane never truncates — essays whole, synopses whole.
 *
 * Below 900px it collapses list-first: the rail fills the screen and
 * .is-detail-open (server-set for explicit ?entry= links, client-set on row
 * taps) pushes the pane full-screen with a back affordance.
 *
 * Tokens only; squared corners; motion tokens. Covers are committed files
 * or the designed spine fallback — nothing external at render.
 */

.library-shell {
  display: grid;
  grid-template-columns: minmax(300px, 348px) minmax(0, 1fr);
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  /* The card fits the viewport under the sticky chrome (--chrome-height is
     published live by chrome_height_controller; the fallback covers the
     pre-JS first paint) so both panes scroll internally, app-like. */
  height: calc(100dvh - var(--chrome-height, 140px) - 3.25rem);
  min-height: 32rem;
  overflow: hidden;
  margin-block: 0.25rem 1.5rem;
}

/* ── Entrance: the hub's motion grammar, once per session ────────────────── */

.library-shell[data-entrance="play"] > * {
  animation: motion-rise var(--motion-enter) var(--ease-out) backwards;
}

.library-shell[data-entrance="play"] > :nth-child(1) { animation-delay: 0ms; }
.library-shell[data-entrance="play"] > :nth-child(2) { animation-delay: 60ms; }

/* ── The master rail ─────────────────────────────────────────────────────── */

.library-master {
  overflow-y: auto;
  border-right: 1px solid var(--border-light);
  /* A quiet tonal step below the detail pane, so the selected row's lift
     to the card surface reads. */
  background: var(--surface-page);
}

.library-masthead {
  padding: 1.35rem 1.25rem 1.05rem;
  border-bottom: 1px solid var(--border-light);
}

.library-masthead h1 {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  font-size: calc(21px * var(--text-scale));
  color: var(--text-dark);
  margin: 0;
}

/* ── Sections: quiet labels over row groups ──────────────────────────────── */

.library-index {
  padding-bottom: 1.25rem;
}

.library-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.25rem 0.45rem;
}

.library-section-head h2 {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Rows ────────────────────────────────────────────────────────────────── */

.library-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1.1rem 0.65rem 0.95rem;
  min-height: var(--tap);
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background var(--motion-quick) var(--ease-out),
              border-color var(--motion-quick) var(--ease-out);
}

@media (hover: hover) {
  a.library-row:hover:not([aria-current]) {
    background: color-mix(in srgb, var(--surface-card) 65%, transparent);
  }
}

/* The selected row lifts to the detail pane's surface off a teal edge. */
.library-row[aria-current] {
  background: var(--surface-card);
  border-left-color: var(--teal-accent);
}

.library-row-body {
  min-width: 0; /* let titles ellipsize instead of widening the rail */
}

.library-row-title {
  display: block;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.35;
  color: var(--navy-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* One line, may ellipsize — list grammar; the pane never truncates. */
.library-row-meta {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-body);
  font-size: calc(12.5px * var(--text-scale));
  line-height: 1.5;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A shelf's honest size, as data. */
.library-row-count {
  font-family: var(--font-body);
  font-size: calc(12px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* The quiet done mark on a completed activity. */
.library-row-done {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(11.5px * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-ink);
  white-space: nowrap;
}

/* ── The detail pane ─────────────────────────────────────────────────────── */

.library-detail {
  overflow-y: auto;
  background: var(--surface-card);
}

turbo-frame#library_detail {
  display: block;
  min-height: 100%;
}

.library-pane {
  min-height: 100%;
}

.library-article {
  max-width: 960px;
  margin-inline: auto;
  padding: clamp(2rem, 5vh, 3rem) clamp(1.5rem, 4vw, 2.75rem) 4rem;
}

.library-detail-head {
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.9rem;
}

.library-detail-heading {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(26px * var(--text-scale));
  line-height: 1.32;
  color: var(--navy-primary);
  margin: 0;
  text-wrap: balance;
}

.library-eyebrow {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 0.6rem;
}

/* Back-to-shelf inside the pane: the way out of a book, always visible. */
.library-pane-back {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  min-height: var(--tap);
  margin-bottom: 1rem;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12.5px * var(--text-scale));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-ink);
  text-decoration: none;
}

.library-pane-back .fa-sharp {
  font-size: 1.35em;
}

@media (hover: hover) {
  .library-pane-back:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* ── The back affordance: narrow screens only ────────────────────────────── */

.library-detail-back {
  display: none;
  align-items: center;
  gap: 0.1rem;
  min-height: var(--tap);
  padding: 0.9rem clamp(1.25rem, 5vw, 2rem) 0;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12.5px * var(--text-scale));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-ink);
  text-decoration: none;
}

.library-detail-back .fa-sharp {
  font-size: 1.35em;
}

/* ── Narrow: list-first, detail pushes full-screen ───────────────────────── */

@media (max-width: 899.98px) {
  .library-shell {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .library-master {
    border-right: 0;
    overflow: visible;
  }

  .library-detail {
    display: none;
    overflow: visible;
  }

  .library-shell.is-detail-open .library-master {
    display: none;
  }

  .library-shell.is-detail-open .library-detail {
    display: block;
  }

  .library-detail-back {
    display: inline-flex;
  }

  .library-article {
    padding-top: 1.25rem;
  }
}

/* ── The shelf grid (a category in the pane) ─────────────────────────────── */

.library-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.75rem 1.5rem;
}

.library-book-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  min-width: 0;
}

.library-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 3px rgba(19, 19, 19, 0.12);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  margin-bottom: 0.55rem;
}

.library-book-card:hover .library-cover {
  box-shadow: 0 4px 12px rgba(19, 19, 19, 0.18);
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  .library-cover,
  .library-book-card:hover .library-cover {
    transition: none;
    transform: none;
  }
}

/* The designed fallback: title + author typeset on a tinted spine. */
.library-cover-spine {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.1rem 0.9rem;
  background: linear-gradient(160deg, var(--teal-light) 0%, var(--bg-secondary) 100%);
  border-left: 6px solid var(--teal-fill);
}

.library-spine-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(16px * var(--text-scale));
  line-height: 1.3;
  color: var(--navy-primary);
  text-wrap: balance;
}

.library-spine-author {
  font-family: var(--font-ui);
  font-size: calc(11.5px * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-ink);
}

.library-book-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.35;
  color: var(--text-dark);
}

.library-book-author {
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale));
  color: var(--text-secondary);
}

.library-book-when {
  font-family: var(--font-body);
  font-style: italic;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.45;
  color: var(--teal-ink);
  margin-top: 0.25rem;
}

/* ── Beyond the shelf (URL-only resources) ───────────────────────────────── */

.library-resource-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-resource {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border-light);
  font-size: calc(14px * var(--text-scale));
}

.library-resource-name {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--teal-ink);
  text-decoration: none;
}

.library-resource-name:hover {
  text-decoration: underline;
}

.library-resource-line {
  color: var(--text-dark);
}

/* ── Book detail (in the pane) ───────────────────────────────────────────── */

.library-book-detail {
  display: grid;
  grid-template-columns: minmax(190px, 250px) 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  max-width: 860px;
}

.library-book-detail-cover .library-cover {
  margin-bottom: 0;
}

.library-book-detail-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(28px * var(--text-scale));
  line-height: 1.25;
  color: var(--navy-primary);
  margin: 0 0 0.3rem;
  text-wrap: balance;
}

.library-book-detail-author {
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
}

.library-book-detail-when {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.5;
  color: var(--teal-ink);
  border-left: 3px solid var(--teal-accent);
  padding-left: 1rem;
  margin: 0 0 1.25rem;
}

.library-book-detail-synopsis {
  font-family: var(--font-body);
  font-size: calc(15.5px * var(--text-scale));
  line-height: 1.65;
  color: var(--text-body);
  margin: 0 0 1.25rem;
}

.library-book-note {
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale));
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
  margin: 0.75rem 0 0;
}

/* "View on Amazon" — a quiet bordered action under the synopsis, new window. */
.library-book-detail-actions { margin: 0.35rem 0 0.85rem; }

.library-amazon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--tap, 44px);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--teal-accent);
  color: var(--teal-ink);
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: calc(0.82rem + var(--text-bump));
  text-decoration: none;
  transition: background var(--motion-quick, 150ms) var(--ease-out, ease);
}

@media (hover: hover) {
  .library-amazon-link:hover { background: var(--teal-light); }
}

/* ── Reading pages (in the pane) ─────────────────────────────────────────── */

.reading-article {
  max-width: 680px;
}

.reading-head {
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.9rem;
}

.reading-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(30px * var(--text-scale));
  line-height: 1.25;
  color: var(--navy-primary);
  margin: 0 0 0.5rem;
  text-wrap: balance;
}

.reading-byline {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: calc(14px * var(--text-scale));
  color: var(--text-dark);
  margin: 0 0 0.25rem;
}

.reading-byline-credit {
  font-weight: 400;
  color: var(--text-secondary);
}

.reading-body {
  font-family: var(--font-body);
  font-size: calc(16.5px * var(--text-scale));
  line-height: 1.75;
  color: var(--text-body);
}

.reading-body p {
  margin: 0 0 1.1em;
}

.reading-body h2 {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(23px * var(--text-scale));
  line-height: 1.3;
  color: var(--navy-primary);
  margin: 1.8em 0 0.6em;
}

.reading-body h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(19px * var(--text-scale));
  line-height: 1.35;
  color: var(--navy-primary);
  margin: 1.5em 0 0.5em;
}

.reading-body ul,
.reading-body ol {
  margin: 0 0 1.1em;
  padding-left: 1.4em;
}

.reading-body li {
  margin-bottom: 0.5em;
}

.reading-body blockquote {
  font-family: var(--font-heading);
  font-size: calc(17.5px * var(--text-scale));
  line-height: 1.7;
  color: var(--navy-primary);
  border-left: 3px solid var(--teal-accent);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 1.5em 0;
}

.reading-body blockquote footer {
  font-family: var(--font-body);
  font-size: calc(13.5px * var(--text-scale));
  color: var(--text-secondary);
  margin-top: 0.5em;
}

.reading-kicker {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: calc(18px * var(--text-scale));
  color: var(--text-secondary);
}

/* Quiet printed-page provenance markers (unused member-facing; kept for the
   partials' own structure). */
.reading-page {
  font-family: var(--font-ui);
  font-size: calc(11px * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-400);
  white-space: nowrap;
  user-select: none;
}

.reading-copyright {
  font-size: calc(12.5px * var(--text-scale));
  color: var(--text-secondary);
}

.reading-signoff {
  font-family: var(--font-heading);
  font-style: italic;
  color: var(--navy-primary);
}

.reading-figure {
  border: 1px solid var(--border-light);
  background: var(--bg-tertiary);
  padding: 1.1rem 1.25rem;
  margin: 1.5em 0;
  font-size: calc(14px * var(--text-scale));
  line-height: 1.6;
  color: var(--text-secondary);
}

.reading-figure figcaption {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12.5px * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.reading-figure p {
  margin: 0;
}

/* The culture-gap chart, rendered as the two point-of-view cards. */
.reading-povs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5em 0;
}

.reading-pov {
  border: 1px solid var(--border-light);
  background: var(--bg-tertiary);
  padding: 1rem 1.1rem;
}

.reading-pov h3 {
  margin: 0 0 0.6em;
}

.reading-pov-label {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-ink);
  margin: 0.75em 0 0.35em;
}

.reading-pov ul {
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.55;
}

.reading-next {
  border-top: 1px solid var(--border-light);
  margin-top: 2rem;
  padding-top: 1rem;
  font-size: calc(14px * var(--text-scale));
  color: var(--text-secondary);
}

.reading-next a {
  color: var(--teal-ink);
}

/* ── Hub entry point (styled here to keep the hub's own sheet untouched) ── */

.hub-library-link {
  margin: 0.75rem 0 1.25rem;
}

.hub-library-anchor {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: calc(14px * var(--text-scale));
  color: var(--teal-ink);
  text-decoration: none;
  padding: 0.4rem 0.25rem;
}

.hub-library-anchor:hover {
  text-decoration: underline;
}

.hub-library-anchor .fa-sharp {
  align-self: center;
}

.hub-library-sub {
  font-weight: 400;
  color: var(--text-secondary);
}

/* ── Activity panes (shared frame) ───────────────────────────────────────── */

.activity-head {
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2rem;
}

.activity-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(30px * var(--text-scale));
  line-height: 1.25;
  color: var(--navy-primary);
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

.activity-intro p,
.activity-guide-words p,
.activity-guide-words {
  font-family: var(--font-body);
  font-size: calc(15.5px * var(--text-scale));
  line-height: 1.65;
  color: var(--text-body);
}

.activity-intro p,
.activity-guide-words p {
  margin: 0 0 0.9em;
}

.activity-guide-words {
  max-width: 64ch;
  margin: 0 0 1.4rem;
}

.activity-step {
  margin-bottom: 2.75rem;
}

.activity-step-head {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(20px * var(--text-scale));
  color: var(--navy-primary);
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.activity-save-status {
  display: block;
  min-height: 1.4em;
  margin-top: 0.75rem;
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale));
}

.activity-keep-note {
  font-family: var(--font-body);
  font-size: calc(13.5px * var(--text-scale));
  color: var(--text-secondary);
  margin: 1.25rem 0 0;
}

/* The binder's grace note, prominent: its own bordered block, never fine print. */
.activity-grace-note {
  border-left: 3px solid var(--teal-accent);
  background: var(--teal-light);
  padding: 1rem 1.25rem;
  margin-top: 1.4rem;
}

.activity-grace-note p {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: calc(16px * var(--text-scale));
  line-height: 1.65;
  color: var(--navy-primary);
  margin: 0;
}

/* ── Values Clarification: the grid of values ────────────────────────────── */

.values-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
}

.values-custom-area {
  display: contents;
}

.values-option {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border-light);
  background: var(--bg-primary, #fff);
  cursor: pointer;
  position: relative;
  transition: background var(--motion-quick, 150ms) var(--ease-out, ease),
              border-color var(--motion-quick, 150ms) var(--ease-out, ease);
}

.values-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.values-option-name {
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  color: var(--text-dark);
}

.values-option:has(input:checked) {
  border-color: var(--teal-accent);
  background: var(--teal-light);
}

.values-option:has(input:checked) .values-option-name {
  color: var(--teal-ink);
  font-weight: 600;
}

.values-option:has(input:focus-visible) {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

@media (hover: hover) {
  .values-option:hover {
    border-color: var(--teal-accent);
  }
}

.values-write-in-label {
  display: block;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(13px * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.values-write-in-row {
  display: flex;
  gap: 0.5rem;
  max-width: 420px;
}

.values-write-in-input {
  flex: 1;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-light);
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-dark);
  background: var(--bg-primary, #fff);
}

.values-write-in-add {
  min-height: 44px;
  min-width: 64px;
  padding: 0.4rem 1rem;
  border: 1px solid var(--teal-accent);
  background: transparent;
  color: var(--teal-ink);
  font-family: var(--font-ui);
  font-size: calc(14px * var(--text-scale));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--motion-quick, 150ms) var(--ease-out, ease);
}

@media (hover: hover) {
  .values-write-in-add:hover {
    background: var(--teal-light);
  }
}

.values-count {
  font-family: var(--font-body);
  font-size: calc(13.5px * var(--text-scale));
  color: var(--text-secondary);
  min-height: 1.4em;
  margin: 0.9rem 0 0;
}

/* ── Values Clarification: the ranked list ───────────────────────────────── */

.values-rank-empty {
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-secondary);
  border: 1px dashed var(--border-light);
  padding: 1.1rem 1.25rem;
  margin: 0;
}

.values-rank-empty.is-hidden {
  display: none;
}

.values-rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 560px;
}

.values-rank-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  padding: 0.35rem 0.5rem 0.35rem 0.25rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary, #fff);
}

.values-rank-item:first-child {
  border-top: 1px solid var(--border-light);
}

/* SortableJS enhancement: the grip is a real element but not a tab stop
   (buttons are the accessible path). */
.values-rank-drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--gray-400, #9aa4b2);
  cursor: grab;
  touch-action: none;
}

.sortable-ghost {
  opacity: 0.4;
}

.values-rank-ordinal {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(17px * var(--text-scale));
  color: var(--teal-ink);
  min-width: 1.6em;
  text-align: right;
}

.values-rank-name {
  flex: 1;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(18px * var(--text-scale));
  color: var(--navy-primary);
}

.values-rank-tools {
  display: inline-flex;
  gap: 0.25rem;
}

.values-rank-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--navy-primary);
  cursor: pointer;
  transition: background var(--motion-quick, 150ms) var(--ease-out, ease),
              border-color var(--motion-quick, 150ms) var(--ease-out, ease);
}

@media (hover: hover) {
  .values-rank-btn:hover {
    border-color: var(--teal-accent);
    background: var(--teal-light);
  }
}

.values-rank-btn.is-remove {
  color: var(--text-secondary);
}

/* ── Spiritual Growth Plan: the assessment ───────────────────────────────── */

.growth-items {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: growth-item;
}

.growth-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border-light);
  counter-increment: growth-item;
}

.growth-item-statement {
  flex: 1 1 34ch;
  font-family: var(--font-body);
  font-size: calc(15.5px * var(--text-scale));
  line-height: 1.6;
  color: var(--text-body);
  margin: 0;
  max-width: 60ch;
}

.growth-item-statement::before {
  content: counter(growth-item) ". ";
  font-family: var(--font-heading);
  font-weight: 500;
  color: var(--teal-ink);
}

/* The slider: a 1-5 range whose reading is the rubric label, not the
   number. The input itself is 44px tall (the finger target); the visible
   track and thumb sit inside it, squared like the rest of the brand. */

.growth-slider {
  flex: 1 1 260px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.growth-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.growth-range::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border-light);
}

.growth-range::-moz-range-track {
  height: 4px;
  background: var(--border-light);
}

.growth-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -12px;
  background: var(--surface-card);
  border: 2px solid var(--teal-accent);
  border-radius: 0;
}

.growth-range::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: var(--surface-card);
  border: 2px solid var(--teal-accent);
  border-radius: 0;
}

.growth-range:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* The readout: the rubric label is the point; the number stays quietly
   visible beside it. 16px floor for legibility. */
.growth-slider-readout {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-height: 1.5em;
  margin: 0;
}

.growth-slider-num {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(16px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.growth-slider-label {
  font-family: var(--font-body);
  font-size: calc(16px * var(--text-scale));
  line-height: 1.4;
  color: var(--text-dark);
}

/* ── Spiritual Growth Plan: results ──────────────────────────────────────── */

.growth-results.is-awaiting .growth-results-progress {
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-secondary);
  border: 1px dashed var(--border-light);
  padding: 1.1rem 1.25rem;
  margin: 0 0 2rem;
  max-width: 64ch;
}

.growth-areas {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.growth-area {
  border: 1px solid var(--border-light);
  padding: 1.25rem 1.4rem;
  background: var(--bg-primary, #fff);
}

.growth-area-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-bottom: 0.75rem;
}

.growth-area-name {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(19px * var(--text-scale));
  color: var(--navy-primary);
  margin: 0;
}

.growth-area-score {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(13px * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-ink);
  white-space: nowrap;
}

.growth-area-books {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
}

.growth-area-book {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-light);
}

.growth-area-book:last-child {
  border-bottom: 0;
}

.growth-area-book-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: calc(14.5px * var(--text-scale));
  color: var(--teal-ink);
  text-decoration: none;
}

.growth-area-book-title:hover {
  text-decoration: underline;
}

.growth-area-book-author {
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale));
  color: var(--text-secondary);
}

.growth-area-book-when {
  flex-basis: 100%;
  font-family: var(--font-body);
  font-style: italic;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.45;
  color: var(--teal-ink);
}

.growth-area-shelf-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 44px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: calc(14px * var(--text-scale));
  color: var(--teal-ink);
  text-decoration: none;
}

.growth-area-shelf-link:hover {
  text-decoration: underline;
}

.growth-area-actions {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
}

.growth-area-actions-head {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12.5px * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 0.4rem;
}

.growth-area-actions ul {
  margin: 0;
  padding-left: 1.2em;
}

.growth-area-actions li {
  font-family: var(--font-body);
  font-size: calc(14px * var(--text-scale));
  line-height: 1.6;
  color: var(--text-body);
  margin-bottom: 0.35em;
}

/* ── Pane responsive (the pane is narrower than the old full page) ───────── */

@media (max-width: 1200px) {
  .library-book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem 1.25rem;
  }
}

@media (max-width: 860px) {
  .library-book-detail {
    grid-template-columns: 1fr;
  }

  .library-book-detail-cover {
    max-width: 220px;
  }

  .reading-povs {
    grid-template-columns: 1fr;
  }

  .growth-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
  }

  /* The row layout's 34ch flex-basis is horizontal; stacked, it would become
     a 34ch-tall column. Let the statement (and the slider) size to content. */
  .growth-item-statement {
    flex: 0 0 auto;
  }

  .growth-slider {
    flex: 0 0 auto;
    width: 100%;
  }

  .values-rank-tools {
    gap: 0.35rem;
  }
}

@media (max-width: 560px) {
  .library-book-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ══════════════════════════════════════════════════════════════════════════
 * Library search (client-side rail filter)
 * A quiet box at the top of the rail, the Notebook search's visual language.
 * The controller only toggles .library-search-hidden; everything else here
 * is the box itself. Tokens only.
 * ══════════════════════════════════════════════════════════════════════════ */

.library-search-hidden {
  display: none !important;
}

.library-search {
  padding: 0.85rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
}

.library-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.65rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  transition: border-color var(--motion-quick) var(--ease-out);
}

.library-search-box:focus-within {
  border-color: var(--teal-accent);
}

.library-search-box .fa-magnifying-glass {
  color: var(--text-secondary);
  font-size: calc(13px * var(--text-scale));
}

/* The input names its own background and color so dark mode never gets the
   UA's white search field. The input carries the standard focus ring (drawn
   by base.css on :focus-visible); the box answers with a teal border. */
.library-search-input {
  flex: 1;
  min-width: 0;
  min-height: calc(var(--tap) - 2px);
  border: 0;
  background: var(--bg-primary);
  font-family: var(--font-body);
  /* 16px floor: anything smaller makes iOS zoom the page on focus. */
  font-size: calc(16px * var(--text-scale));
  color: var(--text-dark);
}

.library-search-input::placeholder {
  color: var(--text-secondary);
}

/* The button is the one clear affordance; hide WebKit's built-in x. */
.library-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.library-search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--tap) - 10px);
  min-height: calc(var(--tap) - 10px);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
}

@media (hover: hover) {
  .library-search-clear:hover {
    color: var(--teal-accent);
  }
}

/* No matches: one flat line. */
.library-search-empty {
  padding: 1.1rem 1.25rem;
}

.library-search-empty p {
  font-family: var(--font-body);
  font-size: calc(13.5px * var(--text-scale));
  color: var(--text-secondary);
  margin: 0;
}

/* == The welcome pane (bare /library) ================================== */

.library-welcome-body {
  max-width: 62ch;
}

.library-welcome-body > p {
  color: var(--text-secondary);
  font-size: calc(15.5px * var(--text-scale, 1));
  line-height: 1.65;
}

.library-welcome-groups {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

.library-welcome-group {
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--teal-accent);
  border-radius: 10px;
  background: var(--bg-primary);
}

.library-welcome-group h3 {
  font-family: var(--font-heading);
  font-size: calc(17px * var(--text-scale, 1));
  color: var(--navy-primary);
  margin: 0 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.library-welcome-group h3 i {
  color: var(--teal-accent);
}

.library-welcome-group p {
  margin: 0;
  color: var(--text-secondary);
  font-size: calc(14.5px * var(--text-scale, 1));
  line-height: 1.6;
}

.library-welcome-link {
  color: var(--teal-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.library-welcome-hint {
  color: var(--text-secondary);
  font-size: calc(13.5px * var(--text-scale, 1));
}
