/* KitobAlmash — "library" look: navy shelves, paper pages, a rust rubber stamp for prices and actions. */

/* Self-hosted fonts (SIL Open Font License, see fonts/LICENSE-*.txt) */
@font-face { font-family: "Domine"; font-style: normal; font-display: swap; font-weight: 400 700; src: url(fonts/domine-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Domine"; font-style: normal; font-display: swap; font-weight: 400 700; src: url(fonts/domine-latin-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(fonts/nunito-sans-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(fonts/nunito-sans-latin-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(fonts/nunito-sans-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-display: swap; font-weight: 200 1000; src: url(fonts/nunito-sans-cyrillic-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }

:root {
  --text: #1B2A3A;
  --text-2: #3D4D5E;
  --muted: #5B6773;
  --paper: #FAF7F0;
  --card: #FFFFFF;
  --tint: #F1ECE1;
  --rule: #E3DCCD;
  --rule-strong: #CBC1AD;
  --navy: #1B2A3A;
  --on-navy: #FAF7F0;
  --stamp: #B4501E;
  --stamp-hover: #973F15;
  --on-stamp: #FFFFFF;
  --link: #1F6FB2;
  --tg: #1F6FB2;
  --ok: #2B6449;
  --ok-bg: #E2EFE6;
  --err: #A3341C;
  --err-bg: #F8E3DC;
  --pending: #8A4B12;
  --pending-bg: #FCEEDF;
  --accepted: #1A5C94;
  --accepted-bg: #E2EDF8;
  --choice-on: #FFF4EC;
  --star: #D9951A;
  --grade-a: #2B6449;
  --grade-b: #1F6FB2;
  --grade-c: #8A5A2B;
  --ghost-1: #E6DFD1;
  --ghost-2: #DCD3C1;
  --ghost-3: #D2C8B4;
  --shadow-sm: 0 1px 2px rgba(27, 42, 58, .08);
  --shadow: 0 1px 2px rgba(27, 42, 58, .1), 0 14px 30px -18px rgba(27, 42, 58, .45);
  --font-serif: "Domine", Georgia, "Times New Roman", serif;
  --font-sans: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --wrap: 1160px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ECE6D9;
    --text-2: #CFC8BA;
    --muted: #A49D91;
    --paper: #14202C;
    --card: #1B2A3A;
    --tint: #182633;
    --rule: #2B3A4A;
    --rule-strong: #3E5063;
    --navy: #0D1720;
    --on-navy: #ECE6D9;
    --stamp: #E58350;
    --stamp-hover: #F09865;
    --on-stamp: #14202C;
    --link: #82BAEA;
    --tg: #3A8FD6;
    --ok: #8FD0A9;
    --ok-bg: #1D3A2C;
    --err: #F2A08A;
    --err-bg: #43231B;
    --pending: #F4BE83;
    --pending-bg: #3D2B19;
    --accepted: #9CC8F0;
    --accepted-bg: #1C3550;
    --choice-on: #2A2722;
    --star: #F2B544;
    --grade-a: #8FD0A9;
    --grade-b: #82BAEA;
    --grade-c: #D9AE7E;
    --ghost-1: #223242;
    --ghost-2: #26384A;
    --ghost-3: #2B3F52;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 30px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; line-height: 1.18; margin: 0 0 .5em; color: var(--text); text-wrap: balance; }
h1 { font-size: clamp(2.05rem, 1.35rem + 2.9vw, 3.4rem); letter-spacing: -0.012em; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.95rem); }
h3 { font-size: 1.18rem; }
p { margin: 0 0 1em; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--stamp); color: var(--on-stamp); }

.wrap { width: min(100% - 32px, var(--wrap)); margin-inline: auto; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -120px; z-index: 100; background: var(--navy); color: var(--on-navy); padding: 10px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.measure { max-width: 36em; }
.lede { font-size: 1.15rem; color: var(--text-2); max-width: 36em; }
main { min-height: 55vh; padding-bottom: 72px; }
.in-tg .only-web { display: none !important; }

/* ------------------------------------------------------------------ icons and logo */
.ico { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico .fill { fill: currentColor; stroke: none; }
.logo { flex: none; display: block; }
.logo .logo-a { fill: var(--logo-a, #1B2A3A); }
.logo .logo-b { fill: #B4501E; }
.logo .logo-c { fill: #1F6FB2; }
@media (prefers-color-scheme: dark) { .logo { --logo-a: #ECE6D9; } .logo .logo-b { fill: #E58350; } .logo .logo-c { fill: #82BAEA; } }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem/1.2 var(--font-sans); padding: 12px 20px; border-radius: 8px;
  border: 1.5px solid transparent; text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-stamp { background: var(--stamp); color: var(--on-stamp); }
.btn-stamp:hover { background: var(--stamp-hover); }
.btn-ink { background: var(--navy); color: var(--on-navy); }
.btn-ink:hover { background: #24384D; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--rule-strong); }
.btn-ghost:hover { border-color: var(--text); }
.btn-quiet { background: transparent; color: var(--link); padding-inline: 10px; }
.btn-quiet:hover { background: var(--tint); }
.btn-tg { background: var(--tg); color: #FFFFFF; }
.btn-tg:hover { filter: brightness(1.08); }
.btn-sm { padding: 8px 14px; font-size: .9rem; }
.btn-lg { padding: 15px 26px; font-size: 1.06rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; font-size: .9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------ header */
.site-head { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.head-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 28px; min-height: 66px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.24rem/1 var(--font-serif); color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 8px 12px; color: var(--text-2); text-decoration: none; font-weight: 600; border-radius: 6px; }
.nav a:hover { background: var(--tint); color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); background: none; border-radius: 0; box-shadow: inset 0 -2px 0 var(--stamp); }
.head-actions { display: flex; align-items: center; gap: 14px; }
.lang-switch { font-size: .88rem; font-weight: 700; color: var(--text-2); text-decoration: none; padding: 5px 9px; border: 1px solid var(--rule); border-radius: 6px; }
.lang-switch:hover { border-color: var(--rule-strong); color: var(--text); }
.head-login { font-weight: 700; color: var(--text); text-decoration: none; }
.head-login:hover { text-decoration: underline; }
.head-user { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; }
.head-user-name { max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-points { background: var(--navy); color: var(--on-navy); border-radius: 999px; padding: 2px 9px; font-size: .8rem; font-weight: 800; }
@media (prefers-color-scheme: dark) { .head-points { background: var(--stamp); color: var(--on-stamp); } }

/* ------------------------------------------------------------------ flash messages */
.flashes { margin-top: 16px; display: grid; gap: 8px; }
.flash { display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 16px; border-radius: 10px; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--err-bg); color: var(--err); }
.page .flash { margin-bottom: 20px; }

/* ------------------------------------------------------------------ hero and the shelf */
.hero { padding-top: clamp(36px, 6vw, 76px); background: linear-gradient(180deg, var(--paper) 0%, var(--tint) 100%); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: end; }
.hero-copy { padding-bottom: 44px; }
.hero-copy h1 { max-width: 14ch; }
.hero-note { margin: 14px 0 0; color: var(--muted); font-size: .95rem; }

.search { display: flex; gap: 6px; max-width: 34rem; padding: 6px; background: var(--card); border: 1.5px solid var(--rule-strong); border-radius: 12px; box-shadow: var(--shadow-sm); }
.search:focus-within { border-color: var(--link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 22%, transparent); }
.search input[type="search"] { flex: 1; min-width: 0; width: auto; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; padding: 10px 12px; }
.search input[type="search"]:focus { outline: none; box-shadow: none; }
.search--wide { max-width: none; }

.shelf {
  --k: 1;
  display: flex; align-items: flex-end; gap: 3px;
  min-height: calc(230px * var(--k)); padding-top: 22px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.shelf::-webkit-scrollbar { display: none; }
.spine {
  flex: none; position: relative; display: flex; align-items: center; justify-content: center;
  width: calc(var(--w) * 1px * var(--k, 1)); height: calc(var(--h) * 1px * var(--k, 1));
  padding: 20px 0; border-radius: 3px 3px 1px 1px;
  background: var(--c, var(--ghost-1)); color: #FAF7F0; text-decoration: none;
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, .12), inset -4px 0 0 rgba(0, 0, 0, .2);
  transform-origin: bottom center; transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.spine span { writing-mode: vertical-rl; font: 700 13px/1 var(--font-serif); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 100%; }
.spine::before, .spine::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: rgba(250, 247, 240, .4); }
.spine::before { top: 9px; }
.spine::after { bottom: 9px; }
.spine--b1::before { box-shadow: 0 5px 0 rgba(250, 247, 240, .4); }
.spine--b2::after { height: 12px; bottom: 14px; background: rgba(0, 0, 0, .2); }
a.spine:hover, a.spine:focus-visible { transform: translateY(-12px); outline-offset: 3px; }
.spine--ghost { background: var(--ghost-1); box-shadow: inset -4px 0 0 rgba(0, 0, 0, .05); }
.spine--ghost::before, .spine--ghost::after { background: rgba(255, 255, 255, .45); }
.spine--ghost:nth-child(3n) { background: var(--ghost-2); }
.spine--ghost:nth-child(4n + 1) { background: var(--ghost-3); }
.spine--lean { transform: rotate(-7deg); transform-origin: bottom left; margin-left: 16px; }
.shelf-board { height: 14px; background: var(--navy); box-shadow: 0 12px 20px -12px rgba(27, 42, 58, .7); }

/* ------------------------------------------------------------------ sections */
.section { padding-block: clamp(52px, 7vw, 92px); }
.section--tint { background: var(--tint); }
.section-sm { margin-top: 56px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 16px; margin-bottom: 24px; }
.sec-head .btn { white-space: nowrap; }
.sec-head h2 { margin: 0; }
.sec-link { font-weight: 700; }
main > .section:last-child { padding-bottom: 24px; }

/* the three (and five) steps: a real sequence, so they are numbered */
.steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding-top: 60px; }
.steps li::before {
  content: counter(step); position: absolute; top: 0; left: 0; width: 42px; height: 42px;
  display: grid; place-items: center; border: 2px solid var(--stamp); border-radius: 50%;
  color: var(--stamp); font: 700 1.1rem/1 var(--font-serif); background: var(--paper);
}
.steps li:not(:last-child)::after { content: ""; position: absolute; top: 21px; left: 56px; right: -24px; border-top: 2px dotted var(--rule-strong); }
.steps h3, .steps h2 { font-size: 1.2rem; margin-bottom: .35em; }
.steps p { color: var(--text-2); margin: 0; }
.steps--long { grid-template-columns: 1fr; gap: 26px; margin-top: 32px; }
.steps--long li { padding: 6px 0 0 64px; }
.steps--long li:not(:last-child)::after { top: 50px; left: 20px; right: auto; bottom: -22px; border-top: 0; border-left: 2px dotted var(--rule-strong); }

/* categories look like the divider cards in a library catalogue drawer */
.cats { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.cat {
  position: relative; display: flex; flex-direction: column; gap: 6px; height: 100%;
  padding: 26px 18px 18px; background: var(--card); color: var(--text); text-decoration: none;
  border: 1px solid var(--rule); border-radius: 3px 3px 10px 10px;
}
.cat::before { content: ""; position: absolute; top: -1px; left: 18px; width: 46px; height: 7px; border-radius: 0 0 3px 3px; background: var(--tab); }
.cat--1 { --tab: #1B2A3A; } .cat--2 { --tab: #B4501E; } .cat--3 { --tab: #1F6FB2; } .cat--4 { --tab: #2E5E4E; } .cat--5 { --tab: #6B4E8A; }
@media (prefers-color-scheme: dark) { .cat--1 { --tab: #ECE6D9; } }
.cat:hover { border-color: var(--rule-strong); }
.cat:hover .cat-name { text-decoration: underline; text-underline-offset: 3px; }
.cat-name { font: 700 1.08rem/1.25 var(--font-serif); }
.cat-hint { color: var(--muted); font-size: .9rem; line-height: 1.4; }
.cat-count { margin-top: auto; padding-top: 10px; font-size: .85rem; font-weight: 800; color: var(--text-2); }

/* ------------------------------------------------------------------ books */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 34px 24px; }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.bk { display: flex; flex-direction: column; min-width: 0; }
.bk-cover { display: block; margin-bottom: 12px; color: inherit; text-decoration: none; }
.ex-cover { display: block; text-decoration: none; }
.bk-cover:hover .cover { transform: translateY(-3px); }
.bk-title { font: 700 1rem/1.3 var(--font-serif); margin: 0 0 2px; overflow-wrap: anywhere; }
.bk-title a { color: var(--text); text-decoration: none; }
.bk-title a:hover { text-decoration: underline; }
.bk-author { margin: 0 0 8px; color: var(--muted); font-size: .9rem; line-height: 1.35; }
.bk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: auto 0 0; font-size: .85rem; color: var(--text-2); }
.bk-district { display: inline-flex; align-items: center; gap: 3px; }
.bk-district .ico { width: 15px; height: 15px; color: var(--muted); }
.bk-price { margin-left: auto; font-weight: 800; color: var(--stamp); white-space: nowrap; }
.bk--mine .bk-meta { margin-bottom: 6px; }

.cover {
  position: relative; display: block; aspect-ratio: 2 / 3; overflow: hidden;
  border-radius: 2px 5px 5px 2px; background: var(--tint);
  box-shadow: 0 1px 1px rgba(27, 42, 58, .16), 0 14px 24px -16px rgba(27, 42, 58, .6);
  container-type: inline-size; transition: transform .2s ease;
}
.cover::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; pointer-events: none; background: linear-gradient(90deg, rgba(0, 0, 0, .24), rgba(255, 255, 255, .14) 55%, transparent); }
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover--gen { display: flex; flex-direction: column; justify-content: center; padding: 16% 13% 16% 17%; background: var(--c); color: #FAF7F0; }
.cover--gen::before { content: ""; position: absolute; inset: 6% 6% 6% 10%; border: 1px solid rgba(250, 247, 240, .5); }
.cover--b1 { background-image: linear-gradient(180deg, transparent 74%, rgba(250, 247, 240, .16) 74% 81%, transparent 81%); }
.cover--b2 { justify-content: flex-end; background-image: linear-gradient(180deg, rgba(0, 0, 0, .18) 0 20%, transparent 20%); }
.cover-title { position: relative; font: 700 13px/1.18 var(--font-serif); font-size: clamp(11px, 10.5cqw, 26px); overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden; }
.cover-author { position: relative; margin-top: .75em; font: 600 11px/1.3 var(--font-sans); font-size: clamp(9px, 6.4cqw, 15px); opacity: .88; }

.grade { display: inline-grid; place-items: center; flex: none; width: 1.6em; height: 1.6em; border: 1.5px solid currentColor; border-radius: 50%; font: 800 .78rem/1 var(--font-sans); }
.grade-A { color: var(--grade-a); } .grade-B { color: var(--grade-b); } .grade-C { color: var(--grade-c); }

/* the price is a rubber stamp */
.stamp {
  display: inline-block; white-space: nowrap; padding: .38em .62em .32em;
  font: 700 .95rem/1 var(--font-serif); color: var(--stamp);
  border: 2px solid currentColor; border-radius: 6px; outline: 1px solid currentColor; outline-offset: -6px;
  transform: rotate(-3deg);
}
.stamp-lg { font-size: 1.3rem; padding: .5em .75em .42em; transform: rotate(-6deg); }

/* ------------------------------------------------------------------ catalogue */
.page { padding-top: 28px; }
.page--narrow { max-width: 720px; }
.page--text { max-width: 780px; }
.page-title { margin-top: 6px; }
.catalog-form { display: grid; gap: 12px; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: center; }
.filters-reset { font-weight: 700; padding-inline: 6px; }
.results-count { margin: 22px 0 18px; color: var(--muted); font-size: .95rem; }
.empty { display: grid; gap: 14px; justify-items: start; padding: clamp(24px, 4vw, 44px); border: 2px dashed var(--rule-strong); border-radius: 12px; }
.empty h2, .empty p { margin: 0; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 44px; }
.pager > :last-child { justify-self: end; }
.pager-info { color: var(--muted); font-size: .95rem; }

/* ------------------------------------------------------------------ forms */
input:not([type]), input[type="text"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text);
  background: var(--card); border: 1.5px solid var(--rule-strong); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 22%, transparent); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235B6773' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
::placeholder { color: var(--muted); opacity: .85; }
.form { display: grid; gap: 24px; margin-top: 8px; }
.field { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { font-weight: 700; padding: 0; }
.field > legend { margin-bottom: 8px; }
.opt { font-weight: 400; color: var(--muted); font-size: .9rem; }
.hint { margin: 0; color: var(--muted); font-size: .9rem; }
.choices { display: grid; gap: 10px; }
.choices--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { position: relative; display: block; }
.choice input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.choice > span { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; border: 1.5px solid var(--rule-strong); border-radius: 8px; background: var(--card); font-weight: 700; }
.choice input:checked + span { border-color: var(--stamp); box-shadow: inset 0 0 0 1px var(--stamp); background: var(--choice-on); }
.choice input:focus-visible + span { outline: 3px solid var(--link); outline-offset: 2px; }
.choice--card .choice-body { justify-content: flex-start; text-align: left; padding: 14px 16px; }
.choice-body > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.choice-body small { color: var(--muted); font-weight: 400; }
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-preview img { display: block; width: 64px; height: 96px; object-fit: cover; border-radius: 2px 4px 4px 2px; box-shadow: var(--shadow); }
input[type="file"] { font: inherit; font-size: .95rem; max-width: 100%; }
input[type="file"]::file-selector-button { font: 700 .9rem var(--font-sans); padding: 9px 14px; margin-right: 12px; border-radius: 8px; border: 1.5px solid var(--rule-strong); background: var(--card); color: var(--text); cursor: pointer; }

/* ------------------------------------------------------------------ book page: a library index card */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; font-size: .92rem; color: var(--muted); }
.crumbs a { color: var(--text-2); }
.book { display: grid; grid-template-columns: minmax(200px, 340px) minmax(0, 1fr); gap: clamp(24px, 5vw, 64px); align-items: start; }
.book-cover .cover { box-shadow: 0 2px 2px rgba(27, 42, 58, .16), 0 28px 44px -26px rgba(27, 42, 58, .75); }
.libcard { position: relative; padding: clamp(22px, 3vw, 36px); background: var(--card); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow-sm); }
.libcard-head { position: relative; padding: 0 128px 16px 0; margin-bottom: 4px; border-bottom: 2px solid var(--stamp); }
.libcard-head h1 { font-size: clamp(1.65rem, 1.2rem + 1.8vw, 2.45rem); margin-bottom: .25em; }
.libcard-author { margin: 0; color: var(--text-2); font-size: 1.1rem; }
.libcard-head .stamp { position: absolute; top: 2px; right: 4px; }
.facts { margin: 0; }
.facts > div { display: grid; grid-template-columns: 9em minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--muted); font-size: .93rem; }
.facts dd { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; font-weight: 600; }
.facts dd small { flex-basis: 100%; color: var(--muted); font-weight: 400; }
.book-desc { margin-top: 20px; }
.book-desc h2 { margin-bottom: 4px; font: 700 .93rem/1.4 var(--font-sans); color: var(--muted); }
.book-desc p { white-space: pre-line; margin: 0; }
.book-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 26px; }
.book-actions form { margin: 0; }
.book-actions .muted { margin: 0; }
.book-how { margin: 20px 0 0; padding: 12px 14px; background: var(--tint); border-radius: 8px; font-size: .93rem; color: var(--text-2); }
.notice { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; background: var(--tint); border-radius: 8px; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }

/* ------------------------------------------------------------------ points, safety, bot */
.points { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.prices { width: 100%; max-width: 540px; margin: 16px 0 24px; border-collapse: collapse; }
.prices th, .prices td { padding: 14px 0; border-bottom: 1px solid var(--rule); text-align: left; font-weight: 400; vertical-align: middle; }
.prices thead th { padding-top: 0; font-size: .85rem; font-weight: 700; color: var(--muted); }
.prices td, .prices thead th:last-child { text-align: right; }
.price-cond { display: flex; align-items: center; gap: 12px; }
.price-cond > span { display: flex; flex-direction: column; }
.prices small { color: var(--muted); }
.ticks, .earn { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 14px; }
.ticks li, .earn li { display: flex; align-items: flex-start; gap: 12px; }
.ticks .ico, .earn .ico { width: 22px; height: 22px; margin-top: 2px; color: var(--stamp); }
.duo { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.bot-cta { padding: 30px; border-radius: 14px; background: var(--navy); color: var(--on-navy); }
.bot-cta h2 { color: var(--on-navy); }
.bot-cta p { opacity: .85; }
.bot-cta .btn-tg { background: var(--on-navy); color: #1B2A3A; }

/* ------------------------------------------------------------------ login */
.login-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: center; margin: 24px 0 18px; padding: 28px; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; }
.login-status { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; color: var(--muted); }
.login-expired, .login-ok { margin: 18px 0 0; font-weight: 700; }
.login-ok { color: var(--ok); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--stamp); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.login-qr { margin: 0; text-align: center; }
.login-qr svg { display: block; width: 176px; height: 176px; border-radius: 8px; shape-rendering: crispEdges; }
.login-qr figcaption { max-width: 176px; margin-top: 8px; font-size: .85rem; color: var(--muted); }

/* ------------------------------------------------------------------ account */
.me { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: clamp(28px, 4vw, 48px); align-items: start; }
.me-side { display: grid; gap: 20px; }
.member { position: relative; overflow: hidden; padding: 26px 22px 22px; border-radius: 14px; background: var(--navy); color: var(--on-navy); box-shadow: var(--shadow); --logo-a: #FAF7F0; }
.member::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 7px; background: repeating-linear-gradient(90deg, #B4501E 0 28px, transparent 28px 34px); }
.member-top { display: flex; justify-content: space-between; gap: 12px; font-size: .84rem; opacity: .78; }
.member-name { margin: 12px 0 18px; font: 700 1.5rem/1.2 var(--font-serif); overflow-wrap: anywhere; }
.member-row { display: flex; flex-wrap: wrap; gap: 14px 22px; padding-right: 40px; }
.member-label { display: block; font-size: .75rem; opacity: .72; }
.member-points { font: 700 2rem/1.05 var(--font-serif); }
.member-val { display: block; font-weight: 700; padding-top: 6px; }
.member .logo { position: absolute; right: 18px; bottom: 18px; opacity: .9; }
.panel { padding: 18px 20px; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; }
.panel h2 { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.panel h2 .ico { color: var(--stamp); }
.panel p { font-size: .95rem; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: .85rem; padding: 8px 10px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 3px 3px 12px; background: var(--tint); border-radius: 999px; font-size: .9rem; }
.chip a { color: var(--text); text-decoration: none; }
.chip a:hover { text-decoration: underline; }
.chip form { margin: 0; }
.chip button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.chip button:hover { background: var(--rule); color: var(--text); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; padding: 8px 10px; }
.history { width: 100%; border-collapse: collapse; font-size: .92rem; }
.history td { padding: 7px 0; border-bottom: 1px solid var(--rule); }
.history td:first-child { width: 3.4em; font-weight: 800; }
.history td:last-child { text-align: right; white-space: nowrap; }
.history .plus { color: var(--ok); }
.history .minus { color: var(--err); }
.block { margin-bottom: 44px; }
.block h2 { font-size: 1.4rem; }
.list { list-style: none; display: grid; gap: 12px; padding: 0; margin: 0; }
.ex { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px; background: var(--card); border: 1px solid var(--rule); border-radius: 10px; }
.ex-cover .cover-title, .ex-cover .cover-author { display: none; }
.ex-title { font: 700 1.04rem/1.3 var(--font-serif); color: var(--text); text-decoration: none; }
.ex-title:hover { text-decoration: underline; }
.ex-who, .ex-state { margin: 2px 0 0; font-size: .92rem; }
.ex-body .small { margin: 4px 0 0; }
.ex-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ex-actions form { margin: 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--tint); color: var(--text-2); font-size: .8rem; font-weight: 800; }
.pill-pending { background: var(--pending-bg); color: var(--pending); }
.pill-accepted, .pill-book-reserved { background: var(--accepted-bg); color: var(--accepted); }
.pill-completed, .pill-book-available { background: var(--ok-bg); color: var(--ok); }
.pill-book-exchanged { background: var(--navy); color: var(--on-navy); }
.grid--mine { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 26px 18px; }
.rate-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 14px; background: var(--card); border: 1px solid var(--rule); border-radius: 10px; }
.stars { display: flex; gap: 2px; margin: 0; }
.stars button { padding: 4px; border: 0; background: none; color: var(--rule-strong); cursor: pointer; }
.stars button .ico { width: 28px; height: 28px; }
.stars:has(button:nth-of-type(1):is(:hover, :focus-visible)) button:nth-of-type(-n + 1),
.stars:has(button:nth-of-type(2):is(:hover, :focus-visible)) button:nth-of-type(-n + 2),
.stars:has(button:nth-of-type(3):is(:hover, :focus-visible)) button:nth-of-type(-n + 3),
.stars:has(button:nth-of-type(4):is(:hover, :focus-visible)) button:nth-of-type(-n + 4),
.stars:has(button:nth-of-type(5):is(:hover, :focus-visible)) button:nth-of-type(-n + 5) { color: var(--star); }
.logout { margin-top: 8px; }

/* ------------------------------------------------------------------ blog, FAQ, 404 */
.posts { list-style: none; display: grid; gap: 36px; padding: 0; margin: 32px 0 0; }
.post-item time, .post time { color: var(--muted); font-size: .9rem; }
.post-item h2 { margin: 4px 0 8px; font-size: 1.45rem; }
.post-item h2 a { color: var(--text); text-decoration: none; }
.post-item h2 a:hover { text-decoration: underline; }
.post-item p { color: var(--text-2); margin-bottom: 6px; }
.prose { font-family: var(--font-serif); font-size: 1.09rem; line-height: 1.78; }
.prose h2 { margin-top: 1.7em; font-size: 1.32rem; }
.prose p { max-width: 68ch; }
.post-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 44px; padding: 22px 24px; background: var(--tint); border-radius: 12px; }
.post-cta p { margin: 0; max-width: 32em; }
.faq details { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.faq summary { display: flex; justify-content: space-between; gap: 16px; font-weight: 700; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--stamp); font: 700 1.25rem/1 var(--font-serif); }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 10px 0 0; color: var(--text-2); }
.nf-shelf { display: flex; align-items: flex-end; gap: 3px; width: max-content; padding: 0 12px; margin: 24px 0 28px; border-bottom: 12px solid var(--navy); }
.nf-gap { width: 44px; height: 168px; border: 2px dashed var(--rule-strong); border-bottom: 0; border-radius: 3px 3px 0 0; }

/* ------------------------------------------------------------------ admin panel */
.head-admin { padding: 3px 8px; border: 1.5px solid currentColor; border-radius: 6px; color: var(--stamp); font-size: .85rem; font-weight: 800; text-decoration: none; }
.head-admin[aria-current="page"] { background: var(--stamp); color: var(--on-stamp); border-color: var(--stamp); }
.nav .nav-admin { display: none; }
.ls-short { display: none; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 8px 0 28px; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; }
.kpis > div { padding: 14px 16px; border-left: 1px solid var(--rule); }
.kpis > div:first-child { border-left: 0; }
.kpis dt { color: var(--muted); font-size: .82rem; line-height: 1.3; }
.kpis dd { margin: 6px 0 0; font: 700 1.55rem/1.1 var(--font-serif); }
.kpis small { display: block; margin-top: 4px; color: var(--muted); font: 600 .78rem/1.3 var(--font-sans); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--rule); scrollbar-width: none; }
.tabs a { margin-bottom: -1px; padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 700; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--stamp); }
.admin-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-filter input[type="search"] { flex: 1 1 240px; width: auto; }
.admin-filter select { flex: 0 1 220px; width: auto; }
.admin .empty { display: block; }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--rule); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; white-space: nowrap; }
.tbl th { background: var(--tint); color: var(--muted); font-size: .8rem; font-weight: 800; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--tint) 55%, transparent); }
.tbl td.wrap { min-width: 200px; white-space: normal; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .sub { display: block; margin-top: 2px; color: var(--muted); font-size: .85rem; }
.tbl a { color: var(--text); }
.tbl a.sub { color: var(--link); }
.tbl form { margin: 0; }
.tag { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: var(--err-bg); color: var(--err); font-size: .72rem; font-weight: 800; vertical-align: 1px; }
.tag-you { background: var(--accepted-bg); color: var(--accepted); }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis > div { border-left: 0; border-top: 1px solid var(--rule); }
  .kpis > div:nth-child(-n + 2) { border-top: 0; }
  .kpis > div:nth-child(even) { border-left: 1px solid var(--rule); }
  .kpis > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .head-admin { display: none; }
  .nav .nav-admin { display: inline-block; color: var(--stamp); font-weight: 800; }
}

/* ------------------------------------------------------------------ footer */
.site-foot { padding: 48px 0 calc(48px + env(safe-area-inset-bottom)); background: var(--navy); color: var(--on-navy); }
.foot-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: start; }
.brand-light { color: var(--on-navy); }
.site-foot .logo { --logo-a: #FAF7F0; }
.foot-brand p { margin: 12px 0 0; max-width: 32em; opacity: .75; }
.foot-links { display: grid; grid-template-columns: repeat(2, auto); gap: 8px 36px; }
.foot-links a { color: var(--on-navy); opacity: .85; text-decoration: none; }
.foot-links a:hover { opacity: 1; text-decoration: underline; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; gap: 8px; }
  .hero-copy { padding-bottom: 8px; }
  .cats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .points, .duo { grid-template-columns: 1fr; }
  /* account page on small screens: card first, then what needs an answer, then the rest */
  .me { display: flex; flex-direction: column; gap: 20px; }
  .me-side, .me-main { display: contents; }
  .member { order: -1; }
  .me-side .panel { order: 1; }
  .logout { order: 2; }
}
@media (max-width: 760px) {
  body { font-size: 1rem; }
  .head-row { grid-template-columns: 1fr auto; gap: 6px 12px; min-height: 0; padding-block: 10px 0; }
  .nav { grid-column: 1 / -1; grid-row: 2; margin-inline: -10px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 8px 10px 10px; }
  .head-actions { gap: 10px; }
  .head-user-name { display: none; }
  .head-add { padding: 8px 10px; }
  .head-add span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lang-switch { font-size: .8rem; padding: 4px 7px; }
  .lang-switch .ls-long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lang-switch .ls-short { display: inline; }
  .shelf { --k: .78; margin-inline: -16px; padding-inline: 16px; }
  .steps { grid-template-columns: 1fr; gap: 26px; }
  .steps li { padding: 4px 0 0 62px; min-height: 44px; }
  .steps li:not(:last-child)::after { top: 50px; left: 20px; right: auto; bottom: -22px; border-top: 0; border-left: 2px dotted var(--rule-strong); }
  .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .cats li:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
  .grid--mine { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 12px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book { grid-template-columns: 1fr; }
  .book-cover { width: min(62%, 260px); }
  .libcard-head { padding-right: 0; padding-top: 52px; }
  .libcard-head .stamp { top: 0; right: auto; left: 0; }
  .facts > div { grid-template-columns: 7.2em minmax(0, 1fr); }
  .choices--3 { grid-template-columns: 1fr 1fr 1fr; }
  .login-grid { grid-template-columns: 1fr; padding: 22px; }
  .only-desktop { display: none; }
  .ex { grid-template-columns: 44px minmax(0, 1fr); }
  .ex-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .foot-grid { grid-template-columns: 1fr; }
  .pager .btn { padding-inline: 12px; }
}
@media (max-width: 380px) {
  .grid--mine { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices--3 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
