/* Little Library — all rules are scoped to .ll-app so the site theme stays untouched. */
.ll-app {
  --ll-bg: #ffffff;
  --ll-surface: #ffffff;
  --ll-surface-2: #f3f2ef;
  --ll-ink: #1e2622;
  --ll-ink-soft: #4b5650;
  --ll-muted: #7c857f;
  --ll-line: #e6e4df;
  --ll-accent: #2f5d4a;
  --ll-accent-strong: #234838;
  --ll-accent-soft: #e2ebe4;
  --ll-on-accent: #ffffff;
  --ll-warn: #b0502e;
  --ll-warn-soft: #f6e3da;
  --ll-missing: #5d4f86;
  --ll-missing-soft: #ebe7f4;
  --ll-shadow-sm: 0 1px 2px rgb(30 38 34 / 6%), 0 2px 6px rgb(30 38 34 / 5%);
  --ll-shadow-md: 0 6px 18px rgb(30 38 34 / 10%), 0 2px 4px rgb(30 38 34 / 6%);
  --ll-shadow-lg: 0 24px 70px rgb(20 28 24 / 22%);
  position: relative;
  color: var(--ll-ink);
  font-size: 15px;
  line-height: 1.5;
}

.ll-app *, .ll-app *::before, .ll-app *::after { box-sizing: border-box; }
.ll-app [hidden] { display: none !important; }
.ll-app button, .ll-app input, .ll-app select { font: inherit; color: inherit; letter-spacing: normal; text-transform: none; margin: 0; }
.ll-app button { cursor: pointer; }
.ll-app h2, .ll-app p { margin-top: 0; }
.ll-app :focus-visible { outline: 2px solid var(--ll-accent); outline-offset: 2px; }
.ll-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- Header ---- */
.ll-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.ll-header-actions { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.ll-search { flex: 1; min-width: 0; max-width: 480px; display: flex; align-items: center; gap: 9px; height: 42px; margin: 0; padding: 0 14px; border-radius: 999px; background: var(--ll-surface); border: 1px solid var(--ll-line); color: var(--ll-muted); transition: border-color .15s, box-shadow .15s; }
.ll-search:focus-within { border-color: var(--ll-accent); box-shadow: 0 0 0 4px rgb(47 93 74 / 15%); }
.ll-app .ll-search input { flex: 1; min-width: 0; height: auto; padding: 0; border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--ll-ink); font-size: 14px; }
.ll-notice { margin: 0 0 20px; padding: 12px 16px; border-radius: 12px; background: var(--ll-accent-soft); color: var(--ll-ink-soft); font-size: 14px; }
.ll-notice a { color: var(--ll-accent); font-weight: 600; }

/* ---- Buttons ---- */
.ll-app .ll-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap; text-decoration: none; box-shadow: none; transition: background .15s, border-color .15s, transform .15s; }
.ll-app .ll-button:active { transform: translateY(1px); }
.ll-app .ll-button:disabled { opacity: .55; cursor: progress; }
.ll-app .ll-button-primary { background: var(--ll-accent); color: var(--ll-on-accent); }
.ll-app .ll-button-primary:hover { background: var(--ll-accent-strong); color: var(--ll-on-accent); }
.ll-app .ll-button-ghost { background: var(--ll-surface); border-color: var(--ll-line); color: var(--ll-ink); }
.ll-app .ll-button-ghost:hover { background: var(--ll-surface-2); color: var(--ll-ink); }
.ll-app .ll-button-small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

/* ---- Toolbar ---- */
.ll-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 24px; border-bottom: 1px solid var(--ll-line); }
.ll-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--ll-surface-2); max-width: 100%; overflow-x: auto; }
.ll-app .ll-tab { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 9px; padding: 7px 14px; background: transparent; color: var(--ll-ink-soft); font-size: 14px; font-weight: 500; white-space: nowrap; box-shadow: none; }
.ll-app .ll-tab:hover { color: var(--ll-ink); background: transparent; }
.ll-app .ll-tab.is-active { background: var(--ll-surface); color: var(--ll-ink); font-weight: 600; box-shadow: var(--ll-shadow-sm); }
.ll-tab-count { padding: 0 7px; border-radius: 999px; background: var(--ll-accent-soft); color: var(--ll-accent); font-size: 12px; font-weight: 600; }
.ll-tab-count.is-warn { background: var(--ll-warn-soft); color: var(--ll-warn); }
.ll-app .ll-header-actions .ll-button { margin-left: auto; flex: 0 0 auto; }
.ll-toolbar-right { display: flex; align-items: center; gap: 12px; }
.ll-results { color: var(--ll-muted); font-size: 13px; white-space: nowrap; }
.ll-cover-status { display: inline-flex; align-items: center; gap: 8px; color: var(--ll-accent); font-size: 13px; font-weight: 500; white-space: nowrap; }
.ll-spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ll-accent-soft); border-top-color: var(--ll-accent); animation: ll-spin .8s linear infinite; vertical-align: -2px; }
@keyframes ll-spin { to { transform: rotate(360deg); } }
.ll-layout-toggle { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--ll-surface-2); }
.ll-app .ll-layout-toggle button { display: grid; place-items: center; width: 32px; height: 30px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--ll-muted); box-shadow: none; }
.ll-app .ll-layout-toggle button[aria-pressed="true"] { background: var(--ll-surface); color: var(--ll-ink); box-shadow: var(--ll-shadow-sm); }

/* ---- Covers ---- */
.ll-app .ll-cover-wrap { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; border-radius: 4px 10px 10px 4px; text-align: left; }
.ll-app .ll-cover, .ll-placeholder { display: block; width: 100%; height: auto; max-width: none; aspect-ratio: 2 / 3; margin: 0; border-radius: 4px 10px 10px 4px; object-fit: cover; background: var(--ll-surface-2); }
.ll-placeholder { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 26% 12% 12% 16%; color: #fff; text-align: left; background: linear-gradient(160deg, var(--c1), var(--c2)); }
.ll-placeholder::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8%; background: linear-gradient(90deg, rgb(0 0 0 / 22%), rgb(255 255 255 / 8%), transparent); }
.ll-placeholder::after { content: ""; position: absolute; left: 16%; right: 12%; top: 58%; height: 1px; background: rgb(255 255 255 / 35%); }
.ll-placeholder-title { font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.ll-placeholder-author { font-size: 11px; opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ll-placeholder.is-pending::after { top: 0; bottom: 0; left: -60%; right: auto; width: 60%; height: auto; background: linear-gradient(90deg, transparent, rgb(255 255 255 / 22%), transparent); animation: ll-shimmer 1.6s ease-in-out infinite; }
@keyframes ll-shimmer { to { left: 110%; } }
.ll-cover-hint { position: absolute; inset: auto 8px 8px 8px; padding: 6px 8px; border-radius: 8px; background: rgb(15 20 18 / 72%); color: #fff; font-size: 12px; font-weight: 500; text-align: center; opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; }
.ll-cover-wrap:hover .ll-cover-hint, .ll-cover-wrap:focus-visible .ll-cover-hint { opacity: 1; transform: none; }

.ll-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--ll-surface); color: var(--ll-accent); font-size: 11.5px; font-weight: 600; line-height: 1.4; box-shadow: var(--ll-shadow-sm); white-space: nowrap; }
.ll-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ll-badge.is-out { color: var(--ll-ink-soft); }
.ll-badge.is-overdue { color: var(--ll-warn); background: var(--ll-warn-soft); }
.ll-badge.is-missing { color: var(--ll-missing); background: var(--ll-missing-soft); }

/* ---- Grid layout ---- */
.ll-layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 32px 22px; }
.ll-layout-grid .ll-book { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ll-layout-grid .ll-cover-wrap { box-shadow: var(--ll-shadow-md); transition: transform .2s, box-shadow .2s; }
.ll-layout-grid .ll-book:hover .ll-cover-wrap { transform: translateY(-4px); box-shadow: var(--ll-shadow-lg); }
.ll-layout-grid .ll-badge { position: absolute; top: 8px; left: 10px; z-index: 1; }
.ll-layout-grid .ll-book-details { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.ll-layout-grid .ll-book-isbn, .ll-layout-grid .ll-list-only { display: none; }
.ll-layout-grid .ll-book-actions .ll-button { width: 100%; }
.ll-app .ll-book-title { width: 100%; padding: 0; border: 0; background: none; box-shadow: none; color: var(--ll-ink); text-align: left; font-weight: 600; font-size: 14.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ll-app .ll-book-title:hover { color: var(--ll-accent); background: none; text-decoration: underline; text-underline-offset: 2px; }
.ll-cover-wrap.is-clickable { cursor: pointer; }
.ll-book-author { color: var(--ll-ink-soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-book-loan { color: var(--ll-muted); font-size: 12.5px; }
.ll-book-loan strong { color: var(--ll-ink); font-weight: 600; }
.ll-book-loan.is-overdue { color: var(--ll-warn); }

/* ---- List layout ---- */
.ll-layout-list { display: flex; flex-direction: column; background: var(--ll-surface); border: 1px solid var(--ll-line); border-radius: 14px; overflow: hidden; }
.ll-layout-list .ll-book { display: grid; grid-template-columns: 44px minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.4fr) 110px; align-items: center; gap: 18px; padding: 12px 18px; border-bottom: 1px solid var(--ll-line); }
.ll-layout-list .ll-book:last-child { border-bottom: 0; }
.ll-layout-list .ll-book:hover { background: #fafaf8; }
.ll-layout-list .ll-cover-wrap { width: 44px; box-shadow: var(--ll-shadow-sm); }
.ll-layout-list .ll-placeholder { padding: 6px 5px 6px 8px; }
.ll-layout-list .ll-placeholder-title { font-size: 7px; -webkit-line-clamp: 4; }
.ll-layout-list .ll-placeholder-author, .ll-layout-list .ll-cover-hint, .ll-layout-list .ll-grid-only { display: none; }
.ll-layout-list .ll-book-details { display: contents; }
.ll-layout-list .ll-book-heading { min-width: 0; }
.ll-app .ll-layout-list .ll-book-title { -webkit-line-clamp: 1; }
.ll-layout-list .ll-book-loan { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.ll-book-isbn { color: var(--ll-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ll-layout-list .ll-book-actions { display: flex; justify-content: flex-end; }

/* ---- History ---- */
.ll-history { background: var(--ll-surface); border: 1px solid var(--ll-line); border-radius: 14px; overflow: hidden; }
.ll-history-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, .9fr) minmax(0, 1fr); gap: 16px; align-items: center; padding: 13px 20px; border-bottom: 1px solid var(--ll-line); font-size: 14px; color: var(--ll-ink-soft); }
.ll-history-row:last-child { border-bottom: 0; }
.ll-history-header { background: var(--ll-surface-2); color: var(--ll-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.ll-history-book { min-width: 0; color: var(--ll-ink); font-weight: 600; }
.ll-history-book span { display: block; margin-top: 2px; color: var(--ll-muted); font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-history-returned { color: var(--ll-muted); }

.ll-empty { grid-column: 1 / -1; padding: 64px 20px; text-align: center; color: var(--ll-muted); }
.ll-empty strong { display: block; margin-bottom: 6px; color: var(--ll-ink); font-size: 20px; }

/* ---- Dialogs ---- */
.ll-dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 28px; border: 1px solid var(--ll-line); border-radius: 18px; background: var(--ll-surface); color: var(--ll-ink); box-shadow: var(--ll-shadow-lg); }
.ll-dialog[open] { animation: ll-pop .18s ease-out; }
@keyframes ll-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.ll-dialog::backdrop { background: rgb(15 20 18 / 45%); backdrop-filter: blur(3px); }
.ll-dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.ll-eyebrow { margin: 0 0 6px; color: var(--ll-accent); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.ll-app .ll-dialog h2 { margin: 0; color: var(--ll-ink); font-size: 24px; font-weight: 700; line-height: 1.2; }
.ll-app .ll-icon-button { flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--ll-surface-2); color: var(--ll-ink-soft); font-size: 22px; line-height: 1; box-shadow: none; }
.ll-field { display: flex; flex-direction: column; gap: 7px; margin: 0 0 16px; color: var(--ll-ink-soft); font-size: 13.5px; font-weight: 600; }
.ll-required { color: var(--ll-warn); }
.ll-field small { color: var(--ll-muted); font-size: 12.5px; font-weight: 400; }
.ll-app .ll-field input, .ll-app .ll-field select { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--ll-line); border-radius: 10px; outline: 0; background: #fff; color: var(--ll-ink); font-size: 15px; font-weight: 400; box-shadow: none; }
.ll-app .ll-field input:focus, .ll-app .ll-field select:focus { border-color: var(--ll-accent); box-shadow: 0 0 0 4px rgb(47 93 74 / 15%); }
.ll-selected-book { margin: -6px 0 20px; padding: 12px 14px; border-radius: 10px; background: var(--ll-accent-soft); color: var(--ll-accent); font-weight: 600; line-height: 1.35; }
.ll-form-error { min-height: 18px; margin: 0; color: var(--ll-warn); font-size: 13px; }
.ll-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.ll-dialog-cover { width: min(560px, calc(100% - 32px)); }
.ll-app .ll-dialog-cover h2 { font-size: 20px; }
.ll-cover-dialog-body { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 24px; align-items: start; }
.ll-cover-dialog-body .ll-cover, .ll-cover-dialog-body .ll-placeholder { box-shadow: var(--ll-shadow-md); }
.ll-cover-dialog-actions { display: flex; flex-direction: column; gap: 10px; }
.ll-cover-dialog-actions p:first-child { margin: 0 0 6px; color: var(--ll-muted); font-size: 13.5px; }

/* Book details */
.ll-dialog-details { width: min(720px, calc(100% - 32px)); }
.ll-details-body { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; align-items: start; }
.ll-details-cover .ll-cover, .ll-details-cover .ll-placeholder { box-shadow: var(--ll-shadow-md); }
.ll-details-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; color: var(--ll-ink-soft); font-size: 13.5px; }
.ll-details-meta strong { color: var(--ll-ink); }
.ll-details-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ll-details-description { color: var(--ll-ink-soft); font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.ll-app .ll-details-description p { margin: 0 0 12px; }
.ll-app .ll-details-empty { color: var(--ll-muted); font-style: italic; }
.ll-app .ll-details-source { margin: 0; color: var(--ll-muted); font-size: 12.5px; }
.ll-app .ll-details-source:empty { display: none; }
.ll-details-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.ll-details-actions:empty { display: none; }

.ll-toast { position: fixed; bottom: 24px; left: 50%; z-index: 100000; max-width: calc(100% - 32px); transform: translate(-50%, 12px); padding: 12px 18px; border-radius: 12px; background: var(--ll-ink); color: #fff; font-size: 14px; font-weight: 500; box-shadow: var(--ll-shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.ll-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .ll-layout-list .ll-book { grid-template-columns: 40px minmax(0, 2fr) minmax(0, 1.4fr) 100px; }
  .ll-layout-list .ll-book-author { display: none; }
  .ll-history-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
  .ll-history-row > :nth-child(3), .ll-history-row > :nth-child(4) { display: none; }
}

@media (max-width: 640px) {
  .ll-search { max-width: none; }
  .ll-toolbar-right { width: 100%; justify-content: space-between; }
  .ll-results { display: none; }
  .ll-layout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; }
  .ll-layout-list .ll-book { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 12px; }
  .ll-layout-list .ll-book-loan { display: none; }
  .ll-history-row { padding: 12px 14px; gap: 10px; }
  .ll-cover-dialog-body { grid-template-columns: 110px minmax(0, 1fr); gap: 16px; }
  .ll-dialog-details { padding: 22px 18px; }
  .ll-details-body { grid-template-columns: 1fr; gap: 18px; }
  .ll-details-cover { width: 120px; }
  .ll-details-actions .ll-button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .ll-app *, .ll-app *::before, .ll-app *::after { animation: none !important; transition: none !important; }
}
