:root {
  --blue: #0754c9;
  --blue-dark: #073b8f;
  --blue-soft: #eaf2ff;
  --blue-pale: #f5f9ff;
  --red: #d6283f;
  --red-soft: #fff0f2;
  --gold: #d8a719;
  --gold-soft: #fff8dc;
  --ink: #10233f;
  --muted: #61708a;
  --line: #dce5f1;
  --line-strong: #c5d2e3;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --success: #18794e;
  --success-soft: #e9f8f0;
  --shadow: 0 8px 24px rgba(24, 55, 95, .08);
  --radius: 10px;
  --radius-small: 7px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 2.4vw, 2.15rem); line-height: 1.15; margin-bottom: .45rem; letter-spacing: -.025em; }
h2 { font-size: 1.22rem; line-height: 1.25; margin-bottom: .75rem; }
h3 { font-size: 1.08rem; margin-bottom: .3rem; }
blockquote { margin: .55rem 0 0; padding: .5rem .75rem; border-left: 3px solid var(--blue); background: var(--blue-pale); color: #304461; }
code { padding: .1rem .3rem; border-radius: 4px; background: #edf2f8; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .875rem; }
.eyebrow { margin: 0 0 .3rem; color: var(--blue); font-size: .76rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.subtitle { font-size: 1.1rem; color: var(--muted); }

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  grid-template-columns: max-content minmax(220px, 1fr) auto max-content max-content;
  align-items: center;
  gap: 1rem;
  min-height: 68px;
  padding: .55rem clamp(1rem, 2.5vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 3px 14px rgba(24, 55, 95, .05);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font-weight: 800; white-space: nowrap; }
.brand img { width: 31px; height: 39px; object-fit: contain; }
.global-search { position: relative; min-width: 180px; }
.global-search input { width: 100%; height: 40px; padding: .55rem 2.6rem .55rem .85rem; border: 1px solid var(--line-strong); border-radius: 20px; background: #f9fbfe; }
.global-search input:focus { outline: 3px solid rgba(7, 84, 201, .13); border-color: var(--blue); background: #fff; }
.global-search button { position: absolute; top: 1px; right: 2px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--blue); font-size: 1.35rem; }
.desktop-nav { display: flex; align-items: stretch; height: 68px; margin: -.55rem 0; }
.desktop-nav a { display: grid; place-items: center; padding: 0 .65rem; border-bottom: 3px solid transparent; color: #334762; font-size: .88rem; font-weight: 650; }
.desktop-nav a.active { color: var(--blue); border-bottom-color: var(--blue); }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: .45rem; list-style: none; padding: .35rem; border-radius: 20px; font-size: .9rem; font-weight: 700; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-panel { position: absolute; top: calc(100% + .65rem); right: 0; min-width: 190px; padding: .45rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.user-menu-panel a, .user-menu-panel .link-button { display: block; width: 100%; padding: .55rem .65rem; border: 0; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; }
.user-menu-panel a:hover, .user-menu-panel .link-button:hover { background: var(--blue-pale); color: var(--blue); }
.avatar { display: inline-grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border: 2px solid #d6e3f6; border-radius: 50%; background: linear-gradient(145deg, var(--blue-soft), #fff); color: var(--blue-dark); font-size: .8rem; font-weight: 850; }

.page-shell { width: min(1660px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 5rem; }
.guest-shell { width: 100%; min-height: 100vh; padding: 0; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-heading p { margin-bottom: 0; color: var(--muted); }
.compact-heading { min-height: 62px; }
.form-required-note { margin-top: .45rem; color: var(--muted); font-size: .82rem; font-weight: 650; }
.form-required-note span, .required-mark { color: var(--red); font-weight: 900; }
.field-label { display: inline-flex; align-items: baseline; gap: .2rem; }
.required-field { color: var(--ink); font-weight: 850; }
.field-badge { padding: .08rem .38rem; border-radius: 10px; background: var(--blue-soft); color: var(--blue-dark); font-size: .68rem; font-weight: 800; letter-spacing: .02em; }
.heading-actions, .book-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .56rem .9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
}
.button:hover { text-decoration: none; }
.button.primary { border-color: var(--blue); background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(7, 84, 201, .2); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { border-color: #a9bfdf; color: var(--blue-dark); }
.button.secondary:hover { border-color: var(--blue); background: var(--blue-pale); }
.button.text { border-color: transparent; background: transparent; color: var(--blue); }
.button.danger { border-color: #e5aab2; background: var(--red-soft); color: #a11329; }
.button.compact { min-height: 35px; padding: .4rem .65rem; font-size: .86rem; }
.button.full { width: 100%; }
.link-button { cursor: pointer; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 1.15rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading > div { display: flex; align-items: center; gap: .55rem; }
.panel-heading h2 { margin: 0; }
.panel-heading a { font-size: .88rem; font-weight: 700; }
.section-icon { display: inline-grid; place-items: center; width: 29px; height: 29px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); font-weight: 900; }

.toast { position: fixed; z-index: 80; top: 78px; left: 50%; width: min(620px, calc(100% - 2rem)); transform: translateX(-50%); padding: .8rem 1rem; border: 1px solid; border-radius: var(--radius-small); box-shadow: var(--shadow); font-weight: 700; }
.toast.success { border-color: #a8d9bf; background: var(--success-soft); color: #0a6840; }
.toast.error { border-color: #efbac2; background: var(--red-soft); color: #a11329; }
.toast.is-hidden { opacity: 0; transition: opacity .25s ease; pointer-events: none; }

.login-page { min-height: 100vh; background: linear-gradient(135deg, #edf5ff 0 50%, #f8fbff 50%); }
.login-card { position: absolute; top: 50%; left: 50%; width: min(530px, calc(100% - 2rem)); transform: translate(-50%, -50%); padding: 1.8rem; border-top: 5px solid var(--blue); border-radius: var(--radius); background: #fff; box-shadow: 0 18px 55px rgba(20, 58, 107, .16); }
.login-mark { display: flex; align-items: center; gap: 1.15rem; padding-bottom: 1.2rem; margin-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.login-mark h1 { margin-bottom: .25rem; }
.login-mark p:last-child { margin-bottom: 0; color: var(--muted); }

label { display: grid; gap: .35rem; color: #334762; font-size: .86rem; font-weight: 730; }
input, select, textarea { width: 100%; min-height: 42px; padding: .55rem .68rem; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(7, 84, 201, .12); border-color: var(--blue); }
.stack-form { display: grid; gap: .9rem; }
.form-grid { display: grid; gap: .9rem; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checkbox { display: flex; align-items: center; gap: .55rem; }
.checkbox input { width: 18px; height: 18px; min-height: 0; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .85fr); gap: 1rem; }
.reading-panel { grid-column: 1; }
.dashboard-side { display: grid; align-content: start; gap: 1rem; grid-column: 2; grid-row: 1 / span 2; }
.activity-panel { grid-column: 1; }
.active-reading-list { display: grid; gap: 1rem; }
.active-reading-card { display: grid; grid-template-columns: 125px 1fr; gap: 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: var(--radius-small); background: #fbfdff; }
.reading-main h3 { font-size: 1.3rem; }
.reading-main > p { margin-bottom: .3rem; }
.progress-line { position: relative; height: 9px; margin: .65rem 0 .35rem; overflow: hidden; border-radius: 6px; background: #e8edf4; }
.progress-line span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.progress-line.large-progress { height: 11px; }
.progress-native { width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 6px; background: #e8edf4; color: var(--blue); }
.progress-native::-webkit-progress-bar { border-radius: 6px; background: #e8edf4; }
.progress-native::-webkit-progress-value { border-radius: 6px; background: var(--blue); }
.progress-native::-moz-progress-bar { border-radius: 6px; background: var(--blue); }
.progress-native.large-progress { height: 11px; }
.progress-meta { display: flex; align-items: center; gap: .25rem; margin: 0; color: var(--muted); font-size: .86rem; }
.progress-meta strong { color: var(--ink); font-size: 1rem; }
.progress-meta span { margin-left: auto; }
.quick-progress { display: grid; grid-template-columns: 130px minmax(180px, 1fr) max-content; align-items: end; gap: .6rem; margin-top: .9rem; }
.random-panel form + form { margin-top: .65rem; }
.random-panel > p { color: var(--muted); font-size: .9rem; }
.random-button { width: 100%; min-height: 48px; border-color: #8dadde; color: var(--blue-dark); }
.random-button:hover { background: var(--blue-pale); border-color: var(--blue); }
.stat-pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.stat-pair > div { display: grid; place-items: center; padding: 1rem .5rem; border: 1px solid #dbe7f7; border-radius: var(--radius-small); background: var(--blue-pale); }
.stat-pair strong { color: var(--blue); font-size: 1.65rem; line-height: 1; }
.stat-pair span { margin-top: .3rem; color: var(--muted); font-size: .82rem; }
.maintenance-list { display: grid; gap: 0; padding: 0; margin: 0 0 1rem; list-style: none; }
.maintenance-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.maintenance-list strong { min-width: 28px; text-align: center; color: var(--blue); }
.activity-list { display: grid; }
.borrowed-list { display: grid; }
.borrowed-list > a { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .65rem 0; border-top: 1px solid var(--line); color: var(--ink); }
.borrowed-list > a:first-child { border-top: 0; }
.borrowed-list > a > span:first-child { display: grid; min-width: 0; }
.borrowed-list small { color: var(--muted); font-size: .76rem; }
.borrowed-list time { flex: 0 0 auto; color: var(--muted); font-size: .76rem; font-weight: 750; }
.activity-row { display: grid; grid-template-columns: 38px 1fr; gap: .7rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.activity-row:first-child { border-top: 0; }
.activity-row p { margin-bottom: .15rem; }
.activity-row time { color: var(--muted); font-size: .76rem; }
.activity-row.final-activity { padding: .8rem; border-left: 3px solid var(--gold); background: var(--gold-soft); }
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.summary-strip > div { display: grid; padding: .8rem 1rem; border-left: 1px solid var(--line); }
.summary-strip > div:first-child { border-left: 0; }
.summary-strip span { color: var(--muted); font-size: .8rem; }
.summary-strip strong { color: var(--blue-dark); font-size: 1.35rem; }

.cover { display: grid; place-items: center; aspect-ratio: 2 / 3; overflow: hidden; border-radius: 4px; background: linear-gradient(145deg, var(--blue-dark), #153055); color: #fff; box-shadow: 0 7px 18px rgba(18, 40, 72, .22); font-size: 2rem; font-weight: 900; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.small-cover { width: 125px; }
.mini-cover { width: 68px; }
.detail-cover { width: 100%; max-width: 280px; margin: 0 auto; }

.library-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); align-items: start; gap: 1rem; }
.filter-panel { position: sticky; top: 84px; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.filter-panel form { display: grid; gap: .75rem; }
.filter-header { display: flex; align-items: center; justify-content: space-between; }
.filter-header h2 { margin: 0; }
.filter-header button, .filter-toggle { display: none; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 1rem; }
.book-card { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: .85rem; min-height: 220px; padding: .85rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 5px 16px rgba(24, 55, 95, .06); }
.book-card .cover { width: 86px; align-self: start; }
.book-card h2 { margin: .4rem 0 .15rem; font-size: 1.08rem; }
.book-subtitle { margin: -.05rem 0 .25rem; color: var(--muted); font-size: .84rem; font-weight: 650; }
.book-author, .book-series { margin-bottom: .2rem; color: #354963; font-size: .88rem; }
.book-series { color: var(--blue); }
.book-card-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; }
.status-badge, .loan-badge, .holding-badge, .favorite, .rating { display: inline-flex; align-items: center; min-height: 23px; padding: .15rem .45rem; border-radius: 4px; font-size: .72rem; font-weight: 800; }
.status-badge.unread { background: #eef1f5; color: #53647b; }
.status-badge.reading { background: var(--blue-soft); color: var(--blue-dark); }
.status-badge.read { background: var(--success-soft); color: var(--success); }
.loan-badge { background: var(--gold-soft); color: #8a6600; }
.holding-badge.friend { background: #f4eafd; color: #74419a; }
.holding-badge.library { background: var(--blue-soft); color: var(--blue-dark); }
.holding-badge.returned { background: #eceff3; color: #68788e; }
.overdue-text { color: var(--red) !important; font-weight: 800; }
.favorite { background: var(--red-soft); color: var(--red); }
.rating { background: var(--gold-soft); color: #7d5d00; }
.book-mini-meta { margin: .7rem 0; font-size: .78rem; }
.book-mini-meta > div { display: grid; grid-template-columns: 62px 1fr; gap: .35rem; }
.book-mini-meta dt { color: var(--muted); }
.book-mini-meta dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { padding: .18rem .42rem; border: 1px solid #ced9e8; border-radius: 4px; background: #f3f6fa; color: #42546b; font-size: .7rem; }
.chip:hover { border-color: #88a9d8; background: var(--blue-soft); color: var(--blue-dark); }
.active-readers { margin: .55rem 0 0; color: var(--blue); font-size: .76rem; font-weight: 700; }
.active-readers a:hover, .book-mini-meta a:hover, .detail-meta a:hover { text-decoration: underline; }
.book-grid.is-list { grid-template-columns: 1fr; }
.book-grid.is-list .book-card { grid-template-columns: 70px minmax(0, 1fr); min-height: 145px; }
.book-grid.is-list .book-card .cover { width: 70px; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.view-switch button { min-height: 32px; padding: .25rem .55rem; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.view-switch button.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 750; }

.book-form { max-width: 1180px; margin: 0 auto; padding: 1.4rem; }
.book-form > section { padding: 1.2rem 0; border-bottom: 1px solid var(--line); }
.book-form > section:first-of-type { padding-top: 0; }
.form-section-heading { display: flex; gap: .8rem; margin-bottom: 1rem; }
.form-section-heading > span { display: grid; flex: 0 0 auto; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: var(--blue); color: #fff; font-weight: 850; }
.form-section-heading h2, .form-section-heading p { margin-bottom: .15rem; }
.form-section-heading p { color: var(--muted); font-size: .88rem; }
.external-book-fields { margin-top: .8rem; padding: .8rem; border: 1px solid #c7b3dd; border-radius: var(--radius-small); background: #fbf7ff; }
.book-form section > label { margin-top: .9rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .7rem; padding-top: 1.1rem; }
.isbn-control { display: grid; gap: .45rem; }
.isbn-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.isbn-preview { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: .9rem 1rem; border: 1px solid #b8ceed; border-radius: var(--radius-small); background: var(--blue-pale); }
.isbn-preview h3, .isbn-preview p { margin-bottom: .15rem; }
.isbn-preview-subtitle { color: var(--ink); font-weight: 700; }
.isbn-preview-warning { max-width: 520px; padding: .55rem .7rem; border-left: 3px solid var(--gold); background: var(--gold-soft); color: #6e5600; font-size: .84rem; }
.scanner-dialog { width: min(620px, calc(100% - 1rem)); padding: 1rem; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 0 20px 60px rgba(10, 30, 60, .35); }
.scanner-dialog::backdrop { background: rgba(5, 18, 38, .72); backdrop-filter: blur(3px); }
.scanner-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.scanner-heading h2 { margin-bottom: .55rem; }
.scanner-close { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); font-size: 1.6rem; }
.scanner-video-wrap { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 10px; background: #081526; }
.scanner-video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scanner-target { position: absolute; inset: 34% 8%; border: 3px solid #64adff; border-radius: 8px; box-shadow: 0 0 0 999px rgba(4, 15, 31, .3); }
.scanner-status { min-height: 1.5rem; margin: .75rem 0; color: var(--muted); }
.scanner-fallback { display: flex; align-items: center; gap: .8rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.scanner-fallback span { color: var(--muted); font-size: .82rem; }

.breadcrumbs { display: flex; gap: .5rem; margin-bottom: 1rem; color: var(--muted); font-size: .86rem; }
.book-detail { display: grid; grid-template-columns: minmax(210px, 285px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.book-detail-sidebar { position: sticky; top: 84px; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.detail-meta { margin: 1rem 0; }
.detail-meta > div { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.detail-meta dt { color: var(--muted); font-size: .76rem; }
.detail-meta dd { margin: .1rem 0 0; font-size: .9rem; font-weight: 650; }
.sidebar-chips { margin-top: .6rem; }
.sidebar-chips.subdued .chip { background: #fff; }
.metadata-source { margin: 1rem 0 0; color: var(--muted); font-size: .75rem; }
.book-detail-main { min-width: 0; }
.book-title-row { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.book-title-row h1 { font-size: clamp(2rem, 3.2vw, 3rem); }
.book-author.large { font-size: 1.15rem; color: #354963; }
.detail-tabs { position: sticky; z-index: 10; top: 68px; display: flex; gap: 1.2rem; padding: .85rem 1rem 0; border-bottom: 1px solid var(--line); background: var(--canvas); }
.detail-tabs a { padding: .5rem .1rem .7rem; border-bottom: 3px solid transparent; color: #40516a; font-weight: 700; }
.detail-tabs a:hover { border-bottom-color: var(--blue); color: var(--blue); }
.detail-section, .my-reading-card { scroll-margin-top: 120px; margin-top: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.annotation { white-space: pre-line; color: #2f4057; }
.copy-note { margin-top: 1rem; padding: .8rem; border-left: 3px solid var(--gold); background: var(--gold-soft); }
.copy-note p { margin: .3rem 0 0; }
.my-reading-card.reading { border-top: 4px solid var(--blue); }
.my-reading-card.read { border-top: 4px solid var(--success); }
.my-reading-card.unread { border-top: 4px solid #9aa9bc; }
.my-reading-heading { display: flex; justify-content: space-between; gap: 1rem; }
.progress-form { display: grid; grid-template-columns: 150px minmax(220px, 1fr) max-content; align-items: end; gap: .8rem; margin-top: 1rem; }
.finish-reading { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.finish-reading summary, .loan-section summary, .danger-zone summary, .admin-create summary { color: var(--blue-dark); font-weight: 780; }
.finish-reading form { display: grid; gap: .8rem; margin-top: .8rem; padding: .9rem; background: #f8faff; border-radius: 7px; }
.external-holding-section { border-left: 4px solid #8b62ad; }
.external-holding-section.library { border-left-color: var(--blue); }
.external-holding-section.returned { border-left-color: #8795a8; }
.cancel-reading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: .8rem; border: 1px dashed #dba5ae; border-radius: 7px; background: #fff8f9; }
.cancel-reading p { margin: .2rem 0 0; color: var(--muted); font-size: .82rem; }
.cancel-reading form { flex: 0 0 auto; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.reader-table { display: grid; }
.reader-row { display: grid; grid-template-columns: 40px minmax(90px, 1fr) max-content minmax(90px, .5fr) 20px; align-items: center; gap: .7rem; padding: .65rem 0; border-top: 1px solid var(--line); color: var(--ink); }
.reader-row:first-child { border-top: 0; }
.comment-timeline { position: relative; display: grid; gap: .85rem; margin-left: .6rem; padding-left: 1.3rem; border-left: 2px solid #d9e4f3; }
.comment-item { position: relative; padding: .8rem; border: 1px solid var(--line); border-radius: 7px; background: #fbfdff; }
.comment-item.final-comment, .feed-comment.final-comment { border-left: 4px solid var(--gold); background: var(--gold-soft); }
.timeline-dot { position: absolute; top: 1rem; left: -1.78rem; width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.comment-head { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .8rem; }
.comment-head time { margin-left: auto; }
.history-list { display: grid; }
.history-list article { display: grid; grid-template-columns: 40px 1fr max-content max-content; align-items: center; gap: .7rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.history-list article:first-child { border-top: 0; }
.history-list p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.inline-form { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)) max-content; align-items: end; gap: .7rem; margin-top: .8rem; }
.danger-zone { margin-top: 1rem; padding: .8rem 1rem; border: 1px dashed #dba5ae; border-radius: var(--radius); background: #fff8f9; }
.danger-zone p { color: var(--muted); }

.horizontal-filters { display: grid; grid-template-columns: minmax(240px, 1fr) 190px 170px max-content max-content; align-items: end; gap: .7rem; margin-bottom: 1rem; }
.comments-feed { padding: 0 1.1rem; }
.feed-comment { display: grid; grid-template-columns: 40px 1fr; gap: .75rem; padding: 1rem .2rem; border-top: 1px solid var(--line); }
.feed-comment:first-child { border-top: 0; }
.feed-comment h2 { margin: .25rem 0; font-size: 1rem; }
.feed-comment.final-comment { margin: .5rem 0; padding: .9rem; }

.profile-header { display: grid; grid-template-columns: max-content 1fr minmax(450px, 1.2fr); align-items: center; gap: 1rem; margin-bottom: 1rem; }
.profile-avatar { width: 72px; height: 72px; font-size: 1.4rem; }
.profile-header h1 { margin-bottom: .15rem; }
.profile-header p { margin-bottom: 0; color: var(--muted); }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.profile-stats > div { display: grid; padding: .55rem; border-left: 1px solid var(--line); }
.profile-stats strong { color: var(--blue); font-size: 1.25rem; }
.profile-stats span { color: var(--muted); font-size: .7rem; }
.profile-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .65fr); align-items: start; gap: 1rem; }
.profile-layout aside { display: grid; gap: 1rem; }
.profile-reading-list { display: grid; }
.profile-reading-list article { display: grid; grid-template-columns: 68px 1fr max-content; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.profile-reading-list article:first-child { border-top: 0; }
.profile-reading-list p { margin-bottom: .15rem; }
.profile-progress { display: grid; justify-items: end; align-content: center; }
.profile-progress strong { font-size: 1.15rem; }
.profile-progress span, .profile-progress small { color: var(--muted); }

.import-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 1rem; align-items: start; }
.export-panel { position: sticky; top: 84px; }
.import-result { margin-top: 1rem; }
.compact-summary { margin: 0 0 1rem; box-shadow: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--blue-pale); color: #40516a; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.import-status { font-size: .78rem; font-weight: 750; }
.inline-error { color: var(--red); font-weight: 750; }

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.admin-grid .full-span { grid-column: 1 / -1; }
.user-admin-list { display: grid; }
.user-admin-list article { display: grid; grid-template-columns: 40px minmax(100px, 1fr) max-content max-content; align-items: center; gap: .7rem; padding: .65rem 0; border-top: 1px solid var(--line); }
.user-admin-list article:first-child { border-top: 0; }
.user-admin-list p { margin: 0; color: var(--muted); font-size: .8rem; }
.admin-create { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.admin-create form { margin-top: .9rem; }
.large-list { margin-bottom: 0; }

.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.series-card { display: grid; grid-template-columns: 52px 1fr max-content; align-items: center; gap: .9rem; color: var(--ink); transition: transform .15s ease, border-color .15s ease; }
.series-card:hover { transform: translateY(-2px); border-color: #9db9df; color: var(--ink); }
.series-card h2, .series-card p { margin-bottom: .15rem; }
.series-card p:last-child { color: var(--muted); font-size: .85rem; }
.series-mark { display: grid; place-items: center; width: 52px; height: 68px; border-radius: 4px 8px 8px 4px; background: linear-gradient(145deg, var(--blue-dark), var(--blue)); color: #fff; font-size: 1.35rem; font-weight: 900; box-shadow: inset 5px 0 rgba(255,255,255,.14); }
.series-arrow { color: var(--blue); font-size: 2rem; }
.series-summary { margin-bottom: 1rem; }
.series-gap-note { margin: 1rem 0; padding: .8rem 1rem; border-left: 4px solid var(--gold); border-radius: 4px; background: var(--gold-soft); color: #6e5600; }
.series-book-list { padding-top: .3rem; padding-bottom: .3rem; }
.series-book-list article { display: grid; grid-template-columns: 48px 68px minmax(0, 1fr) max-content; align-items: center; gap: .9rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.series-book-list article:first-child { border-top: 0; }
.series-number { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #b9cae0; border-radius: 50%; background: var(--blue-pale); color: var(--blue-dark); font-weight: 850; }
.series-book-main h2, .series-book-main p { margin-bottom: .15rem; }
.series-book-main > p:not(.eyebrow) { color: var(--muted); font-size: .85rem; }
.series-readers a { font-weight: 700; }

.quality-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .55rem; margin-bottom: 1rem; }
.quality-filters a { display: grid; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-small); background: #fff; color: var(--ink); }
.quality-filters a.active, .quality-filters a:hover { border-color: #8aabda; background: var(--blue-pale); }
.quality-filters span { color: var(--muted); font-size: .72rem; }
.quality-filters strong { color: var(--blue); font-size: 1.25rem; }
.quality-list { padding-top: .2rem; padding-bottom: .2rem; }
.quality-list article { display: grid; grid-template-columns: 68px minmax(0, 1fr) max-content; align-items: center; gap: .9rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.quality-list article:first-child { border-top: 0; }
.quality-book-main h2, .quality-book-main p { margin-bottom: .25rem; }
.quality-book-main > p { color: var(--muted); font-size: .85rem; }
.missing-chip { border-color: #e2bdc4; background: var(--red-soft); color: #9f2638; }
.quality-progress { display: grid; grid-template-columns: minmax(120px, 260px) max-content; align-items: center; gap: .6rem; margin-top: .6rem; }
.quality-progress progress, .reader-stat-card > progress, .monthly-chart progress { width: 100%; height: 10px; accent-color: var(--blue); }
.quality-progress span { color: var(--muted); font-size: .72rem; }
.quality-actions { display: grid; justify-items: stretch; gap: .4rem; }

.year-picker label { display: flex; align-items: center; gap: .55rem; }
.year-picker select { min-width: 105px; }
.stats-summary { margin-bottom: 1rem; }
.statistics-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); align-items: start; gap: 1rem; }
.monthly-chart { display: grid; gap: .55rem; }
.monthly-chart > div { display: grid; grid-template-columns: 78px minmax(100px, 1fr) 62px 62px; align-items: center; gap: .55rem; }
.monthly-chart > div > span { color: var(--muted); font-size: .78rem; }
.monthly-chart > div > strong { text-align: right; color: var(--blue-dark); }
.monthly-chart > div > small { color: var(--muted); text-align: right; }
.reader-stat-grid { display: grid; gap: 1rem; }
.reader-stat-card { display: grid; gap: .75rem; color: var(--ink); }
.reader-stat-card:hover { color: var(--ink); border-color: #9db9df; }
.reader-stat-heading { display: flex; align-items: center; gap: .7rem; }
.reader-stat-heading h2, .reader-stat-heading p { margin-bottom: 0; }
.reader-stat-values { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.reader-stat-values > div { display: grid; padding: .45rem; border-left: 1px solid var(--line); }
.reader-stat-values > div:first-child { border-left: 0; }
.reader-stat-values strong { color: var(--blue); }
.reader-stat-values span { color: var(--muted); font-size: .68rem; }
.rating-line { margin: .65rem 0 0; color: #735800; font-size: .82rem; font-weight: 750; }
.profile-year-panel { margin-bottom: 1rem; }
.profile-year-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .7rem; font-size: .82rem; }
.compact-chart { grid-template-columns: repeat(6, 1fr); gap: .8rem; }
.compact-chart > div { grid-template-columns: 32px minmax(45px, 1fr) 48px; }
.compact-chart > div small { display: none; }

.empty-state { display: grid; justify-items: center; gap: .7rem; padding: 1.3rem; color: var(--muted); text-align: center; }
.empty-state p { margin: 0; }
.large-empty { min-height: 280px; place-content: center; }
.empty-inline { padding: .9rem; border: 1px dashed var(--line-strong); border-radius: 7px; background: #fafcff; color: var(--muted); }
.empty-inline p:last-child { margin-bottom: 0; }
.mobile-nav { display: none; }

@media (min-width: 1600px) {
  body { font-size: 17px; }
  .page-shell { padding-top: 1.8rem; }
  .panel { padding: 1.3rem; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); }
}

@media (max-width: 1180px) {
  .topbar { grid-template-columns: max-content minmax(180px, 1fr) auto max-content; }
  .desktop-nav { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .reading-panel, .activity-panel, .dashboard-side { grid-column: 1; grid-row: auto; }
  .dashboard-side { grid-template-columns: repeat(3, 1fr); }
  .profile-header { grid-template-columns: max-content 1fr; }
  .profile-stats { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  body { font-size: 16px; padding-bottom: 68px; }
  .topbar { grid-template-columns: max-content 1fr max-content; min-height: 62px; padding: .45rem .75rem; }
  .topbar > .add-book { display: none; }
  .brand span, .add-book, .user-menu summary:not(:focus) { font-size: 0; }
  .brand img { width: 28px; height: 35px; }
  .global-search { min-width: 0; }
  .user-menu summary { padding: .2rem; }
  .user-menu summary .avatar { font-size: .78rem; }
  .page-shell { width: min(100% - 1rem, 760px); padding-top: 1rem; }
  .page-heading { align-items: flex-start; }
  .heading-actions { justify-content: flex-start; }
  .view-switch { display: none; }
  .dashboard-side { grid-template-columns: 1fr; }
  .active-reading-card { grid-template-columns: 82px 1fr; }
  .small-cover { width: 82px; }
  .quick-progress, .progress-form, .inline-form { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-strip > div:nth-child(odd) { border-left: 0; }
  .summary-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .library-layout { grid-template-columns: 1fr; }
  .filter-toggle { display: inline-flex; }
  .filter-panel { position: fixed; z-index: 70; inset: 0 0 0 auto; width: min(340px, 92vw); overflow-y: auto; border-radius: 0; transform: translateX(105%); transition: transform .2s ease; }
  .filter-panel.is-open { transform: translateX(0); }
  .filter-header button { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 5px; background: var(--blue-soft); color: var(--blue); font-size: 1.4rem; }
  .book-detail { grid-template-columns: 1fr; }
  .book-detail-sidebar { position: static; display: grid; grid-template-columns: 135px 1fr; gap: 1rem; }
  .detail-cover { width: 135px; }
  .detail-meta { margin: 0; }
  .sidebar-chips, .metadata-source { grid-column: 1 / -1; }
  .book-title-row { display: block; }
  .book-actions { justify-content: flex-start; margin-top: 1rem; }
  .detail-tabs { top: 62px; overflow-x: auto; }
  .reader-row { grid-template-columns: 36px 1fr max-content 20px; }
  .reader-row > :nth-child(4) { display: none; }
  .horizontal-filters { grid-template-columns: 1fr 1fr; }
  .horizontal-filters label:first-child { grid-column: 1 / -1; }
  .profile-layout, .import-layout, .admin-grid { grid-template-columns: 1fr; }
  .statistics-layout { grid-template-columns: 1fr; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .compact-chart { grid-template-columns: repeat(2, 1fr); }
  .compact-chart > div { grid-template-columns: 32px minmax(55px, 1fr) 45px; }
  .series-book-list article { grid-template-columns: 42px 58px minmax(0, 1fr); }
  .series-book-list .mini-cover { width: 58px; }
  .series-book-list article > .status-badge { grid-column: 3; justify-self: start; }
  .quality-list article { grid-template-columns: 58px minmax(0, 1fr); align-items: start; }
  .quality-list .mini-cover { width: 58px; }
  .quality-actions { grid-column: 2; display: flex; flex-wrap: wrap; }
  .export-panel { position: static; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; z-index: 60; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; height: 62px; border-top: 1px solid var(--line); background: #fff; box-shadow: 0 -4px 16px rgba(20, 58, 107, .08); }
  .mobile-nav a { display: grid; place-items: center; height: 100%; color: #40516a; font-size: .7rem; font-weight: 700; }
  .mobile-nav .mobile-add { width: 46px; height: 46px; margin: -16px auto 0; border-radius: 50%; background: var(--blue); color: #fff; font-size: 1.65rem; box-shadow: 0 5px 14px rgba(7, 84, 201, .28); }
}

@media (max-width: 520px) {
  .topbar { grid-template-columns: max-content minmax(0, 1fr) max-content; }
  .page-heading { display: grid; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .active-reading-card { grid-template-columns: 1fr; }
  .small-cover { width: 105px; }
  .book-grid { grid-template-columns: 1fr; }
  .book-card { min-height: 180px; }
  .book-detail-sidebar { grid-template-columns: 105px 1fr; }
  .detail-cover { width: 105px; }
  .detail-tabs { gap: .8rem; }
  .cancel-reading { align-items: stretch; flex-direction: column; }
  .cancel-reading .button { width: 100%; }
  .comment-head { align-items: flex-start; flex-wrap: wrap; }
  .comment-head time { width: 100%; margin-left: 40px; }
  .history-list article { grid-template-columns: 36px 1fr max-content; }
  .history-list article > :last-child { grid-column: 2 / -1; }
  .horizontal-filters { grid-template-columns: 1fr; }
  .horizontal-filters label:first-child { grid-column: auto; }
  .profile-header { grid-template-columns: 58px 1fr; }
  .profile-avatar { width: 58px; height: 58px; }
  .profile-reading-list article { grid-template-columns: 58px 1fr; }
  .mini-cover { width: 58px; }
  .profile-progress { grid-column: 2; justify-items: start; }
  .user-admin-list article { grid-template-columns: 36px 1fr max-content; }
  .user-admin-list form { grid-column: 2 / -1; }
  .isbn-preview { display: grid; }
  .scanner-dialog { width: calc(100% - .5rem); padding: .75rem; }
  .scanner-video-wrap { aspect-ratio: 3 / 4; }
  .scanner-fallback { display: grid; }
  .monthly-chart > div { grid-template-columns: 52px minmax(70px, 1fr) 52px; }
  .monthly-chart > div small { display: none; }
  .compact-chart { grid-template-columns: 1fr; }
  .reader-stat-values { grid-template-columns: repeat(2, 1fr); }
  .reader-stat-values > div:nth-child(3) { border-left: 0; }
  .quality-progress { grid-template-columns: 1fr; gap: .2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
