/* ============================================================
   Bottom Bar + FAB
   ============================================================ */

.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    justify-items: center;
    z-index: 500;
    padding-bottom: env(safe-area-inset-bottom);
}
.bar-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-muted);
    transition: color 0.15s, transform 0.15s;
    text-decoration: none;
}
.bar-item:hover { color: var(--primary); }
.bar-item:active { transform: scale(0.92); }
.bar-icon { font-size: 1.5rem; line-height: 1; }

/* FAB — theme selector */
.theme-fab {
    position: fixed;
    right: 16px;
    bottom: 80px;                     /* above the bar */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--header-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 510;
    transition: transform 0.2s, box-shadow 0.2s;
}
.theme-fab:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(0,0,0,0.32); }
.theme-fab:active { transform: scale(0.96); }
.theme-fab-icon { font-size: 1.5rem; line-height: 1; }

/* Theme modal */
.theme-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.theme-modal[hidden] { display: none; }
.theme-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.theme-modal-panel {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 22px;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.theme-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.theme-modal-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-strong);
}
.theme-modal-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 1.1rem;
}
.theme-modal-close:hover { background: var(--danger-soft); color: var(--danger); }

.theme-modal-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    transition: all 0.15s;
    text-align: center;
}
.theme-swatch:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.theme-swatch.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.theme-swatch-colors {
    display: flex;
    gap: 3px;
    margin-bottom: 4px;
}
.theme-swatch-colors span {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
}
.theme-swatch-emoji { font-size: 1.3rem; line-height: 1; }
.theme-swatch-name {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Desktop: panel anchored bottom-right */
@media (min-width: 600px) {
    .theme-modal { align-items: center; padding: 20px; }
    .theme-modal-panel {
        border-radius: var(--radius-lg);
        max-width: 560px;
        max-height: 80vh;
        animation: popIn 0.25s cubic-bezier(0.16,1,0.3,1);
    }
    @keyframes popIn {
        from { opacity: 0; transform: scale(0.95); }
        to   { opacity: 1; transform: scale(1); }
    }
}

/* Desktop: bottom bar centered, narrower */
@media (min-width: 900px) {
    .bottom-bar {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 520px;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.08);
    }
    .theme-fab { right: 24px; bottom: 90px; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .bottom-bar { height: 52px; }
    .bar-icon { font-size: 1.2rem; }
}