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

:root {
    --deep: #0a0f0d;
    --surface: #111916;
    --card: #162019;
    --gold: #c9a84c;
    --gold-soft: #d4b96a;
    --sage: #7a9e7e;
    --mist: #b8cbb9;
    --white: #edf2ed;
    --dim: #6b7f6e;
    --danger: #c94c4c;
    --danger-soft: #d46a6a;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--deep);
    color: var(--white);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

/* ── Nav ── */
nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    padding: 1.25rem 2rem;
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(10, 15, 13, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(122, 158, 126, 0.08);
}
.nav-brand {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem; font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.5px;
    text-decoration: none;
}
.nav-links {
    display: flex; align-items: center; gap: 1.5rem;
}
.nav-link {
    font-size: 0.9rem;
    color: var(--mist);
    text-decoration: none;
    transition: color 0.2s;
}
.nav-link:hover { color: var(--white); }
.nav-btn {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--deep);
    background: var(--gold);
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}
.nav-btn:hover { background: var(--gold-soft); }

/* ── Loading ── */
.loading-state {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 8rem 2rem;
    color: var(--dim);
}
.loading-spinner {
    width: 32px; height: 32px;
    border: 2px solid var(--card);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
footer {
    max-width: 1200px; margin: 0 auto; width: 100%;
    padding: 2rem;
    border-top: 1px solid rgba(122, 158, 126, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-brand {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem; font-weight: 700;
    color: var(--gold);
}
.footer-right {
    font-size: 0.8rem;
    color: var(--dim);
}

/* ── Create Memorial Page ── */
.create-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 7rem 2rem 4rem;
}
.create-page h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.create-page .subtitle {
    color: var(--dim);
    font-size: 1rem;
    margin-bottom: 2.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mist);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid rgba(122, 158, 126, 0.15);
    border-radius: 10px;
    color: var(--white);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--gold);
}
.form-group textarea {
    min-height: 100px;
    resize: vertical;
}
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--dim);
}
.form-group select option {
    background: var(--surface);
    color: var(--white);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--dim);
    margin-top: 0.35rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 2rem;
    background: var(--gold);
    color: var(--deep);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
    justify-content: center;
}
.btn-primary:hover { background: var(--gold-soft); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    color: var(--mist);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid rgba(122, 158, 126, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    text-decoration: none;
}
.btn-secondary:hover {
    border-color: var(--gold);
    color: var(--white);
}

/* ── Memorial View Page ── */
.memorial-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 7rem 2rem 4rem;
}
.memorial-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(122, 158, 126, 0.1);
}
.memorial-header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.memorial-dates {
    font-size: 1.1rem;
    color: var(--gold-soft);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.memorial-relationship {
    font-size: 0.85rem;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    margin-bottom: 1rem;
}
.memorial-description {
    font-size: 1.05rem;
    color: var(--mist);
    line-height: 1.8;
    max-width: 600px;
    margin: 0 auto;
}

/* ── Upload Area ── */
.upload-section {
    margin-bottom: 3rem;
}
.upload-section h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}
.dropzone {
    border: 2px dashed rgba(201, 168, 76, 0.25);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    background: rgba(22, 32, 25, 0.5);
}
.dropzone:hover,
.dropzone.dragover {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.04);
}
.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}
.dropzone-text {
    font-size: 1rem;
    color: var(--mist);
    margin-bottom: 0.5rem;
}
.dropzone-hint {
    font-size: 0.82rem;
    color: var(--dim);
}
.dropzone input[type="file"] {
    display: none;
}

/* Upload progress */
.upload-progress {
    margin-top: 1.5rem;
}
.upload-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: 10px;
    margin-bottom: 0.5rem;
}
.upload-item-name {
    flex: 1;
    font-size: 0.88rem;
    color: var(--mist);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-item-status {
    font-size: 0.78rem;
    color: var(--dim);
}
.upload-item-status.success { color: var(--sage); }
.upload-item-status.error { color: var(--danger); }

/* ── Gallery ── */
.gallery-section {
    margin-bottom: 3rem;
}
.gallery-section h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--surface);
    cursor: pointer;
    transition: transform 0.2s;
}
.gallery-item:hover { transform: scale(1.02); }
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-item-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 0.75rem;
    background: linear-gradient(transparent, rgba(10, 15, 13, 0.85));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 0.2s;
}
.gallery-item:hover .gallery-item-overlay { opacity: 1; }
.gallery-item-name {
    font-size: 0.75rem;
    color: var(--mist);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.gallery-delete-btn {
    background: rgba(201, 76, 76, 0.8);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.2s;
}
.gallery-delete-btn:hover { background: var(--danger); }

.gallery-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--dim);
    font-size: 0.95rem;
}

/* ── Lightbox ── */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 13, 0.95);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: pointer;
}
.lightbox img, .lightbox video {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    cursor: default;
}
.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    background: none;
    border: none;
    color: var(--mist);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}
.lightbox-close:hover { color: var(--white); }

/* ── Memorials List Page ── */
.memorials-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 7rem 2rem 4rem;
}
.memorials-page h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.memorials-page .subtitle {
    color: var(--dim);
    font-size: 1rem;
    margin-bottom: 2.5rem;
}
.memorials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
.memorial-card {
    background: var(--card);
    border: 1px solid rgba(122, 158, 126, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.3s, transform 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.memorial-card:hover {
    border-color: rgba(201, 168, 76, 0.3);
    transform: translateY(-2px);
}
.memorial-card-image {
    width: 100%;
    height: 200px;
    background: var(--surface);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.memorial-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.memorial-card-placeholder {
    font-size: 3rem;
    opacity: 0.2;
}
.memorial-card-body {
    padding: 1.5rem;
}
.memorial-card-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 0.35rem;
}
.memorial-card-dates {
    font-size: 0.85rem;
    color: var(--gold-soft);
    margin-bottom: 0.35rem;
}
.memorial-card-meta {
    font-size: 0.78rem;
    color: var(--dim);
    display: flex;
    gap: 1rem;
}

.memorials-empty {
    text-align: center;
    padding: 4rem 2rem;
}
.memorials-empty h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--mist);
}
.memorials-empty p {
    color: var(--dim);
    margin-bottom: 2rem;
}

/* ── Toast Notifications ── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--card);
    border: 1px solid rgba(122, 158, 126, 0.2);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--white);
    z-index: 300;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast.success { border-color: rgba(122, 158, 126, 0.4); }
.toast.error { border-color: rgba(201, 76, 76, 0.4); }

/* ── Responsive ── */
@media (max-width: 768px) {
    nav { padding: 1rem 1.25rem; }
    .nav-links { gap: 0.75rem; }
    .nav-link { font-size: 0.82rem; }
    .nav-btn { padding: 0.5rem 1rem; font-size: 0.8rem; }
    .create-page, .memorial-page, .memorials-page { padding: 6rem 1.25rem 3rem; }
    .form-row { grid-template-columns: 1fr; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .memorials-grid { grid-template-columns: 1fr; }
    footer { padding: 1.5rem 1.25rem; flex-direction: column; text-align: center; }
}
