body {
    background-color: #f9f7f7;
    color: #5a5a5a;
    font-family: 'Raleway', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Syne', sans-serif;
    color: #B8BDE1;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* border-bottom: 1px solid #f0f0f0; */
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 60px;
    /* background: #7f4747; */
    transition: background-color 0.3s ease, border-color 0.3s ease;
    width: 0%;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.header-logo {
    height: 100%;
    display: flex;
    align-items: center;
}

.logo-image {
    height: 40px;
    width: auto;
    transition: opacity 0.3s ease;
}

.header-title {
    flex: 1;
    text-align: center;
    margin: 0 1rem;
}

.main-content {
    flex-grow: 1;
    position: relative;
    /* padding-top: 1rem; */
    position: absolute;
}

.main-content.full-width {
    margin-left: 0;
    width: 100%;
}

.input-field {
    border: 2px solid #e8e8e8;
    border-radius: 1.5rem;
    padding: 0.75rem 1.25rem;
    width: 100%;
    background-color: white;
    transition: all 0.3s ease;
    font-family: 'Raleway', sans-serif;
}

.input-field:focus {
    outline: none;
    border-color: #B8BDE1;
    box-shadow: 0 0 0 3px rgba(184, 189, 225, 0.3);
}

.btn {
    background-color: #B8BDE1;
    color: #404992;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    transition: all 0.3s ease;
    border: none;
    font-weight: 500;
    font-family: 'Raleway', sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    background-color: #A3A8D6;
    transform: translateY(-1px);
}

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

.btn i {
    font-size: 1rem;
}

.story-btn {
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    background-color: rgba(184, 189, 225, 0.1);
    border: 2px solid rgba(184, 189, 225, 0.2);
    transition: all 0.3s ease;
}

.story-btn:hover {
    background-color: rgba(184, 189, 225, 0.2);
    border-color: rgba(184, 189, 225, 0.3);
}

.story-btn i {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.story-btn:hover i {
    opacity: 1;
}

.submit-btn {
    width: 100%;
    background-color: #B8BDE1;
    color: #404992;
}

.submit-btn:hover {
    background-color: #A3A8D6;
}

/* Dark Mode Styles */
.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

.dark-mode .app-header {
    background-color: #2d2d2d;
    border-bottom-color: #404040;
}

.dark-mode .input-field {
    background-color: #2d2d2d;
    border-color: #404040;
    color: #e0e0e0;
}

.dark-mode .btn {
    background-color: #404992;
    color: #e0e0e0;
}

.dark-mode .btn:hover {
    background-color: #333876;
}

.dark-mode .story-btn {
    background-color: rgba(64, 73, 146, 0.1);
    border-color: rgba(64, 73, 146, 0.2);
    color: #e0e0e0;
}

.dark-mode .story-btn:hover {
    background-color: rgba(64, 73, 146, 0.2);
    border-color: rgba(64, 73, 146, 0.3);
}

.dark-mode .submit-btn {
    background-color: #404992;
}

.dark-mode .submit-btn:hover {
    background-color: #333876;
}

.dark-mode .story-message {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

.dark-mode .user-message {
    background-color: #404992;
    color: #e0e0e0;
}

.dark-mode .story-modal {
    background-color: #2d2d2d;
}

.dark-mode .modal-title {
    color: #e0e0e0;
}

.dark-mode .modal-description {
    color: #b0b0b0;
}

.dark-mode .menu-content {
    background-color: #2d2d2d;
    border: 1px solid #404040;
}

.dark-mode .menu-item {
    color: #e0e0e0;
}

.dark-mode .menu-item:hover {
    background-color: #404040;
}

.dark-mode .menu-divider {
    background-color: #404040;
}

/* Content Enhancements */
.story-paragraph {
    line-height: 1.8;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    text-align: justify;
}

.story-paragraph p {
    margin-bottom: 1.2rem;
}

.story-message {
    padding: 1.5rem;
    border-radius: 1.5rem;
    margin-bottom: 1.5rem;
    background-color: rgba(244, 246, 250, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.story-message:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.story-message p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.2rem;
    text-align: justify;
}

.user-message {
    background-color: rgba(232, 240, 254, 0.95);
    margin-left: 2rem;
    margin-right: 0;
    padding: 1.25rem 1.5rem;
    border-radius: 1.5rem 0 1.5rem 1.5rem;
    position: relative;
}

.user-message::before {
    content: '';
    position: absolute;
    top: 0;
    right: -10px;
    width: 20px;
    height: 20px;
    background-color: rgba(232, 240, 254, 0.95);
    border-radius: 0 0 0 20px;
}

.message-timestamp {
    display: block;
    font-size: 0.8rem;
    color: #a0aec0;
    text-align: right;
    margin-top: 0.5rem;
}

/* Enhanced Typography */
.paragraph-heading {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    color: #85C7D3;
}

.dark-mode .paragraph-heading {
    color: #85C7D3;
}

/* Reading Progress */
.reading-progress {
    height: 4px;
    background-color: #B8BDE1;
    position: fixed;
    top: 60px;
    left: 0;
    z-index: 40;
    transition: width 0.3s ease;
}

.dark-mode .reading-progress {
    background-color: #404992;
}

/* Loading and Error Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.dark-mode .loading-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background-color: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark-mode .loading-spinner {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

.loading-spinner i {
    color: #B8BDE1;
}

.dark-mode .loading-spinner i {
    color: #B8BDE1;
}

.error-banner {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(252, 165, 165, 0.95);
    color: #7f1d1d;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 90;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 90%;
}

.error-banner button {
    background: none;
    border: none;
    color: #7f1d1d;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background-color: rgba(252, 165, 165, 0.2);
    color: #7f1d1d;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.dark-mode .error-message {
    background-color: rgba(252, 165, 165, 0.1);
    color: #fca5a5;
}

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

.story-content {
    animation: fadeIn 0.5s ease-out;
}

.message {
    animation: fadeIn 0.5s ease-out;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    .header-title {
        margin: 0 0.5rem;
    }

    .logo-image {
        height: 30px;
    }

    .btn {
        padding: 0.5rem 1rem;
    }

    .story-btn {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .btn {
        font-size: 0.875rem;
    }

    .story-btn {
        font-size: 0.875rem;
    }

    .paragraph-heading {
        font-size: 1.2rem;
    }

    .user-message {
        margin-left: 1rem;
    }
}

/* Accessibility Improvements */
.btn:focus, .input-field:focus, .story-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(184, 189, 225, 0.5);
}

.dark-mode .btn:focus, .dark-mode .input-field:focus, .dark-mode .story-btn:focus {
    box-shadow: 0 0 0 3px rgba(64, 73, 146, 0.5);
}

/* Print Styles */
@media print {
    .app-header, .story-options, .character-chat {
        display: none;
    }

    .story-content {
        margin: 0;
        padding: 0;
        width: 100%;
    }

    body {
        background-color: white;
        color: black;
    }

    .story-message, .user-message {
        break-inside: avoid;
        background: none;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Gluten Font Styles */
.gluten-heading {
  font-family: "Gluten", cursive;
  font-optical-sizing: auto;
  font-weight: 700;
  font-style: normal;
  font-variation-settings: "slnt" 0;
  color: #B8BDE1;
}

.gluten-subtitle {
  font-family: "Gluten", cursive;
  font-optical-sizing: auto;
  font-weight: 500;
  font-style: normal;
  font-variation-settings: "slnt" 0;
  color: #85C7D3;
}

.gluten-accent {
  font-family: "Gluten", cursive;
  font-optical-sizing: auto;
  font-weight: 600;
  font-style: normal;
  font-variation-settings: "slnt" 0;
  color: #85C7D3;
}

/* Chat Messages Styles */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
