:root {
    --primary-blue: #0f172a;
    --royal-blue: #1e3a8a;
    --accent-gold: #fbbf24;
    --text-light: #f8fafc;
    --glass-bg: rgba(30, 58, 138, 0.25);
    --glass-border: rgba(251, 191, 36, 0.3);
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;
    --font-print: 'Georgia', serif;
    /* New font for print view */
}

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

body {
    font-family: var(--font-body);
    /* New Background Image */
    background: url('https://storage.googleapis.com/images_spearhead/spearhead/66781.jpg') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    overflow-x: hidden;
}

.background-ornament {
    /* Optional: Add a dark overlay to ensure text pops even on bright parts of the image */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background: rgba(0, 0, 0, 0.5);
    /* Dark overlay */
}

.main-container {
    width: 100%;
    max-width: 900px;
    /* Increased opacity for better contrast against complex background */
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    text-shadow: 0 4px 10px rgba(251, 191, 36, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    font-style: italic;
    margin-bottom: 1.5rem;
}

.api-config {
    max-width: 400px;
    margin: 0 auto;
}

#apiKey {
    text-align: center;
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(0, 0, 0, 0.4);
    font-size: 0.8rem;
    color: var(--accent-gold);
    padding: 0.75rem;
}

#apiKey::placeholder {
    color: rgba(251, 191, 36, 0.5);
}

.input-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .input-section {
        grid-template-columns: 1fr 1fr;
    }

    .full-width {
        grid-column: span 2;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input,
textarea,
select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    color: white;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

/* File Drop Area */
.file-drop-area {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    transition: 0.2s;
}

.file-drop-area:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-gold);
}

.file-msg {
    font-size: 0.9rem;
    font-weight: 300;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #94a3b8;
}

.file-input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    cursor: pointer;
    opacity: 0;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: #000;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    box-shadow: 0 10px 15px -3px rgba(251, 191, 36, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(251, 191, 36, 0.4);
}

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

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: #475569;
    box-shadow: none;
    transform: none;
}

.result-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
}

.result-section.visible {
    display: block;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.result-header h2 {
    font-family: var(--font-heading);
    color: white;
    font-size: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* PAPER STYLE OUTPUT */
.output-container {
    background: #ffffff;
    /* White paper */
    color: #1e293b;
    /* Dark text */
    padding: 2.5rem;
    /* Generous margins */
    border-radius: 4px;
    /* Slight round, mostly sharp like paper */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    /* Lifted effect */
    position: relative;
    line-height: 1.6;
    font-family: var(--font-print);
    /* Georgia-like serif */
}

/* Prevent Print Breaks */
.markdown-body p,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body li,
.markdown-body blockquote {
    page-break-inside: avoid;
    break-inside: avoid;
}

/* Markdown Styles for PAPER */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #0f172a;
    /* Dark Blue Heading */
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.markdown-body h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid #b45309;
    /* Dark Orange/Gold Underline */
    padding-bottom: 0.5rem;
    text-align: center;
}

.markdown-body h2 {
    font-size: 1.4rem;
    border-bottom: 1px solid #cbd5e1;
}

.markdown-body h3 {
    font-size: 1.1rem;
    color: #b45309;
}

.markdown-body p {
    margin-bottom: 1rem;
    color: #334155;
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    list-style-position: outside;
}

.markdown-body li {
    margin-bottom: 0.5rem;
    color: #334155;
}

.markdown-body strong {
    color: #0f172a;
    font-weight: 700;
}

.markdown-body em {
    color: #475569;
}

.markdown-body blockquote {
    border-left: 4px solid #fbbf24;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #475569;
    font-style: italic;
    background: #fffbeb;
    /* Light yellow bg for quotes */
    padding: 1rem;
}

/* Buttons */
.copy-btn,
.pdf-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.pdf-btn {
    background: #b45309;
    /* Stronger color for primary action */
    border-color: #b45309;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pdf-btn:hover {
    background: #d97706;
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: #b45309;
    /* Darker gold for better visibility on white */
    font-family: var(--font-heading);
    animation: pulse 1.5s infinite;
}

/* MENU STYLES */
.welcome-screen {
    animation: fadeIn 0.5s ease;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 600px) {
    .menu-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.menu-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.menu-card:hover {
    background: rgba(30, 58, 138, 0.4);
    border-color: var(--accent-gold);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.menu-card .icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.menu-card h3 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1.2rem;
    margin: 0;
}

.menu-card p {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin: 0;
}

/* NAV HEADER */
.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--accent-gold);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn svg {
    transition: transform 0.3s ease;
}

.back-btn:hover {
    background: var(--accent-gold);
    color: #0f172a;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
}

.back-btn:hover svg {
    transform: translateX(3px);
}

.mode-title {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1.2rem;
    margin: 0;
}

/* HIDDEN UTILITY */
.hidden {
    display: none !important;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* Responsive Design for Mobile */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
        /* Less padding on body */
        align-items: flex-start;
        /* Ensure scrolling works well */
    }

    .main-container {
        padding: 1.5rem;
        /* Reduced padding inside the glass box */
        width: 100%;
        margin-top: 1rem;
        border-radius: 16px;
        /* Slightly less rounded corners */
    }

    h1 {
        font-size: 1.8rem;
        /* Smaller title */
        word-wrap: break-word;
        /* Prevent title overflow */
    }

    .input-section {
        display: flex;
        /* Flex works better than grid for simple stacking sometimes, but grid is fine too. Let's force strict stacking. */
        flex-direction: column;
        grid-template-columns: 1fr;
        /* Stack inputs */
        gap: 1rem;
    }

    input,
    textarea,
    select {
        width: 100%;
        /* Ensure they don't exceed container */
        max-width: 100%;
        /* Extra safety */
        font-size: 1rem;
        /* Prevent zoom on IOS */
        padding: 0.8rem;
        /* Slightly smaller padding */
    }

    .full-width {
        grid-column: span 1;
    }

    .result-header {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
        text-align: center;
    }

    .action-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.8rem;
    }

    .copy-btn,
    .pdf-btn {
        width: 100%;
        text-align: center;
        padding: 1rem;
    }
}