:root {
  color-scheme: light;
  --navy: #071a33;
  --navy-2: #0d2d55;
  --blue: #155ca8;
  --gold: #d6a84b;
  --paper: #f4f7fb;
  --ink: #102038;
  --muted: #64748b;
  --line: #dce5ef;
  --white: #ffffff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
a { color: inherit; }

.site-header {
  min-height: 76px;
  padding: 12px clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img, footer img { border-radius: 50%; object-fit: cover; background: white; }
.brand span { display: grid; line-height: 1.15; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; letter-spacing: .01em; }
.brand small { margin-top: 4px; color: #b9c8da; font-size: .75rem; letter-spacing: .07em; text-transform: uppercase; }
nav { display: flex; gap: 6px; }
nav a { padding: 10px 14px; border-radius: 999px; text-decoration: none; color: #dce8f5; font-size: .92rem; }
nav a:hover, nav a:focus-visible { background: rgba(255,255,255,.1); color: #fff; outline: none; }

.access-section {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .75fr);
  align-items: center;
  gap: clamp(44px, 8vw, 118px);
  padding: clamp(48px, 7vw, 96px) clamp(20px, 8vw, 120px);
  color: white;
  background:
    radial-gradient(circle at 75% 18%, rgba(43,114,190,.34), transparent 28%),
    linear-gradient(135deg, #071a33 0%, #0b274a 58%, #061426 100%);
}

.access-section::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 540px;
  height: 540px;
  right: -260px;
  bottom: -260px;
  border: 1px solid rgba(214,168,75,.22);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(214,168,75,.035), 0 0 0 140px rgba(214,168,75,.025);
}

.access-copy { max-width: 720px; }
.eyebrow { margin: 0 0 14px; color: #ebc777; font-size: .78rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow.dark { color: var(--blue); }
h1, h2 { font-family: Georgia, "Times New Roman", serif; text-wrap: balance; }
h1 { margin: 0; max-width: 680px; font-size: clamp(2.6rem, 6vw, 5.3rem); line-height: .98; font-weight: 600; letter-spacing: -.035em; }
.lead { margin: 28px 0 0; max-width: 630px; color: #d4e0ec; font-size: clamp(1rem, 1.5vw, 1.2rem); line-height: 1.65; }
.steps { display: grid; gap: 12px; margin: 34px 0 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 12px; color: #edf4fb; font-size: 1rem; }
.steps span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(235,199,119,.55); border-radius: 50%; color: #ebc777; font-weight: 800; font-size: .82rem; }
.privacy-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 30px; color: #9fb2c8; font-size: .88rem; line-height: 1.5; }
.privacy-note span { color: #7dd9ae; font-weight: 900; }
.privacy-note p { margin: 0; }

.qr-card { width: min(100%, 440px); justify-self: end; padding: clamp(22px, 3vw, 32px); border: 1px solid rgba(255,255,255,.22); border-radius: 30px; color: var(--ink); background: rgba(255,255,255,.98); box-shadow: 0 30px 80px rgba(0,0,0,.32); }
.qr-card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.qr-label { margin: 0; font-weight: 800; font-size: 1.05rem; }
.qr-status { display: flex; align-items: center; gap: 7px; margin: 6px 0 0; color: var(--muted); font-size: .82rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #29a66f; box-shadow: 0 0 0 4px rgba(41,166,111,.12); }
.status-dot.error { background: #cf3e4a; box-shadow: 0 0 0 4px rgba(207,62,74,.12); }
.status-dot.authorized { background: #14905f; animation: accessPulse .8s ease-in-out infinite alternate; }
@keyframes accessPulse { to { transform: scale(1.35); } }
.shield-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px 14px 18px 18px; color: white; background: var(--navy-2); font-family: Georgia, serif; font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.qr-frame { position: relative; aspect-ratio: 1; display: grid; place-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 22px; background: #fff; }
#qrcode { width: 100%; height: 100%; display: grid; place-items: center; }
#qrcode img, #qrcode canvas { width: 100% !important; height: 100% !important; image-rendering: pixelated; }
.qr-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: inherit; background: #fff; }
.qr-loading span { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); animation: pulse 1s ease-in-out infinite; }
.qr-loading span:nth-child(2) { animation-delay: .15s; }
.qr-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-6px); } }
.timer-row { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: .9rem; }
.timer-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.progress { height: 5px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: #e7edf4; }
.progress span { display: block; width: 100%; height: 100%; transform-origin: left; background: linear-gradient(90deg, var(--gold), #e9c982); transition: width .3s linear; }
.access-wait { margin: 14px 0 0; color: var(--muted); text-align: center; font-size: .86rem; }
.retry-button { width: 100%; margin-top: 16px; padding: 12px 16px; border: 0; border-radius: 12px; color: white; background: var(--navy-2); font-weight: 800; cursor: pointer; }

.catalog-section { max-width: 1440px; margin: 0 auto; padding: clamp(70px, 8vw, 118px) clamp(20px, 6vw, 88px); }
.catalog-section--main { min-height: calc(100vh - 180px); }
.library-title { margin: 0; max-width: 760px; font-size: clamp(2.4rem, 5vw, 4.8rem); line-height: 1; color: var(--navy); }
.logout-link { padding: 10px 16px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; color: #e7eef7; text-decoration: none; font-size: .9rem; }
.logout-link:hover, .logout-link:focus-visible { background: rgba(255,255,255,.1); outline: none; }
.section-heading { display: grid; grid-template-columns: 1fr minmax(260px, 470px); align-items: end; gap: 36px; }
.section-heading h2 { margin: 0; font-size: clamp(2.2rem, 4vw, 4.2rem); line-height: 1; color: var(--navy); }
.section-heading > p { margin: 0 0 6px; color: var(--muted); font-size: 1.02rem; line-height: 1.6; }
.filters { display: grid; grid-template-columns: minmax(240px, 1.4fr) repeat(2, minmax(160px, .6fr)) auto; align-items: end; gap: 14px; margin-top: 42px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 12px 38px rgba(29,54,83,.07); }
.filters label { display: grid; gap: 8px; }
.filters label span { color: #465970; font-size: .8rem; font-weight: 800; }
.filters input, .filters select { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid #cdd9e5; border-radius: 12px; color: var(--ink); background: #fff; outline: none; }
.filters input:focus, .filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,92,168,.12); }
.filter-button { min-height: 48px; padding: 0 22px; border: 0; border-radius: 12px; color: white; background: var(--navy-2); font-weight: 800; cursor: pointer; }
.filter-button:hover { background: var(--blue); }
.catalog-meta { min-height: 24px; margin: 30px 0 14px; color: var(--muted); font-size: .9rem; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.book-card { min-height: 290px; display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 8px 24px rgba(29,54,83,.05); transition: transform .2s ease, box-shadow .2s ease; }
.book-card:hover { transform: translateY(-3px); box-shadow: 0 16px 38px rgba(29,54,83,.1); }
.book-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.book-icon { width: 50px; height: 58px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px 14px 14px 8px; color: white; background: linear-gradient(145deg, var(--navy-2), var(--blue)); font-family: Georgia, serif; font-size: 1.35rem; font-weight: 800; box-shadow: inset 4px 0 rgba(255,255,255,.12); }
.book-type { padding: 6px 9px; border-radius: 999px; color: var(--blue); background: #eaf3fd; font-size: .72rem; font-weight: 800; }
.book-card h2, .book-card h3 { margin: 20px 0 6px; font-family: Georgia, serif; font-size: 1.35rem; line-height: 1.2; }
.book-author { margin: 0; color: var(--muted); font-size: .88rem; }
.book-description { display: -webkit-box; overflow: hidden; margin: 18px 0 20px; color: #52647a; font-size: .9rem; line-height: 1.55; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.book-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 16px; border-top: 1px solid #edf1f5; color: var(--muted); font-size: .78rem; }
.book-footer a { color: var(--blue); font-weight: 800; text-decoration: none; }
.book-footer .document-link { padding: 8px 11px; border-radius: 9px; color: white; background: var(--blue); white-space: nowrap; }
.book-footer .document-link:hover, .book-footer .document-link:focus-visible { background: var(--navy-2); outline: none; }
.skeleton { min-height: 290px; border-radius: 20px; background: linear-gradient(100deg, #e7edf3 20%, #f6f8fa 40%, #e7edf3 60%); background-size: 200% 100%; animation: shimmer 1.25s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty-state { padding: 64px 24px; text-align: center; border: 1px dashed #bdcad8; border-radius: 20px; background: rgba(255,255,255,.55); }
.empty-state span { font-size: 2.4rem; color: var(--blue); }
.empty-state h3 { margin: 12px 0 6px; }
.empty-state p { margin: 0; color: var(--muted); }

footer { min-height: 104px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 24px; color: #b9c8da; background: var(--navy); font-size: .88rem; }

@media (max-width: 980px) {
  .access-section { grid-template-columns: 1fr; min-height: auto; }
  .qr-card { justify-self: start; }
  .section-heading { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:first-child { grid-column: 1 / -1; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .site-header { min-height: 68px; }
  .brand img { width: 42px; height: 42px; }
  .brand small { display: none; }
  nav a { padding: 9px; font-size: .82rem; }
  .access-section { padding-top: 54px; padding-bottom: 64px; }
  h1 { font-size: clamp(2.55rem, 13vw, 4rem); }
  .lead { margin-top: 22px; }
  .steps { margin-top: 28px; }
  .qr-card { width: 100%; padding: 20px; border-radius: 24px; }
  .filters { grid-template-columns: 1fr; }
  .filters label:first-child { grid-column: auto; }
  .catalog-grid { grid-template-columns: 1fr; }
  .section-heading > p { font-size: .96rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
