* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scrollbar-gutter: stable;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.lang-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 6px 0 10px;
    font-size: 0.85em;
    color: rgba(255,255,255,0.9);
}

.lang-bar a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
}

.lang-bar a.lang-actiu {
    font-weight: bold;
    text-decoration: underline;
    color: white;
}

.lang-bar .lang-sep {
    color: rgba(255,255,255,0.5);
}

nav {
    background: white;
    border-radius: 15px;
    padding: 15px 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

nav a {
    text-decoration: none;
    color: #667eea;
    font-weight: bold;
    padding: 8px 20px;
    border-radius: 25px;
    transition: all 0.3s ease;
}

nav a:hover {
    background: #667eea;
    color: white;
}

.card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

h1 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
    color: #667eea;
    margin-bottom: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input[type="text"],
input[type="url"],
input[type="file"],
textarea {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

button,
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

button:hover,
.btn:hover {
    transform: scale(1.02);
}

.lista-enlaces { list-style: none; }

.enlace-item {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.enlace-item a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
    flex: 1;
}

.enlace-item a:hover { text-decoration: underline; }

.btn-eliminar {
    background: #dc3545;
    padding: 5px 15px;
    font-size: 12px;
}

.btn-editar {
    background: #ffc107;
    color: #333;
    padding: 5px 15px;
    font-size: 12px;
}

.mensaje {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.mensaje-exito {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.mensaje-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* GALERÍA */
.galeria {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

.foto {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.foto:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.foto img {
    width: 100%;
    height: 90px;
    object-fit: cover;
}

.foto .info {
    padding: 10px;
    text-align: center;
    font-size: 12px;
    color: #666;
    background: white;
    word-break: break-all;
}

@media (max-width: 1024px) {
    .galeria { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
    .foto img { height: 75px; }
}

@media (max-width: 768px) {
    body { padding-top: 0; }
    .lang-bar {
        padding: 4px 0 8px;
        font-size: 0.8em;
    }
    nav {
        padding: 10px 15px;
        margin-bottom: 15px;
        gap: 8px;
    }
    nav a {
        padding: 6px 12px;
        font-size: 0.88em;
    }
    h1 {
        font-size: 1.05em;
        font-weight: 600;
        letter-spacing: 0.2px;
        margin: 0 -20px 20px;
        padding: 15px 20px;
        line-height: 1.3;
        text-align: center;
        text-shadow: none;
        background: rgba(0, 0, 0, 0.18);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-radius: 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        position: sticky;
        top: 0;
        z-index: 100;
    }
    .enlace-item { flex-direction: column; text-align: center; }
    .galeria { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 5px; }
    .foto img { height: 70px; }
    .foto .info { font-size: 10px; }
}

@media (max-width: 480px) {
    body { padding: 12px; padding-top: 0; }
    h1 { margin: 0 -12px 16px; }
    .galeria { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 4px; }
    .foto img { height: 60px; }
}

/* App mode elements: ocultos en escritorio, visibles solo en móvil */
.app-header { display: none; }
.app-tabs   { display: none; }

/* ============================================================
   APP MODE — activado en móvil (≤ 768px)
   Oculta nav web, añade header slim + bottom tabs nativos
   ============================================================ */
@media (max-width: 768px) {

    /* Mostrar elementos app-mode */
    .app-header { display: flex; }
    .app-tabs   { display: flex; }

    /* Ocultar elementos de la web de escritorio */
    .lang-bar { display: none !important; }
    nav:not(.app-tabs) { display: none !important; }
    h1        { display: none !important; }

    /* Espacio para el header fijo y los tabs inferiores */
    body {
        padding-top: 52px;
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* El banner de actualización Android queda justo bajo el header */
    #banner-update {
        position: fixed !important;
        top: 52px !important;
        bottom: auto !important;
    }

    /* ---- Header slim ---- */
    .app-header {
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 200;
        height: 52px;
        background: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        border-bottom: 1px solid #f0f0f0;
        box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    }

    .app-header-title {
        font-size: 1em;
        font-weight: 700;
        color: #1a1a2e;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-right: 12px;
    }

    .app-profile-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1em;
        flex-shrink: 0;
    }

    /* ---- Dropdown de perfil ---- */
    .app-profile-wrap {
        position: relative;
    }

    .app-profile-menu {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.15);
        min-width: 190px;
        overflow: hidden;
        z-index: 300;
    }
    .app-profile-menu.open { display: block; }

    .app-profile-lang {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        border-bottom: 1px solid #f5f5f5;
        font-size: 0.82em;
        color: #999;
    }
    .app-profile-lang a {
        padding: 4px 11px;
        border-radius: 20px;
        background: #f0f0f0;
        color: #667eea;
        font-weight: 700;
        font-size: 0.9em;
        text-decoration: none;
    }
    .app-profile-lang a.lang-actiu {
        background: #667eea;
        color: #fff;
    }

    .app-profile-menu a {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 18px;
        color: #333;
        text-decoration: none;
        font-size: 0.9em;
        border-bottom: 1px solid #f5f5f5;
    }
    .app-profile-menu a:last-child { border-bottom: none; }
    .app-profile-menu a:active { background: #f5f5f5; }

    /* ---- Bottom tab bar ---- */
    .app-tabs {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 200;
        background: #fff;
        border-top: 1px solid #e8e8e8;
        display: flex;
        align-items: stretch;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    }

    .app-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 8px 4px;
        text-decoration: none;
        color: #aaa;
        position: relative;
        min-height: 56px;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.15s;
    }

    /* Línea indicadora en el borde superior del tab activo */
    .app-tab::before {
        content: '';
        position: absolute;
        top: 0;
        left: 20%; right: 20%;
        height: 2px;
        border-radius: 0 0 2px 2px;
        background: transparent;
        transition: background 0.15s;
    }
    .app-tab.active { color: #667eea; }
    .app-tab.active::before { background: #667eea; }

    .app-tab-icon  { font-size: 1.4em; line-height: 1; }
    .app-tab-label { font-size: 0.65em; font-weight: 600; }
}
