:root {
    --parchment-cream: #F5E6C8;
    --parchment-light: #FAF3E3;
    --aged-sepia: #D4A574;
    --ink-black: #2C1810;
    --burnt-umber: #8B4513;
    --wax-seal-red: #8B0000;
    --gold-accent: #C9A227;
    --coffee-stain: rgba(139, 69, 19, 0.15);
}

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

body {
    font-family: 'Cormorant Garamond', serif;
    background: linear-gradient(135deg, #2C1810 0%, #4A3728 50%, #2C1810 100%);
    min-height: 100vh;
    color: var(--ink-black);
}

.app-container {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(ellipse at 20% 30%, rgba(201, 162, 39, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(201, 162, 39, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.header {
    padding: 2rem 1rem;
    text-align: center;
    background: linear-gradient(180deg, rgba(245, 230, 200, 0.95) 0%, rgba(245, 230, 200, 0.85) 100%);
    border-bottom: 4px solid var(--burnt-umber);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--gold-accent), transparent);
}

.title-container {
    position: relative;
    z-index: 1;
}

.main-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: 900;
    color: var(--ink-black);
    text-shadow: 2px 2px 0 var(--gold-accent), 4px 4px 8px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.05em;
}

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--burnt-umber);
    margin-top: 0.5rem;
}

.flourish {
    color: var(--gold-accent);
    width: 150px;
    opacity: 0.8;
}

.header-flourish {
    display: none;
}

@media (min-width: 768px) {
    .header-flourish {
        display: block;
    }
    .header-flourish.left {
        transform: scaleX(-1);
    }
}

/* Main content */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
        padding: 2rem;
    }
}

.input-column, .preview-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Parchment card */
.parchment-card {
    background: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E"),
        linear-gradient(135deg, var(--parchment-cream) 0%, var(--parchment-light) 50%, var(--parchment-cream) 100%);
    border-radius: 8px;
    position: relative;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 0 30px rgba(139, 69, 19, 0.1);
}

.thought-section {
    padding: 1.5rem;
    border: 3px solid var(--aged-sepia);
}

.torn-edge {
    position: absolute;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--parchment-cream) 5%, 
        transparent 10%, 
        var(--parchment-cream) 15%, 
        transparent 20%,
        var(--parchment-cream) 30%,
        transparent 35%,
        var(--parchment-cream) 45%,
        transparent 50%,
        var(--parchment-cream) 55%,
        transparent 65%,
        var(--parchment-cream) 70%,
        transparent 80%,
        var(--parchment-cream) 85%,
        transparent 90%,
        var(--parchment-cream) 95%,
        transparent 100%
    );
}

.torn-edge.top {
    top: -10px;
}

.thought-input {
    width: 100%;
    min-height: 180px;
    padding: 1rem;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    color: var(--ink-black);
    background: transparent;
    border: 2px dashed var(--aged-sepia);
    border-radius: 4px;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s;
}

.thought-input:focus {
    border-color: var(--gold-accent);
}

.thought-input::placeholder {
    color: var(--burnt-umber);
    opacity: 0.7;
    font-style: italic;
}

.word-count {
    text-align: right;
    font-style: italic;
    color: var(--burnt-umber);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.ink-stain {
    position: absolute;
    bottom: 20px;
    right: 30px;
    width: 60px;
    height: 40px;
    background: radial-gradient(ellipse, var(--coffee-stain) 0%, transparent 70%);
    transform: rotate(-15deg);
    pointer-events: none;
}

/* Gilded frame / Image upload */
.gilded-frame {
    background: linear-gradient(135deg, #B8860B 0%, var(--gold-accent) 20%, #DAA520 50%, var(--gold-accent) 80%, #B8860B 100%);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.gilded-frame:hover, .gilded-frame.dragging {
    transform: scale(1.02);
    box-shadow: 
        0 6px 25px rgba(201, 162, 39, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.gilded-frame > div {
    background: var(--parchment-cream);
    border: 2px solid var(--burnt-umber);
    border-radius: 4px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--burnt-umber);
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.85rem;
    opacity: 0.7;
    display: block;
    margin-top: 0.5rem;
}

.image-preview {
    padding: 0.5rem;
    width: 100%;
}

.image-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.hidden {
    display: none;
}

/* Style selection */
.style-selection {
    background: rgba(245, 230, 200, 0.9);
    padding: 1.5rem;
    border-radius: 8px;
    border: 2px solid var(--aged-sepia);
}

.style-title {
    font-family: 'Cinzel Decorative', serif;
    text-align: center;
    color: var(--ink-black);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.style-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.wax-seal {
    background: linear-gradient(145deg, #A52A2A 0%, var(--wax-seal-red) 50%, #5C0000 100%);
    border: none;
    border-radius: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--parchment-cream);
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.75rem;
    text-align: center;
    padding: 1rem;
    transition: all 0.3s;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.wax-seal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 30% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 50%);
    pointer-events: none;
}

.wax-seal:hover {
    transform: scale(1.05);
}

.wax-seal.selected {
    box-shadow: 
        0 0 20px var(--gold-accent),
        0 0 40px rgba(201, 162, 39, 0.5),
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px var(--gold-accent), 0 0 40px rgba(201, 162, 39, 0.5), 0 4px 10px rgba(0, 0, 0, 0.4); }
    50% { box-shadow: 0 0 30px var(--gold-accent), 0 0 60px rgba(201, 162, 39, 0.7), 0 4px 10px rgba(0, 0, 0, 0.4); }
}

.seal-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.seal-text {
    line-height: 1.2;
}

/* Generate button */
.generate-button {
    background: linear-gradient(145deg, #4A3728 0%, var(--ink-black) 50%, #1A0F0A 100%);
    border: 4px solid var(--gold-accent);
    border-radius: 12px;
    padding: 1.25rem 2rem;
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.2rem;
    color: var(--parchment-cream);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.generate-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 30px rgba(201, 162, 39, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.generate-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.generate-button.generating {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.loading-quill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.loading-quill .quill {
    animation: write 0.5s ease-in-out infinite;
}

@keyframes write {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    50% { transform: translateX(5px) rotate(10deg); }
}

.quill-icon {
    margin-right: 0.25rem;
}

/* Preview column */
.preview-title {
    font-family: 'Cinzel Decorative', serif;
    color: var(--parchment-cream);
    text-align: center;
    font-size: 1.3rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Scroll preview */
.scroll-preview {
    position: relative;
    background: transparent;
}

.scroll-roll {
    height: 30px;
    background: linear-gradient(180deg, #8B7355 0%, #A08060 30%, #D4B896 50%, #A08060 70%, #8B7355 100%);
    border-radius: 15px;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 -2px 5px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
}

.scroll-roll.top {
    margin-bottom: -10px;
}

.scroll-roll.bottom {
    margin-top: -10px;
}

.scroll-content {
    background: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at center, var(--parchment-light) 0%, var(--parchment-cream) 60%, var(--aged-sepia) 100%);
    padding: 3rem 2rem;
    position: relative;
    min-height: 400px;
    box-shadow: inset 0 0 50px rgba(139, 69, 19, 0.2);
}

.ornate-border {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border: 3px double var(--aged-sepia);
    border-radius: 4px;
    pointer-events: none;
}

.corner-flourish {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--aged-sepia);
    z-index: 3;
}

.corner-flourish.top-left {
    top: 5px;
    left: 5px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 12px;
}

.corner-flourish.top-right {
    top: 5px;
    right: 5px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 12px;
}

.corner-flourish.bottom-left {
    bottom: 5px;
    left: 5px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 12px;
}

.corner-flourish.bottom-right {
    bottom: 5px;
    right: 5px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 12px;
}

.scroll-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
}

.top-flourish, .bottom-flourish {
    width: 120px;
    color: var(--burnt-umber);
}

.bottom-flourish {
    transform: scaleY(-1);
}

.vintage-frame {
    background: linear-gradient(145deg, #8B7355 0%, #A08060 50%, #8B7355 100%);
    padding: 8px;
    border-radius: 4px;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    max-width: 80%;
}

.vintage-frame img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border: 2px solid var(--ink-black);
}

.scroll-text {
    text-align: center;
    line-height: 1.8;
    color: var(--ink-black);
    padding: 0 1rem;
    max-width: 100%;
    word-wrap: break-word;
}

.scroll-text.disney-font {
    font-family: 'Great Vibes', cursive;
    font-size: 1.4rem;
}

.scroll-text.french-font {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.wax-seal-stamp {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #A52A2A 0%, var(--wax-seal-red) 50%, #5C0000 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--parchment-cream);
    font-size: 1.5rem;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    margin-top: 1rem;
}

/* Download section */
.download-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-button {
    background: linear-gradient(145deg, var(--gold-accent) 0%, #DAA520 50%, var(--gold-accent) 100%);
    border: none;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    font-family: 'Cinzel Decorative', serif;
    font-size: 1rem;
    color: var(--ink-black);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(201, 162, 39, 0.4);
}

.download-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 162, 39, 0.6);
}

.reset-button {
    background: transparent;
    border: 2px solid var(--parchment-cream);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    color: var(--parchment-cream);
    cursor: pointer;
    transition: all 0.3s;
}

.reset-button:hover {
    background: rgba(245, 230, 200, 0.1);
}

/* Footer */
.footer {
    background: linear-gradient(180deg, transparent 0%, rgba(44, 24, 16, 0.9) 20%, var(--ink-black) 100%);
    padding: 3rem 1rem 1.5rem;
    text-align: center;
    margin-top: 2rem;
    position: relative;
}

.footer .flourish {
    margin: 0 auto 1rem;
    width: 100px;
}

.footer-text {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: var(--aged-sepia);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.remix-seal {
    display: inline-block;
    background: linear-gradient(145deg, #A52A2A 0%, var(--wax-seal-red) 50%, #5C0000 100%);
    color: var(--parchment-cream);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.85rem;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.remix-seal:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.5);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .wax-seal {
        width: 100px;
        height: 100px;
        font-size: 0.7rem;
    }
    
    .scroll-content {
        padding: 2rem 1rem;
    }
    
    .scroll-text.disney-font {
        font-size: 1.2rem;
    }
    
    .scroll-text.french-font {
        font-size: 1rem;
    }
}