:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #a8a8b8;
    --accent: #c4a882;
    --accent-light: #d4c4a8;
    --timeline-line: #c4a882;
    --danger: #c0392b;
    --border-radius: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.6;
    min-height: 100vh;
}

img, video, iframe { max-width: 100%; display: block; }

/* ── Header ───────────────────────────────────────────────────── */
.memorial-header {
    text-align: center;
    padding: 80px 20px 40px;
    background: linear-gradient(180deg, rgba(15,52,96,0.5) 0%, rgba(26,26,46,0) 100%);
}

.memorial-header h1 {
    font-size: 3rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    margin: 0 0 8px;
}

.memorial-header h1::after {
    content: '';
    display: block;
    width: 80px;
    height: 2px;
    background-color: var(--accent);
    margin: 16px auto 0;
}

.memorial-header .subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    font-style: italic;
    margin: 12px 0 0;
}

.memorial-header .title-quote {
    font-size: 1.3rem;
    color: var(--accent-light);
    font-style: italic;
    margin: 20px 0 0;
    letter-spacing: 0.02em;
}

/* ── Playlist Section ─────────────────────────────────────────── */
.playlist-section {
    max-width: 800px;
    margin: 0 auto 50px;
    padding: 0 20px;
}

.playlist-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(196,168,130,0.15);
}

.playlist-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: var(--border-radius);
}

/* ── Flash Messages ───────────────────────────────────────────── */
.flash-message {
    max-width: 600px;
    margin: 20px auto;
    padding: 14px 20px;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    text-align: center;
}

.flash-error {
    background-color: rgba(192,57,43,0.2);
    border: 1px solid var(--danger);
    color: #e74c3c;
}

.flash-success {
    background-color: rgba(39,174,96,0.15);
    border: 1px solid #27ae60;
    color: #2ecc71;
}

/* ── Share Form ───────────────────────────────────────────────── */
.post-form-section {
    max-width: 600px;
    margin: 0 auto 60px;
    padding: 0 20px;
}

.post-form-section h2 {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--accent-light);
    margin-bottom: 24px;
}

.post-form-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.form-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid rgba(196,168,130,0.3);
    border-radius: 50px;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.tab-btn.active {
    background-color: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    font-weight: 600;
}

.tab-content { display: none; margin-bottom: 20px; }
.tab-content.active { display: block; }

.file-input-wrapper input[type="file"] {
    width: 100%;
    padding: 12px;
    background-color: rgba(26,26,46,0.6);
    border: 1px dashed rgba(196,168,130,0.4);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.25s ease;
}

.file-input-wrapper input[type="file"]:focus {
    outline: none;
    border-color: var(--accent);
}

.file-input-wrapper input[type="file"]::file-selector-button {
    padding: 6px 16px;
    margin-right: 12px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background-color: transparent;
    color: var(--accent);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-input-wrapper input[type="file"]::file-selector-button:hover {
    background-color: var(--accent);
    color: var(--bg-primary);
}

#file-preview { margin-top: 12px; }
#file-preview img { max-width: 200px; max-height: 200px; border-radius: 6px; }

.youtube-input {
    width: 100%;
    padding: 12px 16px;
    background-color: rgba(26,26,46,0.6);
    border: 1px solid rgba(196,168,130,0.3);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.95rem;
    transition: border-color 0.25s ease;
}

.youtube-input:focus { outline: none; border-color: var(--accent); }
.youtube-input:disabled { opacity: 0.5; cursor: not-allowed; }

#yt-preview { margin-top: 12px; }
#yt-preview img { max-width: 300px; border-radius: 6px; }

.caption-wrapper { margin-bottom: 20px; }

.caption-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    background-color: rgba(26,26,46,0.6);
    border: 1px solid rgba(196,168,130,0.3);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.25s ease;
}

.caption-wrapper textarea:focus { outline: none; border-color: var(--accent); }

.char-counter {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--border-radius);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.25s ease;
}

.submit-btn:hover {
    background-color: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(196,168,130,0.3);
}

.submit-btn:active { transform: translateY(0); }

/* ── Timeline ─────────────────────────────────────────────────── */
.timeline-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

.timeline-section h2 {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--accent-light);
    margin-bottom: 40px;
}

.timeline {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    background-color: var(--timeline-line);
}

.timeline-item {
    position: relative;
    width: 50%;
    padding: 0 40px 40px;
}

.timeline-item.left { left: 0; text-align: right; }
.timeline-item.right { left: 50%; text-align: left; }

.timeline-dot {
    position: absolute;
    top: 8px;
    width: 14px;
    height: 14px;
    background-color: var(--accent);
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    z-index: 2;
}

.timeline-item.left .timeline-dot { right: -7px; }
.timeline-item.right .timeline-dot { left: -7px; }

.timeline-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(196,168,130,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: left;
}

.timeline-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.post-image {
    width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 14px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.post-image:hover { opacity: 0.85; }

.post-video {
    width: 100%;
    border-radius: 6px;
    margin-bottom: 14px;
    cursor: pointer;
}

.yt-responsive-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 6px;
    margin-bottom: 14px;
}

.yt-responsive-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 6px;
}

.post-caption {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 10px;
    word-wrap: break-word;
}

.post-date {
    display: block;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-style: italic;
}

.delete-form { margin-top: 12px; text-align: right; }

.delete-btn {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 4px 12px;
    border-radius: 4px;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-btn:hover { background-color: var(--danger); color: #fff; }

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1.05rem;
    padding: 60px 20px;
}

/* ── Footer ───────────────────────────────────────────────────── */
.memorial-footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
    border-top: 1px solid rgba(196,168,130,0.15);
}

/* ── Media Modal ──────────────────────────────────────────────── */
.media-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.92);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.media-modal.active {
    display: flex;
}

.modal-close {
    position: fixed;
    top: 16px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 1001;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.modal-close:hover { opacity: 1; }

.modal-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.modal-content video {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 4px;
}

.modal-caption {
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
    margin-top: 16px;
    max-width: 600px;
    line-height: 1.5;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .memorial-header { padding: 50px 20px 30px; }
    .memorial-header h1 { font-size: 2.2rem; }
    .memorial-header .title-quote { font-size: 1.05rem; }
    .form-tabs { flex-direction: column; }

    .timeline::before { left: 20px; transform: none; }

    .timeline-item {
        width: 100%;
        padding-left: 50px;
        padding-right: 0;
        text-align: left;
    }

    .timeline-item.left { left: 0; text-align: left; }
    .timeline-item.right { left: 0; }

    .timeline-item.left .timeline-dot,
    .timeline-item.right .timeline-dot {
        left: 13px;
        right: auto;
    }

    .post-form-card { padding: 20px; }

    .modal-close {
        top: 10px;
        right: 16px;
        font-size: 2rem;
    }
}

::placeholder { color: var(--text-secondary); opacity: 0.7; }
