/* ========================================================================
   Variables
   ======================================================================== */
:root {
    --md-primary: #D8BBFF;
    --md-on-primary: #45197A;
    --md-primary-container: #5A2E93;
    --md-on-primary-container: #EEDBFF;

    --md-secondary: #D0C1E8;
    --md-tertiary: #F3B8C5;

    --md-error: #FFB4AA;
    --md-on-error-container: #FFDAD4;

    --md-surface: #0D0B11;
    --md-surface-container-lowest: #08070B;
    --md-surface-container-low: #1B1620;
    --md-surface-container: #1F1A25;
    --md-surface-container-high: #2A2430;
    --md-surface-container-highest: #352E3B;
    --md-surface-bright: #38323F;
    --md-on-surface: #EAE0EF;
    --md-on-surface-variant: #C9BFD4;
    --md-outline: #948F9C;
    --md-outline-variant: #4A4451;

    --shape-xs: 10px;
    --shape-sm: 14px;
    --shape-md: 18px;
    --shape-lg: 24px;
    --shape-xl: 32px;
    --shape-full: 999px;

    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-soft: cubic-bezier(0.2, 0.9, 0.3, 1.2);
    --standard: cubic-bezier(0.2, 0, 0, 1);

    --warning-bg: rgba(255, 193, 7, 0.08);
    --warning-border: rgba(255, 193, 7, 0.22);
    --warning-text: #FFD54F;

    /* Espaciado fluido: crece con el viewport sin necesitar media queries para todo */
    --space-page: clamp(14px, 4vw, 28px);
    --space-card: clamp(16px, 3.5vw, 28px);
}

/* ========================================================================
   Reset & Base
   ======================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    background: var(--md-surface);
    color: var(--md-on-surface);
    font-family: 'Roboto Flex', system-ui, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    line-height: 1.4;
}

::selection { background: var(--md-primary); color: var(--md-on-primary); }

button, input, select { font: inherit; color: inherit; }

/* ========================================================================
   Ambient background
   ======================================================================== */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.28;
    animation: drift 24s ease-in-out infinite;
}
.blob.b1 { width: min(500px, 90vw); height: min(500px, 90vw); background: var(--md-primary-container); top: -200px; left: -150px; }
.blob.b2 { width: min(400px, 80vw); height: min(400px, 80vw); background: var(--md-tertiary); bottom: -160px; right: -120px; animation-delay: -8s; }
.blob.b3 { width: min(320px, 70vw); height: min(320px, 70vw); background: #2F5D8A; top: 45%; right: 10%; animation-delay: -14s; opacity: 0.14; }

@keyframes drift {
    0%, 100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(40px, -30px) scale(1.08); }
    66% { transform: translate(-30px, 20px) scale(0.95); }
}

/* ========================================================================
   Layout
   ======================================================================== */
.app {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--space-page);
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 20px;
}

section, header { min-width: 0; }

/* ========================================================================
   Developer Warning — banner en flujo normal (evita superposición con topbar)
   ======================================================================== */
.dev-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--shape-md);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--warning-text);
    font-size: 12.5px;
    animation: fadeSlide .4s var(--spring);
}
.dev-warning svg { flex-shrink: 0; }
.dev-warning strong { color: #FFE082; font-weight: 700; }
.dev-warning span { flex: 1; min-width: 0; }

.warning-close {
    background: rgba(255,255,255,0.08);
    border: none;
    color: inherit;
    width: 26px; height: 26px;
    border-radius: var(--shape-full);
    cursor: pointer;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .2s var(--standard), transform .3s var(--spring);
}
.warning-close:hover { background: rgba(255,255,255,0.18); transform: rotate(90deg); }

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================================================
   Top bar
   ======================================================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand-mark {
    width: 46px; height: 46px;
    border-radius: var(--shape-md);
    background: linear-gradient(135deg, var(--md-primary-container), var(--md-tertiary));
    display: flex; align-items: center; justify-content: center;
    font-family: 'Google Sans Text', sans-serif;
    font-weight: 700;
    color: var(--md-on-primary-container);
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 18px rgba(90, 46, 147, 0.35);
}

.brand-text { min-width: 0; }
.brand-text h1 {
    font-family: 'Google Sans Text', sans-serif;
    font-size: clamp(18px, 3.2vw, 22px);
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.2px;
}
.brand-text p {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--md-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.repo-badge {
    display: flex; align-items: center; gap: 7px;
    background: var(--md-surface-container-high);
    color: var(--md-on-surface-variant);
    padding: 9px 14px 9px 11px;
    border-radius: var(--shape-full);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Google Sans Text', sans-serif;
    border: 1px solid var(--md-outline-variant);
    transition: background .2s var(--standard), color .2s var(--standard), border-color .2s var(--standard);
    white-space: nowrap;
}
.repo-badge:hover { background: var(--md-surface-container-highest); color: var(--md-on-surface); border-color: var(--md-primary); }
.repo-badge svg { width: 15px; height: 15px; flex-shrink: 0; }

.icon-btn {
    width: 42px; height: 42px;
    border-radius: var(--shape-full);
    border: none;
    background: var(--md-surface-container-high);
    color: var(--md-on-surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .25s var(--spring), background .2s var(--standard);
}
.icon-btn:hover { background: var(--md-surface-container-highest); transform: rotate(-10deg); }
.icon-btn:active { transform: scale(0.92) rotate(-10deg); }
.icon-btn svg { width: 20px; height: 20px; }

.contact-line {
    font-size: 12px;
    color: var(--md-on-surface-variant);
    margin: -8px 0 0;
}
.contact-line a { color: var(--md-primary); text-decoration: none; }
.contact-line a:hover { text-decoration: underline; }

/* ========================================================================
   Settings panel
   ======================================================================== */
.settings {
    background: var(--md-surface-container-low);
    border-radius: var(--shape-lg);
    overflow: hidden;
    border: 1px solid var(--md-outline-variant);
}

.settings-head {
    width: 100%;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    transition: background .2s var(--standard);
}
.settings-head:hover { background: var(--md-surface-container-high); }

.settings-head-left { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; font-family: 'Google Sans Text', sans-serif; min-width: 0; }
.settings-head-left svg { color: var(--md-primary); opacity: 0.85; flex-shrink: 0; }
.settings-head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.settings-status {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--shape-full);
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface-variant);
    white-space: nowrap;
}
.settings-status.ok { background: rgba(184, 251, 175, 0.14); color: #B8FBAF; }

.chevron { transition: transform .3s var(--spring); color: var(--md-on-surface-variant); flex-shrink: 0; }
.settings.open .chevron { transform: rotate(180deg); }

.settings-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .4s var(--standard);
    padding: 0 18px;
}
.settings.open .settings-body {
    max-height: 480px;
    padding: 4px 18px 18px;
}

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.diagnostic {
    margin-top: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--md-surface-container-high);
    border-radius: var(--shape-sm);
    padding: 10px 12px;
    display: none;
}
.diagnostic:not(:empty) { display: block; }

@media (max-width: 620px) {
    .settings-grid { grid-template-columns: 1fr; }
}

/* ========================================================================
   Form fields
   ======================================================================== */
.field { position: relative; }

.field input {
    width: 100%;
    background: var(--md-surface-container-high);
    border: 1.5px solid transparent;
    border-radius: var(--shape-sm);
    padding: 19px 14px 8px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s var(--standard), background .2s var(--standard);
}
.field input:focus { border-color: var(--md-primary); background: var(--md-surface-container-highest); }
.field input:disabled { opacity: 0.5; }

.field label {
    position: absolute;
    left: 14px; top: 14px;
    font-size: 15px;
    color: var(--md-on-surface-variant);
    pointer-events: none;
    transition: transform .18s var(--standard), font-size .18s var(--standard), top .18s var(--standard), color .18s var(--standard);
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
    top: 6px; font-size: 10.5px; color: var(--md-primary);
}

.field .hint { font-size: 11px; color: var(--md-on-surface-variant); margin: 5px 2px 0; opacity: 0.75; }
.field.mono input { font-family: 'Roboto Mono', monospace; font-size: 12.5px; }

/* ========================================================================
   Cards
   ======================================================================== */
.surface-card {
    background: var(--md-surface-container-low);
    border-radius: var(--shape-xl);
    border: 1px solid var(--md-outline-variant);
    padding: var(--space-card);
}

.section-title {
    font-family: 'Google Sans Text', sans-serif;
    font-size: clamp(17px, 2.6vw, 20px);
    font-weight: 700;
    margin: 0 0 4px;
}
.section-sub { margin: 0 0 18px; color: var(--md-on-surface-variant); font-size: 13px; line-height: 1.5; }

/* ========================================================================
   Dropzone
   ======================================================================== */
.dropzone {
    border: 2px dashed var(--md-outline-variant);
    border-radius: var(--shape-lg);
    padding: clamp(24px, 6vw, 32px) 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .25s var(--standard), background .25s var(--standard), transform .2s var(--spring-soft);
    background: var(--md-surface-container-lowest);
    position: relative;
}
.dropzone.drag { border-color: var(--md-primary); background: rgba(216,187,255,0.05); transform: scale(1.008); }
.dropzone.has-file { border-style: solid; border-color: var(--md-primary); padding: 0; overflow: hidden; }

.dz-icon {
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    border-radius: var(--shape-md);
    background: var(--md-surface-container-high);
    display: flex; align-items: center; justify-content: center;
    color: var(--md-primary);
    transition: transform .3s var(--spring);
}
.dropzone:hover .dz-icon { transform: translateY(-3px) scale(1.05); }

.dz-title { font-weight: 600; margin-bottom: 4px; font-size: 14.5px; }
.dz-sub { font-size: 12.5px; color: var(--md-on-surface-variant); opacity: 0.75; }

.preview-wrap {
    position: relative;
    width: 100%;
    max-width: 260px;
    aspect-ratio: 9 / 14;
    margin: 0 auto;
    background: #000;
}
.preview-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }

.preview-remove {
    position: absolute; top: 10px; right: 10px;
    width: 32px; height: 32px;
    border-radius: var(--shape-full);
    background: rgba(20,16,24,0.75);
    backdrop-filter: blur(6px);
    border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform .2s var(--spring), background .2s var(--standard);
}
.preview-remove:hover { background: rgba(255,70,70,0.6); transform: scale(1.08); }

.preview-meta {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 10px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    font-size: 11.5px;
    color: #fff;
    font-weight: 500;
}

/* ========================================================================
   Modo álbum
   ======================================================================== */
.mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--md-surface-container-high);
    border-radius: var(--shape-md);
    padding: 13px 16px;
    margin-top: 16px;
}
.mode-toggle-text { min-width: 0; }
.mode-toggle-text strong { display: block; font-size: 13px; font-family: 'Google Sans Text', sans-serif; margin-bottom: 2px; }
.mode-toggle-text span { font-size: 11px; color: var(--md-on-surface-variant); line-height: 1.4; display: block; }

.switch {
    width: 46px; height: 26px;
    border-radius: var(--shape-full);
    background: var(--md-surface-container-highest);
    border: none;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .25s var(--standard);
}
.switch .switch-thumb {
    position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--md-on-surface-variant);
    transition: transform .25s var(--spring), background .25s var(--standard);
}
.switch[aria-checked="true"] { background: var(--md-primary-container); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(20px); background: var(--md-primary); }

.field-disabled { opacity: 0.4; pointer-events: none; }

/* ========================================================================
   Form grid
   ======================================================================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ========================================================================
   Buttons
   ======================================================================== */
.btn {
    border: none;
    border-radius: var(--shape-full);
    padding: 13px 24px;
    font-family: 'Google Sans Text', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    transition: transform .2s var(--spring), box-shadow .2s var(--standard), filter .2s var(--standard), background .2s var(--standard);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-filled {
    background: var(--md-primary);
    color: var(--md-on-primary);
    box-shadow: 0 4px 16px rgba(216, 187, 255, 0.2);
}
.btn-filled:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn-filled:not(:disabled):active { transform: scale(0.97); }
.btn-tonal { background: var(--md-surface-container-highest); color: var(--md-on-surface); }
.btn-tonal:hover { background: var(--md-surface-bright); }
.btn-block { width: 100%; margin-top: 20px; }

.btn-export { font-size: 12.5px; padding: 9px 16px; flex-shrink: 0; }

/* ========================================================================
   Progress
   ======================================================================== */
.progress-wrap { margin-top: 16px; display: none; }
.progress-wrap.show { display: block; }
.progress-track { height: 8px; border-radius: var(--shape-full); background: var(--md-surface-container-highest); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--md-primary-container), var(--md-primary)); border-radius: var(--shape-full); transition: width .2s var(--standard); }
.progress-label { font-size: 11.5px; color: var(--md-on-surface-variant); margin-top: 6px; }

/* ========================================================================
   Snackbar
   ======================================================================== */
.snackbar {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 130%);
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface);
    padding: 13px 20px;
    border-radius: var(--shape-md);
    font-size: 13.5px;
    box-shadow: 0 8px 34px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 60;
    transition: transform .4s var(--spring);
    max-width: min(92vw, 480px);
    border: 1px solid var(--md-outline-variant);
}
.snackbar.show { transform: translate(-50%, 0); }
.snackbar.error { background: var(--md-on-error-container); color: #410E0B; border-color: var(--md-error); }
.snackbar .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--md-primary); flex-shrink: 0; }
.snackbar.error .dot { background: var(--md-error); }

/* ========================================================================
   Gallery section
   ======================================================================== */
.gallery-section { display: flex; flex-direction: column; gap: 12px; }

.gallery-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.stats-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-pill {
    background: var(--md-surface-container-low);
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--shape-md);
    padding: 9px 14px;
    font-size: 11.5px;
    color: var(--md-on-surface-variant);
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.stat-pill strong { color: var(--md-on-surface); font-family: 'Google Sans Text', sans-serif; font-size: 13px; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-field {
    position: relative;
    flex: 1 1 220px;
    min-width: 0;
    max-width: 380px;
}
.search-field input {
    width: 100%;
    background: var(--md-surface-container-high);
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--shape-full);
    padding: 11px 40px 11px 42px;
    color: var(--md-on-surface);
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s var(--standard), background .2s var(--standard);
}
.search-field input:focus { border-color: var(--md-primary); background: var(--md-surface-container-highest); }
.search-field svg {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--md-on-surface-variant); width: 16px; height: 16px; opacity: 0.6;
    pointer-events: none;
}
.search-field .clear-btn {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px;
    border-radius: 50%; border: none;
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface-variant);
    display: none; align-items: center; justify-content: center;
    cursor: pointer; font-size: 10px;
}
.search-field.has-text .clear-btn { display: flex; }

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--md-outline-variant);
    background: transparent;
    color: var(--md-on-surface-variant);
    padding: 7px 14px;
    border-radius: var(--shape-full);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s var(--standard), color .2s var(--standard), border-color .2s var(--standard);
    font-family: 'Google Sans Text', sans-serif;
    white-space: nowrap;
}
.chip:hover { background: var(--md-surface-container-high); }
.chip.active { background: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); }

.sort-select {
    background: var(--md-surface-container-high);
    color: var(--md-on-surface);
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--shape-full);
    padding: 7px 32px 7px 14px;
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C9BFD4' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
}

.chip-count { font-size: 12px; color: var(--md-on-surface-variant); margin: 0; }

/* ========================================================================
   Gallery grid
   ======================================================================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
@media (min-width: 560px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
}

.card {
    background: var(--md-surface-container-low);
    border-radius: var(--shape-lg);
    overflow: hidden;
    border: 1px solid var(--md-outline-variant);
    transition: transform .3s var(--spring), border-color .2s var(--standard), box-shadow .3s var(--standard);
    cursor: pointer;
}
.card:hover { transform: translateY(-5px); border-color: var(--md-primary); box-shadow: 0 14px 32px rgba(0,0,0,0.35); }
.card:active { transform: translateY(-2px) scale(0.99); }

.card-media { position: relative; width: 100%; aspect-ratio: 9 / 16; background: var(--md-surface-container-highest); overflow: hidden; }
.card-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media .play-hint {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.18);
    opacity: 0;
    transition: opacity .2s var(--standard);
}
.card:hover .play-hint { opacity: 1; }
.card-media .play-hint svg { width: 34px; height: 34px; opacity: 0.9; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4)); }

.badge-album {
    position: absolute; top: 9px; left: 9px;
    background: rgba(20,16,24,0.7);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 9.5px;
    padding: 4px 9px;
    border-radius: var(--shape-full);
    font-weight: 600;
    letter-spacing: .2px;
}

.card-body { padding: 11px 12px 13px; }
.card-artist {
    font-family: 'Google Sans Text', sans-serif;
    font-weight: 700;
    font-size: 12.5px;
    margin: 0 0 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sub {
    font-size: 11px;
    color: var(--md-on-surface-variant);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin: 0;
    opacity: 0.8;
}

.empty-state { text-align: center; padding: 50px 16px; color: var(--md-on-surface-variant); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: 14px; opacity: 0.4; }
.empty-state h4 { font-family: 'Google Sans Text', sans-serif; color: var(--md-on-surface); margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0; font-size: 13px; opacity: 0.75; }

.skeleton {
    aspect-ratio: 9/16;
    border-radius: var(--shape-lg);
    background: linear-gradient(100deg, var(--md-surface-container-low) 30%, var(--md-surface-container-high) 50%, var(--md-surface-container-low) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ========================================================================
   Modal
   ======================================================================== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(5,3,8,0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 70;
    padding: 16px;
}
.modal-backdrop.show { display: flex; }

.modal {
    background: var(--md-surface-container);
    border-radius: var(--shape-xl);
    max-width: 400px;
    width: 100%;
    overflow-y: auto;
    transform: scale(0.94);
    opacity: 0;
    transition: transform .3s var(--spring), opacity .2s var(--standard);
    max-height: min(600px, 92dvh);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--md-outline-variant);
}
.modal-backdrop.show .modal { transform: scale(1); opacity: 1; }

.modal-media-wrap { position: relative; flex-shrink: 0; }
.modal-media { width: 100%; aspect-ratio: 9/13; max-height: 55dvh; background: #000; }
.modal-media video { width: 100%; height: 100%; object-fit: contain; }

.modal-body { padding: 18px 20px 20px; overflow-y: auto; }
.modal-body h3 { font-family: 'Google Sans Text', sans-serif; font-size: 17px; margin: 0; }
.modal-body p { margin: 0; color: var(--md-on-surface-variant); font-size: 13px; }

.modal-scope-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: var(--shape-full);
    margin-bottom: 9px;
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface-variant);
}
.modal-scope-badge.album { background: rgba(216, 187, 255, 0.15); color: var(--md-primary); }
.modal-album-info { margin-top: 6px !important; font-size: 11.5px !important; opacity: .7; }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

.modal-close-x {
    position: absolute; top: 12px; right: 12px;
    width: 34px; height: 34px;
    border-radius: var(--shape-full);
    background: rgba(0,0,0,0.55);
    border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: background .2s var(--standard), transform .2s var(--spring);
}
.modal-close-x:hover { background: rgba(255,70,70,0.5); transform: rotate(90deg); }

/* ========================================================================
   FAB
   ======================================================================== */
.fab {
    position: fixed;
    right: calc(20px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: 56px; height: 56px;
    border-radius: var(--shape-lg);
    background: var(--md-primary);
    color: var(--md-on-primary);
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(216, 187, 255, 0.35);
    z-index: 40;
    opacity: 0;
    transform: translateY(16px) scale(0.9);
    pointer-events: none;
    transition: opacity .3s var(--standard), transform .3s var(--spring);
}
.fab.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.fab:hover { transform: translateY(-3px) scale(1.05); }
.fab:active { transform: scale(0.94); }

/* ========================================================================
   Footer
   ======================================================================== */
footer { padding-top: 16px; border-top: 1px solid var(--md-outline-variant); text-align: center; }
footer p { margin: 0; color: var(--md-on-surface-variant); font-size: 12px; }
footer p:last-child { font-size: 10.5px; opacity: 0.55; margin-top: 4px; }
footer a { color: inherit; }

/* ========================================================================
   Responsive fine-tuning
   ======================================================================== */
@media (max-width: 640px) {
    .topbar { gap: 10px; }
    .brand-text p { max-width: 60vw; }
    .toolbar-right { width: 100%; margin-left: 0; justify-content: space-between; }
    .gallery-title-row { flex-direction: column; align-items: stretch; }
    .btn-export { align-self: flex-start; }
}

@media (max-width: 420px) {
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .repo-badge span { display: none; }
    .repo-badge { padding: 9px; }
    .dev-warning { font-size: 11.5px; }
    .settings-status { display: none; }
}

@media (min-width: 900px) {
    .fab { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}