:root {
    --bg-color: #fcfbf9;
    --card-bg: #ffffff;
    --text-primary: #2c2c2c;
    --text-secondary: #666666;
    --accent: #8b5e3c;
    --accent-light: #d4c5b9;
    --shadow: 0 10px 30px -10px rgba(0,0,0,0.08);
    --font-serif: 'Cormorant Garamond', serif;
    --font-sans: 'Montserrat', sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    background-image: url('images/bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Overlay to ensure text readability over background image */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(252, 251, 249, 0.85);
    z-index: -1;
}

.app-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    margin-bottom: 20px;
}

.logo {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-btn {
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding-bottom: 5px;
    transition: all 0.3s ease;
}

.nav-btn:hover,
.nav-btn.active {
    color: var(--accent);
    border-bottom: 1px solid var(--accent);
}

/* Main Content Area */
main {
    flex: 1;
    position: relative;
    padding: 0 20px;
    overflow-y: auto;
}

.content-section {
    display: none;
    animation: fadeIn 0.5s ease;
    height: 100%;
}

.content-section.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Poem Card (Read Mode) */
.poem-card {
    background: var(--card-bg);
    padding: 60px;
    border-radius: 4px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 600px;
    text-align: center;
    position: relative;
    border: 1px solid rgba(0,0,0,0.03);
}

.poem-content h2 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    margin-bottom: 30px;
    font-weight: 400;
    color: var(--text-primary);
}

.poem-body {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 40px;
    font-style: italic;
}

.poem-author {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.poem-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: auto;
}

/* Buttons */
.primary-btn {
    background-color: var(--text-primary);
    color: white;
    border: none;
    padding: 12px 30px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.3s ease;
    border-radius: 2px;
}

.primary-btn:hover {
    background-color: var(--accent);
}

.control-btn {
    background: none;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.control-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Write Mode */
.write-card {
    background: var(--card-bg);
    padding: 50px;
    border-radius: 4px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 600px;
}

.write-card h2 {
    font-family: var(--font-serif);
    margin-bottom: 30px;
    text-align: center;
    font-weight: 400;
}

.form-group {
    margin-bottom: 25px;
}

input, textarea {
    width: 100%;
    padding: 15px;
    border: none;
    border-bottom: 1px solid #ddd;
    background: transparent;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    transition: border-color 0.3s;
}

input:focus, textarea:focus {
    outline: none;
    border-bottom-color: var(--accent);
}

textarea {
    min-height: 200px;
    resize: none;
    line-height: 1.6;
}

/* Library Grid */
.library-container {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    padding-bottom: 50px;
}

.library-container h2 {
    font-family: var(--font-serif);
    text-align: center;
    margin-bottom: 40px;
    font-weight: 400;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.mini-card {
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.3s ease;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mini-card:hover {
    transform: translateY(-5px);
}

.mini-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.mini-preview {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    font-style: italic;
}

.mini-date {
    font-size: 0.7rem;
    color: #999;
    margin-top: 10px;
    text-align: right;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 10px;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .poem-card, .write-card {
        padding: 30px 20px;
        height: auto;
        min-height: 60vh;
    }
    
    .poem-content h2 {
        font-size: 1.8rem;
    }
    
    .poem-body {
        font-size: 1.1rem;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
    }
}