/*
 * TỦ SÁCH LÝ LUẬN ĐIỆN TỬ
 * Visual system 8.0 — editorial, accessible, responsive.
 * This layer intentionally changes presentation only.
 */

:root {
    --red-brand: #991b1f;
    --red-hover: #771115;
    --red-deep: #5f0d12;
    --red-soft: #fff1f1;
    --red-glow: rgba(153, 27, 31, .16);
    --yellow-brand: #e7b647;
    --yellow-soft: #fff8e5;
    --navy: #15233d;
    --navy-soft: #edf2f8;
    --success: #08775e;
    --info: #2457a6;
    --warning: #a65b09;
    --bg-main: #f6f3ed;
    --bg-card: rgba(255, 255, 255, .96);
    --bg-card-solid: #fff;
    --surface-raised: #fff;
    --surface-subtle: #f3efe8;
    --text-dark: #172033;
    --text-muted: #637083;
    --border-light: #e4ded4;
    --border-glass: rgba(255, 255, 255, .72);
    --border-color: #e4ded4;
    --shadow-sm: 0 2px 8px rgba(22, 32, 51, .06);
    --shadow-md: 0 12px 28px rgba(22, 32, 51, .09);
    --shadow-lg: 0 28px 70px rgba(22, 32, 51, .16);
    --shadow-gold: 0 12px 28px rgba(166, 91, 9, .14);
    --radius-sm: 10px;
    --radius-md: 18px;
    --radius-lg: 26px;
    --radius-pill: 999px;
    --trans: .22s cubic-bezier(.2, .7, .2, 1);
    --focus-ring: 0 0 0 4px rgba(153, 27, 31, .14);
}

[data-theme="dark"] {
    --bg-main: #0d1421;
    --bg-card: rgba(24, 34, 52, .96);
    --bg-card-solid: #182234;
    --surface-raised: #1c283d;
    --surface-subtle: #121c2c;
    --text-dark: #f6f1e8;
    --text-muted: #aeb9c9;
    --border-light: #2d3a50;
    --border-glass: rgba(255, 255, 255, .08);
    --border-color: #2d3a50;
    --red-brand: #ed6c6f;
    --red-hover: #ff8587;
    --red-deep: #4a090d;
    --red-soft: rgba(237, 108, 111, .12);
    --yellow-brand: #f0c760;
    --yellow-soft: rgba(240, 199, 96, .12);
    --navy: #e8edf5;
    --navy-soft: #243149;
    --shadow-sm: 0 3px 10px rgba(0, 0, 0, .2);
    --shadow-md: 0 14px 30px rgba(0, 0, 0, .28);
    --shadow-lg: 0 30px 75px rgba(0, 0, 0, .5);
}

html {
    scroll-behavior: smooth;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    background:
        radial-gradient(circle at 8% 5%, rgba(231, 182, 71, .10), transparent 26rem),
        radial-gradient(circle at 95% 25%, rgba(153, 27, 31, .07), transparent 28rem),
        var(--bg-main);
    color: var(--text-dark);
    font-family: "Plus Jakarta Sans", "Montserrat", system-ui, sans-serif;
    letter-spacing: -.01em;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .23;
    background-image: linear-gradient(rgba(21, 35, 61, .035) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(21, 35, 61, .035) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

button, input, select, textarea, audio { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
img { max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--red-brand);
    outline-offset: 3px;
}

.container {
    width: min(100% - 40px, 1240px);
    max-width: none;
    padding: 0;
}

/* Header */
.navbar {
    padding: 10px 0;
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid rgba(153, 27, 31, .10);
    box-shadow: 0 8px 35px rgba(22, 32, 51, .07);
    backdrop-filter: saturate(150%) blur(18px);
}

[data-theme="dark"] .navbar { background: rgba(13, 20, 33, .9); }
.nav-content { min-height: 58px; }
.logo-area { gap: 12px; color: var(--text-dark); text-transform: none; }
.logo-area:hover { transform: none; color: var(--red-brand); }
.logo-area img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 5px 10px rgba(95, 13, 18, .18));
}
.logo-area:hover img { transform: translateY(-1px); }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong {
    font-family: "Montserrat", sans-serif;
    font-size: 1rem;
    line-height: 1.15;
    letter-spacing: .055em;
    color: var(--red-brand);
}
.brand-copy small {
    color: var(--text-muted);
    font-size: .69rem;
    font-weight: 600;
    letter-spacing: .025em;
}
.nav-actions { gap: 10px; }
.theme-toggle, .back-to-top {
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-light);
    background: var(--surface-raised);
    color: var(--navy);
    box-shadow: var(--shadow-sm);
}
.theme-toggle:hover {
    color: var(--red-brand);
    border-color: rgba(153, 27, 31, .35);
    background: var(--red-soft);
    transform: translateY(-2px);
}
.btn-donate {
    min-height: 44px;
    padding: 0 20px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: linear-gradient(135deg, #a51d22, #7b1116);
    box-shadow: 0 8px 20px rgba(123, 17, 22, .2);
}
.btn-donate:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(123, 17, 22, .3);
    filter: none;
}

/* Hero */
.hero {
    min-height: 480px;
    display: grid;
    place-items: center;
    margin-bottom: -74px;
    padding: 86px 0 142px;
    background-position: center 38% !important;
}
.hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    z-index: 1;
    height: 140px;
    background: linear-gradient(to bottom, transparent, rgba(32, 12, 13, .35));
}
.hero-overlay {
    background:
        radial-gradient(circle at 50% 24%, rgba(231, 182, 71, .13), transparent 36%),
        linear-gradient(115deg, rgba(71, 7, 11, .94), rgba(115, 15, 20, .78) 50%, rgba(14, 28, 52, .88));
}
.hero-content { max-width: 940px; }
.hero-badge {
    margin-bottom: 24px;
    padding: 9px 18px;
    background: rgba(255, 255, 255, .09);
    color: #ffe5a8;
    border-color: rgba(255, 229, 168, .34);
    box-shadow: inset 0 1px rgba(255,255,255,.12);
    font-size: .8rem;
    letter-spacing: .045em;
}
.hero h1 {
    max-width: 900px;
    margin: 0 auto 16px;
    color: #fff;
    background: none;
    -webkit-text-fill-color: initial;
    font-family: "Montserrat", sans-serif;
    font-size: clamp(2.25rem, 5vw, 4.35rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.045em;
    text-wrap: balance;
    text-shadow: 0 8px 30px rgba(0,0,0,.28);
}
.hero p {
    max-width: 750px;
    color: rgba(255,255,255,.84);
    font-size: 1.03rem;
    line-height: 1.75;
    text-shadow: none;
    text-wrap: balance;
}
.search-wrapper {
    max-width: 720px;
    margin-top: 34px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .28);
    background: rgba(255, 255, 255, .14);
    border-radius: 16px;
    transform: none;
    box-shadow: 0 24px 52px rgba(0,0,0,.22);
}
.search-wrapper:focus-within {
    border-color: rgba(255, 229, 168, .7);
    transform: translateY(-2px);
    box-shadow: 0 28px 58px rgba(0,0,0,.26), 0 0 0 4px rgba(255,255,255,.08);
}
.search-wrapper input {
    min-height: 58px;
    padding-left: 54px;
    border-radius: 11px;
    background: rgba(255,255,255,.98);
    color: #172033;
    box-shadow: none;
}
.search-wrapper input::placeholder { color: #768195; }
.search-icon { left: 26px; color: #991b1f; }

/* Dashboard surfaces */
main.container { position: relative; z-index: 2; }
.stats-container {
    gap: 14px;
    margin: 0 0 36px;
}
.stat-card {
    min-height: 112px;
    padding: 22px;
    border: 1px solid rgba(255,255,255,.85);
    border-bottom-color: var(--border-light);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.stat-card::after {
    content: "";
    position: absolute;
    inset: auto 22px 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(90deg, var(--red-brand), var(--yellow-brand));
    opacity: .8;
}
.stat-card:hover { border-color: rgba(153, 27, 31, .18); transform: translateY(-4px); }
.stat-card i {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--red-soft);
    color: var(--red-brand);
    box-shadow: inset 0 0 0 1px rgba(153,27,31,.08);
}
.stat-info h3 { color: var(--navy); font-size: 2rem; }
.stat-info p { font-size: .72rem; letter-spacing: .065em; }

.trending-section, .quote-slider-section, .honor-section {
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}
.trending-section {
    margin-bottom: 32px;
    padding: 24px;
    border-radius: var(--radius-md);
}
.trending-header h2, .podcast-section-header h2, .honor-header h2 {
    font-family: "Montserrat", sans-serif;
    font-size: 1.25rem;
    letter-spacing: -.025em;
}
.trending-slider { gap: 14px; padding: 8px 2px 12px; }
.trending-card { min-width: 160px; width: 160px; }

.quote-slider-section {
    overflow: hidden;
    margin-bottom: 28px;
    padding: 20px 24px;
    border-radius: var(--radius-md);
    background:
        linear-gradient(100deg, var(--yellow-soft), transparent 34%),
        var(--bg-card);
}
.quote-slider-container { gap: 18px; }
.quote-bracket-left, .quote-bracket-right { color: var(--yellow-brand); opacity: .55; }
.quote-slide .quote-text {
    color: var(--navy);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1rem;
    line-height: 1.65;
}
.quote-slide .quote-attribution { color: var(--text-muted); }
.btn-share-quote {
    min-height: 40px;
    border-color: rgba(153, 27, 31, .2);
    background: var(--red-soft);
    color: var(--red-brand);
    box-shadow: none;
}

/* Navigation and filters */
.controls-bar {
    gap: 14px;
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}
.filter-tabs { gap: 6px; }
.tab-btn, .fav-sub-tab {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: .79rem;
    font-weight: 700;
}
.tab-btn i, .fav-sub-tab i { font-size: .88em; }
.tab-btn.active, .tab-btn:hover,
.fav-sub-tab.active, .fav-sub-tab:hover {
    border-color: rgba(153, 27, 31, .12);
    background: var(--red-soft);
    color: var(--red-brand);
    box-shadow: none;
    transform: none;
}
.tab-btn.active { box-shadow: inset 0 -2px var(--red-brand); }
.sort-select {
    min-height: 42px;
    padding: 0 38px 0 13px;
    border-color: var(--border-light);
    border-radius: 10px;
    background-color: var(--surface-subtle);
    color: var(--text-dark);
    font-size: .78rem;
}
.sort-select:focus { box-shadow: var(--focus-ring); }

.tag-cloud, .author-cloud {
    gap: 7px;
    margin-bottom: 28px;
    padding: 0 2px;
}
.tag-filter-btn, .author-filter-btn {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 700;
    box-shadow: none;
}
.tag-filter-btn.active, .tag-filter-btn:hover,
.author-filter-btn.active, .author-filter-btn:hover {
    border-color: var(--red-brand);
    background: var(--red-brand);
    color: #fff;
    transform: translateY(-1px);
}
.fav-sub-tabs {
    padding: 8px !important;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--bg-card);
}

/* Book and podcast cards */
.book-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 20px;
    margin-bottom: 44px;
}
.book-card {
    overflow: hidden;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    background: var(--bg-card-solid);
    box-shadow: 0 5px 18px rgba(22,32,51,.07);
    isolation: isolate;
}
.book-card:hover {
    border-color: rgba(153, 27, 31, .25);
    transform: translateY(-7px);
    box-shadow: 0 22px 46px rgba(22,32,51,.14);
}
.book-card .book-cover {
    height: 260px;
    border-radius: 0;
    background:
        linear-gradient(145deg, rgba(255,255,255,.12), transparent 45%),
        linear-gradient(135deg, #7c1217, #13233e);
    box-shadow: inset 10px 0 18px rgba(0,0,0,.14);
}
.book-cover::before {
    content: "";
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(231,182,71,.38);
    pointer-events: none;
}
.book-cover::after { left: 13px; width: 2px; background: rgba(255,255,255,.24); }
.book-card:hover .book-cover { transform: none; filter: saturate(1.06); }
.cover-title {
    max-width: 86%;
    color: #fff8e7;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1rem;
    line-height: 1.35;
    text-shadow: 0 3px 10px rgba(0,0,0,.45);
}
.contributor-badge {
    left: 8px;
    top: 8px;
    max-width: calc(100% - 52px);
    padding: 6px 9px;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(21,35,61,.88);
    color: #ffe6aa;
    border-radius: 8px;
    backdrop-filter: blur(8px);
}
.fav-btn {
    top: 9px;
    right: 9px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.34);
    background: rgba(255,255,255,.9);
    color: #7b1116;
    box-shadow: 0 6px 16px rgba(0,0,0,.13);
}
.fav-btn.active { background: var(--red-brand); color: #fff; }
.book-content { padding: 15px 15px 16px; }
.book-content h3 {
    min-height: 44px;
    margin-bottom: 10px;
    color: var(--navy);
    font-size: .92rem;
    line-height: 1.45;
}
.book-meta { margin-bottom: 10px; font-size: .72rem; line-height: 1.5; }
.book-meta p { margin-bottom: 6px; }
.book-meta i { color: var(--red-brand); }
.tag {
    min-height: 24px;
    padding: 3px 7px;
    border-radius: 6px;
    font-size: .62rem;
}
.tag-cung { background: var(--red-soft); color: var(--red-brand); }
.tag-mem { background: rgba(8, 119, 94, .1); color: var(--success); }
.btn-action, .btn-submit, .btn-load-more, .btn-resume-read, .btn-play-pod, .btn-export-pdf {
    min-height: 42px;
    border-radius: 10px;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .005em;
}
.btn-action { gap: 7px; }
.btn-read { background: var(--navy); color: var(--bg-card-solid); }
[data-theme="dark"] .btn-read { background: #e7edf6; color: #121c2c; }
.btn-read:hover { background: #243a5f; transform: translateY(-2px); }
.btn-borrow, .btn-submit {
    background: linear-gradient(135deg, #a51d22, #7b1116);
    color: #fff;
    box-shadow: 0 7px 16px rgba(123,17,22,.17);
}
.btn-borrow:hover, .btn-submit:hover { background: linear-gradient(135deg, #b52429, #8a151a); }
.btn-load-more {
    min-width: 190px;
    border-color: var(--border-light);
    background: var(--bg-card);
    color: var(--navy);
}

.podcast-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.podcast-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}
.podcast-card:hover { border-color: rgba(153,27,31,.22); box-shadow: var(--shadow-md); }
.podcast-disc {
    background: radial-gradient(circle at center, var(--yellow-brand) 0 11%, #273956 12% 25%, #101a2b 26% 100%);
    box-shadow: 0 12px 22px rgba(16,26,43,.28);
}
.podcast-card .btn-play-pod { background: var(--red-brand); border-radius: 9px; }

/* Empty/loading/status */
.loader {
    min-height: 180px;
    padding: 42px 20px;
    color: var(--red-brand);
}
.spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
}
.reading-state-badge { top: 53px; right: 9px; border-radius: 7px; box-shadow: var(--shadow-sm); }

/* Modals and forms */
.modal {
    padding: 24px;
    background: rgba(8, 14, 25, .68);
    backdrop-filter: blur(10px) saturate(120%);
}
.modal-content {
    width: min(100%, 560px);
    max-height: min(90dvh, 820px);
    overflow-y: auto;
    padding: 32px;
    border: 1px solid var(--border-glass);
    border-radius: 22px;
    background: var(--bg-card-solid);
    box-shadow: 0 35px 90px rgba(0,0,0,.3);
}
.close-btn {
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-subtle);
    color: var(--text-muted);
}
.close-btn:hover { background: var(--red-soft); color: var(--red-brand); transform: none; }
.modal-header { gap: 13px; padding-right: 36px; }
.modal-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 13px;
    background: var(--red-soft);
    color: var(--red-brand);
    font-size: 1.25rem;
}
.modal-header h2 {
    color: var(--navy);
    font-family: "Montserrat", sans-serif;
    font-size: 1.35rem;
}
.modal-subtitle { line-height: 1.6; }
.highlight-text {
    border: 1px solid rgba(153,27,31,.12);
    border-left: 3px solid var(--red-brand);
    border-radius: 10px;
    background: var(--red-soft);
}
.form-group {
    min-height: 50px;
    margin-bottom: 13px;
    border: 1px solid var(--border-light);
    border-radius: 11px;
    background: var(--surface-subtle);
}
.form-group:focus-within {
    border-color: var(--red-brand);
    background: var(--bg-card-solid);
    box-shadow: var(--focus-ring);
}
.form-group i { color: var(--text-muted); }
.form-group:focus-within i { color: var(--red-brand); }
.custom-form input, .custom-form select, .custom-form textarea {
    color: var(--text-dark);
    caret-color: var(--red-brand);
}
.custom-form input::placeholder, .custom-form textarea::placeholder { color: var(--text-muted); opacity: .8; }
.btn-submit { min-height: 50px; border-radius: 11px; }

/* Detail modal */
.detail-modal-content {
    width: min(100%, 940px);
    max-width: 940px;
    border-radius: 24px;
}
.detail-left {
    width: 36%;
    padding: 36px 30px;
    background:
        radial-gradient(circle at 50% 20%, rgba(231,182,71,.14), transparent 48%),
        var(--surface-subtle);
}
.detail-right { width: 64%; padding: 38px; }
.detail-cover-large {
    height: 345px;
    border-radius: 8px 14px 14px 8px;
    background: linear-gradient(135deg, #771115, #15233d);
    box-shadow: 8px 16px 30px rgba(22,32,51,.24);
}
.detail-right h2 {
    color: var(--navy);
    font-family: "Montserrat", sans-serif;
    font-size: 1.55rem;
}
.detail-meta-info span {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface-subtle);
}
.detail-summary-box {
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--yellow-brand);
    border-radius: 12px;
    background: var(--yellow-soft);
}
.detail-summary-box p { text-align: left; }
.qr-container {
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--bg-card-solid);
    box-shadow: var(--shadow-sm);
}
.related-item { border: 1px solid var(--border-light); border-radius: 10px; background: var(--bg-card-solid); }

/* Reader, media and floating utilities */
.reader-modal { padding: 12px; }
.reader-modal-content { border-radius: 18px; background: #111a29; }
.reader-header {
    min-height: 70px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card-solid);
}
.reader-title-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--red-soft);
    color: var(--red-brand);
}
.reader-book-title { color: var(--navy); }
.eye-care-toolbar { border: 1px solid var(--border-light); border-radius: 10px; background: var(--surface-subtle); }
.eye-care-btn { width: 24px; height: 24px; }
.btn-close-reader {
    min-height: 40px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-subtle);
    color: var(--text-dark);
}
.floating-player {
    left: 50%;
    bottom: 22px;
    width: min(calc(100% - 40px), 820px);
    transform: translateX(-50%);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    background: var(--bg-card-solid);
    box-shadow: var(--shadow-lg);
}
.radio-badge { color: #5f0d12; background: #f5d77e; }
.floating-cart, .floating-dice, .back-to-top {
    z-index: 900;
    border: 1px solid rgba(255,255,255,.17);
    background: var(--navy);
    color: var(--bg-card-solid);
    box-shadow: 0 12px 26px rgba(21,35,61,.2);
}
.floating-dice { background: linear-gradient(135deg, #a51d22, #711015); }
.floating-cart:hover, .floating-dice:hover, .back-to-top:hover { transform: translateY(-3px); }
.reading-progress-banner {
    left: 50%;
    right: auto;
    bottom: 18px;
    width: min(calc(100% - 40px), 760px);
    transform: translateX(-50%);
    border: 1px solid rgba(231,182,71,.35);
    border-radius: 16px;
    background: #17243a;
    color: #fff;
    box-shadow: var(--shadow-lg);
}
.progress-title { color: #fff; }
.progress-label { color: #e8c567; }
.btn-resume-read { background: #f4d274; color: #4a2a00; }

/* Admin */
#adminDashboardModal .modal-content {
    width: min(96vw, 1040px) !important;
    max-width: 1040px !important;
    max-height: 92dvh !important;
}
#adminDashboardModal .controls-bar { flex: 0 0 auto; }
.admin-tab-content {
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-card-solid);
}
.admin-table { min-width: 720px; }
.admin-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--navy-soft);
    color: var(--navy);
    font-size: .7rem;
    letter-spacing: .03em;
}
.admin-table th, .admin-table td { padding: 12px; border-color: var(--border-light); }
.admin-table tbody tr:hover { background: var(--surface-subtle); }

/* Gratitude and footer */
.honor-section {
    margin-bottom: 58px;
    padding: 28px;
    border-radius: var(--radius-md);
    background:
        radial-gradient(circle at top left, rgba(231,182,71,.16), transparent 26rem),
        var(--bg-card);
}
.honor-badge { border: 1px solid rgba(231,182,71,.3); background: var(--bg-card-solid); box-shadow: var(--shadow-sm); }
footer {
    border-top: 4px solid var(--red-brand);
    background:
        radial-gradient(circle at 5% 0, rgba(231,182,71,.11), transparent 28rem),
        #111d31;
}
.footer-content { padding-top: 58px; padding-bottom: 44px; gap: 52px; }
.footer-brand-logo { border-radius: 14px; background: rgba(255,255,255,.96); padding: 5px; }
.footer-brand-title, .footer-column-title { color: #f5d77e; }
.footer-about-text, .footer-list, .footer-brand-subtitle, .social-label { color: rgba(255,255,255,.7); }
.footer-list li .list-icon { background: rgba(255,255,255,.07); color: #f5d77e; }
.footer-social-links .social-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); }
.footer-bottom { border-top-color: rgba(255,255,255,.1); background: rgba(0,0,0,.12); }

/* SweetAlert — all app notifications */
div.swal2-container { padding: 20px; backdrop-filter: blur(6px); }
div.swal2-popup {
    width: min(92vw, 440px);
    padding: 28px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    background: var(--bg-card-solid);
    color: var(--text-dark);
    box-shadow: 0 30px 85px rgba(0,0,0,.28);
}
div.swal2-icon { transform: scale(.88); margin-top: 6px; }
h2.swal2-title {
    padding: 4px 0 0;
    color: var(--navy);
    font-family: "Montserrat", sans-serif;
    font-size: 1.35rem;
}
div.swal2-html-container { margin: 12px 0 0; color: var(--text-muted); font-size: .9rem; line-height: 1.65; }
div.swal2-actions { gap: 9px; margin-top: 22px; }
button.swal2-styled {
    min-height: 42px;
    margin: 0;
    padding: 0 18px;
    border-radius: 10px !important;
    box-shadow: none !important;
    font-size: .82rem;
    font-weight: 800;
}
button.swal2-confirm { background: var(--red-brand) !important; }
button.swal2-cancel { background: var(--surface-subtle) !important; color: var(--text-dark) !important; border: 1px solid var(--border-light) !important; }
div.swal-wide-popup { width: min(94vw, 760px) !important; }

/* Tablet */
@media (max-width: 992px) {
    .container { width: min(100% - 32px, 1240px); }
    .hero { min-height: 430px; padding: 74px 0 130px; }
    .controls-bar { align-items: stretch; flex-direction: column; }
    .filter-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; scrollbar-width: none; }
    .filter-tabs::-webkit-scrollbar { display: none; }
    .tab-btn { flex: 0 0 auto; }
    .sort-wrapper, .sort-select { width: 100%; }
    .detail-left { width: 38%; }
    .detail-right { width: 62%; padding: 30px; }
    .footer-content { grid-template-columns: 1fr 1fr; }
}

/* Phone */
@media (max-width: 768px) {
    .container { width: min(100% - 24px, 1240px); }
    .navbar { padding: 7px 0; }
    .nav-content { min-height: 50px; }
    .logo-area { max-width: calc(100% - 132px); gap: 8px; }
    .logo-area img { width: 38px; height: 38px; }
    .brand-copy strong { font-size: .78rem; letter-spacing: .025em; }
    .brand-copy small { display: none; }
    .theme-toggle { width: 38px; height: 38px; }
    .btn-donate {
        width: 42px;
        min-width: 42px;
        height: 38px;
        min-height: 38px;
        padding: 0;
        justify-content: center;
        border-radius: 10px;
        font-size: 0;
    }
    .btn-donate i { margin: 0; font-size: .95rem; }

    .hero {
        min-height: 390px;
        margin-bottom: -50px;
        padding: 56px 0 96px;
        background-position: center !important;
    }
    .hero-badge {
        max-width: 100%;
        margin-bottom: 18px;
        padding: 7px 11px;
        font-size: .63rem;
        line-height: 1.45;
    }
    .hero h1 {
        padding: 0;
        font-size: clamp(1.7rem, 8.5vw, 2.35rem) !important;
        line-height: 1.08;
    }
    .hero p { padding: 0; font-size: .78rem !important; line-height: 1.6; }
    .search-wrapper {
        width: 100%;
        margin: 24px 0 0;
        padding: 4px;
        border-radius: 13px;
    }
    .search-wrapper input { min-height: 50px; padding: 12px 14px 12px 44px; font-size: .82rem; }
    .search-icon { left: 19px; }

    .stats-container {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
        margin-bottom: 24px;
    }
    .stat-card {
        min-width: 0;
        min-height: 116px;
        padding: 13px 8px;
        flex-direction: column;
        justify-content: center;
        gap: 7px;
        text-align: center;
        border-radius: 13px;
    }
    .stat-card::after { inset: auto 12px 0; }
    .stat-card i { width: 38px; height: 38px; border-radius: 10px; font-size: 1rem; }
    .stat-info h3 { font-size: 1.3rem; }
    .stat-info p { font-size: .55rem; line-height: 1.3; letter-spacing: .025em; }

    .trending-section { padding: 17px 14px; margin-bottom: 20px; }
    .trending-header h2, .podcast-section-header h2 { font-size: 1.02rem; }
    .trending-slider { margin-right: -14px; }
    .quote-slider-section { padding: 16px; }
    .quote-slider-container { flex-direction: column; }
    .quote-slide .quote-text { font-size: .87rem; }
    .btn-share-quote { width: 100%; justify-content: center; }

    .controls-bar { padding: 7px; border-radius: 13px; }
    .controls-bar > .filter-tabs {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 1 1 0;
        justify-content: flex-start;
    }
    .tab-btn { min-height: 40px; padding: 0 12px; font-size: .72rem; }
    .sort-select { min-height: 42px; }
    .tag-cloud, .author-cloud {
        overflow-x: auto;
        justify-content: flex-start;
        flex-wrap: nowrap;
        margin-right: -12px;
        padding-right: 12px;
        scrollbar-width: none;
    }
    .tag-filter-btn, .author-filter-btn { flex: 0 0 auto; }
    .author-filter-btn {
        max-width: min(78vw, 280px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .fav-sub-tabs {
        overflow-x: auto;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
    }
    .fav-sub-tab { flex: 0 0 auto; min-height: 38px; font-size: .7rem; }

    .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
    .book-card { min-width: 0; border-radius: 13px; }
    .book-card:hover { transform: translateY(-3px); }
    .book-card .book-cover { height: clamp(200px, 58vw, 245px); }
    .cover-title { font-size: .78rem; }
    .book-content { padding: 11px 10px 12px; }
    .book-content h3 { min-height: 38px; font-size: .76rem; line-height: 1.35; }
    .book-meta { font-size: .64rem; }
    .book-meta strong { min-width: 40px; }
    .book-meta p { gap: 4px; }
    .tag { font-size: .55rem; }
    .btn-action { min-height: 38px; padding: 7px; font-size: .65rem; }
    .contributor-badge { max-width: calc(100% - 45px); font-size: .52rem; }
    .fav-btn { width: 34px; height: 34px; }
    .podcast-grid { grid-template-columns: 1fr; }

    .modal { align-items: flex-end; padding: 0; }
    .modal-content {
        width: 100% !important;
        max-width: none !important;
        max-height: 92dvh !important;
        padding: 25px 18px max(22px, env(safe-area-inset-bottom)) !important;
        border: 0;
        border-top: 1px solid var(--border-light);
        border-radius: 22px 22px 0 0 !important;
    }
    .modal-content::before {
        content: "";
        display: block;
        width: 42px;
        height: 4px;
        margin: -13px auto 16px;
        border-radius: 4px;
        background: var(--border-light);
    }
    .modal-header { margin-bottom: 15px; }
    .modal-icon { width: 42px; height: 42px; flex-basis: 42px; margin: 0; font-size: 1.05rem; }
    .modal-header h2 { font-size: 1.1rem; }
    .form-group { min-height: 48px; }
    .custom-form input, .custom-form select { height: 48px; font-size: .8rem; }

    .detail-modal-content { padding: 0 !important; }
    .detail-modal-content::before { position: absolute; z-index: 3; top: 13px; left: 50%; margin: 0; transform: translateX(-50%); }
    .detail-layout { display: block; }
    .detail-left { width: 100%; padding: 30px 18px 20px; border: 0; }
    .detail-cover-large { width: 150px; height: 225px; }
    .qr-container { display: none; }
    .detail-right { width: 100%; max-height: none; padding: 22px 18px 28px; }
    .detail-right h2 { padding-right: 25px; font-size: 1.2rem; }
    .detail-summary-box p { font-size: .84rem; }
    .detail-action-buttons { position: sticky; bottom: 0; z-index: 2; margin: 18px -18px -28px; padding: 12px 18px max(12px, env(safe-area-inset-bottom)); background: var(--bg-card-solid); box-shadow: 0 -10px 28px rgba(22,32,51,.09); }

    .reader-modal { align-items: stretch; padding: 0; }
    .reader-modal-content { height: 100dvh; max-height: none !important; border-radius: 0 !important; padding: 0 !important; }
    .reader-modal-content::before { display: none; }
    .reader-header { min-height: auto; padding: 9px 10px; flex-wrap: wrap; gap: 8px; }
    .reader-title-area { width: calc(100% - 47px); }
    .reader-title-icon { display: none; }
    .reader-book-title { max-width: 100%; font-size: .8rem; }
    .reader-subtitle { font-size: .58rem; }
    .btn-close-reader { width: 39px; min-width: 39px; padding: 0; font-size: 0; }
    .btn-close-reader i { font-size: .9rem; }
    .eye-care-toolbar { order: 3; width: 100%; justify-content: center; min-height: 38px; }
    .reader-iframe-wrapper { height: calc(100dvh - 105px); }

    .floating-player {
        bottom: max(8px, env(safe-area-inset-bottom));
        width: calc(100% - 16px);
        padding: 10px;
        border-radius: 14px;
        flex-wrap: wrap;
    }
    .floating-player audio { order: 3; width: 100%; height: 38px; }
    .floating-cart { right: 12px; bottom: 78px; width: 48px; height: 48px; }
    .floating-dice { right: 12px; bottom: 136px; width: 48px; height: 48px; z-index: 900 !important; }
    .reading-progress-banner {
        bottom: max(8px, env(safe-area-inset-bottom));
        width: calc(100% - 16px);
        padding: 10px;
    }
    .progress-icon { display: none; }
    .progress-label { font-size: .5rem; }
    .progress-title { font-size: .72rem; }
    .btn-resume-read { min-width: 78px; padding: 0 9px; font-size: .64rem; }

    #adminDashboardModal .modal-content { height: 94dvh; max-height: 94dvh !important; }
    #adminDashboardModal .modal-header { flex: 0 0 auto; }
    #adminDashboardModal .controls-bar { margin-bottom: 10px !important; padding: 7px !important; }
    #adminDashboardTabs { width: 100%; overflow-x: auto; }
    .admin-tab-content { min-height: 0; overflow: auto !important; }
    .admin-table { font-size: .68rem; }
    .admin-table th, .admin-table td { padding: 9px; }

    .honor-section { padding: 20px 14px; }
    .footer-content { display: grid; grid-template-columns: 1fr; gap: 34px; padding-top: 42px; text-align: left; }
    .footer-brand-header { flex-direction: row; align-items: center; text-align: left; }
    .footer-brand-text { align-items: flex-start; }
    .footer-about-text { text-align: left; }
    .footer-social-wrapper { align-items: flex-start; }
    .footer-contact-column, .footer-bcn-column { text-align: left; }
    .footer-column-title { align-self: flex-start; text-align: left; }
    .footer-column-title::after { left: 0; transform: none; }
    .footer-list { align-items: stretch; }
    .footer-list li { flex-direction: row; justify-content: flex-start; text-align: left; gap: 12px; }
    .footer-list li .list-icon { flex: 0 0 30px; margin: 0; }
    .bcn-info { align-items: flex-start; text-align: left; }
    .footer-bottom-content { text-align: left; }
    .footer-bottom .copyright { font-size: .65rem; line-height: 1.6; }

    div.swal2-container { padding: 12px; }
    div.swal2-popup { width: 100%; padding: 24px 18px; border-radius: 17px; }
}

@media (max-width: 390px) {
    .brand-copy strong { font-size: .69rem; }
    .book-grid { gap: 8px; }
    .book-card .book-cover { height: 205px; }
    .book-content { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
