:root {
    --bg-color: #0A0A1A;
    --text-color: #F0EAD6;
    --accent-color: #D9CBBF;
    --font-heading: 'Unbounded', sans-serif;
    --font-body: 'Cormorant Garamond', serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,%3Csvg width="6" height="6" viewBox="0 0 6 6" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="%231a1a2e" fill-opacity="0.4" fill-rule="evenodd"%3E%3Cpath d="M5 0h1L0 6V5zM6 5v1H0V5z"/%3E%3C/g%3E%3C/svg%3E');
    opacity: 0.2;
    z-index: -1;
}

.container {
    max-width: 700px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Typography */
h1, h2, h3, .voice-info h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin: 0 0 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.voice-btn.selected .voice-info h3 {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
}

.subtitle {
    font-size: 1rem;
    text-align: center;
    color: var(--bg-color);
    font-family: var(--font-body);
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #000;
    padding: 5px 10px;
}

h1.title {
    font-size: 2.5rem;
    line-height: 1.2;
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 5px 15px;
    width: 80%;
    text-align: center;
}

h2 {
    font-family: var(--font-body);
    font-size: 2rem;
    font-weight: 600;
    font-style: italic;
    text-align: center;
    margin-bottom: 25px;
    color: var(--accent-color);
    text-transform: none;
    letter-spacing: normal;
    padding-bottom: 0;
}

.section-intro {
    font-size: 1.1rem;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 25px;
    font-style: italic;
}

/* Header */
/* This was previously .header, which was incorrect */
header {
    text-align: center;
    padding: 20px 0;
    position: relative;
}

header {
    position: relative;
    margin-bottom: 40px;
}

.header-image {
    width: 100%;
    max-width: 800px;
    height: auto;
    margin: 0 auto;
    display: block;
}

/* Sections */
.control-panel {
    padding: 35px 0;
}

.divider {
    text-align: center;
    margin: 40px 0;
    color: var(--accent-color);
    font-family: var(--font-body);
    font-size: 1.5rem;
    opacity: 0.6;
}

.divider span {
    margin: 0 10px;
}

.control-panel > section {
    padding: 0;
    border: none;
}

.audio-section, .history-section {
    padding: 25px;
    border-radius: 0;
}

/* Voice Selection */
.voice-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    text-align: center;
}

.voice-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-body);
    opacity: 0.7;
}

.voice-btn:hover:not(.selected) {
    opacity: 1;
}

.voice-btn.selected {
    opacity: 1;
    color: var(--text-color);
}

.voice-icon {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.voice-info h3 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.voice-info p {
    font-size: 1rem;
    font-style: italic;
    opacity: 0.8;
}

/* Text Input */
#textInput {
    width: 100%;
    min-height: 150px;
    background-color: rgba(240, 234, 214, 0.05);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    color: var(--text-color);
    padding: 20px;
    font-family: var(--font-body);
    font-size: 1.2rem;
    resize: vertical;
    transition: all 0.3s ease;
}

#textInput:focus {
    outline: none;
    border-color: var(--text-color);
    background-color: transparent;
}

.char-counter {
    text-align: right;
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-top: 10px;
}

/* Generate Button */
.generate-section {
    text-align: center;
}

.generate-btn {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border: none;
    padding: 15px 20px;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1.5px;
    width: 100%;
    text-align: center;
}

.generate-btn:hover:not(:disabled) {
    background-color: var(--text-color);
    color: var(--bg-color);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.generate-note {
    font-size: 1rem;
    color: var(--accent-color);
    font-style: italic;
    margin-top: 15px;
}

/* Audio Section */
#audioPlayer {
    width: 100%;
    margin-bottom: 15px;
}

.download-btn {
    display: inline-block;
    background-color: transparent;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    padding: 10px 20px;
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

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

/* History Section */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.clear-history-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    padding: 5px 10px;
    cursor: pointer;
    font-family: var(--font-body);
    text-decoration: underline;
    transition: all 0.3s ease;
}

.clear-history-btn:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.history-item {
    padding: 15px 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 1px solid transparent;
}

.history-item:hover {
    background-color: rgba(240, 234, 214, 0.05);
    border-color: rgba(240, 234, 214, 0.2);
}

.history-item:hover {
    opacity: 0.7;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--accent-color);
}

.history-text {
    font-size: 1.1rem;
}

.history-delete {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.history-delete:hover {
    color: var(--text-color);
}

/* Loading & Messages */
.loading-overlay, .error-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 1000;
    padding: 20px;
    font-family: var(--font-body);
}

.loading-content {
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    padding: 40px;
    max-width: 400px;
    width: 100%;
}

.loading-content p {
    font-size: 1.2rem;
    color: var(--text-color);
    margin: 0 0 10px 0;
}

.loading-content small {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.error-message {
    background: rgba(10, 10, 26, 0.95);
}

.error-message p {
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    padding: 30px;
    margin: 0;
    color: var(--text-color);
    font-size: 1.1rem;
    position: relative;
    max-width: 400px;
    width: 100%;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 1.5rem;
    cursor: pointer;
    font-family: var(--font-body);
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--text-color);
}

.spinner {
    border: 4px solid var(--accent-color);
    border-radius: 50%;
    border-top: 4px solid var(--text-color);
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 0;
    font-size: 0.9rem;
    color: var(--accent-color);
    border-top: 1px solid var(--accent-color);
    margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 20px 15px;
    }

    .container {
        gap: 30px;
    }

    .title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .voice-options {
        grid-template-columns: 1fr;
    }

    .voice-btn, #textInput, .generate-btn {
        padding: 15px;
    }
}
