/* Shared controls loaded after page styles. */
/* Customer discovery uses the existing palette and preference system. */
.library-home .hero { border-radius: 14px; min-height: 440px; gap: 2.5rem; }
.library-home .hero h1 { font-size: clamp(2.6rem, 5.3vw, 4.6rem); }
.library-home .search-help { font-size: .85rem; color: #d5dce8; margin: .75rem 0 0; max-width: 38rem; }
.library-home .hero-covers a { display: block; min-width: 0; border-radius: 6px; }
.library-home .hero-covers a:nth-child(2) { margin-top: 1.8rem; }
.library-home .hero-covers img { border-radius: 6px; box-shadow: 0 6px 18px #0003; margin: 0; }
.library-home .hero-covers:empty { display: none; }
.library-home .hero:has(.hero-covers:empty) { grid-template-columns: 1fr; }
.reading-paths { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: -3rem 0 3.5rem; padding: 1.5rem 0; border-bottom: 1px solid var(--ui-line); }
.reading-paths a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ui-text); text-underline-offset: .25em; font-weight: 650; }
.home-page .surface-action { border-color: var(--ui-line); color: var(--ui-text); background: transparent; }
.home-page .surface-action:hover { background: var(--ui-paper); color: var(--ui-text); }
.book-body h3 a, .catalogue-card h3 a, .author-book h4 a { text-decoration: none; }
.book-body h3 a:hover, .catalogue-card h3 a:hover, .author-book h4 a:hover { text-decoration: underline; text-underline-offset: .15em; }
.book-cover, .catalogue-cover { display: block; }
.book-meta a, .catalogue-card__author a { text-underline-offset: .2em; }
.discovery-section { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 3rem; padding: 2rem 0; }
.discovery-links > a { position: relative; display: block; padding: 1.3rem 2rem 1.3rem 0; border-bottom: 1px solid var(--ui-line); text-decoration: none; }
.discovery-links > a:first-child { border-top: 1px solid var(--ui-line); }
.discovery-links h3 { font-size: 1.5rem; color: var(--ui-text); margin-bottom: .5rem; }
.discovery-links p { color: var(--ui-muted); font-size: .95rem; margin: 0; }
.discovery-links > a > span { position: absolute; right: 0; top: 1.2rem; font-size: 1.4rem; }
.discovery-links > a:hover { border-bottom-color: var(--ui-gold); }
.author-works-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; text-underline-offset: .2em; }
.reader-contact { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1.5rem; padding: clamp(1.25rem, 4vw, 2.5rem); border-top: 3px solid var(--ui-gold); background: var(--ui-paper); }
.reader-contact > div { max-width: 46rem; }
.reader-contact p { color: var(--ui-muted); margin-bottom: 0; }
.catalogue-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.catalogue-controls label { display: grid; gap: .4rem; color: var(--ui-muted); font-size: .9rem; flex: 1 1 13rem; max-width: 23rem; }
.catalogue-controls select { width: 100%; border: 1px solid var(--ui-line); background: var(--ui-paper); color: var(--ui-text); padding: .65rem .75rem; border-radius: 6px; min-width: 0; }
.author-discovery { margin: 1.5rem 0; max-width: 38rem; }
.author-discovery label { display: block; font-weight: 650; margin-bottom: .5rem; }
.author-discovery > div { display: flex; gap: .5rem; }
.author-discovery input { min-width: 0; flex: 1; border: 1px solid var(--ui-line); border-radius: 6px; padding: .75rem; color: var(--ui-text); background: var(--ui-paper); }
.author-discovery button { border: 1px solid var(--ui-line); border-radius: 6px; padding: .5rem .8rem; color: var(--ui-text); background: var(--ui-paper); cursor: pointer; }
#author-search-status { margin: .5rem 0; color: var(--ui-muted); font-size: .9rem; }
.author-index { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; border-block: 1px solid var(--ui-line); margin-bottom: 2rem; padding: .75rem 0; }
.author-index a { min-height: 44px; display: inline-flex; align-items: center; text-underline-offset: .2em; }
.author-profile { scroll-margin-top: 1.5rem; }
.author-profile:target { border-color: var(--ui-gold); }
.author-profile__label { color: var(--ui-muted); font-size: .85rem; margin-bottom: .4rem; }
.author-book__details { display: inline-flex; align-items: center; min-height: 44px; margin-right: .75rem; font-size: .85rem; text-underline-offset: .2em; }
.author-book__cover-link { align-self: start; }
.detail-author { font-family: var(--home-serif); font-size: 1.5rem; margin: 0 0 1rem; color: var(--ui-text); }
.detail-author a { text-underline-offset: .2em; }
.book-reading-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
.book-reading-info > div { padding: 1.5rem; border-top: 1px solid var(--ui-line); }
.book-reading-info h2 { font-size: 1.8rem; color: var(--ui-text); }
.book-reading-info p { color: var(--ui-muted); }
.book-reading-info a { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: .2em; }
.preview-notice { background: var(--ui-paper); }
.checkout-book-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--ui-primary); text-underline-offset: .2em; }
.checkout-guidance { font-size: .9rem; line-height: 1.6; color: var(--ui-muted); margin-bottom: 1.5rem; }
@media (max-width: 760px) {
    .discovery-section, .book-reading-info { grid-template-columns: 1fr; gap: 1rem; }
    .reading-paths { gap: .5rem 1rem; }
}
@media (max-width: 620px) {
    .library-home .hero { padding: 1.5rem; gap: 1.5rem; }
    .library-home .hero-covers { display: grid; max-width: 300px; }
    .library-home .search-row { flex-wrap: wrap; border-radius: 8px; padding: .6rem; }
    .library-home .search-row input { flex: 1 0 100%; }
    .library-home .search-row button[type="submit"] { flex: 1; }
    .catalogue-controls label { max-width: none; }
}
:root {
    --ui-bg: #f8f2e7;
    --ui-paper: #fffdf8;
    --ui-text: #172033;
    --ui-muted: #596375;
    --ui-line: #c9c5bc;
    --ui-gold: #c89b3c;
    --ui-primary: #081a33;
}
[data-theme="dark"] {
    --ui-bg: #081322;
    --ui-paper: #10233c;
    --ui-text: #edf1f5;
    --ui-muted: #b8c4d5;
    --ui-line: #455870;
    --ui-primary: #e4c782;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 1rem; }
.theme-toggle { border: 1px solid var(--ui-line); border-radius: 6px; padding: .5rem .75rem; background: var(--ui-paper); color: var(--ui-text); cursor: pointer; }
.admin-preferences { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.5rem; }
.admin-preferences a { color: var(--ui-primary); padding: .5rem; }
body:has(.admin-preferences) { --bg: var(--ui-bg); --panel: var(--ui-paper); --field: var(--ui-bg); --line: var(--ui-line); --text: var(--ui-text); --muted: var(--ui-muted); background: var(--ui-bg); color: var(--ui-text); }
body:has(.admin-preferences) :is(h1, h2, label, small) { color: var(--ui-text); }
body:has(.admin-preferences) :is(table, .panel, .stat-card, .modal-panel) { background: var(--ui-paper); color: var(--ui-text); border-color: var(--ui-line); box-shadow: none; }
body:has(.admin-preferences) :is(th, input, select, textarea) { background: var(--ui-bg); color: var(--ui-text); border-color: var(--ui-line); }
body:has(.admin-preferences) tr:hover { background: var(--ui-bg); }
body:has(.admin-preferences) :is(.topbar, .page-header) { flex-wrap: wrap; }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; }
.admin-preferences .language-select { width: auto; }
.admin-preferences + main { min-width: 0; }
body.centered-page:has(.admin-preferences) { flex-direction: column; align-items: center; gap: 1rem; }
body:has(.admin-preferences) .stat-card.available strong { color: #23784f; }
body:has(.admin-preferences) .stat-card.unavailable strong { color: #ab3448; }
[data-theme="dark"] body:has(.admin-preferences) .stat-card.available strong { color: #72ddb0; }
[data-theme="dark"] body:has(.admin-preferences) .stat-card.unavailable strong { color: #ff9ca8; }
body { overflow-wrap: anywhere; }
.home-page { overflow-x: visible; }
.home-page .site-footer a { min-height: 44px; display: flex; align-items: center; }
.table-scroll td[style], .table-scroll td > span:not(.badge) { color: var(--ui-text) !important; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, select, .nav-links a, .contact-header__nav a { min-height: 44px; }
button:disabled, [aria-disabled="true"], .action-unavailable { cursor: not-allowed; opacity: .7; }
button[aria-busy="true"] { cursor: progress; }
.action-unavailable { display: block; padding: .7rem; text-align: center; color: var(--ui-muted); }
.skip-link { position: absolute; top: -6rem; left: 1rem; z-index: 100; background: var(--ui-primary); color: var(--ui-bg); padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }
.language-select option { color: var(--ui-text); background: var(--ui-paper); }
.home-page .eyebrow:not(.hero .eyebrow):not(.catalogue-hero .eyebrow):not(.details-hero .eyebrow):not(.authors-hero .eyebrow) { color: #775512; }
[data-theme="dark"] .home-page .eyebrow { color: #e4c782 !important; }
.home-page .book-card, .catalogue-page .catalogue-card, .authors-page .author-profile, .details-page .book-details { border-radius: 10px; box-shadow: 0 3px 12px #081a330a; }
.home-page .book-card:hover, .catalogue-page .catalogue-card:hover { transform: none; box-shadow: 0 5px 18px #081a3314; border-color: var(--ui-gold); }
.home-page .book-body h3, .catalogue-page .catalogue-card h3 { line-height: 1.25; min-height: 2.5em; }
.home-page .price, .catalogue-page .catalogue-card__price, .checkout-price, .authors-page .author-book__price { font-variant-numeric: tabular-nums; font-size: 1.2rem; letter-spacing: .01em; line-height: 1.5; }
.home-page .btn, .catalogue-page .catalogue-card__buy, .catalogue-page .catalogue-card__details, .authors-page .author-book__buy { min-height: 44px; border-radius: 6px; box-shadow: none; }
.home-page .book-actions .btn:first-child { background: transparent; color: var(--ui-text); border: 1px solid var(--ui-line); }
.home-page .book-actions .btn:last-child, .catalogue-page .catalogue-card__buy, .authors-page .author-book__buy { background: var(--ui-gold); color: #172033; }
.authors-page .author-book__buy { display: inline-flex; align-items: center; justify-content: center; padding: .5rem .8rem; }
.home-page .btn:hover, .catalogue-page .catalogue-card__buy:hover, .catalogue-page .catalogue-card__details:hover { transform: none; filter: brightness(.95); }
.home-page .book-actions .btn:active, .catalogue-page .catalogue-card__buy:active { filter: brightness(.88); }
[data-theme="dark"] .home-page .author-card { background: var(--ui-paper); }
[data-theme="dark"] .catalogue-page .catalogue-card__details:hover { background: #233b56; color: var(--ui-text); }
[data-theme="dark"] .home-page .site-footer a:hover { color: var(--ui-text); }
.catalogue-page .catalogue-no-results:not([hidden]) { display: block; }
.cover-fallback-text { display: flex; align-items: center; justify-content: center; background: var(--ui-paper); color: var(--ui-muted); text-align: center; padding: 1rem; box-sizing: border-box; }
.author-book .cover-fallback-text { font-size: .7rem; min-height: 0; padding: .25rem; }
.checkout-cover.cover-fallback-text { min-height: 180px; }
.centered-page { --bg: var(--ui-bg); --bg-soft: var(--ui-bg); --card: var(--ui-paper); --field: var(--ui-bg); --text: var(--ui-text); --muted: var(--ui-muted); --line: var(--ui-line); --accent: var(--ui-primary); padding-top: 6rem; }
body.centered-page { padding-top: 6rem; align-items: flex-start; }
.centered-page .login-box { background: var(--ui-paper); color: var(--ui-text); box-shadow: 0 4px 20px #081a3310; border: 1px solid var(--ui-line); padding: clamp(1rem, 4vw, 2rem); }
body:has(.admin-preferences) main:not(:has(.panel)) { background: var(--ui-paper); color: var(--ui-text); }
body:has(.admin-preferences) main > p:not(.message) { color: var(--ui-muted); }
.centered-page .login-box input { color: var(--ui-text); }
.centered-page .login-box button { background: var(--ui-gold); color: #172033; min-height: 48px; }
.centered-page .error { background: #fbe9e7; color: #8a302b; border-color: #ad4a40; }
[data-theme="dark"] .centered-page .error { background: #442324; color: #ffd8d5; }
.page-preferences { background: var(--ui-bg); color: var(--ui-text); border-radius: 8px; padding: .25rem; max-width: calc(100% - 2rem); flex-wrap: wrap; }
.contact-info-card a { overflow-wrap: anywhere; }
.contact-field__input { min-width: 0; }
.home-page .book-grid > *, .catalogue-grid > *, .authors-grid > * { min-width: 0; }
@media (max-width: 520px) {
    .home-page h1 { font-size: clamp(2rem, 10vw, 3rem); }
    .home-page .hero, .catalogue-page .catalogue-hero, .details-page .details-hero, .authors-page .authors-hero { border-radius: 12px; }
    .home-page .book-actions { flex-direction: column; }
    .home-page .nav-links, .contact-header__nav { width: 100%; gap: .25rem; flex-wrap: wrap; }
    .contact-header { flex-wrap: wrap; }
    .centered-page .login-box { width: 100% !important; }
}
.language-select {
    min-height: 44px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    padding: .35rem .5rem;
}
.page-preferences {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.page-preferences a, .page-preferences .theme-toggle {
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: .8rem;
    font-weight: 800;
    padding: .45rem .65rem;
    text-decoration: none;
}
@media (max-width: 520px) { .page-preferences a { display: none; } }
.language-select:focus-visible, .theme-toggle:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 3px solid #c89b3c !important;
    outline-offset: 3px;
}
[data-theme="dark"] .language-select { color: #f4efe6; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Shared customer presentation: long titles, full cover artwork and compact navigation. */
.nav-links, .contact-header__nav { flex-wrap: wrap; gap: .4rem 1rem; }
.nav-links a, .contact-header__nav a { min-height: 44px; display: inline-flex; align-items: center; }
.book-card, .catalogue-card, .author-book { min-width: 0; overflow-wrap: anywhere; }
.book-cover img, .catalogue-card__cover img, .hero-covers img, .book-details__cover img, .author-book img { object-fit: contain; }
@media (max-width: 768px) { .nav-links, .contact-header__nav { justify-content: center; width: 100%; } .hero h1 { font-size: clamp(2rem, 8vw, 3rem); } }
