/* Shelf module styles. Jost and Source Serif 4 are vendored inside the module
   (ruling 14, @fontsource, SIL Open Font License), never from Google Fonts. */
@font-face { font-family: Jost; font-style: normal; font-weight: 400; font-display: swap; src: url(/shelf/ui/vendor/fonts/jost-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Jost; font-style: normal; font-weight: 500; font-display: swap; src: url(/shelf/ui/vendor/fonts/jost-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Jost; font-style: normal; font-weight: 600 700; font-display: swap; src: url(/shelf/ui/vendor/fonts/jost-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: Jost; font-style: normal; font-weight: 800; font-display: swap; src: url(/shelf/ui/vendor/fonts/jost-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400; font-display: swap; src: url(/shelf/ui/vendor/fonts/source-serif-4-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600 700; font-display: swap; src: url(/shelf/ui/vendor/fonts/source-serif-4-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap; src: url(/shelf/ui/vendor/fonts/source-serif-4-latin-400-italic.woff2) format('woff2'); }
.shelf { --ink: #1C1C1C; --muted: #5E5A55; --paper: #FAF8F4; --cream: #F3EFE7; --navy: #0C1C35; --line: #E7E3DB;
  font-family: Jost, "Avenir Next", "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--paper); padding: 24px; min-height: 100vh; box-sizing: border-box; }
.shelf *, .shelf *::before, .shelf *::after { box-sizing: border-box; }
.shelf h1, .shelf h2, .shelf .serif { font-family: "Source Serif 4", Georgia, serif; }
.shelf button, .shelf a.btn, .shelf input, .shelf select, .shelf textarea { min-height: 44px; font: inherit; }
.shelf button, .shelf a.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0 14px; border-radius: 2px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.shelf button.primary { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.shelf button:disabled { opacity: .5; cursor: not-allowed; }
.shelf :focus-visible { outline: 3px solid #2C4F8C; outline-offset: 2px; }
.shelf-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.shelf-head h1 { margin: 0; font-size: 28px; }
.shelf-head .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.shelf-section { margin: 0 0 26px; }
.shelf-section > h2 { font-family: Jost, sans-serif; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; display: flex; gap: 10px; align-items: center; }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; }
.shelf-binderwrap { position: relative; align-self: start; min-width: 0; }
/* Overlays (viewer, menus, peek, toast) live in their own .shelf host on body. */
.shelf.shelf-ov { padding: 0; min-height: 0; background: none; }
.shelf-viewer .strip .shelf-thumb .typed { display: none; }
.shelf .shelf-binder { position: relative; aspect-ratio: 3 / 4; border-radius: 2px; padding: 14px 14px 52px; border: 0; text-align: left; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; width: 100%; transition: filter 120ms cubic-bezier(0.4, 0, 0.2, 1); }
.shelf .shelf-binderwrap > .star { position: absolute; right: 4px; bottom: 4px; min-width: 44px; background: transparent; border: 0; font-size: 20px; justify-content: center; padding: 0; }
.shelf-binder:hover { filter: brightness(0.92); }
.shelf-binder .cover-name { min-width: 0; width: 100%; }
.shelf-binder .cover-name, .shelf-binder textarea { font-family: Jost, sans-serif; font-weight: 700; font-size: 16px; line-height: 1.2; text-align: left; overflow-wrap: break-word; word-break: normal; hyphens: none; text-transform: none;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.shelf-binder textarea { display: block; width: 100%; height: calc(16px * 1.2 * 3 + 4px); resize: none; background: transparent; border: 0; border-bottom: 2px solid currentColor; color: inherit; padding: 0; min-height: 0; }
.shelf-binder .meta { position: absolute; left: 14px; bottom: 16px; font-size: 12px; opacity: .85; }
.shelf-blank { aspect-ratio: 3 / 4; border: 2px dashed #B9B3AA; background: transparent; color: var(--muted); justify-content: center; width: 100%; }
.shelf-naming { outline: 2px solid var(--navy); outline-offset: 2px; }
.shelf-hint { font-size: 12px; margin-top: 8px; }
.shelf-empty { color: var(--muted); margin: 6px 0; }
.shelf-recent { display: flex; gap: 10px; flex-wrap: wrap; }
.shelf-recent button { max-width: 240px; }
.shelf-recent .two { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-align: left; }
.shelf-panel { border: 1px solid var(--line); background: #fff; padding: 16px; margin: 10px 0 20px; max-width: 640px; }
.shelf-panel label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.shelf-panel input[type=text] { width: 100%; padding: 0 10px; border: 1px solid var(--line); }
.shelf-palettes { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.shelf-palettes button { padding: 4px 8px; }
.shelf-palettes button[aria-pressed=true] { border: 2px solid var(--navy); }
.shelf-swatch { display: inline-flex; }
.shelf-swatch i { display: inline-block; width: 14px; height: 22px; }
.shelf-line { min-height: 22px; color: var(--muted); font-size: 14px; }
.shelf-binderview { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 18px; }
.shelf .shelf-bindername { font-family: Jost, sans-serif; font-weight: 800; font-size: 40px; line-height: 1.1; overflow-wrap: break-word; margin: 0 0 8px; }
.shelf-tabs { display: flex; flex-direction: column; gap: 6px; max-height: 75vh; overflow-y: auto; }
.shelf-tab { justify-content: space-between; text-align: left; width: 100%; flex-direction: column; align-items: flex-start; padding: 8px 12px; }
.shelf-tab .tname { font-weight: 700; font-size: 13px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; }
.shelf-tab .tmeta { font-size: 12px; color: var(--muted); }
.shelf-tab[aria-current=true] { background: var(--navy); color: var(--cream); }
.shelf-tab[aria-current=true] .tmeta { color: #C9D3E6; }
.shelf-tab.drop { outline: 2px dashed var(--navy); }
.shelf-tabrow { display: flex; gap: 4px; }
.shelf-tabrow .shelf-tab { flex: 1; }
.shelf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px; }
.shelf-card { display: flex; flex-direction: column; gap: 6px; background: transparent; border: 0; padding: 0; text-align: left; width: 100%; }
.shelf-card .cardname { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.shelf-card .carddate { font-size: 12px; color: var(--muted); }
.shelf-cardwrap { position: relative; }
.shelf-cardwrap .more { position: absolute; top: 4px; right: 4px; min-width: 44px; justify-content: center; background: rgba(255,255,255,.9); }
.shelf-thumb { position: relative; width: 100%; aspect-ratio: 8.5 / 11; background: #fff; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.shelf-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.shelf-thumb .label { position: absolute; left: 6px; top: 6px; background: var(--navy); color: var(--cream); font-size: 10px; font-weight: 700; padding: 2px 5px; letter-spacing: .05em; }
.shelf-thumb .badge { position: absolute; right: 6px; bottom: 6px; background: #fff; border: 1px solid var(--line); font-size: 10px; padding: 1px 5px; }
.shelf-thumb .opening { position: absolute; inset: 24px 8px 8px; font-family: "Source Serif 4", Georgia, serif; font-size: 9px; line-height: 1.3; white-space: pre-wrap; overflow: hidden; color: #333; }
.shelf-thumb .typed { padding: 8px; font-size: 11px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.shelf-thumb.small { width: 64px; flex: none; }
.shelf-menu { position: absolute; z-index: 5; background: #fff; border: 1px solid var(--line); display: flex; flex-direction: column; min-width: 180px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.shelf-menu button { border: 0; justify-content: flex-start; }
.shelf-toast { position: fixed; z-index: 20; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--navy); color: var(--cream); padding: 12px 18px; display: flex; gap: 12px; align-items: center; animation: shelf-fade 200ms cubic-bezier(0.4, 0, 0.2, 1); }
.shelf-toast button { background: transparent; color: var(--cream); border-color: var(--cream); }
.shelf-dim { position: fixed; inset: 0; background: rgba(12, 28, 53, .55); animation: shelf-fade 200ms cubic-bezier(0.16, 1, 0.3, 1); z-index: 10; }
.shelf-viewer { position: fixed; inset: 3vh 4vw; background: #fff; z-index: 11; display: grid; grid-template-rows: auto 1fr auto; animation: shelf-up 200ms cubic-bezier(0.16, 1, 0.3, 1); }
.shelf-viewer header { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.shelf-viewer header h2 { flex: 1; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.shelf-viewer .body { overflow: auto; padding: 16px 24px; }
.shelf-viewer .body pre { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.shelf-viewer .body img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.shelf-viewer .body img.actual { max-width: none; max-height: none; }
.shelf-viewer .strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; border-top: 1px solid var(--line); }
.shelf-viewer .strip button { flex-direction: column; width: 84px; padding: 4px; }
.shelf-viewer .strip button[aria-current=true] { border: 2px solid var(--navy); }
.shelf-viewer .strip .shelf-thumb { width: 60px; }
.shelf-viewer .strip span { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 76px; }
.shelf-pdf { display: grid; grid-template-columns: 64px 1fr; gap: 12px; }
.shelf-pdfrail { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; max-height: 70vh; overflow-y: auto; }
.shelf-pdfrail button { min-width: 0; justify-content: center; }
.shelf-pdfpages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.shelf-pdfpage { min-height: 200px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.shelf-docx { max-width: 760px; margin: 0 auto; padding: 32px 40px; box-shadow: 0 1px 4px rgba(0,0,0,.15); font-family: "Source Serif 4", Georgia, serif; }
.shelf-docx img { max-width: 100%; }
.shelf-docx table { border-collapse: collapse; }
.shelf-docx td, .shelf-docx th { border: 1px solid var(--line); padding: 4px 8px; }
.shelf-typedcard { max-width: 420px; margin: 40px auto; border: 1px solid var(--line); padding: 24px; text-align: center; }
.shelf-email dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.shelf-email dt { color: var(--muted); }
.shelf-email dd { margin: 0; }
.shelf-results { display: flex; flex-direction: column; gap: 10px; }
.shelf-result { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 8px; width: 100%; }
.shelf-result .shelf-thumb { width: 96px; flex: none; }
.shelf-result mark { background: #FCE7A8; }
.shelf-trashrow { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0; }
.shelf-trashrow .shelf-thumb { width: 40px; flex: none; }
.shelf-trashrow .grow { flex: 1; overflow-wrap: anywhere; }
.shelf-peek { position: fixed; inset: 6vh 20vw; z-index: 12; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.shelf-peek .shelf-thumb { height: 100%; width: auto; }
.shelf-error { color: #8A1C1C; }
.shelf-card, .shelf-binder { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.shelf-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; }
.shelf-tabtools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.shelf-banner { background: var(--navy); color: var(--cream); padding: 10px 14px; margin: 0 0 14px; }
.shelf-binderwrap.dim { opacity: .45; }
.shelf-binder .meta.needs { font-weight: 600; }
.shelf-addtab.drop input { outline: 2px dashed var(--navy); }
.shelf-panel label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 15px; }
.shelf-panel label.check input { min-height: 0; width: 22px; height: 22px; }
.shelf-panel select { min-width: 220px; }
.shelf-shade { width: 44px; justify-content: center; font-weight: 700; }
.shelf-shade[aria-pressed=true] { outline: 3px solid var(--navy); outline-offset: 2px; }
.shelf-thumb table.sheet { position: absolute; inset: 24px 4px 4px; border-collapse: collapse; font-size: 7px; line-height: 1.2; table-layout: fixed; width: calc(100% - 8px); }
.shelf-thumb table.sheet td, .shelf-thumb table.sheet th { border: 1px solid var(--line); padding: 1px 2px; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.shelf-thumb table.sheet th { background: var(--cream); font-weight: 700; }
.shelf-sheetwrap { overflow-x: auto; max-width: 100%; }
.shelf-sheet, .shelf-print table { border-collapse: collapse; font-size: 13px; }
.shelf-sheet th, .shelf-sheet td { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; }
.shelf-sheet thead th, .shelf-sheet tbody th { background: var(--cream); color: var(--muted); font-weight: 600; }
.shelf-sheettabs { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; flex-wrap: wrap; }
.shelf-sheettabs button[aria-current=true] { background: var(--navy); color: var(--cream); }
.shelf-fileto { position: fixed; left: 0; right: 0; bottom: 0; z-index: 13; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0,0,0,.15); padding: 16px; max-height: 85vh; overflow-y: auto; }
.shelf-pages { display: flex; gap: 8px; overflow-x: auto; min-height: 66px; margin: 8px 0; }
.shelf-pages .shelf-thumb, .shelf-sharelist .shelf-thumb { width: 48px; flex: none; }
.shelf-sharelist { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.shelf-sharelist li { display: flex; gap: 10px; align-items: center; }
.shelf-picker { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.shelf-picker label { font-size: 13px; color: var(--muted); }
.shelf-print { display: none; }
@media print {
  body > #shelf, .shelf-ov > :not(.shelf-print) { display: none !important; }
  .shelf.shelf-ov { position: static; }
  .shelf-print { display: block; font-family: "Source Serif 4", Georgia, serif; }
  .shelf-printfile { break-after: page; }
  .shelf-printfile:last-child { break-after: auto; }
  .shelf-printfile h2 { font-family: Jost, sans-serif; font-size: 14px; }
  .shelf-printfile img.page { display: block; width: 100%; max-width: 680px; break-inside: avoid; margin: 0 0 12px; }
  .shelf-printfile pre { white-space: pre-wrap; }
}
@keyframes shelf-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shelf-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Locked mode: the opening status line and its bar (Vault blueprint v2, field 12 motion 1). */
.shelf .shelf-opening { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); background: var(--paper); }
.shelf .shelf-opening p { margin: 0 0 8px; font-size: 14px; }
.shelf .shelf-openbar { height: 4px; background: var(--line); }
.shelf .shelf-openbar i { display: block; height: 100%; background: var(--ink, #1C1C1C); transition: width 200ms linear; }
@media (prefers-reduced-motion: reduce) { .shelf *, .shelf-dim, .shelf-viewer, .shelf-toast { animation: none !important; transition: none !important; } }
@media (max-width: 767px) {
  .shelf { padding: 14px; }
  .shelf-grid { display: flex; flex-direction: column; gap: 8px; }
  .shelf .shelf-binder { aspect-ratio: auto; min-height: 56px; padding: 10px 56px 10px 14px; }
  .shelf-recent > :nth-child(n+4) { display: none; }
  .shelf-binderwrap { align-self: stretch; width: 100%; }
  .shelf-binder .cover-name { -webkit-line-clamp: 2; }
  .shelf-binder .meta { display: none; }
  .shelf .shelf-binderwrap > .star { top: 6px; bottom: auto; }
  .shelf-card .shelf-thumb .typed { display: none; }
  .shelf-blank { aspect-ratio: auto; }
  .shelf-binderview { grid-template-columns: 1fr; }
  .shelf .shelf-bindername { font-size: 28px; }
  .shelf-tabs { flex-direction: row; overflow-x: auto; order: -1; max-height: none; }
  .shelf-tabs .shelf-tabrow, .shelf-tabs > .shelf-tab, .shelf-tabs > form { flex: none; width: 150px; }
  .shelf-cards { display: flex; flex-direction: column; }
  .shelf-card { flex-direction: row; align-items: center; }
  .shelf-card .shelf-thumb { width: 48px; flex: none; }
  .shelf-viewer { inset: 0; }
  .shelf-viewer .strip { display: none; }
  .shelf-desktop-only { display: none !important; }
  .shelf-binder .meta[data-onphone], .shelf-binder .meta.needs { display: block; position: static; margin-top: 4px; }
  .shelf-tabtools { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; background: var(--paper); padding: 8px 14px; margin: 0; border-top: 1px solid var(--line); }
  .shelf-binderview { padding-bottom: 72px; }
  .shelf-toast { bottom: 84px; width: calc(100% - 28px); }
  .shelf-tabtools > button { flex: 1; justify-content: center; }
}
