:root {
    /* Dark Mode Palette */
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --accent: #d4a373; /* Gold */
    --border-color: #333333;
    
    --font-serif: 'Cormorant Garamond', serif;
    --font-sans: 'Lato', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

header {
    text-align: center;
    padding: 4rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 3rem;
}

.logo {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent);
    border: 2px solid var(--accent);
    width: 60px;
    height: 60px;
    line-height: 56px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    background-color: var(--bg-color);
}

h1 {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 400;
    margin: 0;
    letter-spacing: -1px;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-style: italic;
    font-family: var(--font-serif);
    font-size: 1.2rem;
}

/* --- NEW GRID SYSTEM --- */
.journal-grid {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 1.5rem;
    padding: 0 1rem 4rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

/* --- UNIFORM CARD STYLES --- */
.memory-card {
    font-size: 16px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    box-shadow: none;
    
    /* Flex column ensures footer sticks to bottom */
    display: flex;
    flex-direction: column;
    height: 100%; /* Take full height of grid row */
}

.memory-card:hover {
    border-color: var(--accent);
}

/* New Subject Header Area */
.card-title-header {
    padding: 1.5rem 1.5rem 1rem;
}

.card-title-header h2 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    margin: 0;
    line-height: 1.2;
    color: var(--text-main);
}

.memory-image img {
    width: 100%;
    object-fit: cover; /* Ensures image fills the area without distortion */
    display: block;

    height: auto;
    max-height: 400px; /* Cap it so vertical photos don't take 2 screens */
    min-height: 250px;
}

/* Content Area */
.memory-content {
    padding: 1rem 1.5rem;
    flex-grow: 1; /* Takes up remaining space pushing footer down */
    display: flex;
    flex-direction: column;
}

/* --- TRUNCATION & EXPANSION --- */

/* Default State: Truncated */
.memory-body-text p {
    font-size: 0.95rem;
    color: #bbbbbb;
    margin: 0;
    /* CSS Magic for multi-line truncation with ellipses */
    display: -webkit-box;
    -webkit-line-clamp: 12; /* Show only 3 lines */
    white-space: pre-wrap;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Expanded State (toggled by JS) */
.memory-card.expanded .memory-body-text p {
    -webkit-line-clamp: unset; /* Remove limit */
    overflow: visible;
    white-space: pre-wrap; /* Preserve line breaks from email */
}

.read-more-trigger {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
    font-weight: bold;
    align-self: flex-start;
}

.read-more-trigger:hover {
    text-decoration: underline;
}


/* --- FOOTER --- */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    background-color: rgba(0,0,0,0.2);
    margin-top: auto; 
}

.date-tag {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.author-tag {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--accent);
}

.empty-state {
    text-align: center;
    padding: 6rem 2rem;
    max-width: 600px;
    margin: 0 auto;
    color: var(--text-muted);
}
.empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; filter: grayscale(1); }
.empty-state h2 { font-family: var(--font-serif); font-size: 2rem; color: var(--text-main); margin-bottom: 0.5rem; }
.empty-state p { font-size: 1.1rem; }
.empty-state strong { color: var(--accent); font-weight: 600; }

@media (min-width: 768px) {
    .journal-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        padding: 0 2rem 4rem;
        gap: 2rem;
    }
    
    header { padding: 4rem 1rem; }
    h1 { font-size: 3rem; }
}

input[type="password"], button {
    font-size: 16px; 
    padding: 1.2rem;
}