/* Book Store - the one stylesheet of the whole app.
   Plain CSS: no framework, no JavaScript, no web fonts, no files from other servers.
   The look: a white page, light grey panels with thin grey lines, one blue for every action,
   and the marigold of the logo only as a small highlight.

   The palette (all of it is in section 1)
     blue     #1658c8  every action: main buttons, links, active menu items
     navy     #132a5c  the logo, prices, the two dark surfaces of the home page
     marigold #f5b01e  the single accent, used small: the bookmark of the logo, stars,
                       "New" tags, the two small labels on navy ("Just arrived", "Best seller"),
                       the edge of a card that needs attention
     green    #17794a  only "in stock" and "done"
     red      #c62828  only errors, delete and low stock
     greys    #1b2130 text, #6a7280 second text, #e2e5ea lines, #f5f6f8 panels

   Contents
     1. Colours, fonts and sizes (variables)
     2. Base: page, text, links
     3. Header (top bar, logo, search, account, shop menu, back office)
     4. Buttons
     5. Forms
     6. Tables
     7. Badges and flash messages
     8. Book covers (picture and the no-picture fallback)
     9. Home page and book list (banner, category band, shelves, cards, listing)
    10. Book page (detail, order form, reviews)
    11. Log in, register and error pages
    12. Admin pages and the database page
    13. SQL: code blocks, reports, "SQL behind this page"
    14. Footer
    15. Smaller screens
*/


/* ---------- 1. Colours, fonts and sizes ---------- */
:root {
  --bg: #ffffff;           /* page */
  --panel: #f5f6f8;        /* light grey: bars, card tops, table heads */
  --panel-deep: #eceef2;   /* a darker grey for hover and code */
  --line: #e2e5ea;         /* thin borders */
  --field: #cbd1d9;        /* border of text boxes and quiet buttons */
  --ink: #1b2130;          /* text */
  --muted: #6a7280;        /* secondary text */
  --blue: #1658c8;         /* the action colour: main buttons, links, active states */
  --blue-dark: #0f4199;    /* the same blue under the mouse */
  --navy: #132a5c;         /* the navy of the logo: prices, dark surfaces (banner, best-seller card) */
  --blue-soft: #e8f0fd;    /* very light blue: chosen rows, the sort list */
  --accent: #f5b01e;       /* marigold: the one small accent (bookmark of the logo, stars, "New" tags, two labels) */
  --accent-soft: #fdf0cc;  /* its pale form: only the "pending" badge */
  --ok: #17794a;           /* green: in stock, done */
  --ok-soft: #e3f4ea;
  --danger: #c62828;       /* red: errors, delete, low stock */
  --danger-soft: #fdeaea;
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(27, 33, 48, 0.06), 0 4px 14px -8px rgba(27, 33, 48, 0.25);
  --width: 1240px;         /* widest the content gets */
}


/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;                      /* header, main and footer in a column; main takes the free space */
  flex-direction: column;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
main { flex: 1; width: 100%; max-width: var(--width); margin: 0 auto; padding: 20px 32px 48px; }
/* The same centred column for the bars of the header and the footer */
.wrap { max-width: var(--width); margin: 0 auto; padding: 0 32px; }

h1, h2, h3 { font-family: var(--sans); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-bottom: 12px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--muted); }
strong, .strong { font-weight: 600; }
/* Keyboard focus: a blue ring */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.icon { display: block; flex: none; }

/* Small grey label above a heading, e.g. "BACK OFFICE" */
.eyebrow { margin: 0 0 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* Title row of a page: heading on the left, main action or note on the right */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.page-head .note { margin: 0; max-width: 560px; color: var(--muted); font-size: 13px; text-align: right; text-wrap: balance; }   /* balance: lines of equal length, no lone last word */
h1 .count, h2 .count { font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--muted); vertical-align: middle; margin-left: 6px; padding: 2px 9px; border-radius: 99px; background: var(--panel); }

/* Two or more buttons on the right of the title row */
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Heading of a block with a small link or note on the right ("Best sellers ... See all") */
.section-head { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head a, .section-head .muted { font-size: 13px; }
.section-head a.more { font-weight: 700; }
.section-head a.more::after { content: " \203A"; }           /* a small arrow after "See all" */

/* Thin bar that shows a part of a whole (rating distribution, best sellers).
   <progress value max> is drawn by the browser; the three rules below only give it our colours. */
progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 99px; background: var(--panel-deep); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--panel-deep); }
progress::-webkit-progress-value { background: var(--blue); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 99px; }

/* White box used for forms and side panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }


/* ---------- 3. Header ---------- */
/* Three rows: the white bar with logo, search and account, the category menu,
   and (for an admin on a back-office page) the back-office menu. */
header { background: #fff; border-bottom: 1px solid var(--line); }
nav { max-width: var(--width); margin: 0 auto; padding: 0 32px; display: flex; align-items: center; }

/* Row 1: logo on the left, search in the middle, account on the right */
.main-nav { min-height: 76px; gap: 40px; }
.main-nav a.brand { color: var(--ink); }
.main-nav a.brand:hover { text-decoration: none; }

/* Logo: the mark (logo.svg) and the name as normal text, bold and tight, in the navy of the mark. */
.logo { display: flex; align-items: center; gap: 9px; margin: 0; }
.logo img { display: block; }
.wordmark { position: relative; top: -2px; font-size: 20px; font-weight: 800; line-height: 1; letter-spacing: -0.025em; white-space: nowrap; color: var(--navy); }   /* top: lines the name up with the book, not with the bookmark under it */

/* Search: a rounded grey field with a round blue button inside its right end */
.search { position: relative; flex: 1; max-width: 560px; margin-right: auto; }
.search input { width: 100%; height: 44px; padding: 0 52px 0 16px; font: inherit; font-size: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.search input::placeholder { color: #8a919d; }
/* An empty box is "invalid" for the browser (it is required); it must not look like an error. */
.search input:invalid { box-shadow: none; }
.search input:focus { outline: none; background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 88, 200, 0.15); }
.search button { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border-radius: 50%; }

/* Account: an icon with a label next to it */
.main-nav .right { display: flex; align-items: center; gap: 26px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.acct { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.acct a { color: var(--ink); }
.acct a:hover, a.acct:hover, a.acct.current { color: var(--blue); text-decoration: none; }
.role { font-weight: 400; color: var(--muted); }

/* Row 2: the categories in small bold capitals; "Database" stands apart at the right end */
.menu-bar { border-top: 1px solid var(--line); }
nav.menu { min-height: 44px; gap: 34px; }
nav.menu a { padding: 13px 0 11px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.menu a:hover { color: var(--blue); text-decoration: none; }
nav.menu a.current { color: var(--blue); border-bottom-color: var(--blue); }
nav.menu a.new { color: var(--blue); }
nav.menu a.apart { margin-left: auto; color: var(--muted); }
nav.menu a.apart:hover, nav.menu a.apart.current { color: var(--blue); }

/* Row 3: the back-office menu */
.admin-bar { background: var(--panel); border-top: 1px solid var(--line); }
nav.admin { min-height: 40px; gap: 24px; font-size: 13px; }
nav.admin .label { padding: 2px 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; background: var(--navy); border-radius: 3px; }
nav.admin a { padding: 10px 0 8px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.admin a:hover { color: var(--ink); text-decoration: none; }
nav.admin a.current { color: var(--blue); border-bottom-color: var(--blue); }


/* ---------- 4. Buttons ---------- */
/* Main button: blue with white text. Also used on links with class "button". */
button, a.button, span.button {
  display: inline-block;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.3;
  padding: 9px 18px;                       /* 38px high, the same as a text box */
  color: #fff; background: var(--blue);
  border: 1px solid var(--blue); border-radius: 6px;
  text-decoration: none; cursor: pointer;
}
button:hover, a.button:hover { background: var(--blue-dark); border-color: var(--blue-dark); text-decoration: none; }
/* Second-rank button: white with a grey outline */
button.quiet, a.button.quiet { color: var(--ink); background: #fff; border-color: var(--field); }
button.quiet:hover, a.button.quiet:hover { color: var(--blue); background: #fff; border-color: var(--blue); }
/* Delete / cancel: red outline, filled red on hover */
button.danger { color: var(--danger); background: #fff; border-color: #ecc1c1; }
button.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
/* White button: only on the dark banner of the home page */
a.button.light { color: var(--navy); background: #fff; border-color: #fff; }
a.button.light:hover { color: var(--blue); background: #fff; border-color: #fff; }
/* Full-width button: the one main action of a box (Place order, Log in) */
button.wide, a.button.wide { display: block; width: 100%; padding: 12px 18px; font-size: 15px; text-align: center; }
/* Small size for buttons inside table rows */
button.small, a.button.small, span.button.small { padding: 4px 11px; font-size: 12.5px; border-radius: 5px; }


/* ---------- 5. Forms ---------- */
/* One set of controls for the whole site: small bold label, 38px high box with a thin grey border,
   blue border and a soft blue ring while the box is being typed in. */
.form label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--ink); }
.form label small { font-weight: 400; color: var(--muted); margin-left: 2px; }
.form input, .form select, .form textarea, .sort-form select, td select {
  font: inherit; font-size: 14px; font-weight: 400; color: var(--ink);
  padding: 8px 11px;
  background: #fff; border: 1px solid var(--field); border-radius: 6px;
}
.form input, .form select, .form textarea { display: block; width: 100%; margin-top: 5px; }
/* Text boxes, lists and the buttons beside them have one height, so a row of them lines up. */
.form input:not([type=checkbox]):not([type=file]), .form select, .sort-form select, .sort-form button { height: 38px; }
.form input:hover, .form select:hover, .form textarea:hover { border-color: #9aa3af; }
.form input:focus, .form select:focus, .form textarea:focus, .sort-form select:focus, td select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 88, 200, 0.15);
}
.form textarea { resize: vertical; line-height: 1.45; }
/* Small grey line under a box: a rule or a tip ("At least 6 characters.") */
.hint { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; color: var(--muted); }
/* File box: dashed area, its "Choose file" button drawn like our quiet button */
.form input[type=file] { padding: 7px; font-size: 12.5px; color: var(--muted); background: var(--panel); border-style: dashed; cursor: pointer; }
.form input[type=file]::file-selector-button { margin-right: 8px; padding: 5px 10px; font: inherit; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--field); border-radius: 5px; cursor: pointer; }
.form input[type=file]::file-selector-button:hover { color: var(--blue); border-color: var(--blue); }

/* Fields in two columns; class "wide" makes one field use both columns */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.fields .wide { grid-column: 1 / -1; }

/* Row with the Save / Cancel buttons */
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

/* Check boxes (authors of a book) */
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 4px 0 18px; padding: 8px 14px 10px; }
legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 16px; }
.form label.check { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 0; font-size: 14px; font-weight: 400; }
.form label.check input { display: inline; width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--blue); }

form.inline { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
td select { padding: 4px 8px; font-size: 13px; border-radius: 5px; }


/* ---------- 6. Tables ---------- */
/* Every table sits in a .table-wrap box: on a narrow screen the box scrolls sideways, not the page. */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: var(--panel); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.id { color: var(--muted); font-variant-numeric: tabular-nums; }
td.code { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
td .item, td .sub { display: block; }
td .sub { color: var(--muted); font-size: 12.5px; }
td .sub.code { font-family: var(--mono); font-size: 11.5px; line-height: 1.3; }
td a { font-weight: 600; }
/* Sideways scrolling for a table that sits inside a white box */
.scroll-x { overflow-x: auto; }
td.actions { white-space: nowrap; text-align: right; padding-top: 7px; padding-bottom: 7px; }   /* the small buttons are taller than a text line: centred on it */
td.actions form { display: inline; margin-left: 4px; }
/* Tighter rows with everything centred: the admin book list with its small covers */
table.compact td { padding: 5px 14px; vertical-align: middle; }
td.empty-row { padding: 32px 16px; text-align: center; color: var(--muted); }


/* ---------- 7. Badges and flash messages ---------- */
/* Small label: role, order status, stock */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--panel-deep); color: var(--ink); white-space: nowrap; }
.badge.admin { background: var(--blue-soft); color: var(--blue-dark); }
.badge.delivered, .badge.in-stock { background: var(--ok-soft); color: var(--ok); }
.badge.pending { background: var(--accent-soft); color: #6b4a00; }
.badge.shipped { background: var(--blue-soft); color: var(--blue-dark); }
.badge.cancelled, .badge.out, .badge.low { background: var(--danger-soft); color: var(--danger); }

/* Message after an action, as a small note that floats at the top right under the header
   (it does not push the page down). Green tick = done, red mark = refused, blue i = anything else.
   A good-news note slides in, stays about five seconds and leaves by itself. An error stays
   longer (about nine seconds), so it is not missed, and then leaves too, so it never keeps covering
   the buttons beneath it. A note that has left is hidden (visibility: hidden), so it takes no clicks. */
.toasts { position: fixed; top: 136px; right: max(24px, calc((100vw - 1240px) / 2 + 32px));   /* in line with the right edge of the content */ z-index: 40; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 48px)); pointer-events: none; }
body:has(.admin-bar) .toasts { top: 178px; }
.flash { position: relative; margin: 0; padding: 12px 16px 12px 46px; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--ink); background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; box-shadow: 0 12px 30px -12px rgba(27, 33, 48, 0.45); pointer-events: auto; animation: toast-in 0.3s cubic-bezier(.2,.7,.3,1) both; }
.flash::before { content: "i"; position: absolute; left: 14px; top: 12px; width: 20px; height: 20px; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; color: #fff; background: var(--blue); border-radius: 50%; }
.flash.ok { border-left-color: var(--ok); animation: toast-in 0.3s cubic-bezier(.2,.7,.3,1) both, toast-out 0.5s ease-in 5.2s forwards; }
.flash.ok::before { content: "\2713"; background: var(--ok); }
.flash.error { border-left-color: var(--danger); animation: toast-in 0.3s cubic-bezier(.2,.7,.3,1) both, toast-out 0.5s ease-in 9s forwards; }
.flash.error::before { content: "!"; background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); visibility: hidden; } }
/* Less motion wanted: the note does not slide or fade. It is simply there and, at the same moment
   as above, it is gone (toast-gone only switches visibility, which is no movement). */
@keyframes toast-gone { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
  .flash.ok { animation: toast-gone 0s 5.7s forwards; }
  .flash.error { animation: toast-gone 0s 9.5s forwards; }
}


/* ---------- 8. Book covers ---------- */
/* Every cover has the same portrait shape (2:3). A picture of another shape is cropped to fit. */
.cover {
  display: block; width: 100%;
  aspect-ratio: 2 / 3; object-fit: cover;
  background: var(--panel-deep);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(27, 33, 48, 0.25), 0 8px 16px -8px rgba(27, 33, 48, 0.45);
}

/* Book without a picture: a plain one-colour cover made with CSS. Title on top, author at the bottom. */
.cover.blank { position: relative; display: flex; flex-direction: column; padding: 14% 10% 10% 14%; color: #fff; overflow: hidden; }
.cover.blank::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 6%; background: rgba(0, 0, 0, 0.22); }   /* spine */
.cover-title { font-size: 13px; font-weight: 700; line-height: 1.2; overflow-wrap: break-word; }
.cover-author { margin-top: auto; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.5); font-size: 10.5px; font-weight: 600; }
/* The colour depends on the category (category_id modulo 5). */
.cover.c0 { background-color: #7a2e2a; }
.cover.c1 { background-color: #1f3f6e; }
.cover.c2 { background-color: #2a6152; }
.cover.c3 { background-color: #56386a; }
.cover.c4 { background-color: #7d4d1f; }

/* No-picture cover where the author is not known to the page: title only */
.cover.title-only .cover-author { display: none; }

/* Small cover in admin tables: no text */
.cover.thumb { width: 28px; flex: none; padding: 0; border-radius: 2px; box-shadow: 0 1px 3px rgba(27, 33, 48, 0.35); }
.cover.thumb span { display: none; }
.with-thumb { display: flex; align-items: center; gap: 12px; }

/* Dashed box in the book form when there is no cover yet */
.cover.placeholder { display: flex; align-items: center; justify-content: center; background: var(--panel); border: 2px dashed var(--field); box-shadow: none; color: var(--muted); font-size: 13px; }


/* ---------- 9. Home page and book list ---------- */
/* Top of the home page: a wide blue banner and a narrower "Best seller" card beside it */
.promo { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 16px; margin-bottom: 28px; }
.banner { position: relative; min-height: 240px; padding: 28px 32px; display: flex; align-items: center; overflow: hidden; color: #fff; border-radius: 12px; background: linear-gradient(115deg, var(--navy) 0%, var(--blue) 100%); }
.banner-text { position: relative; z-index: 1; max-width: 270px; }
.banner-kicker { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.banner h1 { font-size: 30px; line-height: 1.15; }
.banner p { margin: 8px 0 16px; font-size: 14px; color: #d5e2fb; }
/* The newest books stand in a row on a pale "shelf" line at the right side of the banner.
   They are real 3D objects: "perspective" on the row gives depth, every book is turned on its
   upright axis (rotateY) so its spine and a narrowed front cover are seen.
   --bw / --bh: width and height of a cover, --bt: thickness of a book, --slot: room one book takes in the row. */
.banner-covers { --bw: 100px; --bh: 150px; --bt: 26px; --slot: 82px;
  position: absolute; right: 44px; bottom: 26px; display: flex; align-items: flex-end; perspective: 1100px; perspective-origin: 50% 40%; }
.banner-covers::after { content: ""; position: absolute; left: -40px; right: -80px; bottom: -8px; height: 8px; background: rgba(255, 255, 255, 0.28); border-radius: 2px; }
.b3d { position: relative; flex: none; display: block; width: var(--bw); height: var(--bh); margin-right: calc(var(--slot) - var(--bw));
  transform-style: preserve-3d; transform-origin: 30% 100%; transform: rotateY(38deg);
  transition: transform 0.45s cubic-bezier(.2,.7,.3,1), margin 0.45s cubic-bezier(.2,.7,.3,1); }      /* going back: slower */
.b3d:last-child { margin-right: 0; }
/* soft shadow where the book touches the shelf */
.b3d::after { content: ""; position: absolute; left: -6%; right: -6%; bottom: -5px; height: 10px; background: radial-gradient(closest-side, rgba(0, 0, 0, 0.45), transparent); transform: translateZ(-2px); }
/* front cover; its left edge is the hinge it opens on */
.b3d .cover { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 1px 3px 3px 1px; box-shadow: none; transform-origin: left center; transition: transform 0.45s cubic-bezier(.2,.7,.3,1); backface-visibility: hidden; }
/* first page under the cover: off-white with a faint edge */
.b3d-page { position: absolute; inset: 2px 2px 2px 0; background: linear-gradient(90deg, #d9d5cb 0, #fbfaf6 10%, #fbfaf6 100%); border-radius: 0 2px 2px 0; transform: translateZ(-1px); }
/* spine: a side face as wide as the book is thick, swung back from the left edge of the cover */
.b3d-spine { position: absolute; top: 0; left: 0; width: var(--bt); height: 100%; overflow: hidden; background: var(--navy); transform-origin: left center; transform: rotateY(90deg); border-radius: 2px 0 0 2px; }
.b3d-spine img { position: absolute; inset: -20%; width: 140%; height: 140%; object-fit: cover; filter: blur(9px) saturate(1.7) brightness(0.6); }
/* two thin bands near the top and the bottom of the spine */
.b3d-spine::before, .b3d-spine::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: rgba(255, 255, 255, 0.55); }
.b3d-spine::before { top: 12%; }
.b3d-spine::after { bottom: 12%; }

/* Under the mouse or with the keyboard on it: the book turns to face the reader, comes forward,
   its cover opens a little, and the books beside it make room. */
.b3d:hover, .b3d:focus-visible { z-index: 2; transform: translate3d(0, -8px, 46px) rotateY(0deg); transition-duration: 0.2s; }      /* coming out: quick */
.b3d:hover .cover, .b3d:focus-visible .cover { transform: rotateY(-24deg); transition-duration: 0.25s; box-shadow: 14px 10px 22px -10px rgba(0, 0, 0, 0.6); }
.b3d:hover ~ .b3d, .b3d:focus-visible ~ .b3d { transform: translateX(22px) rotateY(38deg); }                              /* the books after it */
.b3d:has(~ .b3d:hover), .b3d:has(~ .b3d:focus-visible) { transform: translateX(-12px) rotateY(38deg); }                 /* the books before it */
.b3d:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
/* Less motion wanted: the row stays as it stands; only a white outline marks the book. */
@media (prefers-reduced-motion: reduce) {
  .b3d, .b3d .cover { transition: none; }
  .b3d:hover, .b3d:focus-visible, .b3d:hover ~ .b3d, .b3d:focus-visible ~ .b3d, .b3d:has(~ .b3d:hover), .b3d:has(~ .b3d:focus-visible) { transform: rotateY(38deg); }
  .b3d:hover .cover, .b3d:focus-visible .cover { transform: none; box-shadow: none; }
  .b3d:hover, .b3d:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
}

/* "Best sellers" card: the three most ordered books on a small podium, in the same light and the
   same 3D way as the books of the banner (class b3d). 2 stands left, 1 in the middle, 3 right. */
.deal { display: flex; flex-direction: column; padding: 14px 16px 12px; color: #fff; border-radius: 12px; overflow: hidden; background: radial-gradient(120% 85% at 50% 36%, #24489a 0%, var(--navy) 64%); }
.deal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.deal h2 { margin: 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.deal-head span { font-size: 11.5px; color: #b9c6e4; }
.podium { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 0 12px; padding-top: 14px; }
.rank { display: flex; flex-direction: column; align-items: center; color: #fff; perspective: 700px; --bt: 18px; --slot: var(--bw); }
.rank:hover { text-decoration: none; }
.rank1 { order: 2; --bw: 74px; --bh: 111px; }
.rank2 { order: 1; --bw: 56px; --bh: 84px; }
.rank3 { order: 3; --bw: 56px; --bh: 84px; }
.rank .b3d { transform-origin: 50% 100%; transform: rotateY(28deg); }
/* the step a book stands on, with its place in the ranking */
.plinth { display: grid; place-items: center; width: calc(var(--bw) + 28px); margin-top: 5px; font-size: 14px; font-weight: 800; color: #c9d3e8; background: linear-gradient(#2c50a2, #1a3472); border-top: 2px solid rgba(255, 255, 255, 0.35); border-radius: 3px 3px 0 0; transition: background-color 0.2s; }
.rank1 .plinth { height: 34px; font-size: 17px; color: var(--accent); border-top-color: var(--accent); }
.rank2 .plinth { height: 23px; }
.rank3 .plinth { height: 14px; font-size: 11px; }
.rank:hover .b3d, .rank:focus-visible .b3d { transform: translate3d(0, -6px, 26px) rotateY(0deg); transition-duration: 0.2s; }
.rank:hover .b3d .cover, .rank:focus-visible .b3d .cover { transform: rotateY(-24deg); transition-duration: 0.25s; box-shadow: 10px 8px 18px -10px rgba(0, 0, 0, 0.6); }
.rank:hover .plinth, .rank:focus-visible .plinth { color: #fff; border-top-color: #fff; }
.rank1:hover .plinth, .rank1:focus-visible .plinth { color: var(--accent); border-top-color: var(--accent); }
.rank:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 4px; }
/* the two lines under the podium: only one of the three is shown */
.cap { order: 4; display: none; flex-basis: 100%; min-width: 0; margin: 0; padding-top: 9px; font-size: 12.5px; text-align: center; color: #c9d3e8; border-top: 1px solid rgba(255, 255, 255, 0.16); }
.cap strong { display: block; font-size: 14.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap1 { display: block; }
.podium:has(.rank2:hover, .rank2:focus-visible, .rank3:hover, .rank3:focus-visible) .cap1 { display: none; }
.podium:has(.rank2:hover, .rank2:focus-visible) .cap2, .podium:has(.rank3:hover, .rank3:focus-visible) .cap3 { display: block; }
@media (prefers-reduced-motion: reduce) {
  .rank:hover .b3d, .rank:focus-visible .b3d { transform: rotateY(28deg); }
  .rank:hover .b3d .cover, .rank:focus-visible .b3d .cover { transform: none; box-shadow: none; }
}

/* ===== Category band (home page) =====
   A grey frame in which every category, drawn as its own small logo, flows slowly to the left.
   Two equal halves in one track; the track moves by one half and starts again, so the loop has no seam.
   The whole frame stops under the mouse and while a cell has keyboard focus.
   Still on phones and with "reduce motion". The logos themselves are in _lockups.html. */
.tiles { margin-bottom: 28px; }
.band-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.band-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.band-head a { font-size: 13px; font-weight: 700; color: var(--blue); text-decoration: none; }
.band { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
/* The padding sits on the view, not on the frame: the view clips and masks, and a cell grown to 1.06
   (85px high, plus its ring and shadow) needs the 10px above and below inside it. Frame: 80 + 20 + 2 = 102px.
   overflow: clip, not hidden: a hidden box scrolls itself to a focused link and stays displaced. */
.band-view { padding: 10px 0; overflow: clip;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent); }
.band-view::-webkit-scrollbar { display: none; }
.band-track { display: flex; width: max-content; will-change: transform; animation: band-flow 94s linear infinite; }
.band-half { display: flex; flex: none; }
@keyframes band-flow { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.band:hover .band-track { animation-play-state: paused; }

/* One cell: the logo of a category and, under it, its number of books. Every cell is 208px + 12px = 220px,
   so a half is a fixed length and a cell grown to 1.06 touches but never covers a neighbour. */
.cell { flex: none; width: 208px; height: 80px; margin-right: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--navy); text-decoration: none; cursor: pointer; border: 1px solid transparent; border-radius: 8px;
  transition: transform .12s cubic-bezier(.3,.7,.4,1), background-color .08s, border-color .08s, box-shadow .12s; }
.cell:hover, .cell:focus-visible { transform: scale(1.06); background: #fff; border-color: var(--line); box-shadow: 0 8px 18px -12px rgba(27,33,48,.45); text-decoration: none; }
.cell:active { transform: scale(.98); background: var(--blue-soft); border-color: var(--blue); box-shadow: none; transition-duration: .05s; }
.cell-count { font-size: 11px; line-height: 13px; letter-spacing: .02em; color: var(--muted); transition: color .08s; }
.cell:hover .cell-count, .cell:focus-visible .cell-count, .cell:active .cell-count { color: var(--ink); font-weight: 600; }

/* The logos. Every one sits in a box 46px high; emblem and letters are built differently in each. */
.lk { display: flex; align-items: center; justify-content: center; height: 46px; line-height: 1; white-space: nowrap; color: var(--navy); }
.lk svg { display: block; flex: none; fill: currentColor; }
/* fallback: a small book and the plain name */
.lk-default { gap: 8px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; max-width: 190px; overflow: hidden; }
.lk-default svg { fill: none; }
/* Computer Science: the name inside a dark "terminal" badge */
.lk-computer-science { height: 34px; margin: 6px 0; padding: 0 13px 0 11px; gap: 8px; font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: #fff; background: #0d4f4a; border-radius: 7px; }
.lk-computer-science b { color: #7fe3c9; }
/* Fantasy: a shield with a tower, then the name in italic */
.lk-fantasy { gap: 10px; font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; font-size: 26px; font-style: italic; }
.lk-fantasy svg { color: #5b3a8c; }
/* Fiction: a pen nib above the name */
.lk-fiction { flex-direction: column; gap: 1px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.lk-fiction svg { height: 22px; width: auto; color: #9b2c2c; }
/* History: capitals between two laurel branches */
.lk-history { gap: 7px; }
.lk-history svg { color: #8c6a1f; }
.lk-history svg.flip { transform: scaleX(-1); }
.lk-history span { padding-left: .22em; font-family: "Times New Roman", Times, Georgia, serif; font-size: 17px; letter-spacing: .22em; text-transform: uppercase; }
/* Science Fiction: the name inside an orbit with a planet on it */
.lk-science-fiction { position: relative; width: 184px; }
.lk-science-fiction svg { position: absolute; inset: 0; color: var(--blue); }
.lk-science-fiction span { position: relative; padding-left: .16em; font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
/* Turkish Classics: an eight-pointed star between two lines, the name under it */
.lk-turkish-classics { flex-direction: column; gap: 4px; font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; font-size: 18px; letter-spacing: .01em; }
.lk-turkish-classics .orn { display: flex; align-items: center; gap: 8px; color: #0f7c88; }
.lk-turkish-classics .orn::before, .lk-turkish-classics .orn::after { content: ""; width: 44px; height: 1px; background: var(--navy); opacity: .55; }

/* Focus inside the band (a click or the Tab key) only stops the flow, exactly like the mouse does.
   The row never changes its layout while it is used, so nothing jumps. */
.band:focus-within .band-track { animation-play-state: paused; }
/* The still row, when less motion is asked for: no flow and no copies; the real cells stand
   centred and wrap inside the half (the half holds the cells). */
@media (prefers-reduced-motion: reduce) {
  .band .band-track { animation: none; width: auto; }
  .band .band-half { flex: 1 1 auto; flex-wrap: wrap; justify-content: center; }
  .band .band-half[aria-hidden], .band .cell[aria-hidden] { display: none; }
  .band .band-view { -webkit-mask-image: none; mask-image: none; }
  .band .cell { width: 184px; margin: 0 4px; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 1220px) {
  .band .band-half { max-width: 600px; margin: 0 auto; }
}
/* Phones: no flow either (a finger cannot pause it); one still line that is swiped sideways */
@media (max-width: 760px) {
  .band .band-track { animation: none; width: max-content; }
  .band .band-half { flex: none; flex-wrap: nowrap; max-width: none; margin: 0; }
  .band .band-half[aria-hidden], .band .cell[aria-hidden] { display: none; }
  .band-view { overflow-x: auto; scroll-snap-type: x proximity; scroll-padding: 0 12px; padding: 10px 12px; -webkit-mask-image: none; mask-image: none; scrollbar-width: none; }
  .band .cell { width: 196px; margin: 0 12px 0 0; scroll-snap-align: start; }
}
/* ===== End of category band ===== */

/* A shelf: a heading with "See all" and one row of book cards */
.shelf, .catalogue { margin-bottom: 32px; scroll-margin-top: 12px; }

/* Grid of book cards: 5 in a row; 4 beside the category column of a listing page */
.books { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.listing .books { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* One card: a grey field with the cover in the middle, then a white part with the text.
   The price row sits at the bottom of the card, so the prices of one row line up. */
.book { position: relative; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease; }      /* going back: a little slower */
/* Under the mouse (or with the keyboard on it) the card lifts, the cover grows a little
   and a "View details" label fades in. Nothing changes size in the layout, so the neighbours stay put. */
.book:hover, .book:focus-within { transform: translateY(-4px); border-color: #b7c4da; box-shadow: 0 14px 28px -14px rgba(19, 42, 92, 0.45); transition-duration: 0.14s; }   /* coming in: quick */
.book .cover { transition: transform 0.28s ease, box-shadow 0.28s ease; }
.book:hover .cover, .book:focus-within .cover { transform: translateY(-3px) scale(1.06); box-shadow: 0 2px 4px rgba(27, 33, 48, 0.25), 0 16px 22px -10px rgba(27, 33, 48, 0.55); transition-duration: 0.14s; }
.peek { position: absolute; left: 50%; bottom: 10px; padding: 4px 12px; font-size: 11.5px; font-weight: 700; white-space: nowrap; color: #fff; background: rgba(19, 42, 92, 0.92); border-radius: 99px;
  opacity: 0; transform: translate(-50%, 6px); transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none; }
.book:hover .peek, .book:focus-within .peek { opacity: 1; transform: translate(-50%, 0); transition-duration: 0.14s; }
.book-media { position: relative; display: flex; justify-content: center; padding: 22px 0; background: var(--panel); }
.book-media .cover { width: 60%; }
.tag-new { position: absolute; top: 0; right: 0; padding: 3px 10px; font-size: 11px; font-weight: 700; color: var(--navy); background: var(--accent); border-radius: 0 0 0 8px; }
.book-info { flex: 1; display: flex; flex-direction: column; padding: 10px 12px 12px; }
.book-rating { margin: 0 0 4px; font-size: 11px; color: var(--muted); }
.book-name { font-size: 14px; font-weight: 400; line-height: 1.35; letter-spacing: 0; }
.book-link { font-weight: 700; color: var(--ink); }
/* The title link covers the whole card, so a click anywhere on the card opens the book. */
.book-link::after { content: ""; position: absolute; inset: 0; }
.book:hover .book-link { color: var(--blue); text-decoration: none; }
.book-authors { color: #414a59; }
.book-meta { margin: 6px 0 0; font-size: 12px; color: #8a919d; }
.stock-cue { display: block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--danger); }
.book-buy { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.price { font-size: 17px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lira { font-weight: 600; margin-right: 1px; }
/* Round blue button in the corner of a card: opens the book page */
.go { position: relative; z-index: 1; flex: none; display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--blue); border-radius: 50%; transition: background-color 0.14s; }
.go .icon { transition: transform 0.2s ease; }
.book:hover .go, .book:focus-within .go, .go:hover { background: var(--blue-dark); }
.book:hover .go .icon, .book:focus-within .go .icon { transform: translateX(3px); }       /* the arrow moves forward */
/* For visitors who asked their system for less motion: colours only, nothing moves. */
@media (prefers-reduced-motion: reduce) {
  .book, .book .cover, .peek, .go .icon { transition: none; }
  .book:hover, .book:focus-within, .book:hover .cover, .book:focus-within .cover, .book:hover .go .icon, .book:focus-within .go .icon { transform: none; }
  .book:hover .peek, .book:focus-within .peek { transform: translate(-50%, 0); }
}
.stars { color: var(--accent); letter-spacing: 1px; }
.stars.off { color: #c5cad2; }

/* Stock text on other pages ("25 in stock") */
.stock { font-size: 12px; font-weight: 600; }
.stock.in-stock { color: var(--ok); }
.stock.low, .stock.out { color: var(--danger); }

/* Row of round links (the jump links of the database page) */
.cats { display: flex; flex-wrap: wrap; gap: 8px; }
.cats a { padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--blue-dark); background: var(--blue-soft); border-radius: 99px; }
.cats a:hover { color: #fff; background: var(--blue); text-decoration: none; }

/* Path of the open page: "Books / Fiction / 1984" */
.crumb { margin-bottom: 18px; font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--blue); }
.crumb strong { color: var(--ink); }

/* Listing page (a category, a search or a sort): categories on the left, the books on the right */
.listing { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
.side h2 { margin: 6px 0 10px; font-size: 15px; }
.side ul { margin: 0; padding: 0; list-style: none; }
.side a { display: block; padding: 6px 10px; font-size: 14px; color: var(--ink); border-radius: 6px; }
.side a span { font-size: 12px; color: var(--muted); }
.side a:hover { background: var(--panel); text-decoration: none; }
.side a.current { font-weight: 700; color: var(--blue); background: var(--blue-soft); }
/* Heading of the list: title and result count on the left, the sort list on the right */
.list-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.list-head h1 { font-size: 22px; }
.result-line { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.result-line .clear { margin-left: 6px; font-weight: 600; }
.sort-form { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
/* The sort list is a light-blue rounded control */
.sort-form select { min-width: 190px; font-weight: 600; color: var(--blue-dark); background-color: var(--blue-soft); border-color: var(--blue-soft); border-radius: 8px; }

/* Shown when a search finds nothing */
.empty { grid-column: 1 / -1; padding: 44px 24px; text-align: center; background: var(--panel); border-radius: var(--radius); }
.empty-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }


/* ---------- 10. Book page ---------- */
/* Cover on the left, everything needed to buy the book on the right */
.detail { display: grid; grid-template-columns: 440px minmax(0, 1fr); gap: 48px; align-items: start; margin-bottom: 36px; }
.detail-cover { display: flex; justify-content: center; padding: 4px 0 12px; }
.detail-cover .cover { width: 330px; border-radius: 3px; box-shadow: 0 2px 4px rgba(27, 33, 48, 0.2), 0 18px 34px -14px rgba(27, 33, 48, 0.5); }
.detail .cover-title { font-size: 30px; }
.detail .cover-author { font-size: 14px; }
.detail h1 { font-size: 24px; }
/* "Author: ..." and "Publisher: ..." under the title */
.by-lines { display: flex; flex-wrap: wrap; gap: 2px 24px; margin: 8px 0 8px; font-size: 13px; color: var(--muted); }
.by-lines a { font-weight: 600; }
.by-lines strong { color: var(--ink); }
.rating-line { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.buyline { display: flex; align-items: center; gap: 14px; margin: 18px 0; }
.price.big { font-size: 30px; line-height: 1; }

/* Order form: quantity and address side by side, then one wide button */
.order-box { max-width: 520px; margin-bottom: 16px; }
.order-box h2 { margin-bottom: 8px; font-size: 14px; }
.order-form { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 0 12px; }
.order-form button { grid-column: 1 / -1; }

/* Grey box with short facts, each with a small icon */
.info-box { max-width: 520px; margin: 0 0 20px; padding: 6px 14px; list-style: none; font-size: 13px; color: var(--navy); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.info-box li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.info-box li + li { border-top: 1px solid var(--line); }
.info-box strong { color: var(--ink); }

/* Small heading with a blue bar in front of it */
.mini-head { margin-bottom: 8px; padding-left: 8px; font-size: 14px; border-left: 3px solid var(--blue); line-height: 1.1; }
/* Three facts of the book as small grey tiles: label above, value below */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 520px; margin: 0; }
.facts div { padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.facts dt { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; }

/* Two tabs (Details, Reviews) without JavaScript. Both parts are in the page; one is shown.
   ":target" is the element whose id stands at the end of the address (after the #).
   Reviews is shown when that is #reviews or #tab-reviews, or something inside the Reviews part
   (a part marked from the SQL list), Details in every other case. */
.tabs { display: flex; gap: 36px; margin: 0 0 22px; border-bottom: 1px solid var(--line); }
.tabs a { margin-bottom: -1px; padding: 0 0 10px; font-size: 18px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--blue); text-decoration: none; }
/* The marks the tabs link to are pinned to the window: the browser finds them "already in view"
   and does not scroll, so a click on a tab changes the part and nothing else moves. */
.tab-mark { position: fixed; top: 0; left: 0; width: 0; height: 0; }
.tabbed .reviews-area { display: none; }
.tabbed:has(#reviews:target, #tab-reviews:target, .reviews-area :target) .reviews-area { display: grid; }
.tabbed:has(#reviews:target, #tab-reviews:target, .reviews-area :target) .details { display: none; }
/* the active tab: Details unless Reviews is chosen */
.tabs a.tab-details { color: var(--ink); border-bottom-color: var(--blue); }
.tabbed:has(#reviews:target, #tab-reviews:target, .reviews-area :target) .tabs a.tab-details { color: var(--muted); border-bottom-color: transparent; }
.tabbed:has(#reviews:target, #tab-reviews:target, .reviews-area :target) .tabs a.tab-reviews { color: var(--ink); border-bottom-color: var(--blue); }
.tabs a:focus-visible { outline-offset: 4px; border-radius: 3px; }
/* A link from another place (#reviews, #details, #order) scrolls there and leaves room for the tab row above. */
.tabbed .reviews-area, .tabbed .details { scroll-margin-top: 80px; }
.order-box { scroll-margin-top: 90px; }
/* The card shown in place of the review form to a reader who has not ordered the book */
.review-note p { margin: 0 0 14px; font-size: 14px; color: var(--muted); }

/* Details: name / value pairs in two columns of grey rows */
.details { margin-bottom: 36px; scroll-margin-top: 12px; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.specs div { display: flex; gap: 12px; padding: 9px 14px; font-size: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.specs dt { flex: none; width: 100px; font-weight: 700; }
.specs dt::after { content: ":"; }
.specs dd { margin: 0; }

/* Reviews on the left, review form on the right */
.reviews-area { scroll-margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 40px; align-items: start; margin-bottom: 36px; }
/* Rating summary: big average on the left, one thin bar per star count on the right */
.rating-box { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 4px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.rating-score { display: flex; flex-direction: column; align-items: flex-start; font-size: 13px; }
.rating-number { font-size: 36px; font-weight: 700; line-height: 1.1; }
.rating-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 18px; gap: 10px; align-items: center; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.rating-row progress::-webkit-progress-value { background: var(--accent); }
.rating-row progress::-moz-progress-bar { background: var(--accent); }
.review { padding: 14px 0; border-top: 1px solid var(--line); }
.rating-box + .review { border-top: 0; }
.no-reviews { padding: 14px 18px; color: var(--muted); background: var(--panel); border-radius: var(--radius); }
.no-reviews .stars { margin-right: 8px; color: #c5cad2; }
.review-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 0 0 2px; font-size: 14px; }
.review-head small { margin-left: auto; font-size: 12px; }
.review-text { margin: 0 0 8px; font-size: 14px; }
.rating { font-size: 12px; color: var(--muted); }

/* "More in this category": a shelf of the same cards */
.related { margin-bottom: 8px; }


/* ---------- 11. Log in, register and error pages ---------- */
/* One box in the middle with two halves: bookshop photo on the left, form on the right */
.auth { display: grid; grid-template-columns: 5fr 6fr; max-width: 880px; margin: 24px auto 36px; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 2px 4px rgba(27, 33, 48, 0.05), 0 24px 48px -24px rgba(27, 33, 48, 0.3); }
.auth.wide { max-width: 1040px; grid-template-columns: 4fr 7fr; }
/* The dark layer over the photo keeps the white text readable. */
.auth-brand { display: flex; flex-direction: column; padding: 36px; min-height: 440px; color: #fff; background: linear-gradient(rgba(20, 22, 28, 0.55), rgba(20, 22, 28, 0.25) 30%, rgba(20, 22, 28, 0.9)), #1b2130 url("img/shop.jpg") center / cover no-repeat; }
.auth-line { margin: auto 0 12px; font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.auth-note { margin: 0; font-size: 15px; color: #dfe3ea; }
.auth-form { padding: 40px 44px 30px; }
.auth-form h1 { font-size: 26px; margin-bottom: 22px; }
.auth-form .form { margin-bottom: 20px; }
.auth-switch { margin: 0; padding-top: 18px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }
.auth-switch a { font-weight: 700; }

/* 403 / 404 / 400: photo of a shelf with a missing book, big number, way back */
.error-page { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; align-items: center; max-width: 900px; margin: 28px auto; }
.error-photo { grid-row: 1 / 6; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; }
.error-page .error-code { margin: 0; font-size: 72px; font-weight: 800; line-height: 1; color: var(--blue); }
.error-page h1 { margin: 6px 0 10px; }


/* ---------- 12. Admin pages and the database page ---------- */
/* Authors, publishers, categories: table on the left, "add" form on the right */
.manage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.manage th, .manage td { padding-left: 12px; padding-right: 12px; }       /* less room beside the form: tighter cells */
.manage .panel h2, .manage-edit .panel h2 { font-size: 16px; }
/* Edit page of the same three: only the form, kept narrow */
.manage-edit { max-width: 480px; }

/* Overview: six totals in a row. Each card is a link. */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; padding: 14px 16px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
a.kpi:hover { border-color: var(--blue); text-decoration: none; }
.kpi-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi-value { margin: 4px 0 0; font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 12px; color: var(--muted); }
/* The first card is the blue one; a card that needs attention gets a marigold edge. */
.kpi.lead { background: var(--blue); border-color: var(--blue); }
.kpi.lead .kpi-label, .kpi.lead .kpi-note { color: #d5e2fb; }
.kpi.lead .kpi-value { color: #fff; }
a.kpi.lead:hover { background: var(--blue-dark); }
.kpi.alert { border-left: 4px solid var(--accent); }

/* Overview: two boxes side by side, then one full-width box */
.dash { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.dash h2, .sellers-head h2 { font-size: 16px; }
/* A table inside a white box: no second frame, first and last cell flush with the box */
.panel-table th { background: none; border-bottom-color: var(--field); }
.panel-table th:first-child, .panel-table td:first-child { padding-left: 0; }
.panel-table th:last-child, .panel-table td:last-child { padding-right: 0; }
.panel-table td { vertical-align: middle; }
.panel-table tr:hover td { background: none; }
/* A list of rows inside a box: small cover, title, number, label */
.rows, .sellers { margin: 0; padding: 0; list-style: none; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.rows .cover.thumb, .sellers .cover.thumb { width: 32px; }
.row-title { font-weight: 600; color: var(--ink); }
.row-title:hover { color: var(--blue); }
.rows .row-title { flex: 1; min-width: 0; }
.row-number { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); font-size: 13px; }
.rows .empty-row, .sellers .empty-row { display: block; padding: 20px 0; text-align: center; color: var(--muted); }
/* Best sellers: up to five books in a row, each with its rank, cover, title and a bar */
.sellers { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.sellers li { display: flex; align-items: flex-start; gap: 10px; }
.rank { font-size: 18px; font-weight: 800; line-height: 1.2; color: var(--blue); }
.seller-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; font-size: 12.5px; }
.seller-text .row-title { font-size: 13.5px; line-height: 1.25; }

/* Database page: three numbers and a short text, then one block per diagram */
.doc-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: center; margin-bottom: 16px; }
.doc-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.doc-intro { margin: 0; font-size: 15px; line-height: 1.6; }
.doc-links { margin-bottom: 4px; }
.doc { margin-top: 32px; scroll-margin-top: 12px; }
.doc-text { max-width: 760px; font-size: 14px; color: var(--muted); }
/* The small closing sentence of the database page */
.project-note { margin: 36px 0 0; padding-top: 14px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); }

/* A diagram on a white card. On a narrow screen the card scrolls sideways and the diagram keeps a readable size. */
.figure { padding: 24px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.figure img { max-width: 100%; height: auto; vertical-align: middle; }

/* Book form: cover on the left, fields on the right */
.book-form { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; padding: 24px; }
.book-form-cover p { margin: 8px 0 14px; font-size: 12.5px; text-align: center; }
.book-form-cover label small { display: block; }   /* the file types on their own line under "Cover picture" */
.book-form-cover .cover { margin-bottom: 14px; }
.book-form-cover img.cover { margin-bottom: 0; }


/* ---------- 13. SQL ---------- */
/* Code block: SQL text, kept in its own box that scrolls sideways if a line is too long */
pre { margin: 0; padding: 9px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: var(--ink); background: #fff; border: 1px solid var(--line); border-left: 3px solid #9aa3af; border-radius: 6px; overflow-x: auto; white-space: pre; }
/* Colours of the SQL text (set by the sql_color filter): keyword, function, string, number, comment, %s placeholder. */
pre .qk { font-weight: 700; color: var(--navy); }
pre .qf { color: var(--blue); }
pre .qs { color: #15803d; }
pre .qn { color: #b45309; }
pre .qc { font-style: italic; color: var(--muted); }
pre .qp { font-weight: 700; color: #b45309; }
.sql-group li.sql-tx > pre span { color: inherit; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-deep); padding: 1px 5px; border-radius: 4px; }

/* Reports: one block per query */
.report { margin-bottom: 32px; }
.report h2 { margin-bottom: 10px; }
.report pre { background: var(--panel); }
.report-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue); vertical-align: middle; margin-right: 4px; }
.result-count { margin: 12px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
/* Result tables show the real column names of the query, so they are in the code font. */
table.result { font-size: 13.5px; }
table.result th { font-family: var(--mono); font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--ink); }
table.result th, table.result td { padding: 8px 12px; }

/* "SQL behind this page": a grey developer strip at the end of every page.
   One slim line when closed, numbered statements when open. */
details.sql { margin-top: 36px; font-family: var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
details.sql summary { display: flex; align-items: center; gap: 12px; padding: 9px 14px; cursor: pointer; list-style: none; color: var(--muted); font-size: 12.5px; }
details.sql summary::-webkit-details-marker { display: none; }          /* hide the default triangle */
details.sql summary::before { content: "+"; width: 18px; height: 18px; line-height: 16px; text-align: center; font-weight: 700; color: var(--ink); border: 1px solid var(--field); border-radius: 4px; background: #fff; }
details.sql[open] summary::before { content: "-"; }
details.sql summary::after { content: "show"; margin-left: auto; color: var(--blue); }
details.sql[open] summary::after { content: "hide"; }
details.sql summary:hover { color: var(--ink); }
.sql-count { white-space: nowrap; }
.sql-title { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.sql-body { padding: 4px 14px 6px; border-top: 1px solid var(--line); }
.sql-group { margin: 12px 0 14px; }
.sql-group h3 { margin: 0 0 8px; font-family: var(--sans); font-size: 14px; }
/* The statements are a numbered list; the number is drawn in front of each code block. */
.sql-group ol { margin: 0; padding: 0; list-style: none; counter-reset: statement; }
.sql-group li { position: relative; counter-increment: statement; display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: start; margin-bottom: 10px; }
/* everything of one statement (code, values, explanation) stands in the second column, under each other */
.sql-group li > * { grid-column: 2; min-width: 0; }
.sql-group li::before { content: counter(statement); padding-top: 9px; font-size: 12px; font-weight: 700; color: var(--muted); }
/* The statements of the action just done stand out with a blue edge. */
.sql-group.last-action pre { border-left-color: var(--blue); background: var(--blue-soft); }

/* Under a statement: the real values that were sent for its %s places, in order, as small chips.
   The line starts at the same left edge as the code above it. */
.sql-values { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 5px 0 0; padding-left: 17px; font-family: var(--sans); font-size: 11.5px; color: var(--muted); }
.sql-values-label { margin-right: 2px; }
.sql-values code { padding: 1px 7px; font-size: 11.5px; line-height: 1.5; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 4px; overflow-wrap: anywhere; }
/* Under a one-word statement (BEGIN, COMMIT, ROLLBACK): one quiet sentence that says what it does */
.sql-note { display: flex; align-items: baseline; gap: 7px; margin: 5px 0 0; padding-left: 17px; font-family: var(--sans); font-size: 12.5px; line-height: 1.45; color: #56678a; }
.sql-note::before { content: "i"; flex: none; width: 14px; height: 14px; font-size: 10px; font-weight: 700; line-height: 14px; text-align: center; color: #fff; background: #8fa0c2; border-radius: 50%; transform: translateY(-1px); }
/* The statements of one transaction are held together by a thin line at their left (class sql-tx on
   every statement from BEGIN to COMMIT or ROLLBACK). BEGIN is navy, COMMIT green, ROLLBACK red, all soft. */
.sql-group li.sql-tx::after { content: ""; position: absolute; left: 17px; top: -5px; bottom: -5px; width: 2px; background: #c3cde2; }
.sql-group li.sql-begin::after { top: 9px; border-radius: 2px 2px 0 0; }
.sql-group li.sql-commit::after, .sql-group li.sql-rollback::after { bottom: auto; height: 27px; border-radius: 0 0 2px 2px; }
.sql-group li.sql-begin > pre { font-weight: 700; color: var(--navy); background: #e9edf6; border-left-color: var(--navy); }
.sql-group li.sql-commit > pre { font-weight: 700; color: var(--ok); background: var(--ok-soft); border-left-color: var(--ok); }
.sql-group li.sql-rollback > pre { font-weight: 700; color: var(--danger); background: var(--danger-soft); border-left-color: var(--danger); }

/* Step-by-step explainer (templates/_steps.html). No JavaScript: every step has a radio button
   in front of it, and only the step right after the checked radio is shown. */
.steps-box { position: relative; font-family: var(--sans); }
/* The radio buttons are not seen, but they stay reachable with Tab and the arrow keys. */
.step-radio { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.pane { display: none; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.pane.text-only { grid-template-columns: minmax(0, 1fr); }
.step-radio:checked + .pane { display: grid; animation: step-in 0.18s ease-out; }
.step-radio:focus-visible + .pane { outline: 2px solid var(--blue); outline-offset: 2px; }
@keyframes step-in { from { opacity: 0; transform: translateY(4px); } }
/* Left side: the statement. The piece of this step keeps its ink on a soft blue ground, the rest turns grey. */
.steps-box pre.step-code { min-height: 100%; padding: 12px 14px; font-size: 12px; line-height: 1.7; color: var(--ink); background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; }
.step-code .off { color: #9aa3af; }
.step-code .off span { color: inherit; font-weight: inherit; font-style: inherit; }
.step-code .on { padding: 2px 0; font-weight: 600; color: var(--navy); background: var(--blue-soft); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.step-figure { padding: 12px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.step-figure img { max-width: 100%; height: auto; vertical-align: middle; }
/* Right side: a white card with the name of the step, the sentence and the buttons */
.step-card { display: flex; flex-direction: column; min-height: 100%; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.step-count { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.step-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--navy); }
.step-note { margin: 0 0 16px; font-size: 15px; line-height: 1.55; color: var(--ink); }
.step-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.step-btn { padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--field); border-radius: 6px; cursor: pointer; user-select: none; }
.step-btn:hover { color: var(--blue); border-color: var(--blue); }
.step-btn.next { color: #fff; background: var(--blue); border-color: var(--blue); }
.step-btn.next::after { content: " \2192"; }
.step-btn.next:hover { color: #fff; background: var(--blue-dark); border-color: var(--blue-dark); }
.step-btn.off { color: #b3bac4; border-color: var(--line); cursor: default; }
.step-btn.off:hover { color: #b3bac4; border-color: var(--line); }
/* Numbered dots: one per step, a click jumps to it */
.step-dots { display: flex; gap: 4px; margin-left: auto; }
.step-dots label { display: grid; place-items: center; width: 22px; height: 22px; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; }
.step-dots label:hover { color: var(--blue); border-color: var(--blue); }
.step-dots label.here { color: #fff; background: var(--navy); border-color: var(--navy); }
@media (prefers-reduced-motion: reduce) { .step-radio:checked + .pane { animation: none; } }

/* "Step by step": a closed box under a statement that holds an explainer.
   The longer selectors are needed inside the SQL strip, whose own summary rules would otherwise apply. */
details.steps, details.sql details.steps { margin-top: 6px; font-family: var(--sans); }
details.steps > summary, details.sql details.steps > summary { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: var(--blue); background: #fff; border: 1px solid var(--field); border-radius: 6px; cursor: pointer; list-style: none; }
details.steps > summary::-webkit-details-marker { display: none; }
details.steps > summary::before, details.sql details.steps > summary::before, details.sql[open] details.steps > summary::before { content: "\25B8"; width: auto; height: auto; line-height: 1; font-weight: 400; color: var(--blue); background: none; border: 0; }
details.steps[open] > summary::before, details.sql[open] details.steps[open] > summary::before { content: "\25BE"; }
details.steps > summary::after, details.sql details.steps > summary::after, details.sql[open] details.steps > summary::after { content: none; display: none; }
details.steps > summary:hover, details.sql details.steps > summary:hover { color: var(--blue-dark); border-color: var(--blue); }
details.steps[open] > summary { margin-bottom: 8px; }

/* ----- "Which part of the page does this statement build?" -----
   Under a statement of the SQL list: on the left what it builds and the values of its %s,
   on the right three tools of one shape (Show on the page, Picture, Step by step). */
.sql-tools { --tw: 146px; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, var(--tw)); grid-template-rows: minmax(30px, auto); gap: 8px; align-items: start; margin-top: 7px; padding-left: 17px; font-family: var(--sans); }
.sql-text { grid-column: 1; min-width: 0; padding-top: 4px; }
.sql-tools .sql-part, .sql-tools .sql-values { margin: 0; padding-left: 0; }
.sql-part { font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.sql-part-label { margin-right: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sql-part + .sql-values { margin-top: 4px; }
/* the three tools: one size, one shape; "Show on the page" is the red one because it leads to the red frame */
.sql-part-link, details.sql .sql-tools > details > summary { display: flex; align-items: center; justify-content: center; gap: 6px; width: var(--tw); height: 30px; padding: 0; font-family: var(--sans); font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--blue); background: #fff; border: 1px solid var(--field); border-radius: 6px; cursor: pointer; list-style: none; }
.sql-part-link { grid-column: 2; color: #b3261e; border-color: #e9b9b5; }
.sql-part-link:hover { color: #fff; background: #d92d20; border-color: #d92d20; text-decoration: none; }
.sql-part-link:visited { color: #9a6f6c; }                        /* already used once: quieter */
.sql-part-link:visited:hover { color: #fff; }
.sql-tools > details.sql-preview { grid-column: 3; }
.sql-tools > details.steps, details.sql .sql-tools > details.steps { grid-column: 4; margin: 0; }
details.sql .sql-tools > details > summary::before, details.sql[open] .sql-tools > details > summary::before, details.sql[open] .sql-tools > details[open] > summary::before,
details.sql .sql-tools > details > summary::after, details.sql[open] .sql-tools > details > summary::after { content: none; display: none; }
details.sql .sql-tools > details > summary::-webkit-details-marker { display: none; }
details.sql .sql-tools > details > summary:hover { color: var(--blue-dark); border-color: var(--blue); }
/* An opened tool: its panel takes the whole width under the row; its button stays in its place
   in the row (put back there with position: absolute) and turns blue. */
.sql-tools > details[open], details.sql .sql-tools > details.steps[open] { grid-column: 1 / -1; grid-row: 2; }
details.sql .sql-tools > details[open] > summary { position: absolute; top: 0; margin: 0; color: #fff; background: var(--blue); border-color: var(--blue); }
details.sql .sql-tools > details.sql-preview[open] > summary { right: calc(var(--tw) + 8px); }
details.sql .sql-tools > details.steps[open] > summary { right: 0; }
/* The picture: one line that says what it is, then the same page in an inner window (iframe) that is
   laid out 1280px wide and shown smaller (--s), under a thin bar with three dots like a browser window. */
.sql-preview-caption { margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.sql-preview-caption strong { color: #d92d20; }
.sql-preview-frame { --s: 0.58; position: relative; width: calc(1280px * var(--s)); max-width: 100%; height: calc(800px * var(--s) + 22px); margin-bottom: 6px; padding-top: 22px; overflow: hidden; background: #fff; border: 1px solid var(--field); border-radius: 8px; box-shadow: 0 10px 26px -14px rgba(27, 33, 48, 0.5); }
.sql-preview-frame::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 22px; border-bottom: 1px solid var(--line);
  background: radial-gradient(circle at 14px 11px, #e0655d 4px, transparent 4.5px), radial-gradient(circle at 28px 11px, #e6b740 4px, transparent 4.5px), radial-gradient(circle at 42px 11px, #5fb760 4px, transparent 4.5px), var(--panel); }
/* the picture fades out at its lower edge: the page goes on below */
.sql-preview-frame::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34px; background: linear-gradient(rgba(255, 255, 255, 0), #fff); pointer-events: none; }
.sql-preview-frame iframe { display: block; width: 1280px; height: 800px; border: 0; transform: scale(var(--s)); transform-origin: 0 0; pointer-events: none; }   /* a picture: it cannot be clicked */

/* ----- Marking a part on the page (after "Show on the page") -----
   Every part has a name. An empty mark <a id="part-NAME" class="part-anchor"> stands near it, and
   every element the part builds carries data-part="NAME". When the address ends in #part-NAME,
   exactly those elements get a red frame. CSS cannot compare an attribute with the address, so each
   name needs its own line in the two lists below.
   A NEW PART NEEDS ONE LINE IN EACH OF THE TWO LISTS (the names are the keys of PARTS in explain.py). */
.part-anchor { display: block; height: 0; scroll-margin-top: 130px; }
/* how the frame looks: these three values are changed further down for small elements and for the picture */
:root { --mark-width: 3px; --mark-offset: 6px; --mark-tint: rgba(217, 45, 32, 0); }
/* small things (a line of stars, a name, a table cell, a ticked box, a menu link): a tight frame and a
   soft red ground, so that many of them read as "these" */
:is(p, span, small, strong, h1, td, label, a:not(.kpi))[data-part] { --mark-offset: 2px; --mark-tint: rgba(217, 45, 32, 0.09); }
/* list 1: the marked elements */
body:has(#part-account:target) [data-part~="account"]:not(.sql-back),
body:has(#part-menu:target) [data-part~="menu"]:not(.sql-back),
body:has(#part-book-list:target) [data-part~="book-list"]:not(.sql-back),
body:has(#part-ratings:target) [data-part~="ratings"]:not(.sql-back),
body:has(#part-best-sellers:target) [data-part~="best-sellers"]:not(.sql-back),
body:has(#part-new-arrivals:target) [data-part~="new-arrivals"]:not(.sql-back),
body:has(#part-book:target) [data-part~="book"]:not(.sql-back),
body:has(#part-book-authors:target) [data-part~="book-authors"]:not(.sql-back),
body:has(#part-reviews:target) [data-part~="reviews"]:not(.sql-back),
body:has(#part-review-form:target) [data-part~="review-form"]:not(.sql-back),
body:has(#part-related:target) [data-part~="related"]:not(.sql-back),
body:has(#part-related-ratings:target) [data-part~="related-ratings"]:not(.sql-back),
body:has(#part-orders:target) [data-part~="orders"]:not(.sql-back),
body:has(#part-order-items:target) [data-part~="order-items"]:not(.sql-back),
body:has(#part-numbers-books:target) [data-part~="numbers-books"]:not(.sql-back),
body:has(#part-numbers-sales:target) [data-part~="numbers-sales"]:not(.sql-back),
body:has(#part-numbers-pending:target) [data-part~="numbers-pending"]:not(.sql-back),
body:has(#part-numbers-customers:target) [data-part~="numbers-customers"]:not(.sql-back),
body:has(#part-recent-orders:target) [data-part~="recent-orders"]:not(.sql-back),
body:has(#part-low-stock:target) [data-part~="low-stock"]:not(.sql-back),
body:has(#part-top-books:target) [data-part~="top-books"]:not(.sql-back),
body:has(#part-list:target) [data-part~="list"]:not(.sql-back),
body:has(#part-form-authors:target) [data-part~="form-authors"]:not(.sql-back),
body:has(#part-form-publishers:target) [data-part~="form-publishers"]:not(.sql-back),
body:has(#part-form-categories:target) [data-part~="form-categories"]:not(.sql-back),
body:has(#part-form-book:target) [data-part~="form-book"]:not(.sql-back),
body:has(#part-form-book-authors:target) [data-part~="form-book-authors"]:not(.sql-back),
body:has(#part-form-row:target) [data-part~="form-row"]:not(.sql-back),
body:has(#part-report-1:target) [data-part~="report-1"]:not(.sql-back),
body:has(#part-report-2:target) [data-part~="report-2"]:not(.sql-back),
body:has(#part-report-3:target) [data-part~="report-3"]:not(.sql-back),
body:has(#part-rows-user_account:target) [data-part~="rows-user_account"]:not(.sql-back),
body:has(#part-rows-author:target) [data-part~="rows-author"]:not(.sql-back),
body:has(#part-rows-publisher:target) [data-part~="rows-publisher"]:not(.sql-back),
body:has(#part-rows-category:target) [data-part~="rows-category"]:not(.sql-back),
body:has(#part-rows-book:target) [data-part~="rows-book"]:not(.sql-back),
body:has(#part-rows-book_author:target) [data-part~="rows-book_author"]:not(.sql-back),
body:has(#part-rows-orders:target) [data-part~="rows-orders"]:not(.sql-back),
body:has(#part-rows-order_item:target) [data-part~="rows-order_item"]:not(.sql-back),
body:has(#part-rows-review:target) [data-part~="rows-review"]:not(.sql-back) {
  outline: var(--mark-width) solid #d92d20; outline-offset: var(--mark-offset); border-radius: 6px;
  box-shadow: inset 0 0 0 999px var(--mark-tint);
}
/* a table box cuts off what stands outside it; the frame of a marked one is drawn inside its edge */
.table-wrap[data-part], .menu-bar[data-part] { --mark-offset: -3px; }
td[data-part] { --mark-offset: -3px; }
/* One small red note per marking, fixed at the bottom left of the window (the mark itself shows it). */
.part-anchor:target::before { content: "Red frame: built by the SQL statement you chose"; position: fixed; left: 22px; bottom: 22px; z-index: 20; padding: 9px 14px; font-family: var(--sans); font-size: 13px; font-weight: 700; line-height: 1.3; letter-spacing: 0; text-transform: none; white-space: nowrap; color: #fff; background: #d92d20; border-radius: 8px; box-shadow: 0 8px 22px -8px rgba(217, 45, 32, 0.6); }
/* "Back to this SQL statement": every statement has its own link; only the one of the marked part
   is shown, as a pill fixed at the bottom right. */
.sql-back { display: none; }
/* list 2: the back links */
body:has(#part-account:target) .sql-back[data-part="account"],
body:has(#part-menu:target) .sql-back[data-part="menu"],
body:has(#part-book-list:target) .sql-back[data-part="book-list"],
body:has(#part-ratings:target) .sql-back[data-part="ratings"],
body:has(#part-best-sellers:target) .sql-back[data-part="best-sellers"],
body:has(#part-new-arrivals:target) .sql-back[data-part="new-arrivals"],
body:has(#part-book:target) .sql-back[data-part="book"],
body:has(#part-book-authors:target) .sql-back[data-part="book-authors"],
body:has(#part-reviews:target) .sql-back[data-part="reviews"],
body:has(#part-review-form:target) .sql-back[data-part="review-form"],
body:has(#part-related:target) .sql-back[data-part="related"],
body:has(#part-related-ratings:target) .sql-back[data-part="related-ratings"],
body:has(#part-orders:target) .sql-back[data-part="orders"],
body:has(#part-order-items:target) .sql-back[data-part="order-items"],
body:has(#part-numbers-books:target) .sql-back[data-part="numbers-books"],
body:has(#part-numbers-sales:target) .sql-back[data-part="numbers-sales"],
body:has(#part-numbers-pending:target) .sql-back[data-part="numbers-pending"],
body:has(#part-numbers-customers:target) .sql-back[data-part="numbers-customers"],
body:has(#part-recent-orders:target) .sql-back[data-part="recent-orders"],
body:has(#part-low-stock:target) .sql-back[data-part="low-stock"],
body:has(#part-top-books:target) .sql-back[data-part="top-books"],
body:has(#part-list:target) .sql-back[data-part="list"],
body:has(#part-form-authors:target) .sql-back[data-part="form-authors"],
body:has(#part-form-publishers:target) .sql-back[data-part="form-publishers"],
body:has(#part-form-categories:target) .sql-back[data-part="form-categories"],
body:has(#part-form-book:target) .sql-back[data-part="form-book"],
body:has(#part-form-book-authors:target) .sql-back[data-part="form-book-authors"],
body:has(#part-form-row:target) .sql-back[data-part="form-row"],
body:has(#part-report-1:target) .sql-back[data-part="report-1"],
body:has(#part-report-2:target) .sql-back[data-part="report-2"],
body:has(#part-report-3:target) .sql-back[data-part="report-3"],
body:has(#part-rows-user_account:target) .sql-back[data-part="rows-user_account"],
body:has(#part-rows-author:target) .sql-back[data-part="rows-author"],
body:has(#part-rows-publisher:target) .sql-back[data-part="rows-publisher"],
body:has(#part-rows-category:target) .sql-back[data-part="rows-category"],
body:has(#part-rows-book:target) .sql-back[data-part="rows-book"],
body:has(#part-rows-book_author:target) .sql-back[data-part="rows-book_author"],
body:has(#part-rows-orders:target) .sql-back[data-part="rows-orders"],
body:has(#part-rows-order_item:target) .sql-back[data-part="rows-order_item"],
body:has(#part-rows-review:target) .sql-back[data-part="rows-review"] {
  display: inline-flex; align-items: center; position: fixed; right: 22px; bottom: 22px; z-index: 20; padding: 9px 16px; font-family: var(--sans); font-size: 13.5px; font-weight: 700; color: #fff; background: var(--navy); border-radius: 99px; box-shadow: 0 8px 22px -8px rgba(19, 42, 92, 0.6);
}
.sql-back::before { content: "\2191"; margin-right: 7px; }
.sql-back:hover { background: var(--blue); text-decoration: none; }
details.sql { scroll-margin-top: 16px; }
/* Coming back: the statement one came from is framed in red, with a small tag; the red ground
   fades away in a few seconds, the frame and the tag stay until something else is clicked. */
.sql-group li[id^="sql-"] { scroll-margin-top: 96px; }
.sql-group li[id^="sql-"]:target > pre { border-color: #d92d20; border-left-color: #d92d20; box-shadow: 0 0 0 2px rgba(217, 45, 32, 0.25); animation: came-back 6s ease-out forwards; }
@keyframes came-back { from { background: #fbd9d5; } }
.sql-group li[id^="sql-"]:target::after { content: "You came from here"; position: absolute; top: -10px; right: 12px; padding: 2px 10px; font-family: var(--sans); font-size: 11.5px; font-weight: 700; color: #fff; background: #d92d20; border-radius: 99px; }
.sql-group li[id^="sql-"]:target::before { color: #d92d20; }
@media (prefers-reduced-motion: reduce) { .sql-group li[id^="sql-"]:target > pre { animation: none; } }

/* The page inside the small picture (body.preview). It is shown at about half size, so the frame is
   much heavier and the small marked things get a stronger red ground. Nothing moves in it. */
body.preview { --mark-width: 8px; --mark-offset: 10px; }
body.preview :is(p, span, small, strong, h1, td, label, a:not(.kpi))[data-part] { --mark-width: 5px; --mark-offset: 3px; --mark-tint: rgba(217, 45, 32, 0.16); }
body.preview .table-wrap[data-part], body.preview .menu-bar[data-part], body.preview td[data-part] { --mark-offset: -8px; }
body.preview .part-anchor { scroll-margin-top: 110px; }
body.preview .part-anchor:target::before { content: none; }
body.preview *, body.preview *::before, body.preview *::after { animation: none !important; transition: none !important; }
body.preview .toasts { display: none; }

/* ---------- 14. Footer ---------- */
/* A grey band with short lists of links, and one small line under them */
footer { margin-top: 8px; font-size: 14px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--line); }
/* Five blocks: the brand, the categories (in two columns of three, so the block is as tall as the others),
   then three short lists of the same width. */
.foot { display: grid; grid-template-columns: 1.5fr 1.9fr repeat(3, minmax(0, 1fr)); gap: 40px; padding-top: 34px; padding-bottom: 30px; }
.foot .two-cols { columns: 2; column-gap: 28px; }
.foot .two-cols li { break-inside: avoid; }
.foot h2 { margin: 4px 0 12px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy); }
.foot ul { margin: 0; padding: 0; list-style: none; }
.foot li { margin-bottom: 7px; }
.foot a { color: #414a59; }
.foot a:hover { color: var(--blue); text-decoration: none; }
.foot-brand p { max-width: 260px; margin: 0 0 8px; line-height: 1.55; text-wrap: pretty; }   /* pretty: no lone last word */
.foot-brand .logo { margin-bottom: 14px; }
.foot-brand .wordmark { font-size: 17px; }


/* ---------- 15. Smaller screens ---------- */
/* Middle screens (a 1024px projector, a tablet) */
@media (max-width: 1100px) {
  .main-nav { gap: 24px; }
  .main-nav .right { gap: 16px; font-size: 13px; }
  nav.menu { gap: 22px; }
  nav.menu a { font-size: 12px; }
  .promo { grid-template-columns: minmax(0, 1fr) 300px; }
  .foot { grid-template-columns: 1.3fr 1.8fr repeat(3, minmax(0, 1fr)); gap: 24px; }
  .sql-tools { --tw: 128px; }
  .sql-preview-frame { --s: 0.5; }
  .banner-covers { --bw: 86px; --bh: 129px; --bt: 22px; --slot: 68px; right: 36px; }
  .rank1 { --bw: 66px; --bh: 99px; }
  .rank2, .rank3 { --bw: 50px; --bh: 75px; }
  .podium { gap: 0 8px; }
  .banner-text { max-width: 250px; }
  .banner h1 { font-size: 26px; }
  .books { gap: 10px; }
  .book-info { padding: 8px 10px 10px; }
  .listing { grid-template-columns: 180px minmax(0, 1fr); gap: 20px; }
  .detail { grid-template-columns: 340px minmax(0, 1fr); gap: 32px; }
  .detail-cover .cover { width: 280px; }
  th, td, table.compact td { padding-left: 10px; padding-right: 10px; }   /* tighter cells: wide tables still fit */
  table.compact td.nowrap { white-space: normal; }           /* admin book list: category and publisher may wrap again */
  table.result { font-size: 12.5px; }
  table.result th { font-size: 11.5px; }
  table.result th, table.result td { padding: 7px 7px; }      /* the 10-column report still fits */
  .manage { grid-template-columns: 1fr; }
  .manage .panel { max-width: 480px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .doc-top { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .sellers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Phones */
@media (max-width: 760px) {
  main { padding: 16px 16px 36px; }
  nav, .wrap { padding-left: 16px; padding-right: 16px; }
  /* Header: logo and account on the first line, the search box on its own line below */
  .main-nav { flex-wrap: wrap; gap: 10px 14px; min-height: 0; padding-top: 12px; padding-bottom: 12px; }
  .main-nav .right { margin-left: auto; gap: 12px; }
  .main-nav .right { font-size: 13px; }
  .main-nav .right .icon, .main-nav .role { display: none; }   /* no room for icons and the role */
  nav.menu a.apart { margin-left: 0; }
  .wordmark { font-size: 18px; }
  .main-nav .logo img { width: 30px; height: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  /* The two menus: one line each that slides sideways instead of wrapping */
  nav.menu, nav.admin { overflow-x: auto; gap: 18px; }
  .promo { grid-template-columns: minmax(0, 1fr); }
  .banner { min-height: 0; padding: 22px 20px; }
  .banner h1 { font-size: 24px; }
  .banner-covers { display: none; }
  .books, .listing .books { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .listing { grid-template-columns: minmax(0, 1fr); }
  /* Tables keep a readable width and scroll inside their box (.table-wrap) instead of squeezing */
  .table-wrap table { min-width: 720px; }
  .detail, .reviews-area, .error-page, .book-form, .rating-box, .specs { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .specs { gap: 6px; }
  .detail-cover .cover { width: 220px; }
  .dash { grid-template-columns: minmax(0, 1fr); }
  .kpis, .sellers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { padding: 12px; text-align: left; }
  .figure img { max-width: none; width: 720px; }               /* readable size; the card scrolls sideways */
  .auth, .auth.wide { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { min-height: 0; padding: 22px; }
  .auth-line { margin-top: 18px; font-size: 26px; }
  .auth-form { padding: 22px; }
  .fields { grid-template-columns: 1fr; }
  /* SQL list: the text above, the three tools in one row under it, an opened panel under the row */
  .sql-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto; padding-left: 0; --tw: 100%; }
  .sql-text { grid-column: 1 / -1; }
  .sql-part-link { grid-column: 1; grid-row: 2; }
  .sql-tools > details.sql-preview { grid-column: 2; grid-row: 2; }
  .sql-tools > details.steps, details.sql .sql-tools > details.steps { grid-column: 3; grid-row: 2; }
  .sql-part-link, details.sql .sql-tools > details > summary { width: 100%; font-size: 10.5px; letter-spacing: -0.01em; gap: 0; overflow: hidden; }
  .sql-tools .icon { display: none; }                        /* no room for the small pictures on the buttons */
  .sql-tools > details[open], details.sql .sql-tools > details.steps[open] { grid-column: 1 / -1; grid-row: 3; }
  details.sql .sql-tools > details[open] > summary { position: static; margin-bottom: 8px; }
  .sql-preview-frame { --s: 0.26; }
  .sql-note { padding-left: 4px; }
  .part-anchor:target::before { left: 10px; bottom: 58px; font-size: 11.5px; white-space: normal; max-width: calc(100% - 20px); }
  .sql-back { right: 10px !important; bottom: 12px !important; }
  .toasts { top: 150px; right: 12px; left: 12px; width: auto; }
  .pane { grid-template-columns: minmax(0, 1fr); padding: 10px; }      /* statement above, explanation under it */
  .step-dots { margin-left: 0; flex-basis: 100%; }
  /* Book form: small cover on the left, file box on the right */
  .book-form { padding: 16px; }
  .book-form-cover { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 0 16px; align-items: center; }
  .book-form-cover .cover { grid-row: 1 / 3; margin: 0; }
  .book-form-cover p { margin: 0 0 8px; text-align: left; }
  .book-form-cover label { margin: 0; }
  .cover.placeholder { font-size: 11px; text-align: center; padding: 8px; }
  .page-head .note { text-align: left; }
  .foot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot .foot-wide { grid-column: 1 / -1; }
  .foot-brand { grid-column: 1 / -1; }
  details.sql summary::after { display: none; }              /* no room for "show": the + box says it */
}
