:root {
    --navy: #16223f;
    --navy-2: #1f3158;
    --gold: #f0a63c;
    --gold-dim: rgba(240, 166, 60, .16);
    --coral: #e8674a;
    --paper: #faf6ec;
    --card: #ffffff;
    --line: #e8e0cf;
    --text-hi: #1c2333;
    --text-mid: #5c6479;
    --text-low: #9298a6;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--text-hi);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--navy-2); text-decoration: none; }
a:hover { color: var(--gold); }

h1, h2, h3, .brand-name { font-family: var(--font-serif); }

/* ---------- Fondo editable ---------- */
.site-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    opacity: .08;
    pointer-events: none;
}

/* ---------- Header ---------- */
.site-header {
    background: var(--navy);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-brand img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    background: #fff;
}

.header-brand-text { min-width: 0; }

.header-brand-text .brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-brand-text .brand-tagline {
    font-size: .78rem;
    color: var(--gold);
    opacity: .9;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .15);
    color: #fff;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
}
.icon-btn:hover { background: var(--gold); border-color: var(--gold); color: var(--navy); }

/* ---------- Dropdown menu ---------- */
.dropdown-wrap { position: relative; }

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 48px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(22, 34, 63, .18);
    min-width: 220px;
    padding: 6px;
    display: none;
    z-index: 50;
}
.dropdown-menu.open { display: block; }

.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: .92rem;
    font-family: var(--font-ui);
    color: var(--text-hi);
    cursor: pointer;
}
.dropdown-menu button:hover { background: var(--gold-dim); }

/* ---------- Contenedor principal ---------- */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 18px 64px;
}

.page-title {
    font-size: 1.7rem;
    margin: 6px 0 4px;
}
.page-sub { color: var(--text-mid); margin: 0 0 20px; }

/* ---------- Filtros / categorías ---------- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.search-input {
    flex: 1 1 220px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: var(--font-ui);
    font-size: .92rem;
    background: var(--card);
}

.sort-select {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    font-family: var(--font-ui);
    font-size: .9rem;
}

.cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
}

.lmdlv-cat-pill {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text-mid);
    font-size: .84rem;
    cursor: pointer;
    white-space: nowrap;
}
.lmdlv-cat-pill.active,
.lmdlv-cat-pill:hover {
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--navy);
}

/* ---------- Grid de libros ---------- */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.book-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    display: flex;
    flex-direction: column;
}
.book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 28px rgba(22, 34, 63, .12);
}

.book-cover {
    aspect-ratio: 2 / 3;
    width: 100%;
    object-fit: contain;
    background: var(--gold-dim);
}
.book-cover-placeholder {
    aspect-ratio: 2 / 3;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy), var(--navy-2));
    color: var(--gold);
    font-family: var(--font-serif);
    font-size: 1.6rem;
    text-align: center;
    padding: 14px;
    line-height: 1.3;
}

.book-info { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.book-cat {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--coral);
    font-weight: 600;
}
.book-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.3;
    color: var(--text-hi);
    margin: 0;
}
.book-author { font-size: .82rem; color: var(--text-mid); }
.book-price-row {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--font-mono);
}
.book-price-usd { font-weight: 700; color: var(--navy); }
.book-price-bs { font-size: .75rem; color: var(--text-low); }

.empty-state {
    text-align: center;
    color: var(--text-mid);
    padding: 60px 20px;
}

/* ---------- Modal genérico ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 34, 63, .55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal-box {
    background: var(--card);
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1rem;
}

/* ---------- Paneles grandes (Recursos/Contactos/Horarios/Conócenos) ---------- */
.panel-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 34, 63, .55);
    display: none;
    z-index: 100;
    justify-content: flex-end;
}
.panel-modal-backdrop.open { display: flex; }

.panel-modal {
    background: var(--paper);
    width: 100%;
    max-width: 480px;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

.panel-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.panel-modal-header h2 { margin: 0; font-size: 1.3rem; }

.panel-item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.panel-item h3 { margin: 0 0 4px; font-size: 1rem; font-family: var(--font-serif); }
.panel-item p { margin: 2px 0; font-size: .88rem; color: var(--text-mid); }
.panel-item .tag { display: inline-block; font-size: .72rem; color: var(--coral); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }

.panel-item-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: .85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--gold-dim);
    color: var(--navy);
}
.panel-item-link.whatsapp { background: #dff5e5; color: #1f7a3d; }

.person-photo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    float: left;
    margin-right: 12px;
    background: var(--gold-dim);
}
.person-photo-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    float: left;
    margin-right: 12px;
    background: var(--navy);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-weight: 700;
}

.panel-loading, .panel-empty {
    text-align: center;
    color: var(--text-mid);
    padding: 30px 10px;
}

/* ---------- Footer ---------- */
.site-footer {
    text-align: center;
    padding: 28px 16px 40px;
    color: var(--text-low);
    font-size: .82rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
    .container { padding: 18px 12px 50px; }
}
