/* Only Ash'aar is recolored; all other feature cards use the original stylesheet colors. */
body:not([data-palette]) .library-nav > .sher-lib {
    background: linear-gradient(135deg, #285650 0%, #46746b 100%);
}

/* Gulabi Mehfil uses distinct, single-colour library cards. */
[data-palette="romantic"] .ghazal-lib { background: #d87893; }
[data-palette="romantic"] .sher-lib { background: #b88cae; }
[data-palette="romantic"] .nazm-lib { background: #a8d7c2; }
[data-palette="romantic"] .shuffle-lib { background: #d9947d; }
[data-palette="romantic"] .diary-lib { background: #bd8b50; }
[data-palette="romantic"] .submit-lib {
    background: #a65378;
    border: 1px solid rgba(255, 255, 255, .32);
    color: #fff !important;
    backdrop-filter: none;
}
[data-palette="romantic"] .quiz-lib { background: #83915b; }
[data-palette="romantic"] .submit-lib .lib-title,
[data-palette="romantic"] .submit-lib .lib-sub { color: #fff !important; }

/* Soften the rose theme's paper surface while preserving its romantic accents. */
[data-palette="romantic"] {
    --paper: #f2e9e5;
    --card-bg: #fcf8f6;
    --shadow: rgba(116, 57, 78, .12);
}

/* Sufi Sabz: neutral paper with Khazra emerald feature colours. */
[data-palette="sufi"] {
    --paper: #eef0e7;
    --ink: #26362d;
    --maroon: #35634b;
    --gold: #c3a36a;
    --card-bg: #fffdf7;
    --shadow: rgba(36, 71, 51, .14);
}
[data-palette="sufi"][data-theme="dark"] {
    --paper: #111a15;
    --ink: #e8eee8;
    --maroon: #8db69a;
    --gold: #d2b779;
    --card-bg: #1b2720;
    --shadow: rgba(0, 0, 0, .42);
}
[data-palette="sufi"] .ghazal-lib { background: #185c46; }
[data-palette="sufi"] .sher-lib { background: #2b7180; }
[data-palette="sufi"] .nazm-lib { background: #625474; }
[data-palette="sufi"] .diary-lib { background: #80663d; }
[data-palette="sufi"] .shuffle-lib { background: #985b45; }
[data-palette="sufi"] .submit-lib { background: #087b5d; }
[data-palette="sufi"] .quiz-lib { background: #5d7043; }

/* Compact chooser attached to the palette button. */
.palette-control {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
}
.palette-control > #palette-toggle {
    width: 100%;
    height: 100%;
    padding: 0;
}
.palette-dropdown {
    box-sizing: border-box;
    position: absolute;
    z-index: 100001;
    top: calc(100% + 12px);
    right: -42px;
    display: none;
    width: min(230px, calc(100vw - 24px));
    overflow-y: auto;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--gold) 38%, transparent);
    border-radius: 18px;
    background: color-mix(in srgb, var(--card-bg) 98%, transparent);
    color: var(--ink);
    box-shadow: 0 18px 44px rgba(24, 20, 17, .18), 0 3px 10px rgba(24, 20, 17, .06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: palettePanelEnter .2s cubic-bezier(.2,.8,.2,1);
}
.palette-dropdown::before {
    content: "";
    position: absolute;
    top: 0;
    right: 18px;
    left: 18px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: .72;
    pointer-events: none;
}
.palette-dropdown.is-open { display: block; }
.palette-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    margin: 2px 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    text-align: left;
    font: 500 .9rem/1.25 'Playfair Display', Georgia, serif;
    letter-spacing: .01em;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease, padding .2s ease;
}
.palette-option:hover { background: color-mix(in srgb, var(--gold) 8%, var(--card-bg)); }
.palette-option:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.palette-option.is-selected {
    border-color: color-mix(in srgb, var(--gold) 34%, transparent);
    border-left-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 7%, var(--card-bg));
    color: var(--maroon);
    font-weight: 600;
}
@keyframes palettePanelEnter {
    from { opacity: 0; transform: translateY(-5px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 768px) {
    .palette-control { flex: 0 0 34px; width: 34px; height: 34px; }
    .palette-dropdown {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 48px);
        right: 12px;
        left: auto;
        width: min(208px, calc(100vw - 24px));
    }
}
@media (max-width: 360px) {
    .palette-dropdown { right: 10px; width: min(208px, calc(100vw - 20px)); }
}

/* Diwali top-bar controls: dark glass surfaces with warm readable icons. */
body[data-palette="diwali"] .top-bar .icon-btn {
    background: linear-gradient(145deg, rgba(65, 46, 57, 0.97), rgba(39, 29, 43, 0.98));
    border-color: rgba(230, 189, 117, 0.42);
    color: #fff5e6;
    box-shadow: 0 4px 14px rgba(7, 5, 10, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body[data-palette="diwali"] .top-bar .icon-btn:hover {
    background: linear-gradient(145deg, #493443, #302437);
    border-color: #e6bd75;
    color: #f0c879;
}

body[data-palette="diwali"] .top-bar .icon-btn.is-playing {
    border-color: #f0c879;
    color: #f0c879;
}

body[data-palette="diwali"] .top-bar .icon-btn:focus-visible {
    outline: 2px solid #f0c879;
    outline-offset: 3px;
}

/* Keep both site wordmarks vivid in Diwali mode. */
body[data-palette="diwali"] .diwan-title {
    background: linear-gradient(90deg, #ff6a1a 0%, #ffad54 50%, #ff6a1a 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body[data-palette="diwali"] .topbar-brand {
    color: #ff7a24;
}

body[data-palette="diwali"] .topbar-brand:hover {
    color: #ffad54;
}
