/* ============================================================
   sixyuan.cc/library — family library, mobile-first.
   Self-contained: carries a copy of the shared design tokens so the
   page needs exactly ONE stylesheet (important on this narrow link).
   Theme is synced with the rest of the site via `sixyuan-theme`.
   ============================================================ */
:root {
  color-scheme: light;
  --paper:        #f6f6f3;
  --surface:      #fffefb;
  --surface-2:    #f0f0ec;
  --ink:          #16181d;
  --ink-2:        #4c515b;
  --ink-3:        #8a909b;
  --line:         rgba(22, 24, 29, .12);
  --line-strong:  rgba(22, 24, 29, .24);
  --blue:         #0066cc;
  --blue-ink:     #ffffff;
  --blue-soft:    rgba(0, 102, 204, .08);
  --coral:        #d94f4f;
  --coral-soft:   rgba(255, 107, 107, .12);
  --green:        #1f8a55;
  --green-soft:   rgba(31, 138, 85, .10);
  --amber-soft:   rgba(214, 150, 30, .13);
  --shadow-sm:    0 1px 2px rgba(22, 24, 29, .05);
  --shadow:       0 10px 40px rgba(22, 24, 29, .09);
  --radius:       16px;
  --radius-sm:    10px;
  --font-sans:    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono:    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --tap:          44px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --paper:       #101216;
  --surface:     #171a20;
  --surface-2:   #1e222a;
  --ink:         #eceef3;
  --ink-2:       #a9b0bd;
  --ink-3:       #717987;
  --line:        rgba(236, 238, 243, .13);
  --line-strong: rgba(236, 238, 243, .26);
  --blue:        #62a6ff;
  --blue-ink:    #0a1524;
  --blue-soft:   rgba(98, 166, 255, .12);
  --coral:       #ff8b8b;
  --coral-soft:  rgba(255, 139, 139, .12);
  --green:       #6ccf9c;
  --green-soft:  rgba(108, 207, 156, .12);
  --amber-soft:  rgba(230, 180, 80, .14);
  --shadow:      0 10px 40px rgba(0, 0, 0, .38);
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #101216; --surface: #171a20; --surface-2: #1e222a;
    --ink: #eceef3; --ink-2: #a9b0bd; --ink-3: #717987;
    --line: rgba(236,238,243,.13); --line-strong: rgba(236,238,243,.26);
    --blue: #62a6ff; --blue-ink: #0a1524; --blue-soft: rgba(98,166,255,.12);
    --coral: #ff8b8b; --coral-soft: rgba(255,139,139,.12);
    --green: #6ccf9c; --green-soft: rgba(108,207,156,.12);
    --amber-soft: rgba(230,180,80,.14);
    --shadow: 0 10px 40px rgba(0,0,0,.38); --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ------------------------------ topbar -------------------------------- */
.lib-topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.lib-topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 14px;
  min-height: 54px; display: flex; align-items: center; gap: 10px;
}
.lib-brand { font-weight: 800; font-size: 15px; letter-spacing: .02em; color: var(--ink); white-space: nowrap; }
.lib-brand span { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.lib-top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.lib-top-link { font-size: 13px; color: var(--ink-2); padding: 8px 4px; white-space: nowrap; }
.lib-icon-btn {
  width: var(--tap); height: var(--tap); display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 12px; color: var(--ink-2);
}
.lib-icon-btn svg { width: 19px; height: 19px; }
.lib-icon-btn:hover { background: var(--surface-2); }
.lib-user {
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-height: 34px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-2); font-size: 12px;
}
.lib-main { min-height: calc(100vh - 56px); padding: 18px 0 96px; }

/* ------------------------- generic controls ---------------------------- */
.btn {
  min-height: var(--tap); padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .12s ease, background .12s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--blue); color: var(--blue-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--coral-soft); color: var(--coral); border-color: transparent; }
.btn.soft { background: var(--surface-2); border-color: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.tiny { min-height: 32px; padding: 4px 10px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.end { justify-content: flex-end; }

.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
}
.textarea { min-height: 108px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); outline: 2px solid var(--blue-soft); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field-hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 5px; line-height: 1.45; }
.field-err { color: var(--coral); font-size: 13px; margin: 8px 0; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.muted { color: var(--ink-3); }
.tiny { font-size: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.owner { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge.member { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.warn { background: var(--amber-soft); color: var(--coral); border-color: transparent; }
.mono { font-family: var(--font-mono); letter-spacing: .04em; }

/* ------------------------------- boot ---------------------------------- */
.lib-boot { max-width: 420px; margin: 52px auto; padding: 34px 24px; text-align: center; }
.lib-boot-mark {
  width: 62px; height: 62px; margin: 0 auto 16px; border-radius: 18px;
  display: grid; place-items: center; font-size: 27px; font-weight: 700;
  background: var(--blue-soft); color: var(--blue); border: 1px solid var(--line);
}
.lib-boot h1 { font-size: 21px; }
.lib-boot-line { color: var(--ink-2); margin-top: 10px; }
.lib-boot-sub { color: var(--ink-3); font-size: 12px; margin-top: 6px; }
.lib-boot-bar { height: 3px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 22px; }
.lib-boot-bar i { display: block; width: 38%; height: 100%; background: var(--blue); animation: libsweep 1.3s ease-in-out infinite; }
@keyframes libsweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* --------------------------- login gate -------------------------------- */
/* Keep a side gutter even on narrow phones (<420px): renderGate() has no
   .wrap parent, so a max-width-only card would otherwise touch both edges. */
.gate { width: calc(100% - 24px); max-width: 420px; margin: 26px auto; padding: 22px; }
.gate h1 { font-size: 20px; }
.gate-lead { color: var(--ink-2); font-size: 13px; margin: 8px 0 18px; line-height: 1.6; }
.gate-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.gate-tab { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.gate-tab.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.gate-foot { margin-top: 14px; font-size: 12px; color: var(--ink-3); text-align: center; line-height: 1.7; }

/* ------------------------------- home ---------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.last-family {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--blue-soft); border: 1px solid transparent; border-radius: 14px;
}
.last-family .lf-text { font-size: 13px; color: var(--ink-2); flex: 1; min-width: 150px; }
.last-family b { color: var(--ink); }
.family-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.family-card {
  display: block; width: 100%; text-align: left; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: var(--ink); min-height: 108px;
  transition: transform .12s ease, border-color .12s ease;
}
.family-card:hover { border-color: var(--blue); }
.family-card:active { transform: scale(.99); }
.fc-top { display: flex; align-items: flex-start; gap: 8px; }
.fc-name { font-size: 17px; font-weight: 700; flex: 1; overflow-wrap: anywhere; }
.fc-arrow { color: var(--blue); font-size: 20px; line-height: 1; }
.fc-code { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.fc-code code { font-family: var(--font-mono); color: var(--ink-2); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.fc-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.empty {
  text-align: center; padding: 34px 18px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); color: var(--ink-2);
}
.empty .em-mark { font-size: 34px; display: block; margin-bottom: 8px; }
.empty h2 { font-size: 16px; color: var(--ink); }
.empty p { font-size: 13px; margin: 8px 0 16px; }
.home-note { margin-top: 18px; font-size: 12px; color: var(--ink-3); line-height: 1.7; }

/* ----------------------------- library --------------------------------- */
.lib-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lib-head .lh-main { flex: 1; min-width: 180px; }
.lib-head h1 { font-size: 21px; overflow-wrap: anywhere; }
.lib-head .lh-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.lib-head .lh-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.toolbar {
  position: sticky; top: 54px; z-index: 20;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px);
  padding: 10px 0; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.search-row { display: flex; gap: 8px; align-items: center; }
.search-wrap { position: relative; flex: 1; }
.search-wrap .input { padding-left: 36px; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search-ico svg { width: 17px; height: 17px; display: block; }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding: 9px 0 2px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.filter-row .select { min-width: 116px; width: auto; flex: 0 0 auto; min-height: 38px; font-size: 13px; padding: 6px 28px 6px 10px;
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; }
.filter-row .select.grow { flex: 1 1 130px; min-width: 130px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex: 0 0 auto; }
.seg button { min-height: 32px; min-width: 42px; border: 0; background: transparent; border-radius: 8px; color: var(--ink-2); font-size: 16px; line-height: 1; }
.seg button.is-on { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-sm); }
.result-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); margin: 4px 0 12px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { flex: 1 1 92px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.stat b { display: block; font-size: 19px; line-height: 1.2; }
.stat span { font-size: 11px; color: var(--ink-3); }

/* grid view */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.book-card {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-sm); min-width: 0;
}
.book-card .bc-head { display: flex; align-items: center; gap: 6px; }
.bc-no { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-soft); padding: 2px 7px; border-radius: 7px; }
.bc-no.empty { color: var(--ink-3); background: var(--surface-2); }
.bc-title { font-size: 14px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bc-author { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.bc-tags .tag { font-size: 10px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-tags .tag.cat { background: var(--blue-soft); color: var(--blue); }
.bc-actions { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.bc-actions button { flex: 1; min-height: 34px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; }
.bc-actions button.del { color: var(--coral); }
.bc-body { cursor: pointer; min-height: 62px; }

/* list view */
.book-list { display: flex; flex-direction: column; gap: 8px; }
.book-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-sm);
}
.br-main { min-width: 0; cursor: pointer; }
.br-title { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.br-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.br-tags .tag { font-size: 10px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.br-actions { display: flex; flex-direction: column; gap: 4px; }
.br-actions button { min-height: 32px; min-width: 46px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; }
.br-actions button.del { color: var(--coral); }

/* --------------------------- bottom bar -------------------------------- */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.bottom-bar .btn { flex: 1; }

/* ------------------------------- modal --------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex;
  align-items: flex-end; justify-content: center;
  background: rgba(10, 12, 18, .48); padding: 0;
  animation: libfade .16s ease-out;
}
@keyframes libfade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  animation: libup .2s ease-out; overflow: hidden;
}
@keyframes libup { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.modal-head h2 { font-size: 16px; flex: 1; overflow-wrap: anywhere; }
.modal-x { width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-size: 22px; line-height: 1; }
.modal-body { padding: 14px 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
.modal-foot { display: flex; gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: 0 0 auto; background: var(--surface); }
.modal-foot .btn { flex: 1; }
.notice { padding: 10px 12px; border-radius: 11px; background: var(--blue-soft); color: var(--ink-2); font-size: 12px; line-height: 1.6; margin-bottom: 12px; }
.notice.warn { background: var(--amber-soft); color: var(--coral); }
.notice.ok { background: var(--green-soft); color: var(--green); }

/* diff / preview tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 420px; }
table.tbl th, table.tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.tbl th { background: var(--surface-2); font-weight: 700; color: var(--ink-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.changed { background: var(--amber-soft); font-weight: 600; }
table.tbl td.old { color: var(--ink-3); text-decoration: line-through; }
table.tbl td.new { color: var(--ink); font-weight: 700; }
.kv { display: grid; grid-template-columns: 78px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* import wizard */
.imp-steps { display: flex; gap: 4px; margin-bottom: 14px; }
.imp-steps span { flex: 1; text-align: center; font-size: 11px; padding: 6px 2px; border-radius: 8px; background: var(--surface-2); color: var(--ink-3); }
.imp-steps span.is-on { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.imp-steps span.is-done { background: var(--green-soft); color: var(--green); }
.imp-drop { display: block; padding: 18px; border: 2px dashed var(--line-strong); border-radius: 14px; text-align: center; font-size: 13px; color: var(--ink-2); background: var(--surface-2); }
.imp-drop input { display: block; width: 100%; margin-top: 10px; font-size: 13px; }
.map-list { display: flex; flex-direction: column; gap: 8px; }
.map-row { display: grid; grid-template-columns: 46px minmax(0,1fr) minmax(110px, 150px); gap: 8px; align-items: center; }
.map-col { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); text-align: center; }
.map-sample { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); padding: 8px 9px; border-radius: 9px; }
.map-row .select { min-height: 40px; font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 40px; }
.checkline input { width: 18px; height: 18px; accent-color: var(--blue); }
.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row .mr-main { flex: 1; min-width: 0; }
.member-row .mr-name { font-size: 14px; font-weight: 600; }
.member-row .mr-sub { font-size: 11px; color: var(--ink-3); }

/* toast */
.lib-toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); z-index: 90;
  max-width: min(90vw, 420px); padding: 11px 16px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: 13px; line-height: 1.5;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; text-align: center;
}
.lib-toast.show { opacity: 1; transform: translate(-50%, 0); }
.lib-toast.err { background: var(--coral); color: #fff; }

/* ---------------------------- responsive -------------------------------- */
@media (min-width: 560px) {
  .family-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; max-height: 86vh; max-height: 86dvh; }
  .modal-foot { padding-bottom: 12px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
@media (min-width: 900px) {
  .family-grid { grid-template-columns: repeat(3, 1fr); }
  .lib-main { padding-top: 26px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .filter-row { overflow: visible; }
}
@media (max-width: 400px) {
  .lib-brand span { display: none; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .book-card { padding: 10px; }
  .btn { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
