:root {
    --primary: #2a4b8d;
    --primary-600: #24427c;
    --bg: #f6f8fb;
    --text: #111827;
    --muted: #6b7280;
    --card: #ffffff;
    --border: #e5e7eb;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --error-border: #fecaca;
    --ok-bg: #ecfdf5;
    --ok-text: #065f46;
    --ok-border: #a7f3d0;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.07);
}

/* Base */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 800px at 10% 10%, #f0f4ff 0%, transparent 50%) no-repeat,
        radial-gradient(900px 600px at 90% 20%, #fef3c7 0%, transparent 40%) no-repeat,
        var(--bg);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Header y menú */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: transparent;
}

.brand {
    font-weight: 800;
    color: var(--primary);
}

.menu {
    display: flex;
    gap: 18px;
}

.menu a {
    padding: 8px 10px;
    border-radius: 8px;
    color: #374151;
}

.menu a:hover,
.menu a:focus {
    background: #f0f4ff;
    color: var(--primary);
}

/* Hero */
.hero {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 16px 8px;
    text-align: center;
}

.hero h1 {
    margin: 12px 0 8px;
    color: var(--primary);
    font-size: 2rem;
}

.hero p {
    margin: 0;
    color: #4b5563;
}

/* Secciones */
main {
    padding: 16px;
}

.section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 0;
}

.section h2 {
    margin: 0 0 12px;
    color: var(--primary);
}

.muted {
    color: var(--muted);
    margin-bottom: 16px;
}

/* Galería grid pública */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

/* Tarjetas de edición (Panel) */
.item {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    min-height: 100%;
}

.item .muted {
    font-size: .9rem;
}

.item .spacer {
    flex: 1 1 auto;
}

.item .actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: nowrap;
}

.item .actions .btn {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
}

@media (max-width: 520px) {
    .item .actions {
        flex-direction: column;
    }

    .item .actions .btn {
        width: 100%;
    }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

/* Tarjeta de figura (Galería pública) */
figure,
.card-figure {
    margin: 0;
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
    transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}

@media (hover: hover) {

    .card-figure:hover,
    figure:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
        filter: saturate(1.03);
    }
}

/* Enlace/imagen de thumbnail */
.card-figure {
    position: relative;
}

.thumb-link,
figure a {
    display: block;
    position: relative;
    z-index: 2;
    border-radius: 8px;
    overflow: hidden;
    pointer-events: auto;
}

.thumb,
figure img {
    width: 100%;
    height: 180px;
    display: block;
    object-fit: cover;
    cursor: default;
    pointer-events: auto;
}

/* Caption sin bloquear taps a la imagen */
.card-figure figcaption,
figure figcaption {
    position: relative;
    z-index: 1;
    pointer-events: none;
    padding: 10px 12px;
    font-size: .95rem;
    color: #374151;
}

figcaption .title {
    font-weight: 600;
    margin-top: 8px;
}

figcaption .meta {
    color: #666;
    font-size: .9rem;
}

figcaption .desc {
    color: #444;
    font-size: .95rem;
}

/* Permitir clics en botones/links dentro del caption */
.card-figure figcaption a,
.card-figure figcaption button,
figure figcaption a,
figure figcaption button {
    pointer-events: auto;
}

/* Sobre mí */
.about {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 99999;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}

.lightbox:target {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
}

.lightbox-image,
.lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
    display: block;
    width: auto;
    height: auto;
    cursor: zoom-out;
}

/* Fondo clicable para cerrar */
.lightbox .backdrop-close {
    position: absolute;
    inset: 0;
    display: block;
}

/* Botón cerrar */
.lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    text-decoration: none;
    font-size: 20px;
    line-height: 1;
    border: 1px solid rgba(255, 255, 255, .25);
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, .8);
}

/* Mejora de interacción táctil */
.lightbox,
.lightbox * {
    touch-action: manipulation;
}

/* Footer */
footer {
    padding: 24px 16px;
    text-align: center;
    color: var(--muted);
}

/* Contenedores comunes */
.container {
    display: flex;
    margin: 0 auto;
    padding: 24px;
    gap: 20px;
}

/* Mobile: apilar contenido de .container uno debajo del otro */
@media (max-width: 768px) {
    .container {
        display: flex;
        /* asegúrate de que sea flex */
        flex-direction: column;
        /* apila verticalmente */
        gap: 16px;
        /* separación entre bloques */
        padding: 16px;
        /* un poco menos de padding */
    }

    .container>* {
        width: 100%;
        /* cada hijo toma todo el ancho */
    }
}

.login-wrap {
    min-height: calc(100vh - 48px);
    display: grid;
    place-items: center;
}

/* Grid uniforme para formularios/listas */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

/* Card genérica */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    width: 100%;
    justify-content: space-between
}

.card-spacer {
    flex: 1 1 auto;
}

/* Tipografía */
h1,
h2,
h3 {
    margin: 0 0 12px 0;
    line-height: 1.2;
}

h1 {
    font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
    text-align: center;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* Formularios */
form label {
    font-weight: 600;
    font-size: .95rem;
    display: block;
    margin: 12px 0 6px;
}

.input,
.textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: #9db2df;
    box-shadow: 0 0 0 4px rgba(42, 75, 141, 0.15);
}

/* Botones */
.btn,
a.btn {
    all: unset;
    /* elimina TODAS las propiedades por defecto del anchor */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 12px 16px;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);

    font: 700 1rem/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    letter-spacing: .2px;

    background: var(--primary);
    color: #fff;

    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
}

.btn>* {
    line-height: 1;
}

.btn svg {
    display: block;
}

.btn:hover {
    background: var(--primary-600);
}

.btn:active {
    transform: translateY(1px);
}

.btn.secondary {
    background: #6b7280;
}

.btn.secondary:hover {
    background: #565d67;
}

.btn.danger {
    background: #b91c1c;
}

.btn.danger:hover {
    background: #991b1b;
}

/* Mensajes */
.msg {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    border: 1px solid var(--border);
}

.msg.err {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}

.msg.ok {
    background: var(--ok-bg);
    color: var(--ok-text);
    border-color: var(--ok-border);
}

/* Layout login */
.login-title {
    text-align: center;
    margin-bottom: 6px;
}

.login-subtitle {
    text-align: center;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: .95rem;
}

.login-footer {
    margin-top: 12px;
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
}

.login-footer a {
    color: var(--primary);
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* About */
.about-hero {
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border);
    padding: 48px 20px;
}

.about-hero .container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: center;
}

.about-title {
    font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
    font-weight: 800;
}

.about-subtitle {
    color: var(--muted);
    font-size: 1.02rem;
    max-width: 65ch;
}

.about-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 6px solid #fff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    background: #e5e7eb;
}

.about-block {
    padding: 28px 20px;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
}

.about-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.about-card h3 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.about-cta {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.about-cta .btn {
    width: auto;
}

.about-editor {
    margin-top: 16px;
    border-top: 1px dashed var(--border);
    padding-top: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.helper {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 4px;
}

.input.invalid {
    border-color: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

.password-tips {
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.92rem;
    color: var(--muted);
    margin-top: 4px;
}

/* Responsive */
@media (min-width: 640px) {
    .form-grid.two-cols {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 780px) {
    .about-hero .container {
        grid-template-columns: 1.2fr 1fr;
    }

    .about-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.admin-container {
    margin: 0 auto;
    padding: 24px;
}