/* OCHST Library - built for phones first, then widened for tablets and computers. */
:root { --navy:#0b1b3f; --blue:#1f4aa0; --gold:#c9a43a; --gold-soft:#f6edd2; --bg:#f4f6fb; --panel:#fff; --line:#e1e6f0; --ink:#1b2133; --muted:#5d6985; --ok:#157f3b; --ok-bg:#e3f5ea; --bad:#b3261e; --bad-bg:#fdeceb; --warn-bg:#fff4d6; --shadow:0 1px 2px rgba(11,27,63,.08), 0 6px 18px rgba(11,27,63,.07); --r:14px; --nav:62px; }
@media (prefers-color-scheme: dark) { :root { --bg:#0d1324; --panel:#161d33; --line:#273150; --ink:#e8ecf8; --muted:#9aa7c6; --gold-soft:#3a3320; --ok-bg:#12331f; --bad-bg:#3b1816; --warn-bg:#3a3320; --shadow:0 1px 2px rgba(0,0,0,.4); } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent; padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom)); }
a { color: var(--blue); }
@media (prefers-color-scheme: dark) { a { color: #8fb4ff; } }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 .9rem; color: var(--navy); }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; color: var(--navy); }
@media (prefers-color-scheme: dark) { h1, h2 { color: #fff; } }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-left)) 2rem; }
.narrow { max-width: 640px; margin-inline: auto; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 8px; background: #fff; padding: 2px; object-fit: contain; }
.brand b { color: var(--gold); }
.top .grow { flex: 1; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .875rem; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; opacity: .9; }
.who button { background: rgba(255,255,255,.12); border: 0; color: #fff; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }

/* navigation: a bar at the bottom on phones, a rail on the left on bigger screens */
.nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--panel); border-top: 1px solid var(--line); display: flex; justify-content: space-around; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; min-width: 0; }
.nav a[aria-current] { color: var(--blue); }
@media (prefers-color-scheme: dark) { .nav a[aria-current] { color: var(--gold); } }
.nav a.scan i { background: var(--blue); width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-top: -22px; box-shadow: var(--shadow); border: 4px solid var(--bg); }
.nav a.scan i { color: #fff; }
.nav a.scan svg { width: 26px; height: 26px; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 210px; }
  .top { margin-left: -210px; }
  .nav { z-index: 10; top: 0; right: auto; bottom: 0; width: 210px; height: auto; flex-direction: column; justify-content: flex-start; gap: .15rem; padding: 4.6rem .6rem 1rem; border-top: 0; border-right: 1px solid var(--line); }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: .7rem; padding: .7rem .9rem; border-radius: 12px; font-size: .95rem; }
  .nav a[aria-current] { background: var(--sel, #e4ecfb); }
  @media (prefers-color-scheme: dark) { .nav a[aria-current] { background: #243766; } }
  .nav a.scan i { background: none; width: auto; height: auto; margin: 0; border: 0; box-shadow: none; color: inherit; display: contents; }
  .nav a.scan svg { width: 22px; height: 22px; }
  .top { position: sticky; }
}

/* flash */
.flash { padding: .8rem 1rem; border-radius: var(--r); margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .flash.ok { color: #7fe0a1; } .flash.err { color: #ffa7a0; } }

/* buttons, forms (16px inputs so phones do not zoom in) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 48px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--blue); }
@media (prefers-color-scheme: dark) { .btn.ghost { color: #8fb4ff; border-color: #3b5aa5; } }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1b1500; }
.btn.red { background: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 40px; padding: .35rem .8rem; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
label { display: block; font-weight: 600; margin: 0 0 .3rem; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea { width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 16px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
textarea { min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
input[type=file] { width: 100%; font-size: 15px; }
.field { margin-bottom: 1rem; }
.err-text { color: var(--bad); font-size: .9rem; margin: .3rem 0 0; }
.grid2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.pw { position: relative; }
.pw input { padding-right: 52px; }
.pw button { position: absolute; right: 4px; top: 4px; width: 44px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); }
.bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.bar form { display: flex; gap: .5rem; flex: 1; min-width: 14rem; }
.bar form input[type=search] { flex: 1; min-width: 0; }

/* stat cards */
.stats { display: grid; gap: .7rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); display: block; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; color: var(--navy); }
@media (prefers-color-scheme: dark) { .stat b { color: #fff; } }
.stat span { font-size: .85rem; color: var(--muted); }
.stat.warn b { color: var(--bad); }
.cols { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .cols { grid-template-columns: 1fr 1fr; } }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .7rem; align-items: center; justify-content: space-between; padding: .75rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .main { min-width: 0; flex: 1 1 14rem; }
.list .main b { display: block; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--gold-soft); color: #6b5410; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.blue { background: #e4ecfb; color: #1f4aa0; }
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: 1rem; -webkit-overflow-scrolling: touch; }
.tabs a { white-space: nowrap; padding: .5rem .9rem; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; }
.tabs a[aria-current] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.2rem; }

/* books */
.books { display: grid; gap: .8rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .books { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .books { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .books { grid-template-columns: repeat(5, 1fr); } }
.book { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.cover { aspect-ratio: 3/4; background: linear-gradient(160deg, var(--navy), var(--blue)); color: #fff; display: grid; place-items: center; text-align: center; padding: .8rem; font-weight: 700; font-size: .95rem; overflow: hidden; position: relative; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.big { max-width: 220px; width: 100%; border-radius: var(--r); box-shadow: var(--shadow); }
.book .info { padding: .6rem .7rem .8rem; display: flex; flex-direction: column; gap: .15rem; }
.book .t { font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book .a { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }
.detail { display: grid; gap: 1.2rem; grid-template-columns: 1fr; justify-items: center; }
@media (min-width: 700px) { .detail { grid-template-columns: 220px 1fr; justify-items: stretch; align-items: start; } }
.detail .meta { width: 100%; }
.meta dl { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem .8rem; margin: 1rem 0; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }

/* the scanning desk */
.scanbox { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 1 / 1; max-width: 420px; margin: 0 auto; display: none; }
.scanbox.on { display: block; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; }
.scanbox .frame { position: absolute; inset: 14%; border: 3px solid var(--gold); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.scanbox .hint { position: absolute; left: 0; right: 0; bottom: .6rem; text-align: center; color: #fff; font-size: .85rem; text-shadow: 0 1px 3px #000; }
.person { display: flex; gap: .9rem; align-items: center; }
.avatar { width: 76px; height: 76px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person h2 { margin: 0; font-size: 1.2rem; }
.status { padding: .8rem 1rem; border-radius: var(--r); font-weight: 600; margin: .8rem 0; }
.status.in { background: var(--ok-bg); color: var(--ok); }
.status.out { background: var(--gold-soft); color: #6b5410; }
.status.bad { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .status.in { color: #7fe0a1; } .status.out { color: #f2d98a; } .status.bad { color: #ffa7a0; } }
.results { list-style: none; margin: .4rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.results li { padding: .75rem .9rem; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.results li:last-child { border-bottom: 0; }
.results li:hover, .results li:focus { background: var(--hover, #eef3fc); }
.toast { position: fixed; left: 1rem; right: 1rem; bottom: calc(var(--nav) + 1rem + env(safe-area-inset-bottom)); z-index: 40; padding: .9rem 1rem; border-radius: 14px; background: var(--navy); color: #fff; font-weight: 600; box-shadow: var(--shadow); max-width: 520px; margin-inline: auto; display: none; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--bad); }
@media (min-width: 900px) { .toast { bottom: 1.5rem; } }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--navy), #14306e); }
.login .card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 20px; padding: 1.6rem 1.3rem; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login .logo { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.2rem; }
.login .logo img { width: 52px; height: 52px; object-fit: contain; border-radius: 12px; background: #fff; }
.login h1 { margin: 0; font-size: 1.3rem; }
@media print { .nav, .top, .bar, .actions { display: none !important; } body { padding: 0; } }
