/* Extend the provided styles.css with page-specific styles */
@media (max-width: 767px) {
    .btn-nav { display: none; }
}

.btn-nav {
    text-decoration: none;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #aaa;
    box-shadow: none;
    padding: 0.35rem 0.8rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    transition: border-color 0.15s, color 0.15s;
}
.btn-nav:hover { border-color: #00ffcc; color: #00ffcc; transform: none; box-shadow: none; }

.filter-toggle-btn {
    display: none;
    align-items: center;
    gap: 0.4rem;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #aaa;
    padding: 0.35rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.filter-toggle-btn.active { border-color: #00ffcc; color: #00ffcc; }
.filter-badge {
    background: #00ffcc;
    color: #000;
    border-radius: 10px;
    padding: 0 5px;
    font-size: 0.72rem;
    font-weight: 700;
    display: none;
    line-height: 1.5;
}
.filter-badge.visible { display: inline; }

@media (max-width: 767px) {
    .filter-toggle-btn { display: inline-flex; }
}

.filters-wrap {
    display: grid;
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    gap: .75rem;
    padding: 1rem 2rem 0 2rem;
}
.filters-wrap label { font-size: .9rem; color: #aaa; padding-left: 2px; margin-bottom: 4px; display: block; }
.filters-wrap .clear-btn { width: 100%; box-sizing: border-box; }
.filters-wrap > div {
    min-width: 0;
}
.filters-wrap input, .filters-wrap select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #333;
    border-radius: 8px;
    padding: .6rem .8rem;
    outline: none;
}

@media (max-width: 1200px) {
    .filters-wrap { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}

@media (max-width: 767px) {
    .filters {
        overflow: hidden;
        max-height: 0;
        transition: max-height 0.25s ease-out;
    }
    .filters.filters-open {
        max-height: 1200px;
        transition: max-height 0.35s ease-in;
    }
    .filters-wrap {
        padding: 0.75rem 1rem 1rem 1rem;
        grid-template-columns: repeat(2, 1fr);
    }
    .view-toggle {
        padding: 0.75rem 1rem 0.5rem;
        gap: 0.4rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .toggle-btn {
        padding: 0.45rem 0.65rem;
        font-size: 0.82rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    #btn-gallery, #btn-table, #btn-keywords, #btn-macros { display: none; }
    .bulk-bar { padding: 0.5rem 1rem; }
    .results { padding: 0.75rem 1rem 2rem 1rem; }
    .cards-grid {
        gap: 0.75rem;
    }
}

.view-toggle {
    display: flex;
    gap: .5rem;
    align-items: center;
    padding: 1rem 2rem 0.5rem;
}
.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .9rem;
    border-radius: 8px;
    background: #1a1a1a;
    border: 1px solid #333;
    color: #fff;
    cursor: pointer;
    user-select: none;
}
.toggle-btn.active { border-color: #00ffcc; box-shadow: 0 0 0 2px rgba(0,255,204,.1); }

/* Bulk download bar */
.bulk-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 0.6rem 2rem;
    background: rgba(0,255,204,0.06);
    border-bottom: 1px solid rgba(0,255,204,0.2);
    flex-wrap: wrap;
}
.bulk-bar span { color: #aaa; font-size: 0.9rem; }
.bulk-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(90deg, #00ffcc, #00ccff);
    color: #000;
    box-shadow: 0 0 10px #00ffcc;
    border: none;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bulk-dl-btn:hover { transform: scale(1.04); box-shadow: 0 0 18px #00ffcc; }

.select-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(90deg, #00ccff, #ffcc00);
    color: #000;
    box-shadow: 0 0 10px #00ccff;
    border: none;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.select-all-btn:hover { transform: scale(1.04); box-shadow: 0 0 18px #00ccff; }

@media (min-width: 768px) {
    .results { padding: 1rem 2rem 3rem 2rem; }
}

/* Gallery grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

/* Gallery card */
.card {
    position: relative;
    background: #181818;
    border: 1px solid #222;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card.selected {
    border-color: #00ffcc;
    box-shadow:
        0 0 0 4px #00ffcc,
        0 0 24px 6px rgba(0,255,204,0.65),
        0 0 60px 12px rgba(0,255,204,0.3);
}
.card.selected:hover {
    box-shadow:
        0 0 0 4px #00ffcc,
        0 0 32px 10px rgba(0,255,204,0.75),
        0 0 70px 16px rgba(0,255,204,0.4);
}
.card.pinned {
    outline: 2px dashed rgba(0,255,204,0.4);
    outline-offset: 3px;
}
.card img {
    width: 100%;
    height: 24.2rem;
    object-fit: cover;
    background: #0d0d0d;
}
.card .meta {
    padding: .75rem .9rem;
    display: grid;
    gap: .25rem;
    font-size: .95rem;
}

@media (max-width: 767px) {
    .card img { object-fit: contain; height: 128vw; flex-shrink: 0; }
    .card .meta { display: none; }
}

.kv { color: #aaa; font-size: .85rem; }

/* Checkbox + download row */
.dl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.35rem;
}
.card-check {
    cursor: pointer;
    line-height: 0;
}
.card-check input[type="checkbox"] {
    width: 1.4rem;
    height: 1.4rem;
    cursor: pointer;
    accent-color: #00ffcc;
}
.dl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    background: linear-gradient(90deg, #00ffcc, #00ccff);
    color: #000;
    box-shadow: 0 0 8px rgba(0,255,204,0.5);
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dl-btn:hover { transform: scale(1.12); box-shadow: 0 0 16px rgba(0,255,204,0.75); }

/* Cards-only grid */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(372px, 1fr));
        gap: 1.25rem;
    }
}
.card-img-item {
    position: relative;
    cursor: pointer;
    /* crop the 20px print bleed: visible area is 1086×1512 */
    aspect-ratio: 1086 / 1512;
    border-radius: min(45px, 12%) / min(45px, 8.62%);
    overflow: hidden;
    background: #111;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-img-item:hover { transform: scale(1.02); box-shadow: 0 0 14px rgba(0,255,204,0.3); }
/* selected: neon glow ring */
.card-img-item.selected {
    box-shadow:
        0 0 0 4px #00ffcc,
        0 0 24px 6px rgba(0,255,204,0.65),
        0 0 60px 12px rgba(0,255,204,0.3);
    transform: scale(1.01);
}
.card-img-item.selected:hover {
    box-shadow:
        0 0 0 4px #00ffcc,
        0 0 32px 10px rgba(0,255,204,0.75),
        0 0 70px 16px rgba(0,255,204,0.4);
}
.cards-grid img {
    /* offset by 20px bleed on all sides */
    position: absolute;
    top: -1.323%;   /* 20/1512 * 100 */
    left: -1.842%;  /* 20/1086 * 100 */
    width: 103.684%; /* 1126/1086 * 100 */
    height: 102.646%; /* 1552/1512 * 100 */
    display: block;
    user-select: none;
    border-radius: min(45px, 12%) / min(45px, 8.62%);
}

/* Data form table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid #222; }
th { color: #00ffcc; position: sticky; top: 0; background: #0f0f0f; }
.table-wrap { overflow: auto; border: 1px solid #222; border-radius: 12px; }
.description { white-space: normal; width: 25%; }

/* Toast */
.toast {
    position: fixed;
    right: 1rem; bottom: 1rem;
    background: #ff0066;
    color: #fff;
    padding: .9rem 1rem;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(255,0,102,.5);
    z-index: 50;
    display: none;
}
.empty { text-align: center; color: #aaa; padding: 2rem; }

/* Export buttons */
.export-btn {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    margin: 15px 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s ease;
}
.export-btn:hover { background-color: #45a049; }
#keywords-export-btn { white-space: nowrap; }

.clear-btn {
    background: #1e1214;
    color: #cc7788;
    border: 1px solid #4a2233;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.clear-btn:hover:not(:disabled) { background: #271520; border-color: #aa4466; color: #ee8899; }
.clear-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Rules view ──────────────────────────────────────────────────────── */
.rules-wrap {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.rules-toc {
    flex: 0 0 250px;
    position: sticky;
    top: 4rem;
    background-color: #1a1a1a;
    background-image:
        radial-gradient(500px circle at 140% -20%, rgba(56,139,253,0.12), transparent 60%),
        radial-gradient(350px circle at -40% 120%, rgba(0,255,204,0.08), transparent 55%),
        radial-gradient(rgba(255,255,255,0.055) 1px, transparent 1px);
    background-size: auto, auto, 20px 20px;
    background-repeat: no-repeat, no-repeat, repeat;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    box-sizing: border-box;
}
.rules-toc-heading {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #888;
    margin-bottom: .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid #333;
}
.rules-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.rules-toc-link {
    display: block;
    background: none;
    box-shadow: none;
    color: #ccc;
    text-decoration: none;
    font-size: .875rem;
    padding: .3rem .5rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.rules-toc-link:hover {
    color: #00ffcc;
    background: rgba(0,255,204,0.07);
    transform: none;
    box-shadow: none;
}
.rules-toc-sub {
    list-style: none;
    padding: .2rem 0 .2rem .8rem;
    margin: .1rem 0 0 .4rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
    border-left: 2px solid #2a2a2a;
}
.rules-toc-sub-link {
    display: block;
    background: none;
    box-shadow: none;
    color: #777;
    text-decoration: none;
    font-size: .8rem;
    padding: .2rem .4rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.rules-toc-sub-link:hover {
    color: #00ffcc;
    background: rgba(0,255,204,0.07);
    transform: none;
    box-shadow: none;
}

.rules-main { flex: 1 1 auto; min-width: 0; }

.rules-section {
    padding-bottom: 2.5rem;
    border-bottom: 1px solid #222;
    margin-bottom: 2.5rem;
    scroll-margin-top: 5rem;
}
.rules-section:last-child { border-bottom: none; margin-bottom: 0; }

.rules-section-title {
    font-size: 1.5rem;
    color: #00ffcc;
    margin: 0 0 1rem;
}
.rules-num { opacity: .55; margin-right: .25rem; }

.rules-body, .rules-subcontent {
    color: #ccc;
    line-height: 1.75;
}
.rules-body p, .rules-subcontent p { margin: 0 0 1em; }
.rules-body ul, .rules-body ol,
.rules-subcontent ul, .rules-subcontent ol { margin: 0 0 1em 1.5rem; }
.rules-body li, .rules-subcontent li { margin-bottom: .35em; }

.rules-subsection {
    margin-top: 1.5rem;
    scroll-margin-top: 5rem;
}
.rules-subtitle {
    font-size: 1.1rem;
    color: #00ccff;
    margin: 0 0 .6rem;
}

.rules-back-to-top {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: .8rem;
    background: none;
    box-shadow: none;
    color: #555;
    text-decoration: none;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: .3rem .7rem;
    transition: color 0.15s, border-color 0.15s;
}
.rules-back-to-top:hover {
    color: #00ffcc;
    border-color: #00ffcc;
    transform: none;
    box-shadow: none;
}

@media (max-width: 767px) {
    .rules-wrap { flex-direction: column; }
    .rules-toc { position: static; width: 100%; max-height: none; flex: none; }
    .rules-section { scroll-margin-top: 1rem; }
    .rules-subsection { scroll-margin-top: 1rem; }
}

/* Glossary */
.rules-glossary {
    display: grid;
    grid-template-columns: minmax(140px, 200px) 1fr;
    gap: .6rem 2rem;
    margin: 0;
    align-items: baseline;
}
.rules-glossary dt {
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: .01em;
    padding: .5rem .75rem;
    background: rgba(0,255,204,0.06);
    border-left: 3px solid #00ffcc;
    border-radius: 0 6px 6px 0;
    align-self: start;
}
.rules-glossary dd {
    margin: 0;
    color: #ccc;
    line-height: 1.75;
    padding: .5rem 0;
    border-bottom: 1px solid #1a1a1a;
    align-self: start;
}

@media (max-width: 600px) {
    .rules-glossary {
        grid-template-columns: 1fr;
        gap: .15rem;
    }
    .rules-glossary dd { border-bottom: none; padding-bottom: 1rem; }
}

/* Rules PDF export button */
.rules-toc-export-wrap {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #2a2a2a;
}
.rules-export-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    background: linear-gradient(135deg, #0b2519 0%, #0f3224 100%);
    border: 1px solid rgba(0, 255, 204, 0.2);
    color: #00ffcc;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
    font-family: inherit;
}
.rules-export-btn:hover {
    background: linear-gradient(135deg, #0f3224 0%, #164030 100%);
    border-color: rgba(0, 255, 204, 0.45);
    box-shadow: 0 0 12px rgba(0, 255, 204, 0.12);
}

/* Collapsible sections */
.rules-section-title {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rules-section-title:hover { color: #00ffcc; }
.rules-collapse-arrow {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    opacity: 0.45;
    transition: transform 0.2s ease, opacity 0.15s;
    flex-shrink: 0;
}
.rules-section.collapsed .rules-collapse-arrow { transform: rotate(-180deg); }
.rules-section-title:hover .rules-collapse-arrow { opacity: 0.75; }
.rules-section-body {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    max-height: 9999px;
    opacity: 1;
}
.rules-section.collapsed .rules-section-body {
    max-height: 0;
    opacity: 0;
}

/* Collapsible subsections */
.rules-subtitle {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
}
.rules-subtitle:hover { color: #00ccff; }
.rules-sub-arrow {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    opacity: 0.35;
    transition: transform 0.18s ease, opacity 0.15s;
    flex-shrink: 0;
}
.rules-subsection.collapsed .rules-sub-arrow { transform: rotate(-180deg); }
.rules-subtitle:hover .rules-sub-arrow { opacity: 0.65; }
.rules-subcontent {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    max-height: 9999px;
    opacity: 1;
}
.rules-subsection.collapsed .rules-subcontent {
    max-height: 0;
    opacity: 0;
}
