/* Folio design system — one stylesheet, no inline styles (CSP style-src 'self'). */
:root {
  --ink: #1f2a44;
  --ink-soft: #3b4766;
  --paper: #faf7f2;
  --surface: #ffffff;
  --muted: #5b6472;
  --line: #e6e0d6;
  --accent: #b4532a;
  --accent-dark: #8f3f1e;
  --accent-soft: #f6e7df;
  --ok: #2f6f4f;
  --ok-soft: #e3f1e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --danger: #a12a2a;
  --danger-soft: #f8e1e1;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(31, 42, 68, .06), 0 4px 14px rgba(31, 42, 68, .06);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem;
  --container: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--paper); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-dark); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.2; margin: 0 0 var(--space-3); color: var(--ink); }
h1 { font-size: clamp(1.7rem, 2.5vw + 1rem, 2.4rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 var(--space-4); }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: var(--space-2) var(--space-4); z-index: 100; }
.skip-link:focus { left: var(--space-4); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--space-4); }
main { min-height: 60vh; padding: var(--space-5) 0 var(--space-7); }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; }
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-serif); font-size: 1.35rem; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand img { height: 36px; width: auto; }
.search-form { flex: 1; display: flex; max-width: 520px; }
.search-form input { flex: 1; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.search-form button { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.main-nav { display: flex; align-items: center; gap: var(--space-4); margin-left: auto; }
.main-nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.main-nav a:hover { color: var(--accent); }
.cart-link { position: relative; }
.cart-count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; text-align: center; margin-left: .2em; }
.nav-menu > summary { list-style: none; cursor: pointer; font-weight: 500; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu { position: relative; }
.nav-menu[open] > .nav-dropdown { display: block; }
.nav-dropdown { display: none; position: absolute; right: 0; top: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-2); min-width: 220px; z-index: 30; }
.nav-dropdown a, .nav-dropdown button { display: block; width: 100%; text-align: left; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.nav-dropdown a:hover, .nav-dropdown button:hover { background: var(--paper); }
.category-bar { border-top: 1px solid var(--line); }
.category-bar ul { display: flex; flex-wrap: wrap; gap: var(--space-4); list-style: none; margin: 0; padding: var(--space-2) 0; font-size: .92rem; }
.category-bar a { color: var(--ink-soft); text-decoration: none; }
.category-bar a:hover { color: var(--accent); }

/* Footer */
.site-footer { background: var(--ink); color: #d9deea; padding: var(--space-6) 0; font-size: .92rem; }
.site-footer a { color: #fff; }
.footer-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.site-footer h2 { color: #fff; font-size: 1rem; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: .06em; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: var(--space-1); }
.footer-note { margin-top: var(--space-5); color: #aab3c7; }

/* Buttons */
.btn, button, input[type="submit"] { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: .55rem 1.05rem; border-radius: var(--radius-sm); text-decoration: none; line-height: 1.2; }
.btn:hover, button:hover { background: var(--ink-soft); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--paper); color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-link { background: none; border: 0; color: var(--accent-dark); padding: 0; font-weight: 500; text-decoration: underline; }
.btn-link:hover { background: none; color: var(--accent); }
.btn-sm { padding: .3rem .65rem; font-size: .88rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
button[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; }

/* Forms */
label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="tel"], input[type="url"], input[type="date"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #cfc7b9; border-radius: var(--radius-sm); padding: .55rem .7rem; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
textarea { min-height: 8rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.field { margin-bottom: var(--space-4); }
.field-inline { display: flex; align-items: center; gap: var(--space-2); }
.field-inline label { margin: 0; font-weight: 500; }
.helptext, .field small { display: block; color: var(--muted); font-size: .86rem; margin-top: var(--space-1); }
.errorlist { list-style: none; padding: 0; margin: var(--space-1) 0 0; color: var(--danger); font-size: .9rem; }
.form-card { max-width: 520px; margin: 0 auto; }
.form-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); margin: 0 0 var(--space-4); }
legend { font-weight: 700; padding: 0 var(--space-2); }
.choice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: var(--space-2); background: var(--surface); }
.choice label { margin: 0; font-weight: 500; }

/* Cards, panels, layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); box-shadow: var(--shadow); }
.card + .card { margin-top: var(--space-4); }
.stack > * + * { margin-top: var(--space-4); }
.split { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.sidebar-layout { display: grid; gap: var(--space-6); grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.section { margin-top: var(--space-7); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-4); }
.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--space-6); }
.prose ul { padding-left: 1.2rem; }
.placeholder-note { background: var(--warn-soft); border: 1px dashed var(--warn); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); color: var(--warn); font-weight: 600; }
.breadcrumbs { font-size: .9rem; color: var(--muted); margin-bottom: var(--space-4); }
.breadcrumbs a { color: var(--muted); }
.kpis { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); }
.kpi strong { display: block; font-size: 1.5rem; font-family: var(--font-serif); }

/* Book grid & cards */
.book-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.book-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease; }
.book-card:hover { transform: translateY(-2px); }
.book-card a { text-decoration: none; color: inherit; }
.book-card .cover { aspect-ratio: 2 / 3; background: var(--accent-soft); }
.book-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card .body { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); flex: 1; }
.book-card .title { font-family: var(--font-serif); font-weight: 700; line-height: 1.25; }
.book-card .author { color: var(--muted); font-size: .9rem; }
.book-card .price-row { margin-top: auto; display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.cover-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: var(--space-4); text-align: center; font-family: var(--font-serif); font-weight: 700; color: var(--ink); background: linear-gradient(160deg, var(--accent-soft), #efe6d8); }
.price { font-weight: 700; font-size: 1.05rem; }
.price-compare { color: var(--muted); text-decoration: line-through; font-size: .9rem; }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .02em; padding: .12rem .5rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft); }
.badge-accent { background: var(--accent-soft); border-color: #ebcbbb; color: var(--accent-dark); }
.badge-ok { background: var(--ok-soft); border-color: #bfdcca; color: var(--ok); }
.badge-warn { background: var(--warn-soft); border-color: #efd9a8; color: var(--warn); }
.badge-danger { background: var(--danger-soft); border-color: #ecc0c0; color: var(--danger); }
.stars { color: #c98a00; letter-spacing: .05em; }

/* Book detail */
.book-detail { display: grid; gap: var(--space-6); grid-template-columns: minmax(220px, 360px) minmax(0, 1fr) 300px; align-items: start; }
.gallery-main { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface); aspect-ratio: 2 / 3; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.gallery-thumbs a { width: 64px; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; }
.gallery-thumbs a.active, .gallery-thumbs a:hover { border-color: var(--accent); }
.buy-box { position: sticky; top: 90px; }
.buy-box .price { font-size: 1.6rem; }
.details-table { width: 100%; border-collapse: collapse; }
.details-table th { text-align: left; color: var(--muted); font-weight: 500; width: 40%; }
.details-table th, .details-table td { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.qty-row { display: flex; gap: var(--space-2); align-items: end; }
.qty-row input { width: 5.5rem; }
.review { border-bottom: 1px solid var(--line); padding: var(--space-4) 0; }

/* Filters */
.filters .field { margin-bottom: var(--space-3); }
.filters h2 { font-size: 1rem; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.filters ul { list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.filters li { margin-bottom: var(--space-1); }
.filter-check { display: flex; gap: var(--space-2); align-items: center; font-weight: 400; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.toolbar form { display: flex; gap: var(--space-2); align-items: center; }
.toolbar select { width: auto; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { padding: var(--space-3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: var(--paper); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table .num { text-align: right; white-space: nowrap; }
.totals { width: 100%; }
.totals td { padding: var(--space-1) 0; }
.totals td:last-child { text-align: right; }
.totals .grand td { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--line); padding-top: var(--space-2); }

/* Alerts & messages */
.messages { list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); margin-bottom: var(--space-3); }
.alert-success { background: var(--ok-soft); border-color: #bfdcca; color: var(--ok); }
.alert-info { background: #e6eef9; border-color: #c5d5ee; color: #24426f; }
.alert-warning { background: var(--warn-soft); border-color: #efd9a8; color: var(--warn); }
.alert-error { background: var(--danger-soft); border-color: #ecc0c0; color: var(--danger); }

/* Hero / banners */
.hero { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; background: var(--ink); color: #f1ede6; border-radius: var(--radius); padding: var(--space-7) var(--space-6); overflow: hidden; }
.hero h1 { color: #fff; font-size: clamp(2rem, 3vw + 1rem, 3rem); }
.hero p { color: #d7dbe6; font-size: 1.1rem; }
.hero img { border-radius: var(--radius); max-height: 320px; width: 100%; object-fit: cover; }
.promo { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; justify-content: space-between; background: var(--accent-soft); border: 1px solid #ebcbbb; border-radius: var(--radius); padding: var(--space-5) var(--space-6); }
.promo h2 { margin: 0; }
.category-tiles { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.category-tiles a { display: block; padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); font-weight: 600; }
.category-tiles a:hover { border-color: var(--accent); color: var(--accent-dark); }

/* Pagination */
.pagination { display: flex; gap: var(--space-2); justify-content: center; margin-top: var(--space-6); flex-wrap: wrap; }
.pagination a, .pagination span { padding: .4rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); text-decoration: none; color: var(--ink); }
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Account area */
.account-nav { list-style: none; padding: 0; margin: 0; }
.account-nav a { display: block; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); }
.account-nav a:hover, .account-nav a[aria-current="page"] { background: var(--surface); color: var(--accent-dark); }
.qr { width: 220px; height: 220px; background: #fff; padding: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.qr svg { width: 100%; height: 100%; }
.status-steps { display: flex; gap: var(--space-2); flex-wrap: wrap; list-style: none; padding: 0; }
.status-steps li { padding: .2rem .6rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: .85rem; }
.status-steps li.done { background: var(--ok-soft); border-color: #bfdcca; color: var(--ok); }

/* Cookie banner */
.cookie-banner { position: fixed; bottom: var(--space-4); left: var(--space-4); right: var(--space-4); max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 30px rgba(0, 0, 0, .18); padding: var(--space-4); z-index: 50; display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.cookie-banner p { margin: 0; flex: 1; min-width: 240px; }
.cookie-banner form { display: flex; gap: var(--space-2); }

/* Charts (server-rendered SVG) */
.chart { width: 100%; height: auto; }
.chart .bar { fill: var(--accent); }
.chart .axis { stroke: var(--line); }
.chart text { font-size: 10px; fill: var(--muted); }

/* Responsive */
@media (max-width: 1000px) {
  .book-detail { grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); }
  .book-detail .buy-box { grid-column: 1 / -1; position: static; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .header-row { flex-wrap: wrap; }
  .search-form { order: 3; max-width: none; flex-basis: 100%; }
  .main-nav { gap: var(--space-3); font-size: .95rem; }
  .sidebar-layout, .hero, .book-detail { grid-template-columns: 1fr; }
  .hero { padding: var(--space-6) var(--space-4); }
  .category-bar { display: none; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
