/* ============================================================
   LIBRARY — books, films and subjects (sources#index / #show)
   The LEDGER look, plus chips on the index, and on an item's page the question
   list: a status dot, the question, hover tools, and an answer box. Status lives
   in the sidebar dashboard, not in a tab row on the page.
   ============================================================ */
.lib-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-3);
  font-size: var(--fs-12);
  text-decoration: none;
}
.lib-chip i { font-size: var(--fs-10); }
.lib-chip:hover { color: var(--text-1); border-color: var(--border-strong); }
.lib-chip.is-active { color: var(--text-1); border-color: var(--text-3); background: var(--surface-2); }

.lib-status.is-queued { background: rgba(255, 255, 255, 0.05); color: var(--text-2); }
.lib-status.is-finished { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
/* In a list row, only a status worth saying shows: Queued is the default, and a finished
   row has its tick and strikethrough already. */
.lib-row .lib-status:is(.is-queued, .is-finished) { display: none; }
.lib-stars { color: var(--gold) !important; letter-spacing: 1px; }

/* Item page */
.lib-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.lib-head-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-18);
}
.lib-head-main { flex: 1 1 auto; min-width: 0; }
/* A cover in place of the kind's icon, at the size of a @@BOOKSUBJECT@@. */
.lib-head-cover { flex: 0 0 auto; width: 76px; height: 112px; overflow: hidden; border-radius: 5px; background: var(--surface-3); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55); }
.lib-head-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* What it is and how long it's been with you, on one quiet line under the title. */
.lib-byline { margin: -2px 0 8px; color: var(--text-2); font-size: var(--fs-13); }
.lib-head-more > summary { list-style: none; }
.lib-head-more > summary::-webkit-details-marker { display: none; }
.lib-menu { display: flex; flex-direction: column; width: 200px; padding: 6px; }
.lib-menu .lib-inline-form { display: block; }
.lib-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-13);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.lib-menu-item i { width: 14px; color: var(--text-3); text-align: center; }
.lib-menu-item:hover { background: var(--surface-3); color: var(--text-1); }
.lib-menu-item.is-danger:hover, .lib-menu-item.is-danger:hover i { background: var(--danger-soft); color: var(--danger-bright); }
.lib-title { margin: 0 0 6px; color: var(--text-1); font-size: var(--fs-22); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; overflow-wrap: anywhere; }
.lib-head-actions { display: flex; gap: 6px; }
.lib-inline-form { display: inline; margin: 0; }

.lib-statusbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 18px; }
.lib-statusbar-sep { width: 1px; height: 16px; margin: 0 8px; background: var(--border); }
.lib-status-btn {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: var(--fs-12);
  cursor: pointer;
}
.lib-status-btn:hover { color: var(--text-1); border-color: var(--border-strong); }
.lib-status-btn.is-active { color: var(--text-1); border-color: var(--text-3); background: var(--surface-2); font-weight: 600; }
.lib-star { padding: 0 1px; border: none; background: none; color: var(--text-3); font-size: var(--fs-16); cursor: pointer; line-height: 1; }
.lib-star.is-on { color: var(--gold); }
.lib-star:hover { color: var(--gold); }

.lib-card .ledger-card-head { flex-wrap: wrap; }
/* Mind › Sources on the home page: the rest of the queue behind "Show N more"
   (calendars/_subcategory_card). */
.sources-more-row > td { border: none; }
tr.sources-more-row > td { padding-bottom: 0; }
tbody.sources-folded[hidden] { display: none; }
/* A source's own task's Details and benefits (sources/show), set apart from Takeaways below. */
.lib-task-card { margin-bottom: 16px; }
.lib-card .lib-copy-all { margin-left: auto; background: none; cursor: pointer; font: inherit; font-size: var(--fs-12); }

.lib-add-questions textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-13);
  line-height: 1.45;
  resize: vertical;
}
.lib-add-questions textarea:focus { outline: none; border-color: var(--text-3); }
.lib-add-questions { padding: 10px 14px 14px; border-top: 1px solid rgba(255, 255, 255, 0.035); }
.lib-add-questions-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

.lib-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-12);
  font-weight: 500;
  cursor: pointer;
}
.lib-btn:hover { color: var(--text-1); border-color: var(--border-strong); }
.lib-btn.is-primary { border-color: #22c55e; background: #22c55e; color: #000; font-weight: 600; }
.lib-btn.is-primary:hover { background: #1eb352; color: #000; }

.lib-takeaways { margin: 0; padding: 4px 0; list-style: none; }
.lib-takeaway {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.035);
  color: inherit;
  text-decoration: none;
}
.lib-takeaways li:first-child .lib-takeaway { border-top-color: transparent; }
.lib-takeaway:hover { background-color: rgba(255, 255, 255, 0.025); }
.lib-takeaway-text { flex: 1 1 auto; min-width: 0; color: var(--text-1); font-size: var(--fs-13); line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.lib-takeaway-date { flex: 0 0 auto; color: var(--text-3); font-size: var(--fs-11); }

/* A source's takeaways as quotes: the serif, a quote's edge, and a feather to send one on
   to Inspirations (a filled one says it's there already). */
.lib-takeaways.is-quotes { padding: 6px 0; }
.lib-quote { position: relative; display: flex; align-items: flex-start; }
.lib-quote .lib-takeaway { flex: 1; min-width: 0; margin: 6px 0 6px 14px; padding: 4px 12px 4px 14px; border-top: none; border-left: 2px solid rgba(255, 255, 255, 0.12); border-radius: 0; }
.lib-quote .lib-takeaway:hover { border-left-color: var(--text-3); background: none; }
.lib-quote .lib-takeaway-text { color: var(--text-1); font-family: Newsreader, Georgia, 'Times New Roman', serif; font-size: 17px; line-height: 1.55; }
.lib-quote .lib-takeaway-date { padding-top: 4px; }
.lib-quote-inspire, .lib-quote-inspired {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin: 8px 10px 0 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  font-size: var(--fs-12);
}
.lib-quote-inspire { color: var(--text-3); cursor: pointer; opacity: 0; transition: opacity var(--dur-fast), color var(--dur-fast), background-color var(--dur-fast); }
.lib-quote:hover .lib-quote-inspire, .lib-quote-inspire:focus-visible { opacity: 1; }
.lib-quote-inspire:hover { background: rgba(167, 139, 250, 0.14); color: #c4b5fd; }
.lib-quote-inspired { color: #a78bfa; }
@media (hover: none) { .lib-quote-inspire { opacity: 0.6; } }
.lib-takeaway-order { display: inline-flex; gap: 2px; margin-left: auto; padding: 2px; border: 1px solid var(--border); border-radius: 999px; }
.lib-takeaway-order a { padding: 2px 9px; border-radius: 999px; color: var(--text-3); font-size: var(--fs-11); text-decoration: none; }
.lib-takeaway-order a:hover { color: var(--text-1); }
.lib-takeaway-order a.is-active { background: var(--surface-3); color: var(--text-1); }

/* Form (modal) */
.lib-form-card {
  background: linear-gradient(180deg, #1c1c1c 0%, #171717 100%);
  border: 1px solid #262626;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.lib-form-title { margin: 0 0 1rem; color: var(--text-1); font-size: var(--fs-16); font-weight: 600; }
.lib-form-errors { margin-bottom: 1rem; padding: 0.6rem 0.8rem; border: 1px solid #a62934; border-radius: 10px; background: rgba(166, 41, 52, 0.15); color: #e08a92; font-size: var(--fs-13); }
.lib-field { flex: 1 1 0; min-width: 0; margin-bottom: 0.9rem; }
.lib-field > label,
.lib-field > .lib-label {
  display: block;
  margin-bottom: 0.35rem;
  color: #8a8a8a;
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lib-form input[type="text"],
.lib-form input[type="date"],
.lib-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.7rem;
  border: 1px solid #2c2c2c;
  border-radius: 9px;
  background-color: #121212;
  color: #e8e8e8;
  font-size: var(--fs-14);
  outline: none;
}
.lib-form input:focus,
.lib-form select:focus { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15); }
/* Scoped to the form: list rows on the index carry .lib-row too and are LEDGER grid rows. */
.lib-form .lib-row { display: flex; flex-wrap: wrap; gap: 0 0.8rem; }
.lib-form .lib-row > .lib-field { min-width: 130px; }
.lib-hint { margin-top: 0.3rem; color: #5a5a5a; font-size: var(--fs-12); }
.lib-kind-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-kind-option input { position: absolute; opacity: 0; pointer-events: none; }
.lib-kind-option span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #2c2c2c;
  border-radius: 999px;
  color: #9a9a9a;
  font-size: var(--fs-13);
  cursor: pointer;
}
.lib-kind-option span i { font-size: var(--fs-11); }
.lib-kind-option input:checked + span { border-color: #22c55e; background: rgba(34, 197, 94, 0.12); color: #e8e8e8; }
.lib-kind-option input:focus-visible + span { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }

/* The source form, in the task form's frame (sources/_form): small labels over the fields
   that need one, pairs of fields side by side, the flags as chips in their own colours. */
.src-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.src-grid.is-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.src-more-body { display: flex; flex-direction: column; gap: 12px; padding-top: 10px; }
.src-form .lib-hint { color: var(--text-3); font-size: var(--fs-11); }
@media (max-width: 560px) {
  .src-grid, .src-grid.is-three { grid-template-columns: 1fr; }
}

.lib-form-actions { display: flex; gap: 8px; margin-top: 0.4rem; }
.lib-form-actions .lib-btn { height: 34px; padding: 0 16px; font-size: var(--fs-14); }

@media (max-width: 720px) {
  .lib-head { flex-wrap: wrap; }
  .lib-head-actions { width: 100%; }
}


.lib-head-actions .lib-pin { background: none; cursor: pointer; font: inherit; font-size: var(--fs-12); }
.lib-head-actions .lib-pin.is-pinned { color: var(--text-1); border-color: var(--text-3); background: var(--surface-2); }

/* ============================================================
   STAT PAGES — /sources/stats and /posts/stats
   Stat tiles, then 12-month column charts. Series colours validated for CVD separation
   against the dark card surface. Each column's hover title is its tooltip, and the same
   numbers sit in the table below. Shared by both pages: the two differ only in what the
   series mean, which each page names in its own legend.
   ============================================================ */
.stat-stats { --stat-x: #3b82f6; --stat-fun: #d97706; --stat-answered: #8b8b95; }
/* The Library's stats in the quieter palette its pages use now; posts keep theirs. */
.stat-stats.is-library { --stat-x: rgba(96, 165, 250, 0.7); --stat-fun: rgba(52, 211, 153, 0.6); --stat-answered: rgba(167, 139, 250, 0.65); }
.stat-stats.is-posts { --stat-x: rgba(52, 211, 153, 0.6); --stat-fun: rgba(245, 158, 11, 0.4); --stat-answered: rgba(96, 165, 250, 0.65); }
.stat-hbars li.is-unset .stat-hbar { background: rgba(255, 255, 255, 0.14); }
.stat-hbars li.is-unset .stat-hbar-label { color: var(--text-3); }
.stat-chart-card.is-empty .ledger-card-head { border-bottom-color: transparent; }
.stat-empty-note { margin: 0; padding: 0 16px 16px; color: var(--text-3); font-size: var(--fs-13); }
.stat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
/* Posts without a Library citation drop that tile. */
.stat-tiles.is-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* A panel whose posts don't carry the thing it counts yet: one line on how to start. */
.stat-hint { margin: 0; padding: 14px 16px 16px; color: var(--text-3); font-size: var(--fs-12); line-height: 1.5; }
.stat-tile {
  padding: 14px 16px;
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  background-color: var(--surface-card);
  background-image: var(--sheen);
}
.stat-tile-label { color: var(--text-3); font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.stat-tile-value { margin: 6px 0 2px; color: var(--text-1); font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-tile-sub { color: var(--text-3); font-size: var(--fs-12); }

.stat-legend { display: inline-flex; gap: 12px; margin-left: auto; color: var(--text-2); font-size: var(--fs-12); }
.stat-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.stat-swatch { width: 10px; height: 10px; border-radius: 3px; }
.stat-swatch.is-x, .stat-seg.is-x { background: var(--stat-x); }
.stat-swatch.is-fun, .stat-seg.is-fun { background: var(--stat-fun); }
.stat-seg.is-answered { background: var(--stat-answered); }

.stat-chart { display: grid; grid-template-columns: repeat(var(--stat-months, 12), minmax(0, 1fr)); gap: 6px; padding: 14px 16px 12px; }
.stat-col { display: flex; flex-direction: column; align-items: stretch; border-radius: 6px; outline: none; }
.stat-col:hover, .stat-col:focus-visible { background: rgba(255, 255, 255, 0.03); }
.stat-col-plot {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 120px;
  padding-top: 16px;
  border-bottom: 1px solid var(--border);
}
.stat-stack { display: flex; flex-direction: column-reverse; gap: 2px; width: min(22px, 70%); min-height: 4px; }
.stat-seg { flex-basis: 0; min-height: 3px; }
.stat-stack .stat-seg:last-child { border-radius: 4px 4px 0 0; }
.stat-col-total { margin-bottom: 3px; color: var(--text-3); font-size: var(--fs-10); font-variant-numeric: tabular-nums; opacity: 0; }
.stat-col:hover .stat-col-total, .stat-col:focus-visible .stat-col-total { opacity: 1; color: var(--text-1); }
.stat-col-label { margin-top: 5px; color: var(--text-3); font-size: var(--fs-10); text-align: center; }

.stat-table-toggle { margin: -4px 0 14px; }
.stat-table-toggle summary { color: var(--text-3); font-size: var(--fs-12); cursor: pointer; }
.stat-table-wrap { overflow-x: auto; margin-top: 8px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.stat-table th { color: var(--text-3); font-weight: 600; }
.stat-table td { color: var(--text-2); }
.stat-table th:first-child, .stat-table td:first-child { text-align: left; }

.stat-stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stat-stats-grid .ledger-card { margin-bottom: 14px; }
.stat-dl { margin: 0; padding: 8px 16px 12px; }
.stat-dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.035); }
.stat-dl > div:first-child { border-top: none; }
.stat-dl dt { color: var(--text-3); font-size: var(--fs-12); }
.stat-dl dd { margin: 0; color: var(--text-1); font-size: var(--fs-12); text-align: right; font-variant-numeric: tabular-nums; }
.stat-hbars { margin: 0; padding: 10px 16px 14px; list-style: none; }
.stat-hbars li { display: grid; grid-template-columns: 90px minmax(0, 1fr) 28px; align-items: center; gap: 10px; padding: 4px 0; }
.stat-hbar-label { color: var(--text-2); font-size: var(--fs-12); white-space: nowrap; }
.stat-hbar-label i { width: 14px; color: var(--text-3); font-size: var(--fs-10); }
.stat-hbar-track { height: 8px; }
.stat-hbar { display: block; height: 100%; min-width: 4px; border-radius: 0 4px 4px 0; background: var(--stat-answered); }
.stat-hbar-value { color: var(--text-1); font-size: var(--fs-12); text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .stat-tiles, .stat-tiles.is-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-stats-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-chart { gap: 3px; padding: 12px 10px 10px; }
  .stat-dl > div { flex-direction: column; gap: 2px; }
  .stat-dl dd { text-align: left; }
}

/* Library scheduling: the Scheduled strip on an item's page, and the Schedule pop-up. */
.lib-scheduled { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 16px; }
.lib-scheduled-label { color: var(--text-3); font-size: var(--fs-12); margin-right: 2px; }
.lib-scheduled-item { text-decoration: none; }
.lib-scheduled-item:hover { color: var(--text-1); }
.lib-scheduled-item.is-done { color: #4ade80; background: rgba(34, 197, 94, 0.1); }
.lib-scheduled-item.is-past:not(.is-done) { opacity: 0.55; }
.lib-optional { color: #555; font-weight: 400; letter-spacing: 0; text-transform: none; }
.lib-form input[type="time"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.7rem;
  border: 1px solid #2c2c2c;
  border-radius: 9px;
  background-color: #121212;
  color: #e8e8e8;
  font-size: var(--fs-14);
  outline: none;
}
.lib-place-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.lib-place-chips .lib-chip { background: none; cursor: pointer; font: inherit; font-size: var(--fs-12); }

.task-source-chip {
  margin-left: 0.4rem;
  padding: 1px 5px;
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 3px;
  background: rgba(217, 119, 6, 0.1);
  color: #f59e0b;
  font-size: var(--fs-11);
  text-decoration: none;
  vertical-align: middle;
  white-space: nowrap;
}
.task-source-chip i { font-size: var(--fs-10); }
.task-source-chip:hover { background: rgba(217, 119, 6, 0.2); }
/* The lead-ins before a title — a source's kind ("Book:"), a thing's name ("1st floor:") — are
   labels, not part of the title (tasks/_task_row), so they take the quieter label colour; a
   colon typed into a title stays the title's colour. A linked one underlines on hover. */
.task-source-prefix { color: var(--text-3) !important; font-weight: 500; }
/* A Library item's subject and a thing's task's thing, after the title (tasks/_task_row):
   a quiet tag, lighter than the date chips beside it. */
.task-row .task-tag-pill { font-weight: 500; color: var(--text-3); text-decoration: none; }
.task-row a.task-tag-pill:hover { color: var(--text-2); background: rgba(255, 255, 255, 0.11); }
.task-source-prefix:hover { color: var(--text-2) !important; text-decoration: underline !important; }

/* A toast with buttons — the Library's finished toast, the day tasks' undo. The container
   ignores the pointer, so this opts back in; it lives 12s instead of 3.5s and pauses while hovered. */
.source-toast, .action-toast { pointer-events: auto; gap: 10px; padding: 6px 8px 6px 14px; animation-duration: 12s; flex-wrap: nowrap; max-width: calc(100vw - 32px); box-sizing: border-box; }
.source-toast:hover, .source-toast:focus-within,
.action-toast:hover, .action-toast:focus-within { animation-play-state: paused; }
.source-toast.is-persistent { animation: none; }
.source-toast-text strong { font-weight: 600; }
.source-toast-form { display: inline; margin: 0; }
.source-toast-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-12);
  line-height: 24px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.source-toast-btn:hover { background: var(--surface-3); }
.source-toast-btn.is-primary { border-color: #22c55e; background: #22c55e; color: #000; font-weight: 600; }
.source-toast-btn.is-link { border-color: transparent; color: var(--text-2); }
.source-toast-close { padding: 4px 6px; border: none; background: none; color: var(--text-3); cursor: pointer; }
.source-toast-close:hover { color: var(--text-1); }
.source-toast-close i { color: inherit !important; }
/* Phones: the container sat at left: 50%, which capped a toast at half the screen, so it
   stacked tick, text, Undo and × in a narrow column. It spans the screen instead (16px
   each side), and a toast keeps one row: its text takes the room and wraps, the buttons
   stay at the right. */
@media (max-width: 600px) {
  #toast-container { left: 16px !important; right: 16px; transform: none !important; }
  .source-toast, .action-toast { flex-wrap: nowrap; max-width: 100%; }
  .source-toast > span, .action-toast > span { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
}
/* A finished film or book: its stars and a thoughts box on a line of their own. */
.source-toast.has-review { flex-wrap: wrap; width: 420px; }
.source-toast.has-review .source-toast-text { flex: 1; min-width: 0; }
.source-toast-review { display: flex; flex-basis: 100%; align-items: flex-start; gap: 8px; margin: 2px 0 2px; }
.source-toast-stars { display: flex; flex-shrink: 0; height: 30px; align-items: center; }
.source-toast-star { padding: 0 2px; border: none; background: none; color: var(--text-3); font-size: 18px; line-height: 1; cursor: pointer; }
.source-toast-star.is-on, .source-toast-star:hover { color: #d4b84a; }
.source-toast-stars:hover .source-toast-star { color: #d4b84a; }
.source-toast-stars .source-toast-star:hover ~ .source-toast-star { color: var(--text-3); }
.source-toast-thoughts {
  flex: 1; min-width: 0; min-height: 30px; max-height: 120px; padding: 5px 8px; box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2, #121212);
  color: var(--text-1); font: inherit; font-size: var(--fs-13); line-height: 1.4; resize: vertical; outline: none;
}
.source-toast-thoughts:focus { border-color: #22c55e; }
.source-toast-review .source-toast-btn { height: 30px; }

/* ============================================================
   LIBRARY SUBJECTS — the path, the subject's head and subject menus on /sources.
   ============================================================ */
.lib-subject-browser { margin-bottom: 16px; }
.lib-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; margin-bottom: 4px; }
.lib-crumb { color: var(--text-3); font-size: var(--fs-14); text-decoration: none; }
.lib-crumb:hover { color: var(--text-1); }
.lib-crumb.is-current { color: var(--text-1); font-weight: 600; }
.lib-crumb-sep { color: var(--border-strong); font-size: var(--fs-10); }

.lib-segment { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lib-segment-btn { padding: 3px 9px; border-radius: 4px; color: var(--text-3); font-size: var(--fs-12); text-decoration: none; white-space: nowrap; }
.lib-segment-btn:hover { color: var(--text-1); }
.lib-segment-btn.is-active { background: var(--surface-2); color: var(--text-1); }

/* Inside a subject: its name, how far through it you are, and Complete / Reopen. */
.lib-subject-head { margin: 4px 0 12px; }
.lib-subject-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.lib-subject-title { display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0; color: var(--text-1); font-size: var(--fs-22); font-weight: 600; line-height: 1.25; }
.lib-subject-title > span { overflow-wrap: anywhere; }
.lib-subject-icon { color: var(--text-3); font-size: var(--fs-18); }
.lib-subject-actions { display: flex; align-items: center; gap: 6px; }
.lib-subject-actions form { margin: 0; }
.lib-subject-complete-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lib-subject-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 6px 0 0; color: var(--text-3); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.lib-subject-done { display: inline-flex; align-items: center; gap: 5px; color: #4ade80; font-weight: 500; }
.lib-subject-progress { display: block; max-width: 360px; height: 3px; margin-top: 8px; overflow: hidden; border-radius: 2px; background: rgba(255, 255, 255, 0.07); }
.lib-subject-progress > span { display: block; height: 100%; background: rgba(34, 197, 94, 0.6); }
.lib-subject-head.is-complete .lib-subject-title > span { color: var(--text-2); }
.lib-subject-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.lib-subject-add { position: relative; }
.lib-subject-add > summary { list-style: none; }
.lib-subject-add > summary::-webkit-details-marker { display: none; }

.lib-pop { position: relative; }
.lib-pop > summary { list-style: none; cursor: pointer; }
.lib-pop > summary::-webkit-details-marker { display: none; }
.lib-pop-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 260px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-pop);
  box-shadow: var(--shadow-card);
}
.lib-subject-add .lib-pop-panel { left: 0; right: auto; }
.lib-pop-form { display: flex; flex-direction: column; gap: 6px; }
.lib-pop-label { color: var(--text-3); font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.lib-pop-form input[type="text"],
.lib-pop-form select {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-13);
}
.lib-pop-form .lib-btn { align-self: flex-end; }
.lib-pop-delete { width: 100%; margin-top: 10px; color: var(--danger-bright); }
.lib-pop-delete:hover { border-color: var(--danger); color: var(--danger-bright); }
.lib-pop-panel.is-wide { width: 340px; }
.lib-pop-form textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-13);
  resize: vertical;
}
.lib-hint strong { color: var(--text-2); font-weight: 600; }

/* Prompts in the Library list: a copy button in the row. */
/* The Library list grouped by subject: a heading per subject, nested subjects indented under a
   guide line, so the list reads like the subject tree. */
/* No rules in the Library list — between rows, above subjects or down their sides; the
   indent alone says what's inside what. */
.lib-arrange .lib-row { border-top: none; }
.lib-group-head { display: flex; align-items: center; padding: 10px 14px 4px 14px; padding-top: 16px; padding-bottom: 12.5px; }
.lib-group-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  letter-spacing: -0.005em;
}
.lib-group-link:hover { color: var(--text-1); }
.lib-group-icon { color: var(--text-3); font-size: var(--fs-11); }
.lib-group-count { color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.lib-group .ledger-list { padding-top: 0; }

/* A subject's heading carries a checkbox: ticked, the subject is complete, and its name is
   struck through. What's inside stays as it was. */
.lib-group-head .lib-subject-complete { flex: 0 0 auto; margin: 0 8px 0 0; }
.lib-group.is-complete > .lib-group-head .lib-group-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.lib-group.is-complete > .lib-group-head .lib-group-icon { opacity: 0.6; }

/* Drag and drop in the grouped list (library_arrange_controller): hold a row or a subject
   heading, in the Manual order. While dragging, empty lists open up to take a drop. */
.lib-items.is-empty { min-height: 0; padding: 0; }
.lib-arrange.is-dragging-item .lib-items.is-empty { min-height: 30px; margin: 2px 14px 6px 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
/* Dragging a subject: every subject shows a place to drop it inside, even one with no subjects yet. */
.lib-arrange.is-dragging-subject .lib-group > .lib-group-children {
  min-height: 26px;
  margin: 2px 14px 6px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.lib-arrange.is-dragging-subject .lib-group > .lib-group-children:empty::before {
  content: 'Drop a subject here to put it inside';
  display: block;
  padding: 5px 10px;
  color: var(--text-3);
  font-size: var(--fs-11);
}
.lib-drag-ghost { opacity: 0.4; background: var(--surface-3) !important; }

/* "+" to add an item under a row or first in a subject (library_quick_add_controller).
   A row's icon and name line up with a subject heading's at the same level: the icon
   6.5px after the checkbox column, the name 21px after that — the
   heading's checkbox margin, icon and gap. */
.lib-row { grid-template-columns: 22px 27.5px minmax(0, 1fr) auto auto auto; column-gap: 0; align-items: start; }
.lib-row > .ledger-icon { justify-self: start; margin-left: 6.5px; text-align: left; }
.lib-row > .ledger-actions { margin-left: 12px; }
/* The checkbox, icon and buttons centre on the title's first line, as a heading's do on its
   name, not on the whole body — so a one-line title sits level with its icon and a longer one
   starts there. */

.lib-row > .lib-complete { margin-top: 1px; }
.lib-row > .ledger-icon { margin-top: 0.5px; }
.lib-row > .ledger-actions { margin-top: -2.5px; }
.lib-row > .lib-row-cover { align-self: center; }
/* A found cover, at the row's far edge; the kind's icon stays at the left. */
.lib-row-cover { grid-column: 6; display: block; width: 28px; height: 40px; margin-left: 12px; overflow: hidden; border-radius: 3px; background: var(--surface-3); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.lib-row-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lib-row.is-done .lib-row-cover { opacity: 0.55; }
.lib-takeaway-link { text-decoration: none; }
.lib-takeaway-link:hover { color: var(--text-1); }
.lib-row-actions { gap: 2px; }
.lib-row .lib-row-add, .lib-group-add { opacity: 0; }
.lib-row:hover .lib-row-add, .lib-group-head:hover .lib-group-add, .lib-row-add:focus-visible, .lib-group-add:focus-visible { opacity: 1; }
@media (hover: none) { .lib-row .lib-row-add, .lib-group-add { opacity: 0.6; } }
.lib-row-add:hover, .lib-group-add:hover { background: var(--surface-3); color: var(--text-1); }
.lib-group-head .lib-group-delete { margin-left: auto; }
.lib-group-head .lib-group-add { margin-right: 10px; }

/* On a phone the title takes the row's whole width instead of wrapping beside a column of
   icons. Only what says something stays — a set star or ? — under
   the details; tags and delete are on the item's own page. */
@media (max-width: 720px) {
  .lib-row { grid-template-columns: 22px 27.5px minmax(0, 1fr) auto; row-gap: 2px; }
  .lib-row > .lib-row-cover { grid-column: 4; grid-row: 1 / span 2; align-self: center; }
  .lib-row > .lib-row-actions { grid-column: 3; grid-row: 2; justify-self: start; margin-left: -4px; }
  .lib-row > .lib-row-actions:not(:has(.lib-flag[aria-pressed="true"])) { display: none; }
  .lib-row > .lib-row-actions .lib-tool { display: none; }
  .lib-row > .lib-row-actions .lib-flag[aria-pressed="true"] { display: inline-flex; opacity: 1; }
  
}
@media (max-width: 720px) { .lib-row > span:nth-child(4) { display: none; } }

/* The complete checkbox at the left of a Library row (library_complete_controller). */
.lib-complete {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  justify-self: center;
  border: 1.5px solid var(--text-3);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.lib-complete:hover { border-color: var(--text-2); }
.lib-complete:checked {
  border-color: #22c55e;
  background: #22c55e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.lib-complete:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.lib-complete:disabled { opacity: 0.6; }
.lib-row.is-done .ledger-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
/* As on task rows: the four-way arrow says a row or heading can be dragged. Its title and
   name keep the link's pointer — they open it (a press-and-move there still drags). */
.lib-arrange.is-arrangeable li[data-item-id],
.lib-arrange.is-arrangeable .lib-group-head { cursor: move; }
.lib-drag-chosen, .lib-drag-chosen * { cursor: grabbing !important; }

.lib-hashtag { color: #93c5fd; background: rgba(59, 130, 246, 0.1); text-decoration: none; }
.lib-hashtag:hover { color: #bfdbfe; background: rgba(59, 130, 246, 0.18); }

/* Priority and maybe on Library items. Titles stay white — a list of gold and violet
   titles reads as noise — and the set star or ? beside the row says which; a priority
   row also carries a thin gold edge, as a favourite does elsewhere. */
.lib-row.is-priority:not(.is-done) { box-shadow: inset 2px 0 0 rgba(212, 184, 74, 0.75); }
.lib-row .lib-flag { opacity: 0; }
.lib-row:hover .lib-flag, .lib-flag:focus-visible, .lib-flag[aria-pressed="true"] { opacity: 1; }
@media (hover: none) { .lib-row .lib-flag { opacity: 0.6; } }
.lib-flag-priority[aria-pressed="true"] { color: #d4b84a; }
.lib-flag-maybe[aria-pressed="true"] { color: #a5b4fc; }
.lib-flag:hover { background: var(--surface-3); }
.lib-priority-tag { color: #d4b84a; background: rgba(212, 184, 74, 0.12); }
.lib-maybe-tag { color: #a5b4fc; background: rgba(165, 180, 252, 0.12); }

/* The form's Priority / Maybe / For X toggles: one line of plain labels, not field headings. */

.lib-row .lib-row-delete { opacity: 0; }
.lib-row:hover .lib-row-delete, .lib-row-delete:focus-visible { opacity: 1; }
@media (hover: none) { .lib-row .lib-row-delete { opacity: 0.6; } }

/* The inline tag editor on a Library row (library_tags_controller). */
.lib-row .lib-tag-btn { opacity: 0; }
.lib-row:hover .lib-tag-btn, .lib-tag-btn:focus-visible, .lib-tag-btn.has-tags { opacity: 1; }
@media (hover: none) { .lib-row .lib-tag-btn { opacity: 0.6; } }
.lib-tag-btn.has-tags { color: #a855f7; }
.lib-tag-btn:hover { background: var(--surface-3); }
.lib-row-tags { display: contents; }
.lib-tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
}
.lib-tag-pills { display: contents; }
.lib-tag-pill { display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 2px 0 7px; border-radius: 999px; background: rgba(59, 130, 246, 0.14); color: #93c5fd; font-size: var(--fs-11); }
.lib-tag-pill-remove { padding: 0 5px; border: none; background: none; color: inherit; font-size: var(--fs-13); line-height: 1; cursor: pointer; opacity: 0.7; }
.lib-tag-pill-remove:hover { opacity: 1; }
.lib-tag-input { flex: 1; min-width: 120px; padding: 2px 4px; border: none; background: none; color: var(--text-1); font: inherit; font-size: var(--fs-12); outline: none; }
/* Group headings read above their rows (titles are 14px): 17px at the top level, a step
   down for each nesting level, never below 15px. */
.lib-group-link { color: var(--text-1); font-size: 17px; font-weight: 600; gap: 9px; }
.lib-group-link .lib-group-icon { font-size: 14px; }
.lib-group-link .lib-group-count { font-size: var(--fs-13); }
/* Headings keep the rows' rhythm: a row's checkbox sits 17.5px into its 41px, so a heading
   (22px of content) has 6.5px above and 12.5px below and every step down the list is 41px.
   A top-level subject alone gets more room above, as a new section. */

.lib-group.is-first > .lib-group-head { padding-top: 12px; }
/* A subject inside another is the size of the item rows it sits among (only bolder); just the
   top-level subjects, the sections, are bigger. */
.lib-group.is-nested > .lib-group-head .lib-group-link { font-size: var(--fs-14); }
.lib-group.is-nested > .lib-group-head .lib-group-icon { font-size: var(--fs-12); }
.lib-group.is-nested > .lib-group-head { padding-top: 6.5px; }

/* Collapsing a Library heading (library_collapse_controller). */
/* The arrow after a heading's name (and count): down while open,
   right while collapsed. */
.lib-group-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 18px; height: 18px; margin: 0 0 0 4px; padding: 0;
  border: none; border-radius: var(--radius-xs); background: none; color: var(--text-3); font-size: var(--fs-10);
  cursor: pointer;
}
.lib-group-toggle:hover { color: var(--text-1); background: var(--surface-3); }
.lib-group-toggle i { transition: transform var(--dur-fast) ease; }
.lib-group.is-collapsed > .lib-group-head .lib-group-toggle i { transform: rotate(-90deg); }
.lib-group.is-collapsed > ul.lib-items,
.lib-group.is-collapsed > .lib-group-children { display: none; }

/* The × in a subject heading. Subjects keep their names and places, so there is no pencil. */
.lib-group-delete { opacity: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.lib-group-head:hover .lib-group-delete, .lib-group-delete:focus-visible { opacity: 1; }
@media (hover: none) { .lib-group-delete { opacity: 0.6; } }
.lib-group-delete-form { display: contents; }

/* Levels in the Library list. Every checkbox at one level sits in one column, whether it's an
   item's or a subject's: rows and headings share a left gutter (the collapse arrow comes after
   a heading's name), and each level steps in by --lib-step. A subject's own items, and the
   subjects inside it, are its next level. */
.lib-arrange { --lib-gutter: 14px; --lib-step: 24px; }
.lib-arrange .lib-row { padding-left: var(--lib-gutter); }
.lib-arrange .lib-group-head { position: relative; padding-left: var(--lib-gutter); }
/* The row's checkbox is centred in its 22px column; the heading's lines up with it. */
.lib-arrange .lib-group-head > .lib-subject-complete { margin: 0 10px 0 3.5px; }
/* Everything inside a subject — its items and the subjects in it — steps in. */
.lib-group[data-subject-id] > ul.lib-items,
.lib-group[data-subject-id] > .lib-group-children { margin-left: var(--lib-step); }
/* No space after a subject's items (the list style's 4px), so the subject below keeps the rhythm. */
.lib-group[data-subject-id] > ul.lib-items { padding-bottom: 0; }
.lib-arrange.is-dragging-subject .lib-group.is-nested > .lib-group-children { margin-left: 18px; }
/* Library entries at the bottom of a task form's category dropdown. */
.cat-sel-header {
  padding: 8px 12px 4px;
  color: var(--text-3);
  font-size: var(--fs-10);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cat-sel-source-icon { width: 9px; flex-shrink: 0; color: #93c5fd; font-size: 9px; text-align: center; }
.cat-sel-item.type-source .cat-sel-source-icon { color: inherit; opacity: 0.8; }

/* The add row's second box: details kept as the new item's first takeaway. */

/* The add row's third line: creator, link and when it came out, all optional. */

.lib-row .ledger-desc { margin-top: 3px; }
.lib-description { margin: 2px 0 8px; color: var(--text-2); font-size: var(--fs-13); line-height: 1.5; max-width: 70ch; }
.lib-form textarea { width: 100%; box-sizing: border-box; padding: 0.5rem 0.7rem; border: 1px solid #2c2c2c; border-radius: 9px; background-color: #121212; color: #e8e8e8; font: inherit; font-size: var(--fs-14); line-height: 1.45; outline: none; resize: vertical; }
.lib-form textarea:focus { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15); }
/* A kind in the dropdown opens onto the subjects; the row at the top of that list goes back. */
.cat-sel-item.opens::after { content: '›'; margin-left: auto; color: var(--text-3); }
.cat-sel-back {
  padding: 7px 12px;
  color: var(--text-3);
  font-size: var(--fs-13);
  cursor: pointer;
  user-select: none;
}
.cat-sel-back:hover { color: #e0e0e0; background: rgba(255, 255, 255, 0.07); }

/* ============================================================
   LIBRARY SHELVES — Up next as covers (sources/_shelves, _card, _poster): the Movies |
   Books toggle, genre chips, the numbers, the hero, and horizontal shelves.
   ============================================================ */
/* The toggle: one pill that slides to the kind picked (moved on click, before the page arrives). */
.lib-kind-toggle { position: relative; display: flex; margin: 4px 0 16px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); }
.lib-kind-toggle-pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border: 1px solid rgba(34, 197, 94, 0.35); border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.07));
  box-shadow: 0 6px 20px -10px rgba(34, 197, 94, 0.6);
  transition: transform 260ms cubic-bezier(0.3, 0.9, 0.3, 1);
}
.lib-kind-toggle[data-active="book"] .lib-kind-toggle-pill { transform: translateX(100%); }
.lib-kind-toggle-btn {
  position: relative; z-index: 1; display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 12px; border-radius: var(--radius-md); color: var(--text-3); font-size: var(--fs-15, 15px); font-weight: 600;
  letter-spacing: 0.01em; text-decoration: none; white-space: nowrap; transition: color var(--dur-fast);
}
.lib-kind-toggle-btn:hover { color: var(--text-1); }
.lib-kind-toggle-btn.is-active { color: var(--text-1); }
.lib-kind-toggle-btn.is-active i { color: var(--accent); }
.lib-kind-toggle-count { padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); font-size: var(--fs-11); font-variant-numeric: tabular-nums; }
.lib-kind-toggle-btn.is-active .lib-kind-toggle-count { background: rgba(34, 197, 94, 0.18); color: #bbf7d0; }

/* Genres as tabs on a hairline, the picked one underlined in green; the shelves | list
   switch at the row's end. Tabs rather than pills: genres are fixed sections, not tags. */
.lib-toolbar { display: flex; align-items: flex-end; gap: 12px; margin: 0 0 18px; }
.lib-genre-chips { display: flex; flex: 1 1 auto; gap: 22px; min-width: 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.lib-genre-chips::-webkit-scrollbar { display: none; }
.lib-genre-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 6px 0 9px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; color: var(--text-3); font-size: var(--fs-14); font-weight: 500;
  text-decoration: none; white-space: nowrap; transition: color var(--dur-fast), border-color var(--dur-fast);
}
.lib-genre-chip:hover { color: var(--text-1); border-bottom-color: var(--border-strong); }
.lib-genre-chip.is-active { color: var(--text-1); font-weight: 600; border-bottom-color: var(--accent); }
.lib-genre-count { color: var(--text-3); font-size: var(--fs-11); font-weight: 500; font-variant-numeric: tabular-nums; }
.lib-genre-chip.is-active .lib-genre-count { color: #86efac; }
.lib-layout-switch { margin-bottom: 6px; }
.lib-layout-switch { flex: 0 0 auto; margin-left: auto; }
.lib-layout-switch .lib-segment-btn { padding: 4px 9px; font-size: var(--fs-13); }

/* The numbers. */
.lib-stats-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0 0 18px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--border); }
.lib-stats-strip > div { padding: 12px 16px; background: var(--surface-1); }
.lib-stats-strip dt { color: var(--text-3); font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.lib-stats-strip dd { margin: 4px 0 0; color: var(--text-1); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.lib-stats-star { color: #e7c25a; font-size: 18px; }

/* A poster: the cover, or the title set on its subject's hue. */
.lib-poster {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; aspect-ratio: 2 / 3; overflow: hidden;
  padding: 12px; border-radius: var(--radius-md); box-sizing: border-box;
  background:
    radial-gradient(120% 80% at 0% 0%, hsl(var(--poster-h) 60% 42% / 0.55), transparent 60%),
    linear-gradient(165deg, hsl(var(--poster-h) 42% 26%), hsl(calc(var(--poster-h) + 30) 48% 9%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 10px 24px -14px rgba(0, 0, 0, 0.8);
}
.lib-poster.has-cover { padding: 0; background: var(--surface-3); }
.lib-poster-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-poster-mark { position: absolute; top: 10px; right: 10px; color: rgba(255, 255, 255, 0.16); font-size: 42px; }
.lib-poster-title {
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 5;
  color: #fff; font-family: 'Chakra Petch', 'Inter', sans-serif; font-size: 17px; font-style: italic; font-weight: 600;
  line-height: 1.12; letter-spacing: -0.01em; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45); overflow-wrap: anywhere;
}
.lib-poster-byline { margin-top: 6px; color: rgba(255, 255, 255, 0.62); font-size: var(--fs-11); }
.lib-poster.is-hero { padding: 7px; border-radius: var(--radius-sm); }
.lib-poster.is-hero .lib-poster-title { font-size: 11px; -webkit-line-clamp: 4; }
.lib-poster.is-hero .lib-poster-byline { display: none; }
.lib-poster.is-hero .lib-poster-mark { top: 6px; right: 6px; font-size: 20px; }

/* The hero: the top of the queue, and what to do about it. */
.lib-hero {
  position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 18px; align-items: center;
  margin: 0 0 24px; padding: 14px 18px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background:
    radial-gradient(90% 140% at 0% 50%, hsl(var(--poster-h) 55% 30% / 0.42), transparent 65%),
    linear-gradient(120deg, var(--surface-1), var(--surface-2));
}
.lib-hero-backdrop { position: absolute; inset: -40px; background-position: center; background-size: cover; opacity: 0.22; filter: blur(40px) saturate(1.3); pointer-events: none; }
.lib-hero > :not(.lib-hero-backdrop) { position: relative; }
.lib-hero-poster { display: block; transition: transform 200ms ease; }
.lib-hero-poster:hover { transform: translateY(-3px) rotate(-0.6deg); }
.lib-hero-eyebrow { font-size: var(--fs-12); }
.lib-hero-day { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: rgba(34, 197, 94, 0.14); color: #bbf7d0; font-size: var(--fs-11); font-weight: 600; vertical-align: 1px; }
.lib-hero-day.is-late { background: rgba(231, 194, 90, 0.14); color: #e9d58a; }
.lib-hero-title { margin: 1px 0 4px; font-size: 20px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.lib-hero-title a { color: var(--text-1); text-decoration: none; }
.lib-hero-title a:hover { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 4px; }
.lib-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--text-2); font-size: var(--fs-13); }
.lib-hero-flag { color: #e7c25a; }
.lib-hero-desc { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 1; max-width: 70ch; margin: 4px 0 0; color: var(--text-2); font-size: var(--fs-13); line-height: 1.45; }
.lib-hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.lib-hero-actions form { margin: 0; }
.lib-hero .lib-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: var(--fs-13); text-decoration: none; cursor: pointer; }
.lib-hero .lib-btn.is-primary, .lib-shelf-empty .lib-btn.is-primary { border-color: var(--accent); background: var(--accent); color: #04130a; }
.lib-hero .lib-btn.is-primary:hover, .lib-shelf-empty .lib-btn.is-primary:hover { background: #4ade80; color: #04130a; }
.lib-btn.is-quiet { border-color: transparent; background: none; color: var(--text-2); }
.lib-hero-done { display: inline-flex; align-items: center; gap: 7px; margin-left: 6px; color: var(--text-2); font-size: var(--fs-13); cursor: pointer; }
.lib-hero.is-done .lib-hero-title a { color: var(--text-3); text-decoration: line-through; }

/* A shelf: a heading, then a row of cards that scrolls sideways. */
.lib-shelf { margin: 0 0 28px; }
.lib-shelf-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.lib-shelf-title { display: inline-flex; align-items: baseline; gap: 8px; margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.lib-shelf-title a { color: var(--text-1); text-decoration: none; }
.lib-shelf-title a:hover { color: #bbf7d0; }
.lib-shelf-count { color: var(--text-3); font-size: var(--fs-13); font-weight: 500; font-variant-numeric: tabular-nums; }
.lib-shelf-hint { color: var(--text-3); font-size: var(--fs-12); }
.lib-shelf-link { margin-left: auto; color: var(--text-3); font-size: var(--fs-13); text-decoration: none; }
.lib-shelf-link:hover { color: #bbf7d0; }
.lib-shelf-add {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; margin-left: auto;
  border: 1px solid var(--border); border-radius: 50%; color: var(--text-3); font-size: 11px; text-decoration: none;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.lib-shelf-hint + .lib-shelf-add, .lib-shelf-link + .lib-shelf-add { margin-left: 0; }
.lib-shelf-add:hover { border-color: rgba(34, 197, 94, 0.5); color: #bbf7d0; }
.lib-shelf-row {
  display: flex; gap: 16px; margin: 0 -2px; padding: 4px 2px 10px; overflow-x: auto; list-style: none;
  scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}

/* A card on a shelf. */
.lib-card { position: relative; flex: 0 0 150px; scroll-snap-align: start; }
.lib-card-poster { position: relative; display: block; border-radius: var(--radius-md); text-decoration: none; transition: transform 200ms ease, box-shadow 200ms ease; }
.lib-card-poster:hover { transform: translateY(-4px); box-shadow: 0 18px 30px -18px rgba(0, 0, 0, 0.9); }
.lib-card-check {
  position: absolute; top: 8px; left: 8px; z-index: 2; width: 18px; height: 18px; margin: 0; opacity: 0;
  background-color: rgba(0, 0, 0, 0.45); cursor: pointer; transition: opacity var(--dur-fast);
}
.lib-card-check:checked, .lib-hero-done .lib-complete:checked { border-color: var(--accent); background-color: var(--accent); }
.lib-card:hover .lib-card-check, .lib-card-check:focus-visible, .lib-card-check:checked { opacity: 1; }
@media (hover: none) { .lib-card-check { opacity: 0.85; } }
.lib-card-rank {
  position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: var(--fs-11); font-weight: 700; backdrop-filter: blur(6px);
}
/* Dragging covers into order (library-shelves). */
.lib-shelf-row[data-library-shelves-target] .lib-card-poster { cursor: grab; }
.lib-card-ghost { opacity: 0.35; }
.lib-card-chosen, .lib-card-chosen * { cursor: grabbing !important; }
.is-dragging-cover .lib-card-poster:hover { transform: none; box-shadow: none; }
.is-dragging-cover .lib-shelf-row { scroll-snap-type: none; }
.lib-card-flag { position: absolute; top: 8px; right: 8px; color: #e7c25a; font-size: 12px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.lib-card-body { padding: 9px 2px 0; }
.lib-card-title {
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  color: var(--text-1); font-size: var(--fs-13); font-weight: 550; line-height: 1.3; text-decoration: none;
}
.lib-card-title:hover { color: #bbf7d0; }
.lib-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; color: var(--text-3); font-size: var(--fs-11); }
.lib-card-subject { padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-11); text-decoration: none; }
a.lib-card-subject:hover { color: #bbf7d0; }
.lib-card-stars { color: #e7c25a; letter-spacing: 1px; }
.lib-card-quote {
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  margin: 6px 0 0; color: var(--text-2); font-size: var(--fs-12); font-style: italic; line-height: 1.4;
}
.lib-shelf:not(.is-finished) .lib-card.is-done .lib-card-poster { opacity: 0.4; }
.lib-shelf:not(.is-finished) .lib-card.is-done .lib-card-title { color: var(--text-3); text-decoration: line-through; }

/* Nothing of this kind yet. */
.lib-shelf-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 0 26px; padding: 40px 24px; border: 1px dashed var(--border-strong); border-radius: calc(var(--radius-lg) + 4px); text-align: center; }
.lib-shelf-empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 54px; border-radius: 50%; background: rgba(34, 197, 94, 0.12); color: var(--accent); font-size: 22px; }
.lib-shelf-empty-title { margin: 4px 0 0; font-size: 20px; font-weight: 700; }
.lib-shelf-empty-text { max-width: 46ch; margin: 0 0 6px; color: var(--text-2); font-size: var(--fs-14); line-height: 1.5; }
.lib-shelf-empty .lib-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 16px; border-radius: 999px; text-decoration: none; }

@media (max-width: 720px) {
  .lib-stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lib-stats-strip dd { font-size: 20px; }
  /* The poster floats beside the title, and the buttons run the hero's full width under both. */
  .lib-hero { display: block; padding: 12px 14px; }
  .lib-hero::after { content: ''; display: table; clear: both; }
  .lib-hero-poster { float: left; width: 56px; margin: 0 12px 4px 0; }
  .lib-hero-actions { clear: both; padding-top: 4px; }
  .lib-hero-title { font-size: 17px; }
  .lib-hero-desc { display: none; }
  .lib-card { flex-basis: 116px; }
  .lib-poster-title { font-size: 14px; }
  .lib-shelf-hint { display: none; }
}

/* ============================================================
   SOURCE FORM — sources/_form (source_preview_controller): Movie | Book, a live poster,
   the title as its caption, genre chips, finishing it, and More in groups.
   ============================================================ */
.src-form-card { width: min(760px, 100%); }
.sf .sf-body { display: flex; flex-direction: column; gap: 18px; }
.sf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sf-label { display: block; margin-bottom: 6px; color: var(--text-3); font-size: var(--fs-11); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.sf-label .lib-optional { margin-left: 4px; color: var(--text-3); font-weight: 400; letter-spacing: 0; text-transform: none; opacity: 0.8; }
.sf-input, .sf .sf-select {
  width: 100%; height: 38px; padding: 0 12px; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-1); color: var(--text-1); font: inherit; font-size: var(--fs-14); outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
textarea.sf-input { height: auto; min-height: 64px; padding: 9px 12px; line-height: 1.45; resize: vertical; }
.sf-input::placeholder { color: var(--text-3); }
.sf-input:focus, .sf .sf-select:focus { border-color: rgba(34, 197, 94, 0.6); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16); }

/* Movie | Book, as on the Library page. */
.sf-kind { position: relative; display: flex; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); }
.sf-kind-pill {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border: 1px solid rgba(34, 197, 94, 0.35); border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.07)); transition: transform 240ms cubic-bezier(0.3, 0.9, 0.3, 1);
}
.sf-kind[data-active="book"] .sf-kind-pill { transform: translateX(100%); }
.sf-kind-option { position: relative; z-index: 1; display: flex; flex: 1 1 0; cursor: pointer; }
.sf-kind-option input { position: absolute; opacity: 0; pointer-events: none; }
.sf-kind-option span { display: flex; flex: 1; align-items: center; justify-content: center; gap: 8px; padding: 9px 12px; color: var(--text-3); font-size: var(--fs-14); font-weight: 600; transition: color var(--dur-fast); }
.sf-kind-option input:checked + span { color: var(--text-1); }
.sf-kind-option input:checked + span i { color: var(--accent); }
.sf-kind-option input:focus-visible + span { outline: 2px solid rgba(34, 197, 94, 0.5); outline-offset: -2px; border-radius: var(--radius-md); }

/* The poster beside everything about it. */
.sf-top { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 22px; align-items: start; }
.sf.is-inline .sf-top { grid-template-columns: minmax(0, 1fr); }
.sf-poster .lib-poster { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 18px 34px -18px rgba(0, 0, 0, 0.9); }
.sf-poster .lib-poster-title.is-placeholder { opacity: 0.45; }
.sf-cover { display: flex; gap: 6px; margin-top: 8px; }
.sf-cover-btn {
  display: inline-flex; flex: 1 1 auto; white-space: nowrap; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: none; color: var(--text-2); font: inherit; font-size: var(--fs-12); cursor: pointer;
}
.sf-cover-btn:hover { border-color: var(--border-strong); color: var(--text-1); }
.sf-cover-btn.is-remove { flex: 0 0 28px; padding: 0; }
.sf-cover-btn[hidden] { display: none; }
.sf-cover-field { margin-top: 8px; }
.sf-cover-field .sf-input { height: 32px; font-size: var(--fs-12); }
.sf-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* The title as a caption, the flags at its end. */
.sf-title-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); transition: border-color var(--dur-fast); }
.sf-title-row:focus-within { border-color: rgba(34, 197, 94, 0.7); }
.sf-title {
  flex: 1 1 auto; min-width: 0; padding: 6px 0 10px; border: none; background: none; color: var(--text-1); outline: none;
  font: inherit; font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
}
.sf-title::placeholder { color: var(--text-3); font-weight: 600; opacity: 0.6; }
.sf.is-inline .sf-title { font-size: 18px; }
.sf-flags { display: flex; flex: 0 0 auto; gap: 4px; margin: 2px 0 -4px; } /* under the title (sources/_form) */
.sf-flag { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: var(--text-3); cursor: pointer; transition: color var(--dur-fast), background var(--dur-fast); }
.sf-flag input { position: absolute; opacity: 0; pointer-events: none; }
.sf-flag:hover { background: var(--surface-3); color: var(--text-1); }
.sf-flag.is-priority:has(input:checked) { background: rgba(231, 194, 90, 0.14); color: #e7c25a; }
.sf-flag.is-maybe:has(input:checked) { background: rgba(165, 180, 252, 0.14); color: #c7d2fe; }
.sf-flag:has(input:focus-visible) { outline: 2px solid rgba(34, 197, 94, 0.5); }

.sf-byline { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; }
.sf-group .sf-byline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sf-field { min-width: 0; }

/* Genre chips. */
.sf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sf-chip { position: relative; display: inline-flex; cursor: pointer; }
.sf-chip[hidden] { display: none; }
.sf-chip input { position: absolute; opacity: 0; pointer-events: none; }
.sf-chip > span, .sf-chip.is-new {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border: 1px solid var(--border); border-radius: 999px;
  background: none; color: var(--text-2); font: inherit; font-size: var(--fs-13); transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.sf-chip:hover > span, .sf-chip.is-new:hover { border-color: var(--border-strong); color: var(--text-1); }
.sf-chip input:checked + span { border-color: rgba(34, 197, 94, 0.55); background: rgba(34, 197, 94, 0.14); color: #bbf7d0; }
.sf-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.sf-chip.is-other > span { border-style: dashed; }
.sf-chip.is-new { border-style: dashed; color: var(--text-3); cursor: pointer; }
.sf-chip.is-new i { font-size: 10px; }
.sf-new-genre { width: 160px; height: 32px; border-radius: 999px; font-size: var(--fs-13); }
.sf-new-genre[hidden] { display: none; }

.sf-day .sf-input { max-width: 240px; }

/* Incomplete | Watched. */
.sf-status { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-1); }
.sf-status-option { position: relative; cursor: pointer; }
.sf-status-option input { position: absolute; opacity: 0; pointer-events: none; }
.sf-status-option > span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 15px; border-radius: 999px; color: var(--text-3); font-size: var(--fs-13); font-weight: 500; transition: color var(--dur-fast), background var(--dur-fast); }
.sf-status-option input:checked + span { background: var(--surface-3); color: var(--text-1); }
.sf-status-option input[value="finished"]:checked + span { background: rgba(34, 197, 94, 0.16); color: #bbf7d0; }
.sf-status-option input:focus-visible + span { outline: 2px solid rgba(34, 197, 94, 0.5); }

/* Finishing it: stars, the day, what you thought. */
.sf-finish { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid rgba(34, 197, 94, 0.25); border-radius: var(--radius-lg); background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), transparent); }
.sf-finish[hidden] { display: none; }
.sf-finish-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 14px; align-items: end; }
.sf-stars { display: flex; align-items: center; gap: 2px; }
.sf-stars-clear { margin-left: 10px; padding: 0; border: none; background: none; color: var(--text-3); font: inherit; font-size: var(--fs-12); cursor: pointer; }
.sf-stars-clear:hover { color: var(--text-1); }
.sf-star { position: relative; cursor: pointer; }
.sf-star input { position: absolute; opacity: 0; pointer-events: none; }
.sf-star span { display: block; padding: 0 2px; color: var(--surface-3); font-size: 28px; line-height: 1; transition: color var(--dur-fast), transform var(--dur-fast); }
/* Lit up to the one picked; while pointing, up to the one under the pointer instead. */
.sf-star:has(input:checked) span, .sf-star:has(~ .sf-star input:checked) span { color: #e7c25a; }
.sf-stars:hover .sf-star span { color: #e7c25a; }
.sf-stars:hover .sf-star:hover ~ .sf-star span { color: var(--surface-3); }
.sf-star:hover span { transform: scale(1.12); }
.sf-star:has(input:focus-visible) span { outline: 2px solid rgba(34, 197, 94, 0.5); border-radius: 4px; }

/* More, in groups. */
.sf-more > summary { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: var(--fs-13); cursor: pointer; list-style: none; }
.sf-more > summary::-webkit-details-marker { display: none; }
.sf-more > summary i { font-size: 10px; transition: transform var(--dur-fast); }
.sf-more[open] > summary i { transform: rotate(90deg); }
.sf-more > summary:hover { color: var(--text-1); }
.sf-more-body { display: flex; flex-direction: column; gap: 16px; padding-top: 14px; }
.sf-group { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.sf-group > legend { padding: 0 6px; color: var(--text-2); font-size: var(--fs-12); font-weight: 600; }
.sf-toggle { position: relative; display: inline-flex; cursor: pointer; }
.sf-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sf-toggle span { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-2); font-size: var(--fs-13); }
.sf-toggle input:checked + span { border-color: rgba(34, 197, 94, 0.55); background: rgba(34, 197, 94, 0.14); color: #bbf7d0; }

/* Over the older .lib-form field rules this form still carries (for the inline row's card). */
.lib-form.sf input.sf-title, .lib-form.sf input.sf-title:focus { height: auto; padding: 6px 0 10px; border: none; border-radius: 0; background: none; box-shadow: none; font-size: 26px; }
.lib-form.sf.is-inline input.sf-title { font-size: 18px; }
.lib-form.sf input.sf-input, .lib-form.sf textarea.sf-input, .lib-form.sf select.sf-select { border: 1px solid var(--border); border-radius: var(--radius-md); background-color: var(--surface-1); color: var(--text-1); }
.lib-form.sf input.sf-input:focus, .lib-form.sf textarea.sf-input:focus, .lib-form.sf select.sf-select:focus { border-color: rgba(34, 197, 94, 0.6); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16); }

/* The save button says what it does. */
.sf-footer { align-items: center; }
.sf-shortcut { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-size: var(--fs-12); }
.sf-shortcut kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; font: inherit; font-size: 11px; }
.sf-submit {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 20px; border: none; border-radius: 999px;
  background: var(--accent); color: #04130a; font: inherit; font-size: var(--fs-14); font-weight: 650; cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(34, 197, 94, 0.8); transition: background var(--dur-fast), transform var(--dur-fast);
}
.sf-submit:hover { background: #4ade80; }
.sf-submit:active { transform: translateY(1px); }
.sf.is-inline .sf-submit { height: 32px; padding: 0 16px; font-size: var(--fs-13); }

@media (max-width: 640px) {
  .sf-top { grid-template-columns: 84px minmax(0, 1fr); gap: 14px; }
  .sf-poster .lib-poster { padding: 8px; }
  .sf-poster .lib-poster-title { font-size: 12px; }
  .sf-poster .lib-poster-mark { font-size: 22px; }
  .sf-cover-btn { padding: 0 6px; font-size: var(--fs-11); }
  .sf-cover-btn > span { display: none; }
  .sf-title { font-size: 20px; }
  .sf-byline { grid-template-columns: minmax(0, 1fr) 80px; }
  .sf-group .sf-byline, .sf-finish-row { grid-template-columns: 1fr; }
  .sf-shortcut { display: none; }
}

/* ============================================================
   FIND MORE — sources/gallery (SourcePicks): the toggle, a search for anything, this week's
   pick, genre chips and shelves of picks (sources/_pick), each saved in a click.
   ============================================================ */
.gallery-page .ledger-head { align-items: center; }
.gallery-page .ledger-head-left { display: flex; align-items: baseline; gap: 14px; }
.gallery-page .ledger-title { font-size: 26px; }
.gallery-head-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* The search: one wide field, results in a shelf right under it. */
.gallery-search { position: relative; margin: 0 0 14px; }
.gallery-search > i { position: absolute; top: 50%; left: 16px; color: var(--text-3); transform: translateY(-50%); pointer-events: none; }
.gallery-search-input {
  width: 100%; height: 46px; padding: 0 16px 0 44px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-1); color: var(--text-1); font: inherit; font-size: var(--fs-15, 15px); outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.gallery-search-input::placeholder { color: var(--text-3); }
.gallery-search-input:focus { border-color: rgba(34, 197, 94, 0.6); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14); }
turbo-frame#gallery-search { display: block; }
turbo-frame#gallery-search[busy] { opacity: 0.55; transition: opacity 150ms; }
.gallery-results { margin-top: 4px; }
.gallery-results-empty { margin: 0 0 20px; color: var(--text-2); font-size: var(--fs-14); }
.gallery-results-empty a { color: #bbf7d0; }
.gallery-genres { margin: 0 0 20px; flex-wrap: wrap; overflow: visible; }

/* This week's pick. */
.gallery-hero {
  position: relative; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 30px; align-items: center;
  margin: 0 0 30px; padding: 26px; overflow: hidden; border: 1px solid var(--border); border-radius: calc(var(--radius-lg) + 6px);
  background:
    radial-gradient(90% 140% at 0% 40%, hsl(var(--poster-h) 55% 30% / 0.45), transparent 65%),
    linear-gradient(120deg, var(--surface-1), var(--surface-2));
}
.gallery-hero-backdrop { position: absolute; inset: -60px; background-position: center; background-size: cover; opacity: 0.2; filter: blur(48px) saturate(1.3); pointer-events: none; }
.gallery-hero > :not(.gallery-hero-backdrop) { position: relative; }
.gallery-hero-poster .lib-poster { box-shadow: 0 24px 40px -20px rgba(0, 0, 0, 0.95), inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.gallery-hero-eyebrow { font-size: var(--fs-14); }
.gallery-hero-title { margin: 4px 0 8px; font-size: 36px; font-weight: 750; line-height: 1.05; letter-spacing: -0.025em; }
.gallery-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--text-2); font-size: var(--fs-14); }
.gallery-hero-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.gallery-hero-desc { max-width: 64ch; margin: 12px 0 0; color: var(--text-2); font-size: var(--fs-14); line-height: 1.55; }

/* A pick: its score, and Save. */
.pick-card { flex-basis: 158px; }
.pick-poster { cursor: default; }
.pick-poster:hover { transform: none; box-shadow: none; }
.pick-saved-badge { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #04130a; font-size: 11px; }
.pick-card.is-saved .lib-poster { opacity: 0.55; }
.pick-score { margin-top: 3px; color: var(--text-3); font-size: var(--fs-11); }
.pick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.pick-form { display: inline; margin: 0; }
.pick-save {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border: 1px solid rgba(34, 197, 94, 0.45); border-radius: 999px;
  background: rgba(34, 197, 94, 0.12); color: #bbf7d0; font: inherit; font-size: var(--fs-12); font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.pick-save:hover { border-color: var(--accent); background: rgba(34, 197, 94, 0.22); }
.pick-save i { font-size: 10px; }
.pick-save.is-quiet { border-color: var(--border); background: none; color: var(--text-1); }
.pick-save.is-link { border-color: transparent; background: none; color: var(--text-2); }
.pick-actions.is-primary { margin-top: 18px; gap: 8px; }
.pick-actions.is-primary .pick-save { height: 38px; padding: 0 18px; font-size: var(--fs-14); }
.pick-actions.is-primary .pick-form:first-child .pick-save { border-color: var(--accent); background: var(--accent); color: #04130a; box-shadow: 0 8px 20px -10px rgba(34, 197, 94, 0.8); }
.pick-in-library { display: inline-flex; align-items: center; gap: 6px; color: #9fc6ff; font-size: var(--fs-12); font-weight: 600; }
.pick-actions.is-just-saved .pick-in-library { animation: pick-saved 400ms ease; }
@keyframes pick-saved { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.pick-open { color: var(--text-2); font-size: var(--fs-12); text-decoration: underline; text-underline-offset: 2px; }
.pick-more { position: relative; }
.pick-more-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 50%; color: var(--text-3); cursor: pointer; list-style: none; }
.pick-more-btn::-webkit-details-marker { display: none; }
.pick-more-btn:hover, .pick-more[open] .pick-more-btn { border-color: var(--border-strong); color: var(--text-1); }
.pick-more-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: flex; flex-direction: column; min-width: 190px; padding: 5px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-pop); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9);
}
.pick-more-panel form { margin: 0; }
.pick-more-item { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border: none; border-radius: var(--radius-sm); background: none; color: var(--text-1); font: inherit; font-size: var(--fs-13); text-align: left; text-decoration: none; cursor: pointer; }
@media (hover: hover) { .pick-more-item:hover { background: var(--surface-3); } }
.pick-more-item i { width: 14px; color: var(--text-3); text-align: center; }
.gallery-shelf-icon { margin-right: 4px; color: #9fc6ff; font-size: 14px; }
.gallery-shelf .lib-shelf-row { padding-bottom: 14px; }
.gallery-credits { margin: 28px 0 10px; color: var(--text-3); font-size: var(--fs-11); line-height: 1.5; }

@media (max-width: 720px) {
  .gallery-page .ledger-head { flex-wrap: wrap; gap: 10px; }
  .gallery-head-actions { margin-left: 0; }
  .gallery-hero { grid-template-columns: 104px minmax(0, 1fr); gap: 16px; align-items: start; padding: 16px; }
  .gallery-hero-title { font-size: 22px; }
  .gallery-hero-desc { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
  .gallery-hero .pick-actions { grid-column: 1 / -1; }
  .pick-card { flex-basis: 120px; }
  .pick-actions.is-primary .pick-save { height: 34px; padding: 0 14px; font-size: var(--fs-13); }
}

/* Adding something is what the Library's header is mostly for: + Source is its one solid
   button, ahead of + Subject and Stats (sources/index). */
.ledger-new.is-primary { border-color: transparent; background: var(--accent); color: #04130a; font-weight: 600; }
.ledger-new.is-primary:hover { background: var(--accent-bright, #4ade80); color: #04130a; }
.yt-channels-file-label { position: relative; margin-bottom: 0.35rem; }
.lib-pop-delete.is-compact { width: auto; padding: 6px 10px; }

/* A family's heading: its delete and add buttons at the far end. */
.lib-family > .lib-group-head .lib-group-delete, .lib-family > .lib-group-head .lib-group-add { margin-left: auto; }

/* An item's page: the cover as the page's anchor, bigger, with the title set to match. */
.lib-show .lib-head { gap: 20px; margin-bottom: 20px; }
.lib-show .lib-head-cover { width: 112px; height: 168px; border-radius: 6px; }
.lib-show .lib-title { font-size: var(--fs-24); line-height: 1.2; }
@media (max-width: 640px) {
  .lib-show .lib-head-cover { width: 84px; height: 126px; }
}


/* ---- Green, as everywhere else: the Library wore blue for its primary actions, the only
   page that did. (The colours above were blue until this pass.) ---- */

/* ---- The numbers strip: three columns when "Led to posts" has nothing to say ---- */
.lib-stats-strip { grid-template-columns: repeat(var(--stat-cols, 4), minmax(0, 1fr)); }
@media (max-width: 720px) { .lib-stats-strip[style*="--stat-cols: 3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- Up next: "Pick a day" as an icon, so the row fits a phone ---- */
.lib-btn.lib-pick-day { padding: 0 11px; }
@media (max-width: 640px) {
  .lib-hero-actions { flex-wrap: nowrap; }
  .lib-hero-actions .lib-btn { padding: 0 10px; white-space: nowrap; }
  .lib-hero-done { margin-left: 2px; white-space: nowrap; }
}

/* ---- A card's caption: who made it, then subject and stars ---- */
.lib-card-body > .lib-card-byline { overflow: hidden; margin-top: 4px; color: var(--text-3); font-size: var(--fs-11); text-overflow: ellipsis; white-space: nowrap; }
.lib-card-body > .lib-card-byline + .lib-card-meta { margin-top: 3px; }

/* ---- Ideas: a quiet list under the shelves ---- */
.lib-idea-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border: 1px solid var(--border-panel); border-radius: var(--radius-lg); background: var(--surface-card); overflow: hidden; }
.lib-idea { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.lib-idea + .lib-idea { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.lib-idea > i { color: var(--gold-bright); font-size: var(--fs-12); }
.lib-idea-text { flex: 1; min-width: 0; color: var(--text-1); font-size: var(--fs-14); }
.lib-idea-go { flex: none; color: var(--text-3); font-size: var(--fs-12); text-decoration: none; }
.lib-idea-go:hover { color: var(--text-1); text-decoration: underline; text-underline-offset: 3px; }

/* ---- A source's page: a larger cover, and putting it on a day ---- */
.lib-show .lib-head-cover { width: 150px; height: 225px; border-radius: 7px; }
.lib-show .lib-head-icon { width: 150px; height: 225px; font-size: 40px; }
@media (max-width: 640px) { .lib-show .lib-head-cover, .lib-show .lib-head-icon { width: 110px; height: 165px; } }
.lib-show-next { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px; }
.lib-show-next form { margin: 0; }
.lib-show-next-label { margin-right: 4px; color: var(--text-3); font-size: var(--fs-12); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.lib-show-next .lib-btn.is-primary { border-color: var(--accent); background: var(--accent); color: #04130a; }

/* ---- A takeaway's "Make a post", beside "Save as an inspiration" ---- */
.lib-quote-post {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 26px; height: 26px; margin: 8px 2px 0 0; border-radius: 50%;
  color: var(--text-3); font-size: var(--fs-12); text-decoration: none; opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast), background-color var(--dur-fast);
}
.lib-quote:hover .lib-quote-post, .lib-quote-post:focus-visible { opacity: 1; }
.lib-quote-post:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-1); }
@media (hover: none) { .lib-quote-post { opacity: 0.6; } }

/* ---- The form's flags say what they are ---- */
.sf-flag { width: auto; gap: 5px; padding: 0 9px; border-radius: 999px; }
.sf-flag-label { color: var(--text-3); font-size: var(--fs-11); font-weight: 600; }
.sf-flag:has(input:checked) .sf-flag-label { color: var(--text-1); }
.lib-show-next .lib-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; }
/* YouTube channels on the shared popup card: its body without a second card's frame. */
.yt-channels-modal .lib-form-card { margin: 0; padding: 16px; border: none; border-radius: 0; background: none; box-shadow: none; }
.yt-channels-modal .task-form-footer { align-items: center; }
.task-form-card.lib-form.yt-channels-modal { width: auto; max-width: none; margin: 0; padding: 0; }
.yt-channels-modal .lib-form-card { box-sizing: border-box; width: 100%; max-width: none; }
.yt-channels-modal .lib-field textarea { box-sizing: border-box; width: 100%; }

/* ---- Movies / Books, slimmer ----
   As the app's other switches are (the calendar's Month/Week, the Stats tabs, To read/Read):
   a raised neutral pill, no green glow, a line of text tall. The active one's icon keeps
   the accent. On the Library, Find More Sources, and the Source form alike. */
.lib-kind-toggle { padding: 3px; border-radius: var(--radius-md); }
.lib-kind-toggle-pill, .sf-kind-pill {
  top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-3); box-shadow: none;
}
.lib-kind-toggle-btn { gap: 7px; padding: 6px 12px; font-size: var(--fs-13); }
.lib-kind-toggle-btn.is-active .lib-kind-toggle-count { background: rgba(255, 255, 255, 0.08); color: var(--text-2); }
.sf-kind { border-radius: var(--radius-md); }
.sf-kind-option span { gap: 7px; padding: 6px 12px; font-size: var(--fs-13); }

/* Movies | Books as a compact switch at the left, the same kind of control as Rules |
   Values and Month | Week, rather than two full-width bars. */
.lib-kind-toggle { display: inline-flex; width: max-content; border-radius: 999px; margin: 0 0 14px; }
.lib-kind-toggle-btn { flex: 1 1 0; min-width: 118px; padding: 5px 16px; border-radius: 999px; }
.lib-kind-toggle-pill { border-radius: 999px; }

/* Phone: the genre tabs scroll sideways; the right edge fades so Horror and Docs read as
   just out of sight rather than missing. */
@media (max-width: 640px) {
  .lib-genre-chips { padding-right: 28px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
}

/* The modal's save: the round arrow other forms use (.task-form-submit), not a worded pill. */
.sf-submit.is-arrow { gap: 0; width: 40px; height: auto; padding: 8px; border-radius: var(--radius-md) !important; font-size: var(--fs-16); box-shadow: none; }
