:root {
    --parchment: #F5F0E8;
    --parchment-dark: #E8E0D0;
    --ink: #1A1A1A;
    --red-stamp: #8B0000;
    --red-stamp-light: #A52A2A;
    --navy: #1B2A4A;
    --gold: #C5A54E;
    --gold-dark: #9E832E;
    --faded-ink: #4A4A4A;
}

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

body {
    background-color: var(--parchment);
    color: var(--ink);
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 80px,
            rgba(139, 0, 0, 0.018) 80px,
            rgba(139, 0, 0, 0.018) 81px
        );
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: 'CLASSIFIED • OFFICIAL DOCUMENT • CLASSIFIED • OFFICIAL DOCUMENT • CLASSIFIED • OFFICIAL DOCUMENT • CLASSIFIED • OFFICIAL DOCUMENT •';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-family: 'Special Elite', monospace;
    font-size: 48px;
    color: rgba(139, 0, 0, 0.035);
    white-space: nowrap;
    pointer-events: none;
    z-index: 0;
    letter-spacing: 12px;
    width: 300%;
    text-align: center;
    line-height: 120px;
    overflow: visible;
}

.document-frame {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 20px auto;
    padding: 4px;
    border: 3px double var(--ink);
    background: var(--parchment);
}

.document-inner {
    border: 1px solid rgba(26, 26, 26, 0.3);
    padding: 40px 50px;
    position: relative;
}

@media (max-width: 768px) {
    .document-frame {
        margin: 8px;
    }
    .document-inner {
        padding: 20px 16px;
    }
}

.corner-flourish {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: var(--gold);
}
.corner-flourish.tl { top: 8px; left: 8px; border-top: 2px solid; border-left: 2px solid; }
.corner-flourish.tr { top: 8px; right: 8px; border-top: 2px solid; border-right: 2px solid; }
.corner-flourish.bl { bottom: 8px; left: 8px; border-bottom: 2px solid; border-left: 2px solid; }
.corner-flourish.br { bottom: 8px; right: 8px; border-bottom: 2px solid; border-right: 2px solid; }

.section-header {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-variant: small-caps;
    color: var(--navy);
    border-bottom: 2px solid var(--navy);
    padding-bottom: 6px;
    margin-bottom: 16px;
    letter-spacing: 1.5px;
    position: relative;
}

.section-header .regen-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid var(--red-stamp);
    color: var(--red-stamp);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 8px;
    font-family: 'IBM Plex Mono', monospace;
    transition: all 0.2s;
}
.section-header .regen-btn:hover {
    background: var(--red-stamp);
    color: var(--parchment);
}

.input-field {
    background: rgba(245, 240, 232, 0.6);
    border: 1px dashed rgba(26, 26, 26, 0.4);
    padding: 10px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    color: var(--ink);
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.input-field:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 2px rgba(27, 42, 74, 0.15);
}
.input-field::placeholder {
    color: #999;
    font-style: italic;
}

textarea.input-field {
    resize: vertical;
    min-height: 80px;
}

.stamp-button {
    display: inline-block;
    background: var(--red-stamp);
    color: #F5F0E8;
    font-family: 'Special Elite', monospace;
    font-size: 18px;
    letter-spacing: 3px;
    padding: 14px 36px;
    border: 3px solid #5A0000;
    cursor: pointer;
    text-transform: uppercase;
    position: relative;
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.15),
        0 4px 8px rgba(0,0,0,0.3),
        0 1px 3px rgba(0,0,0,0.2);
    transform: rotate(-0.5deg);
    transition: all 0.15s;
}
.stamp-button:hover {
    background: var(--red-stamp-light);
    transform: rotate(0deg) scale(1.02);
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.2),
        0 6px 12px rgba(0,0,0,0.3);
}
.stamp-button:active {
    transform: rotate(0deg) scale(0.98);
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.3),
        0 1px 2px rgba(0,0,0,0.2);
}
.stamp-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.clearance-badge {
    display: inline-block;
    border: 2px solid var(--gold);
    padding: 4px 16px;
    font-family: 'Special Elite', monospace;
    font-size: 12px;
    letter-spacing: 3px;
    color: var(--gold-dark);
    text-transform: uppercase;
}

.star-divider {
    text-align: center;
    margin: 16px 0;
    color: var(--gold);
    font-size: 14px;
    letter-spacing: 8px;
}
.star-divider::before {
    content: '— ★ —';
}

.margin-stamp {
    font-family: 'Special Elite', monospace;
    color: rgba(139, 0, 0, 0.2);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    transform: rotate(-8deg);
    display: inline-block;
    border: 1px solid rgba(139, 0, 0, 0.15);
    padding: 2px 8px;
    position: absolute;
}

.flag-frame {
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 12px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.1);
    background: white;
    padding: 4px;
    display: inline-block;
    transform: rotate(-0.5deg);
}

.portrait-frame {
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 8px rgba(0,0,0,0.2);
    background: white;
    padding: 3px;
    display: inline-block;
}

.dossier-field {
    margin-bottom: 10px;
    line-height: 1.7;
}
.dossier-field .label {
    font-weight: 700;
    color: var(--navy);
    font-variant: small-caps;
    letter-spacing: 0.5px;
}

.thin-rule {
    border: none;
    border-top: 1px solid rgba(26, 26, 26, 0.2);
    margin: 24px 0;
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    50% { border-color: transparent; }
}

@keyframes pulse-classified {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.18; }
}

.loading-text {
    font-family: 'Special Elite', monospace;
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 2s steps(40) forwards;
    border-right: 2px solid var(--ink);
}

.pulse-bg {
    animation: pulse-classified 2s ease-in-out infinite;
}

.progress-bar-container {
    width: 100%;
    height: 24px;
    border: 1px solid var(--ink);
    background: var(--parchment-dark);
    position: relative;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: repeating-linear-gradient(
        -45deg,
        var(--navy),
        var(--navy) 8px,
        #2A3D5E 8px,
        #2A3D5E 16px
    );
    transition: width 0.5s ease;
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.seal-placeholder {
    width: 64px;
    height: 64px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 10px;
    color: var(--gold-dark);
    text-align: center;
    line-height: 1.2;
}