/* ==========================================================================
   BookFlow — design system
   Clarity · Deference · Depth
   ========================================================================== */

/* ---------- Tokens --------------------------------------------------------- */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --sidebar: rgba(255, 255, 255, .62);
  --material: rgba(242, 242, 247, .78);
  --material-thick: rgba(250, 250, 252, .86);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --fill-3: rgba(118, 118, 128, .07);
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --label-3: #aeaeb2;
  --separator: rgba(60, 60, 67, .13);
  --separator-strong: rgba(60, 60, 67, .26);
  --seg-thumb: #ffffff;

  --blue: #007aff;   --blue-ink: #0066cc;
  --green: #34c759;  --green-ink: #248a3d;
  --orange: #ff9500; --orange-ink: #c93400;
  --red: #ff3b30;    --red-ink: #d70015;
  --indigo: #5856d6; --indigo-ink: #3634a3;
  --purple: #af52de; --purple-ink: #8944ab;
  --teal: #30b0c7;   --teal-ink: #0071a4;
  --pink: #ff2d55;
  --gray: #8e8e93;   --gray-ink: #6e6e73;
  --accent: var(--blue);
  --accent-ink: var(--blue-ink);
  /* Collection meter (validated for color-vision deficiency) */
  --m-avail: #34c759; --m-loan: #007aff; --m-damaged: #ff9500; --m-lost: #ff3b30;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 0 0 .5px rgba(0, 0, 0, .03);
  --shadow: 0 6px 24px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .05);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .12), 0 4px 14px rgba(0, 0, 0, .06);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, .22), 0 8px 24px rgba(0, 0, 0, .08);

  --r-xs: 8px; --r-sm: 10px; --r: 14px; --r-lg: 18px; --r-xl: 24px;

  --ease: cubic-bezier(.25, .1, .25, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-ios: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --spring-soft: cubic-bezier(.3, 1.3, .6, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", "Iowan Old Style", "Palatino Linotype", Georgia, ui-serif, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 256px;
  --gutter: 32px;
  --tabbar-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1c1c1e; --surface-elevated: #2c2c2e; --sidebar: rgba(28, 28, 30, .7);
    --material: rgba(0, 0, 0, .72); --material-thick: rgba(36, 36, 38, .86);
    --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36); --fill-3: rgba(118, 118, 128, .14);
    --label: #f5f5f7; --label-2: #98989d; --label-3: #636366;
    --separator: rgba(84, 84, 88, .55); --separator-strong: rgba(120, 120, 128, .6); --seg-thumb: #636366;
    --blue: #0a84ff; --blue-ink: #409cff; --green: #30d158; --green-ink: #30db5b; --orange: #ff9f0a; --orange-ink: #ffb340;
    --red: #ff453a; --red-ink: #ff6961; --indigo: #5e5ce6; --indigo-ink: #7d7aff; --purple: #bf5af2; --purple-ink: #da8fff;
    --teal: #40c8e0; --teal-ink: #5de6ff; --gray-ink: #aeaeb2;
    --m-avail: #2aa84f; --m-loan: #0a84ff; --m-damaged: #bb8900; --m-lost: #c4302a;
    --shadow-sm: 0 0 0 .5px rgba(255, 255, 255, .06); --shadow: 0 0 0 .5px rgba(255, 255, 255, .07), 0 8px 24px rgba(0, 0, 0, .4);
    --shadow-lg: 0 0 0 .5px rgba(255, 255, 255, .08), 0 18px 50px rgba(0, 0, 0, .6);
    --shadow-xl: 0 0 0 .5px rgba(255, 255, 255, .1), 0 30px 80px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .only-light { display: none !important; }
  :root:not([data-theme="light"]) .only-dark { display: inline-block !important; }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-elevated: #2c2c2e; --sidebar: rgba(28, 28, 30, .7);
  --material: rgba(0, 0, 0, .72); --material-thick: rgba(36, 36, 38, .86);
  --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36); --fill-3: rgba(118, 118, 128, .14);
  --label: #f5f5f7; --label-2: #98989d; --label-3: #636366;
  --separator: rgba(84, 84, 88, .55); --separator-strong: rgba(120, 120, 128, .6); --seg-thumb: #636366;
  --blue: #0a84ff; --blue-ink: #409cff; --green: #30d158; --green-ink: #30db5b; --orange: #ff9f0a; --orange-ink: #ffb340;
  --red: #ff453a; --red-ink: #ff6961; --indigo: #5e5ce6; --indigo-ink: #7d7aff; --purple: #bf5af2; --purple-ink: #da8fff;
  --teal: #40c8e0; --teal-ink: #5de6ff; --gray-ink: #aeaeb2;
  --m-avail: #2aa84f; --m-loan: #0a84ff; --m-damaged: #bb8900; --m-lost: #c4302a;
  --shadow-sm: 0 0 0 .5px rgba(255, 255, 255, .06); --shadow: 0 0 0 .5px rgba(255, 255, 255, .07), 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-lg: 0 0 0 .5px rgba(255, 255, 255, .08), 0 18px 50px rgba(0, 0, 0, .6);
  --shadow-xl: 0 0 0 .5px rgba(255, 255, 255, .1), 0 30px 80px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
:root[data-theme="dark"] .only-light { display: none !important; }
:root[data-theme="dark"] .only-dark { display: inline-block !important; }
.only-dark { display: none; }

/* ---------- Base ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: 400 15px/1.47 var(--font); letter-spacing: -.009em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg { display: block; }
.i { width: 20px; height: 20px; flex: none; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 2000; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 10px; }
.skip:focus { left: 8px; }

/* ---------- App shell ------------------------------------------------------ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 12px 12px; background: var(--sidebar); border-right: .5px solid var(--separator);
  backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  view-transition-name: sidebar; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand img { border-radius: 9px; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.brand strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.brand small { display: block; font-size: 11.5px; color: var(--label-2); line-height: 1.25; }
.side-search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; margin: 0 2px 6px;
  border-radius: 9px; background: var(--fill); color: var(--label-2); font-size: 14px; transition: background .2s;
}
.side-search:hover { background: var(--fill-2); }
.side-search .i { width: 16px; height: 16px; }
.side-search span { flex: 1; text-align: left; }
kbd { font: 500 11px/1 var(--font); padding: 3px 5px; border-radius: 5px; background: var(--fill); color: var(--label-2); }
.side-nav { position: relative; flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.side-label { font-size: 11.5px; font-weight: 600; color: var(--label-3); padding: 14px 10px 4px; letter-spacing: .01em; }
.side-nav a {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--label); transition: background .2s, color .25s;
}
.side-nav a .i { width: 18px; height: 18px; color: var(--accent); transition: color .25s; }
.side-nav a:hover { background: var(--fill-3); }
.side-nav a.active { background: var(--accent); color: #fff; }
.side-nav a.active .i { color: #fff; }
.side-nav.js a.active { background: transparent; }
.side-nav a span { flex: 1; }
.side-indicator {
  position: absolute; left: 4px; right: 4px; top: 0; height: 34px; border-radius: 8px; background: var(--accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .5s var(--spring-soft), opacity .2s; z-index: 0; pointer-events: none;
}
.count {
  font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red);
  color: #fff; font-size: 12px; font-weight: 600; display: inline-grid; place-items: center;
}
.side-foot { display: flex; align-items: center; gap: 6px; padding-top: 10px; border-top: .5px solid var(--separator); }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; transition: background .2s; }
.me:hover { background: var(--fill-3); }
.me span { min-width: 0; }
.me strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { display: block; font-size: 12px; color: var(--label-2); }

.shell { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--gutter); border-bottom: .5px solid transparent; view-transition-name: topbar;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
}
.topbar-title { font-size: 15px; font-weight: 600; opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .35s var(--ease-out); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.app.scrolled .topbar { background: var(--material); border-bottom-color: var(--separator); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.app.scrolled .topbar-title { opacity: 1; transform: none; }
.bell { position: relative; }
.dot {
  position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: #fff; font: 600 11px/17px var(--font); text-align: center; font-style: normal;
  box-shadow: 0 0 0 2px var(--bg);
}
.top-avatar { display: none; }

.main { flex: 1; view-transition-name: main; }
.page { max-width: 1180px; margin: 0 auto; padding: 4px var(--gutter) 56px; }
.page.narrow { max-width: 760px; }
.page.wide { max-width: 1400px; }

.tabbar { display: none; }

/* ---------- Page header ---------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 26px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 2px; }
.large-title { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.025em; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 15px; margin: 0 0 4px -6px; padding: 4px 6px; border-radius: 8px; transition: opacity .2s; }
.back:hover { opacity: .7; }
.back .i { width: 18px; height: 18px; }

/* ---------- Layout helpers ------------------------------------------------- */
.section { margin-top: 36px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 21px; font-weight: 700; letter-spacing: -.018em; }
.section-sub { font-size: 13px; color: var(--label-2); }
.link { color: var(--accent); font-size: 15px; font-weight: 400; transition: opacity .2s; }
.link:hover { opacity: .7; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.hstack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--label-2); }
.faint { color: var(--label-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; } .mb { margin-bottom: 16px; }
.ink-red { color: var(--red-ink); } .ink-green { color: var(--green-ink); } .ink-orange { color: var(--orange-ink); }
.show-mobile { display: none; }

/* ---------- Cards & lists -------------------------------------------------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-title { font-size: 17px; font-weight: 600; letter-spacing: -.012em; }
a.card, .card.hoverable { transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out); }

.list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.list-head { font-size: 13px; color: var(--label-2); padding: 0 16px 6px; text-transform: uppercase; letter-spacing: .02em; font-weight: 500; }
.list-foot { font-size: 13px; color: var(--label-2); padding: 8px 16px 0; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 16px;
  transition: background .2s var(--ease);
}
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--sep-inset, 16px); border-top: .5px solid var(--separator); }
.list.has-icons .row { --sep-inset: 62px; }
.list.has-covers .row { --sep-inset: 72px; }
.list.has-avatars .row { --sep-inset: 64px; }
a.row:hover, button.row:hover, .row.clickable:hover { background: var(--fill-3); }
a.row:active, button.row:active { background: var(--fill); }
button.row { width: 100%; text-align: left; }
.row-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; color: #fff; background: var(--tone, var(--accent)); }
.row-icon .i { width: 19px; height: 19px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row-end { display: flex; align-items: center; gap: 10px; color: var(--label-2); flex: none; font-size: 14px; }
.row-end > .i { width: 16px; height: 16px; color: var(--label-3); }
.row .cover-sm { margin: 2px 0; }

.tone-blue { --tone: var(--blue); --tone-ink: var(--blue-ink); }
.tone-green { --tone: var(--green); --tone-ink: var(--green-ink); }
.tone-orange { --tone: var(--orange); --tone-ink: var(--orange-ink); }
.tone-red { --tone: var(--red); --tone-ink: var(--red-ink); }
.tone-indigo { --tone: var(--indigo); --tone-ink: var(--indigo-ink); }
.tone-purple { --tone: var(--purple); --tone-ink: var(--purple-ink); }
.tone-teal { --tone: var(--teal); --tone-ink: var(--teal-ink); }
.tone-gray { --tone: var(--gray); --tone-ink: var(--gray-ink); }
.tone-pink { --tone: var(--pink); --tone-ink: var(--pink); }

/* ---------- Stat tiles ----------------------------------------------------- */
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px 18px; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out);
}
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, transparent); }
.stat-icon .i { width: 18px; height: 18px; }
.stat-go { width: 16px; height: 16px; color: var(--label-3); transition: transform .3s var(--ease-out); }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { font-size: 13.5px; color: var(--label-2); font-weight: 500; }
.stat-foot { font-size: 12.5px; color: var(--label-2); margin-top: 6px; }

/* ---------- Buttons -------------------------------------------------------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 980px; background: var(--fill); color: var(--label);
  font-size: 14.5px; font-weight: 500; white-space: nowrap; user-select: none;
  transition: transform .2s var(--ease-out), background .2s, opacity .2s, box-shadow .2s, color .2s;
}
.btn .i { width: 17px; height: 17px; }
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-tinted { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent-ink); }
.btn-tinted:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.btn-plain { background: transparent; color: var(--accent-ink); padding: 0 10px; }
.btn-plain:hover { background: var(--fill-3); }
.btn-danger { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red-ink); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 20%, transparent); }
.btn-success { background: var(--green); color: #fff; }
.btn-dark { background: var(--label); color: var(--bg); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 17px; font-weight: 600; border-radius: 14px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.disabled { opacity: .4; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { opacity: 0; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.2px solid currentColor; border-color: var(--spin, var(--label-2)) transparent var(--spin, var(--label-2)) var(--spin, var(--label-2));
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading, .btn-success.is-loading, .btn-dark.is-loading { --spin: rgba(255, 255, 255, .9); }
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--label-2);
  transition: background .2s, transform .2s var(--ease-out), color .2s; flex: none; position: relative;
}
.btn-icon:hover { background: var(--fill); color: var(--label); }
.btn-icon:active { transform: scale(.9); }
.btn-icon.filled { background: var(--fill); }
.btn-icon.accent { color: var(--accent); }

/* ---------- Forms ---------------------------------------------------------- */
.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; align-content: start; }
.field > .label, .label { font-size: 13px; font-weight: 600; color: var(--label-2); }
.field .hint { font-size: 12.5px; color: var(--label-2); }
.field .err { font-size: 12.5px; color: var(--red-ink); display: none; }
.field.has-error .err { display: block; animation: fade-down .25s var(--ease-out); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { box-shadow: 0 0 0 1.5px var(--red); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--fill);
  font-size: 15px; outline: none; -webkit-appearance: none; appearance: none;
  transition: background .2s, box-shadow .25s var(--ease-out);
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--label-3); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: .5; cursor: not-allowed; }
.input:focus, .select:focus, .textarea:focus { background: var(--surface); box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent); }
.sheet .input:focus, .sheet .select:focus, .sheet .textarea:focus { background: var(--surface-elevated); }
.select {
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .btn-icon { position: absolute; right: 4px; top: 4px; }
.input-xl { height: 56px; font-size: 19px; border-radius: 16px; padding: 0 18px; }
.input-wrap .input-xl { padding-right: 60px; }
.input-wrap .input-xl ~ .btn-icon { top: 8px; right: 8px; width: 40px; height: 40px; }
.input-inline { width: 120px; height: 34px; text-align: right; font-variant-numeric: tabular-nums; padding: 0 10px; border-radius: 9px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }

/* Floating-label fields (sign-in) */
.float { position: relative; }
.float .input { height: 56px; padding: 22px 16px 6px; font-size: 17px; border-radius: 14px; }
.float label {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%); transform-origin: left center;
  color: var(--label-2); font-size: 17px; pointer-events: none; transition: transform .25s var(--ease-out), color .25s;
}
.float .input:focus + label, .float .input:not(:placeholder-shown) + label { transform: translateY(-112%) scale(.72); }
.float .input:focus + label { color: var(--accent); }
.float .btn-icon { position: absolute; right: 10px; top: 10px; }

/* iOS switch */
.switch { position: relative; display: inline-flex; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-2); transition: background .3s var(--ease); }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 999px; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
  transition: transform .4s var(--spring), width .25s var(--ease-out), left .25s var(--ease-out);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:active + span::after { width: 33px; }
.switch input:checked:active + span::after { left: -4px; }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* Segmented control */
.segmented {
  position: relative; display: inline-flex; padding: 2px; border-radius: 10px; background: var(--fill); max-width: 100%;
  overflow-x: auto; scrollbar-width: none; isolation: isolate;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented > a, .segmented > button {
  position: relative; z-index: 1; flex: 1 0 auto; padding: 6px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  text-align: center; white-space: nowrap; color: var(--label); transition: opacity .2s, transform .2s;
}
.segmented > .active { font-weight: 600; background: var(--seg-thumb); box-shadow: 0 3px 8px rgba(0, 0, 0, .1), 0 1px 1px rgba(0, 0, 0, .04); }
.segmented.js > .active { background: transparent; box-shadow: none; }
.segmented > :active { transform: scale(.96); }
.seg-thumb {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 0; border-radius: 8px; background: var(--seg-thumb);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .1), 0 1px 1px rgba(0, 0, 0, .04);
  transition: transform .45s var(--spring-soft), width .45s var(--spring-soft);
}
.segmented.lg > a, .segmented.lg > button { padding: 9px 22px; font-size: 15px; }
.segmented.block { display: flex; }

/* Search field */
.searchbar {
  position: relative; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 6px 0 11px;
  border-radius: 12px; background: var(--fill); transition: background .25s, box-shadow .25s var(--ease-out); min-width: 0;
}
.searchbar > .i { width: 17px; height: 17px; color: var(--label-2); }
.searchbar input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 16px; }
.searchbar input::placeholder { color: var(--label-2); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar:focus-within { background: var(--surface); box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px color-mix(in srgb, var(--accent) 16%, transparent); }
.search-clear, .search-scan { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--label-2); transition: background .2s, transform .2s; }
.search-clear { display: none; }
.search-clear .i { width: 13px; height: 13px; padding: 2px; border-radius: 50%; background: var(--label-3); color: var(--surface); stroke-width: 3; }
.searchbar.has-value .search-clear { display: grid; animation: pop .3s var(--spring); }
.search-scan { color: var(--accent); }
.search-scan:hover { background: var(--fill); }
.search-scan .i { width: 19px; height: 19px; }
.searchbar.lg { height: 48px; border-radius: 14px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .searchbar { flex: 1 1 260px; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1) 18px; padding: 2px var(--gutter) 4px; scroll-padding-inline: var(--gutter); scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); box-shadow: inset 0 0 0 .5px var(--separator-strong); font-size: 14px; font-weight: 500;
  white-space: nowrap; scroll-snap-align: start; transition: background .25s, color .25s, transform .2s var(--ease-out), box-shadow .25s;
}
.chip:hover { background: var(--fill-3); }
.chip:active { transform: scale(.95); }
.chip.active, .chip:has(input:checked) { background: var(--label); color: var(--bg); box-shadow: none; }
.chip .i { width: 15px; height: 15px; display: none; stroke-width: 2.4; }
.chip:has(input:checked) .i { display: block; animation: pop .35s var(--spring); }
.chip:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; background: var(--fill); border-radius: 10px; height: 36px; }
.stepper button { width: 40px; height: 36px; display: grid; place-items: center; color: var(--label); transition: transform .15s, opacity .2s; }
.stepper button:active { transform: scale(.85); }
.stepper button .i { width: 16px; height: 16px; }
.stepper input { width: 44px; text-align: center; border: 0; background: none; outline: none; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 16px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper i { width: .5px; height: 18px; background: var(--separator-strong); }

/* Drop zone */
.dropzone {
  display: flex; align-items: center; gap: 16px; padding: 14px; border-radius: 16px; border: 1.5px dashed var(--separator-strong);
  transition: border-color .25s, background .25s, transform .3s var(--spring-soft); cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); transform: scale(1.01); }
.dropzone .cover-sm { width: 56px; }
.dropzone input { display: none; }
.dropzone .row-main > * { display: block; }

/* ---------- Badges & pills ------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px;
  font-size: 12px; font-weight: 600; white-space: nowrap; letter-spacing: 0; justify-self: start;
  color: var(--b-ink); background: color-mix(in srgb, var(--b) 14%, transparent);
}
.badge-gray { --b: var(--gray); --b-ink: var(--gray-ink); }
.badge-blue { --b: var(--blue); --b-ink: var(--blue-ink); }
.badge-green { --b: var(--green); --b-ink: var(--green-ink); }
.badge-orange { --b: var(--orange); --b-ink: var(--orange-ink); }
.badge-red { --b: var(--red); --b-ink: var(--red-ink); }
.badge-indigo { --b: var(--indigo); --b-ink: var(--indigo-ink); }
.badge-purple { --b: var(--purple); --b-ink: var(--purple-ink); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; width: fit-content;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--p-ink); background: color-mix(in srgb, var(--p) 14%, transparent);
  transition: background .3s, color .3s;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--p); }
.pill-green { --p: var(--green); --p-ink: var(--green-ink); }
.pill-orange { --p: var(--orange); --p-ink: var(--orange-ink); }
.pill-gray { --p: var(--gray); --p-ink: var(--gray-ink); }
.pill.flash { animation: pill-flash 1.4s var(--ease-out); }

/* ---------- Book covers ---------------------------------------------------- */
.cover {
  --h: 220; position: relative; aspect-ratio: 2 / 3; width: 100%; border-radius: 4px 8px 8px 4px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; padding: 14% 11% 12% 15%; color: #fff;
  background: linear-gradient(155deg, hsl(var(--h) 58% 56%), hsl(calc(var(--h) + 35) 62% 32%));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 10px 24px -10px rgba(0, 0, 0, .45);
  container-type: inline-size; isolation: isolate;
}
.cover::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; z-index: 1; background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(255, 255, 255, .12) 70%, transparent); }
.cover::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(135deg, rgba(255, 255, 255, .26), transparent 42%); }
.cover-title {
  font-family: var(--serif); font-weight: 700; font-size: 12.5cqw; line-height: 1.08; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.cover-author { font-size: 7.6cqw; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .04em; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover.has-img { padding: 0; background: var(--fill); }
.cover.has-img img { width: 100%; height: 100%; object-fit: cover; }
.cover-sm { width: 44px; flex: none; padding: 0; border-radius: 3px 5px 5px 3px; box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 4px 10px -4px rgba(0, 0, 0, .35); }
.cover-sm .cover-title, .cover-sm .cover-author { display: none; }
.cover-md { width: 100%; }
.cover-lg { width: 100%; border-radius: 6px 12px 12px 6px; box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 30px 60px -20px rgba(0, 0, 0, .5); }

/* Book grid & shelves */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 30px 22px; }
.book-card { display: flex; flex-direction: column; gap: 11px; min-width: 0; -webkit-user-select: none; user-select: none; }
.book-card .tilt { position: relative; transition: transform .6s var(--ease-out); transform-style: preserve-3d; will-change: transform; }
.book-card .tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: 4px 8px 8px 4px; pointer-events: none; opacity: 0; z-index: 3;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .35), transparent 55%); transition: opacity .4s;
}
.book-card:active .tilt { transform: scale(.97); transition-duration: .15s; }
.book-meta { display: grid; gap: 3px; min-width: 0; }
.book-meta strong { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta > span:not(.pill) { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta .pill { margin-top: 4px; }
.shelf {
  display: grid; grid-auto-flow: column; grid-auto-columns: 138px; gap: 20px; overflow-x: auto; overscroll-behavior-x: contain;
  margin: 0 calc(var(--gutter) * -1); padding: 4px var(--gutter) 14px; scroll-padding-inline: var(--gutter);
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf > * { scroll-snap-align: start; }

/* Book detail */
.book-hero { position: relative; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 40px; align-items: start; margin-top: 6px; }
.hero-ambient {
  position: absolute; z-index: -1; inset: -120px -80px auto -80px; height: 460px; pointer-events: none; opacity: .55;
  background: radial-gradient(ellipse 60% 70% at 20% 40%, hsl(var(--h) 75% 60% / .45), transparent 70%),
              radial-gradient(ellipse 50% 60% at 60% 30%, hsl(calc(var(--h) + 40) 70% 55% / .25), transparent 70%);
  filter: blur(30px); animation: fade-in 1.2s var(--ease) both;
}
.main { position: relative; isolation: isolate; overflow-x: clip; }
.book-info h1 { font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: -.025em; text-wrap: balance; }
.book-info .author { font-size: 19px; color: var(--accent-ink); margin-top: 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0; margin: 22px 0; padding: 14px 0; border-block: .5px solid var(--separator); }
.fact { padding: 0 14px; border-left: .5px solid var(--separator); }
.fact:first-child { border-left: 0; padding-left: 0; }
.fact small { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--label-2); }
.fact strong { display: block; font-size: 16px; font-weight: 600; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desc { font-size: 16px; line-height: 1.6; color: var(--label); max-width: 64ch; }
.avail-big { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); margin-top: 22px; }

/* ---------- Avatars, rings ------------------------------------------------- */
.avatar {
  --h: 210; width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  font-size: 13px; font-weight: 600; color: #fff; letter-spacing: .02em;
  background: linear-gradient(180deg, hsl(var(--h) 52% 64%), hsl(var(--h) 56% 46%));
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 64px; height: 64px; font-size: 23px; }
.avatar.xl { width: 92px; height: 92px; font-size: 34px; box-shadow: 0 10px 30px -8px hsl(var(--h) 50% 40% / .55); }

.ring { --size: 46px; --tone: var(--green); position: relative; width: var(--size); height: var(--size); flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; stroke-linecap: round; }
.ring-track { stroke: var(--fill-2); }
.ring-fill { stroke: var(--tone); stroke-dasharray: 119.4; stroke-dashoffset: calc(119.4 * (1 - var(--p))); transition: stroke-dashoffset 1.1s var(--ease-out); }
.ring:not(.in) .ring-fill { stroke-dashoffset: 119.4; }
.ring span { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.ring b { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring small { font-size: 9px; font-weight: 600; color: var(--label-2); text-transform: uppercase; margin-top: 1px; }
.ring-green { --tone: var(--green); } .ring-orange { --tone: var(--orange); } .ring-red { --tone: var(--red); } .ring-gray { --tone: var(--gray); }
.ring.lg { --size: 64px; } .ring.lg b { font-size: 20px; }

/* Loan cards (student) */
.loan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.loan-card { display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out); }
.loan-card .cover-sm { width: 52px; }
.loan-card .row-main { display: grid; gap: 4px; }
.loan-card.is-overdue { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--red) 45%, transparent); }

/* Banner */
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; margin-bottom: 20px; background: color-mix(in srgb, var(--tone) 12%, var(--surface)); }
.banner .row-icon { background: var(--tone); }
.banner strong { display: block; font-size: 15px; }
.banner p { font-size: 13.5px; color: var(--label-2); }

/* ---------- Tables --------------------------------------------------------- */
.table-wrap { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--label-2); padding: 12px 16px 8px; border-bottom: .5px solid var(--separator); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: .5px solid var(--separator); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .2s; }
.table tbody tr:hover { background: var(--fill-3); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .cell-title { font-weight: 600; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table tfoot td { font-weight: 600; border-top: .5px solid var(--separator-strong); }

/* ---------- Empty, skeleton, more ----------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 56px 16px; }
.empty-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--label-2); margin-bottom: 6px; }
.empty-icon .i { width: 28px; height: 28px; }
.empty h3 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.empty p { color: var(--label-2); max-width: 36ch; }
.empty .btn { margin-top: 10px; }
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--fill-3) 25%, var(--fill) 37%, var(--fill-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.more-wrap { display: flex; justify-content: center; padding: 18px 0 4px; }
[data-live-target] { transition: opacity .25s var(--ease); }
[data-live-target].loading { opacity: .45; }

/* ---------- Charts --------------------------------------------------------- */
.chart { position: relative; height: 220px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .gridline { stroke: var(--separator); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-label { fill: var(--label-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); transform-box: fill-box; transform-origin: bottom; animation: grow-y .8s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 22ms); transition: fill .2s, opacity .2s; }
.chart .bar.is-today { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { fill: color-mix(in srgb, var(--accent) 70%, #fff); }
.chart .hit:focus { outline: none; }
.chart-tip {
  position: absolute; top: 0; left: 0; pointer-events: none; z-index: 5; background: var(--surface-elevated); border-radius: 10px;
  padding: 7px 10px; box-shadow: var(--shadow-lg); font-size: 12px; color: var(--label-2); white-space: nowrap;
  opacity: 0; transform: translate(-50%, calc(-100% - 6px)) scale(.96); transition: opacity .15s, transform .2s var(--ease-out);
}
.chart-tip.show { opacity: 1; transform: translate(-50%, calc(-100% - 10px)); }
.chart-tip strong { display: block; color: var(--label); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hbars { display: grid; gap: 4px; }
.hbar { display: grid; grid-template-columns: 26px minmax(0, 1.2fr) minmax(0, 1.4fr) 44px; gap: 12px; align-items: center; padding: 7px 4px; border-radius: 10px; transition: background .2s; }
.hbar:hover { background: var(--fill-3); }
.hbar-rank { font-weight: 700; color: var(--label-3); font-variant-numeric: tabular-nums; text-align: center; }
.hbar-label { min-width: 0; }
.hbar-label strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-label span { display: block; font-size: 12.5px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { display: block; height: 14px; }
.hbar-fill { display: block; height: 100%; width: calc(var(--v) * 100%); min-width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); transform-origin: left; animation: grow-x .9s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms); }
.hbar-value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

.meter { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; background: var(--fill); }
.meter > span { height: 100%; transform-origin: left; animation: grow-x 1s var(--ease-out) both; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: 13px; color: var(--label-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }
.legend b { color: var(--label); font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-meter { width: 80px; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-meter span { display: block; height: 100%; border-radius: 3px; background: var(--accent); width: calc(var(--v) * 100%); transform-origin: left; animation: grow-x .9s var(--ease-out) both; }

/* ---------- Overlays: island, sheet, alert, spotlight ---------------------- */
.island { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 1200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: 94vw; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 20px 8px 9px; border-radius: 999px;
  background: #000; color: #fff; font-size: 14.5px; font-weight: 500; box-shadow: 0 14px 40px rgba(0, 0, 0, .3);
  max-width: min(94vw, 460px); transform-origin: top center; animation: island-in .62s var(--spring-soft) both; cursor: default;
}
:root[data-theme="dark"] .toast { box-shadow: 0 0 0 .5px rgba(255, 255, 255, .14), 0 14px 40px rgba(0, 0, 0, .6); }
.toast > * { animation: fade-in .3s .14s both; }
.toast .t-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--tone, var(--blue)); }
.toast .t-icon .i { width: 17px; height: 17px; stroke-width: 2.4; }
.toast.out { animation: island-out .4s var(--ease-ios) forwards; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, .34); opacity: 0; transition: opacity .4s var(--ease); }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 901; left: 50%; top: 50%; width: min(560px, calc(100vw - 32px)); max-height: min(88vh, 820px);
  display: flex; flex-direction: column; background: var(--surface-elevated); border-radius: 22px; box-shadow: var(--shadow-xl);
  transform: translate(-50%, -47%) scale(.95); opacity: 0; transition: transform .5s var(--ease-ios), opacity .3s var(--ease);
}
.sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.sheet.lg { width: min(760px, calc(100vw - 32px)); }
.sheet-grabber { display: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 10px; }
.sheet-head h2 { flex: 1; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.sheet-head .btn-icon { background: var(--fill); width: 30px; height: 30px; }
.sheet-head .btn-icon .i { width: 15px; height: 15px; stroke-width: 2.4; }
.sheet-body { padding: 6px 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px calc(16px + var(--safe-b)); border-top: .5px solid var(--separator); }
.sheet-foot .btn { min-width: 96px; }
body.sheet-lock { overflow: hidden; }

.alert-wrap { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .3); animation: dim-in .2s both; }
.alert-wrap.out { animation: dim-out .2s forwards; }
.alert-box {
  width: 280px; border-radius: 16px; overflow: hidden; text-align: center; background: var(--material-thick);
  backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px); box-shadow: var(--shadow-xl);
  animation: alert-in .4s var(--spring-soft) both;
}
.alert-wrap.out .alert-box { animation: alert-out .2s var(--ease) forwards; }
.alert-body { padding: 20px 18px 16px; }
.alert-body h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.alert-body p { white-space: pre-line; font-size: 13.5px; margin-top: 4px; color: var(--label); opacity: .85; }
.alert-body .input { margin-top: 12px; height: 36px; border-radius: 9px; font-size: 14px; background: var(--surface); }
.alert-actions { display: flex; border-top: .5px solid var(--separator-strong); }
.alert-actions button { flex: 1; height: 46px; font-size: 16.5px; color: var(--accent-ink); transition: background .15s; }
.alert-actions button + button { border-left: .5px solid var(--separator-strong); }
.alert-actions button:hover { background: var(--fill-3); }
.alert-actions button:active { background: var(--fill); }
.alert-actions .primary { font-weight: 600; }
.alert-actions .destructive { color: var(--red); font-weight: 600; }

.spotlight-wrap { position: fixed; inset: 0; z-index: 1000; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(0, 0, 0, .18); animation: dim-in .2s both; }
.spotlight-wrap.out { animation: dim-out .18s forwards; }
.spotlight {
  width: min(640px, 100%); border-radius: 20px; overflow: hidden; background: color-mix(in srgb, var(--surface-elevated) 90%, transparent);
  backdrop-filter: saturate(180%) blur(40px); -webkit-backdrop-filter: saturate(180%) blur(40px);
  box-shadow: var(--shadow-xl); animation: spot-in .38s var(--spring-soft) both;
}
.spotlight-wrap.out .spotlight { animation: spot-out .18s var(--ease) forwards; }
.spot-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 60px; }
.spot-input .i { width: 22px; height: 22px; color: var(--label-2); }
.spot-input input::-webkit-search-cancel-button { display: none; }
.spot-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 21px; font-weight: 400; letter-spacing: -.01em; }
.spot-results { max-height: min(52vh, 460px); overflow-y: auto; border-top: .5px solid var(--separator); padding: 6px; }
.spot-results:empty { display: none; }
.spot-group { font-size: 12px; font-weight: 600; color: var(--label-2); padding: 10px 12px 4px; }
.spot-item { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 10px; cursor: pointer; }
.spot-item .row-icon { width: 30px; height: 30px; border-radius: 8px; }
.spot-item .row-icon .i { width: 17px; height: 17px; }
.spot-item .cover-sm { width: 30px; }
.spot-item .avatar { width: 30px; height: 30px; font-size: 11px; }
.spot-item strong { display: block; font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-item small { display: block; font-size: 12.5px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-item > .spot-text { flex: 1; min-width: 0; }
.spot-item.sel { background: var(--accent); color: #fff; }
.spot-item.sel small, .spot-item.sel .pill { color: rgba(255, 255, 255, .85); }
.spot-item.sel .pill { background: rgba(255, 255, 255, .2); }
.spot-item.sel .pill i { background: #fff; }
.spot-empty { padding: 26px; text-align: center; color: var(--label-2); }

.progress { position: fixed; top: 0; left: 0; height: 2.5px; width: 0; z-index: 1300; background: var(--accent); opacity: 0; box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); transition: width .4s var(--ease-out), opacity .4s; pointer-events: none; }

/* More menu (mobile) */
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-bottom: 8px; }
.more-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 4px; border-radius: 16px; font-size: 13px; font-weight: 500; text-align: center; transition: background .2s, transform .2s var(--ease-out); }
.more-item:active { transform: scale(.94); background: var(--fill); }
.more-icon { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--tone, var(--blue)); box-shadow: 0 4px 12px -4px var(--tone, var(--blue)); }
.more-icon .i { width: 24px; height: 24px; }
.more-item:nth-child(8n+1) { --tone: var(--indigo); } .more-item:nth-child(8n+2) { --tone: var(--orange); }
.more-item:nth-child(8n+3) { --tone: var(--green); } .more-item:nth-child(8n+4) { --tone: var(--purple); }
.more-item:nth-child(8n+5) { --tone: var(--teal); } .more-item:nth-child(8n+6) { --tone: var(--red); }
.more-item:nth-child(8n+7) { --tone: var(--blue); } .more-item:nth-child(8n+8) { --tone: var(--gray); }

/* ---------- Scanner -------------------------------------------------------- */
.scanner { position: relative; aspect-ratio: 4 / 3; border-radius: 18px; overflow: hidden; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 22% 12%; border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .42); transition: box-shadow .3s; }
.scan-frame::before {
  content: ""; position: absolute; inset: -3px; border-radius: 16px; padding: 3px;
  background: conic-gradient(from 0deg, #fff 0 8%, transparent 8% 17%, #fff 17% 33%, transparent 33% 42%, #fff 42% 58%, transparent 58% 67%, #fff 67% 83%, transparent 83% 92%, #fff 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  transition: transform .4s var(--spring);
}
.scan-line { position: absolute; left: 6%; right: 6%; height: 2px; top: 10%; border-radius: 2px; background: var(--accent); box-shadow: 0 0 14px 2px var(--accent); animation: scan-sweep 1.8s var(--ease) infinite alternate; }
.scan-frame.hit::before { transform: scale(1.06); background: var(--green); }
.scan-frame.hit .scan-line { background: var(--green); box-shadow: 0 0 18px 4px var(--green); animation: none; top: 50%; }
.scan-hint { text-align: center; color: var(--label-2); font-size: 13.5px; margin-top: 12px; }
.scan-msg { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; backdrop-filter: blur(10px); white-space: nowrap; }

/* ---------- Circulation ---------------------------------------------------- */
.desk { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.step { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--fill); color: var(--label-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; transition: background .3s, color .3s; }
.step.done .step-num { background: var(--green); color: #fff; }
.step.current .step-num { background: var(--accent); color: #fff; }
.step h3 { font-size: 17px; font-weight: 600; }
.patron { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); animation: card-in .5s var(--spring-soft) both; }
.patron .row-main { display: grid; gap: 2px; }
.patron-name { font-size: 17px; font-weight: 600; }
.patron-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.cart { display: grid; gap: 8px; }
.cart-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); animation: card-in .45s var(--spring-soft) both; }
.cart-item.out { animation: card-out .3s var(--ease-ios) forwards; }
.summary { position: sticky; top: 68px; }
.summary .big { font-size: 44px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.typeahead { position: relative; }
.ta-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--surface-elevated); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 320px; overflow-y: auto; animation: drop-in .25s var(--ease-out) both; }
.ta-list:empty { display: none; }
.ta-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.ta-item:hover, .ta-item.sel { background: var(--fill); }
.ta-item strong { display: block; font-size: 14px; font-weight: 600; }
.ta-item small { display: block; font-size: 12.5px; color: var(--label-2); }
.ta-item > .ta-text { flex: 1; min-width: 0; }
.return-card { padding: 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); animation: card-in .5s var(--spring-soft) both; }
.done-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 30px 10px; }
.success-mark { width: 84px; height: 84px; border-radius: 50%; background: var(--green); display: grid; place-items: center; box-shadow: 0 12px 30px -8px color-mix(in srgb, var(--green) 70%, transparent); animation: pop-big .65s var(--spring) both; }
.success-mark .i { width: 44px; height: 44px; color: #fff; stroke-width: 3; }
.success-mark path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .45s .28s var(--ease-out) forwards; }
.timer { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--label-2); display: inline-flex; align-items: center; gap: 5px; }
.timer .i { width: 14px; height: 14px; }

/* ---------- Profile -------------------------------------------------------- */
.profile-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 10px 0 26px; }
.profile-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.person-head { display: flex; align-items: center; gap: 18px; margin: 6px 0 26px; flex-wrap: wrap; }
.person-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -.022em; }

/* Settings rows */
.form-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; min-height: 54px; }
.form-row + .form-row::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--separator); }
.form-row > div:first-child { min-width: 0; }
.form-row strong { display: block; font-size: 15px; font-weight: 500; }
.form-row small { display: block; font-size: 12.5px; color: var(--label-2); }
.form-row .unit { color: var(--label-2); font-size: 14px; margin-left: 6px; }

/* Labels (print) */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.label-card { background: #fff; color: #000; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm); display: grid; gap: 4px; break-inside: avoid; }
.label-card small { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #555; }
.label-card strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-card svg { width: 100%; height: 64px; }
.label-card small:last-child { text-transform: none; font-family: var(--mono); letter-spacing: 0; }

/* ---------- Sign-in -------------------------------------------------------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.auth-bg span { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(80px); opacity: .5; animation: drift 22s ease-in-out infinite alternate; }
.auth-bg span:nth-child(1) { background: #5ac8fa; top: -25vmax; left: -15vmax; }
.auth-bg span:nth-child(2) { background: #5856d6; bottom: -30vmax; right: -20vmax; animation-delay: -7s; animation-duration: 26s; }
.auth-bg span:nth-child(3) { background: #ff9f0a; top: 40%; left: 55%; width: 34vmax; height: 34vmax; opacity: .28; animation-delay: -12s; }
:root[data-theme="dark"] .auth-bg span { opacity: .32; }
.auth-card {
  width: min(400px, 100%); padding: 40px 32px 30px; border-radius: 30px; background: var(--material-thick);
  backdrop-filter: saturate(180%) blur(40px); -webkit-backdrop-filter: saturate(180%) blur(40px); box-shadow: var(--shadow-xl);
  animation: auth-in .9s var(--spring-soft) both;
}
.auth-logo { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 19px; box-shadow: 0 12px 28px -8px rgba(88, 86, 214, .55); animation: pop-big .8s .1s var(--spring) both; }
.auth-card h1 { font-size: 27px; font-weight: 700; letter-spacing: -.025em; text-align: center; }
.auth-card .sub { text-align: center; color: var(--label-2); margin: 4px 0 26px; font-size: 15px; }
.auth-card .form { gap: 12px; }
.auth-card .float .input { background: var(--surface); box-shadow: inset 0 0 0 .5px var(--separator-strong); }
.auth-card .float .input:focus { box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent); }
.auth-msg { min-height: 20px; font-size: 13.5px; color: var(--red-ink); text-align: center; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--label-2); margin-top: 22px; }
.auth-card.success { animation: auth-out .6s var(--ease-ios) forwards; }

/* ---------- Motion --------------------------------------------------------- */
.reveal { animation: rise .6s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 38ms); }
.main.enter .page { animation: page-in .45s var(--ease-out) both; }
.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97) both; }
.pop { animation: pop .45s var(--spring); }
.bounce .tab-icon { animation: tab-bounce .5s var(--spring); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
/* Overlays dim by color, not opacity, so frosted glass inside them can blur the page */
@keyframes dim-in { from { background-color: transparent; } }
@keyframes dim-out { to { background-color: transparent; } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes pop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
@keyframes pop-big { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes tab-bounce { 0% { transform: scale(1); } 35% { transform: scale(.8); } 100% { transform: scale(1); } }
@keyframes island-in { 0% { opacity: 0; transform: scale(.3, .5) translateY(-24px); filter: blur(8px); } 50% { opacity: 1; filter: blur(0); } 100% { transform: none; } }
@keyframes island-out { to { opacity: 0; transform: scale(.4, .5) translateY(-20px); filter: blur(6px); } }
@keyframes alert-in { from { opacity: 0; transform: scale(1.18); } }
@keyframes alert-out { to { opacity: 0; transform: scale(.94); } }
@keyframes spot-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes spot-out { to { opacity: 0; transform: scale(.98); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes card-out { to { opacity: 0; transform: translateX(-24px) scale(.96); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes scan-sweep { from { top: 10%; } to { top: 88%; } }
@keyframes pill-flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--p) 60%, transparent); transform: scale(1.08); } 100% { box-shadow: 0 0 0 10px transparent; transform: scale(1); } }
@keyframes drift { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(8vmax, 6vmax) scale(1.1); } 100% { transform: translate(-6vmax, 10vmax) scale(.95); } }
@keyframes auth-in { from { opacity: 0; transform: translateY(24px) scale(.96); } }
@keyframes auth-out { to { opacity: 0; transform: scale(1.04); filter: blur(6px); } }

/* View transitions between pages */
::view-transition-group(main) { animation: none; }
::view-transition-old(main) { animation: fade-out .16s var(--ease) both; }
::view-transition-new(main) { animation: fade-in .3s var(--ease) both; }
::view-transition-old(main), ::view-transition-new(main) { height: auto; mix-blend-mode: normal; }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease-ios); }

/* Theme switch: circular reveal from the tap point */
html.theme-anim .sidebar, html.theme-anim .main, html.theme-anim .topbar, html.theme-anim .tabbar, html.theme-anim [data-cover-id] { view-transition-name: none !important; }
html.theme-anim::view-transition-old(root) { animation: none; }
html.theme-anim::view-transition-new(root) { animation: circle-in .7s var(--ease-ios); }
@keyframes circle-in { from { clip-path: circle(0 at var(--tx, 50%) var(--ty, 0)); } to { clip-path: circle(150vmax at var(--tx, 50%) var(--ty, 0)); } }
.me.active { background: var(--fill); }

/* Hover affordances only where a pointer can hover */
@media (hover: hover) and (pointer: fine) {
  a.stat:hover, a.card:hover, .card.hoverable:hover, .loan-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
  a.stat:hover .stat-go { transform: translateX(3px); }
  .book-card:hover .tilt { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px) scale(1.03); transition-duration: .2s; }
  .book-card:hover .tilt::after { opacity: 1; }
  .book-card:hover .cover { box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 24px 40px -14px rgba(0, 0, 0, .5); }
}

/* ---------- Responsive ----------------------------------------------------- */
@media (max-width: 1100px) {
  .desk, .split { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
}
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .app { display: block; }
  .sidebar { display: none; }
  .topbar { height: calc(48px + var(--safe-t)); padding: var(--safe-t) 12px 0; }
  .topbar-title { position: absolute; left: 64px; right: 64px; text-align: center; font-size: 17px; bottom: 13px; }
  .top-avatar { display: inline-grid; }
  .page { padding: 0 var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  .large-title { font-size: 32px; }
  .page-head { margin-bottom: 20px; }
  .page-head .page-actions { width: 100%; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; height: calc(var(--tabbar-h) + var(--safe-b));
    padding: 4px 4px var(--safe-b); background: var(--material); border-top: .5px solid var(--separator);
    backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); view-transition-name: tabbar;
  }
  .tabbar > a, .tabbar > button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
    font-size: 10.5px; font-weight: 500; color: var(--label-2); transition: color .2s; -webkit-touch-callout: none;
  }
  .tab-icon { position: relative; display: grid; place-items: center; height: 26px; }
  .tab-icon .i { width: 25px; height: 25px; }
  .tab-icon .dot { top: -4px; right: -10px; box-shadow: 0 0 0 2px var(--surface); }
  .tabbar .active { color: var(--accent); }
  .tabbar .active .i { stroke-width: 2.2; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 26px; }
  .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 22px 14px; }
  .book-meta strong { font-size: 13px; }
  .book-meta > span:not(.pill) { font-size: 12px; }
  .shelf { grid-auto-columns: 116px; gap: 14px; }
  .book-hero { grid-template-columns: minmax(0, 1fr); gap: 20px; text-align: center; }
  .book-hero .cover-wrap { width: 168px; margin: 0 auto; }
  .book-info h1 { font-size: 26px; }
  .book-info .author { font-size: 17px; }
  .book-info .hstack { justify-content: center; }
  .facts { text-align: left; grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .fact:nth-child(odd) { border-left: 0; padding-left: 0; }
  .desc { text-align: left; font-size: 15.5px; }
  .avail-big { text-align: left; }
  .input, .select, .textarea { font-size: 16px; }
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: calc(100dvh - 44px - var(--safe-t));
    border-radius: 22px 22px 0 0; transform: translateY(100%); opacity: 1;
  }
  .sheet.open { transform: translateY(0); }
  .sheet.lg { width: 100%; }
  .sheet.dragging { transition: none; }
  .sheet-grabber { display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--label-3); opacity: .6; margin: 7px auto 0; flex: none; }
  .sheet-head { padding-top: 10px; touch-action: none; }
  .hbar { grid-template-columns: 22px minmax(0, 1fr) 40px; }
  .hbar-track { grid-column: 2 / 3; grid-row: 2; }
  .hbar-value { grid-row: 1 / 3; grid-column: 3; }
  .hbar-rank { grid-row: 1 / 3; }
  .table { font-size: 13.5px; }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: initial; }
  .loan-cards { grid-template-columns: minmax(0, 1fr); }
  .spotlight-wrap { padding-top: calc(10px + var(--safe-t)); }
  .spot-input input { font-size: 18px; }
  .island { top: calc(8px + var(--safe-t)); }
  .person-head { gap: 14px; }
  .person-head h1 { font-size: 24px; }
}
@media (max-width: 420px) {
  .stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats.three .stat-value { font-size: 22px; }
  .stats.three .stat-top { margin-bottom: 6px; }
  .segmented > a, .segmented > button { padding: 6px 12px; }
  .auth-card { padding: 34px 22px 26px; border-radius: 26px; }
}

/* Reduced motion: keep fades, drop movement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- Print ---------------------------------------------------------- */
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --label: #000; --label-2: #444; --separator: #ccc; color-scheme: light; }
  body { background: #fff; font-size: 11pt; }
  .app { display: block; }
  .sidebar, .topbar, .tabbar, .page-actions, .toolbar, .segmented, .chips, .no-print, .btn, .island, .more-wrap { display: none !important; }
  .page { padding: 0; max-width: none; }
  .print-only { display: block; }
  .card, .list, .stat, .table-wrap { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .reveal, .bar, .hbar-fill, .meter > span { animation: none !important; }
  .table { font-size: 9.5pt; }
  .table tbody tr:hover { background: none; }
  .label-card { box-shadow: none; border: 1px dashed #bbb; border-radius: 4px; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 16px; }
  .print-head h2 { font-size: 16pt; }
  a[href]::after { content: none; }
}
