:root {
    /* Color Palette - Strict Monochrome */
    --bg-color: #ffffff;
    --text-color: #000000;
    --border-color: #000000;
    --pane-bg: #ffffff;
    
    /* Typography */
    /* Serif for the Interface/Authority */
    /* --font-serif: "Georgia", "Times New Roman", Times, serif; */
    --font-serif: "Courier New", Courier, "Lucida Sans Typewriter", monospace;
    /* Monospace for the Data/Inputs */
    --font-mono: "Courier New", Courier, "Lucida Sans Typewriter", monospace;
}

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

body {
    font-family: var(--font-serif);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* LAYOUT: CSS GRID 
   Rows: Content (1fr) -> Footer (auto)
*/
.app-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto; 
    min-height: 100vh;
    border-top: 5px solid var(--border-color); /* Masthead line */
}

.pane {
    padding: 2rem 2.5rem;
    position: relative;
    background: var(--pane-bg);
}

/* --- HEADER & TYPOGRAPHY --- */

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    letter-spacing: -0.05rem;
    line-height: 1;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

hr {
    border: 0;
    border-bottom: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* --- INPUTS PANE (Left) --- */

.control-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* The Brutalist Input Style */
input, textarea, select {
    width: 100%;
    padding: 1rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 0; /* Crucial: No rounded corners */
    
    /* Data font */
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-color);
    
    /* Reset native styles */
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--text-color);
    outline-offset: -2px;
    background-color: #fff;
}

/* Custom Arrow for Select */
select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path d="M0 7.33l2.829-2.83 9.175 9.339 9.167-9.339 2.829 2.83-11.996 12.17z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    cursor: pointer;
}

/* Form Visibility Animation */
.input-form {
    display: none;
    animation: fadeIn 0.3s ease;
}

/* Advanced Options Module */
details.advanced-options {
    margin-top: 2rem;
    border: 1px solid var(--border-color);
    padding: 0;
    background: #fdfdfd; /* Slight contrast from white */
}

summary {
    cursor: pointer;
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    list-style: none; /* Hide default triangle */
    background-color: #f0f0f0;
    border-bottom: 1px solid transparent; /* Prepare for expansion */
    transition: background 0.1s;
}

/* Custom indicator logic if you want complete control, 
   but standard text [+]/[-] is very brutalist. */
details[open] summary {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--border-color); /* Invert header when open */
    color: var(--bg-color);
}

details .control-group {
    padding: 1.5rem;
    margin-bottom: 0; /* Override default margin inside box */
    border-bottom: 1px solid var(--border-color);
}

details .control-group:last-child {
    border-bottom: none;
}

.input-form.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- PREVIEW PANE (Right) --- */

.preview-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.sticky-wrapper {
    width: 100%;
    max-width: 320px;
    padding-top: 1rem;
}

/* QR Container - The "Art" */
#qr-container {
    width: 256px;
    height: 256px;
    margin: 0 auto 2rem auto;
    
    /* Frame */
    border: 1px solid var(--border-color);
    padding: 10px; 
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

#qr-container img, #qr-container canvas {
    display: block;
    max-width: 100%;
    image-rendering: pixelated; /* Crisp edges */
}

/* Buttons */
button {
    width: 100%;
    padding: 1rem;
    background-color: var(--text-color); /* Black */
    color: var(--bg-color); /* White */
    border: 1px solid var(--text-color);
    border-radius: 0;
    
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.1s;
}

button:hover:not(:disabled) {
    background-color: var(--bg-color);
    color: var(--text-color);
    /* Inverted effect */
}

button:disabled {
    background-color: #f0f0f0;
    color: #aaa;
    border-color: #ccc;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* --- FOOTER --- */

.app-footer {
    grid-column: 1 / -1; /* Span full width */
    border-top: 5px solid var(--border-color); /* Thick closure line */
    padding: 3rem 2rem;
    background-color: var(--bg-color);
    text-align: center;
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.8;
}

.app-footer p {
    margin-bottom: 0.5rem;
}

.app-footer a {
    color: var(--text-color);
    text-decoration: underline;
    font-family: var(--font-mono);
}

.app-footer a:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
    text-decoration: none;
}

/* --- RESPONSIVE / DESKTOP --- */

@media (min-width: 768px) {
    .app-container {
        /* Sidebar fixed 400px, Content fluid */
        grid-template-columns: 400px 1fr; 
        max-width: 100%;
        margin: 0;
        border-top: none;
    }

    .input-pane {
        border-right: 1px solid var(--border-color);
        /* Allow natural height so page scrolls to footer */
        height: auto; 
        min-height: 100vh;
    }

    .preview-pane {
        min-height: 100vh;
        justify-content: center; /* Center Vertically */
        
        /* Engineering Paper Texture */
        background-color: #fdfdfd;
        background-image: radial-gradient(#000 0.5px, transparent 0.5px);
        background-size: 20px 20px;
    }
    
    .sticky-wrapper {
        position: sticky;
        top: 2rem;
        background: #fff;
        padding: 2rem;
        border: 1px solid black;
        box-shadow: 10px 10px 0px 0px #000; /* Hard Block Shadow */
    }
}

/* --- PRINT STYLES (The Manifest) --- */

@media print {
    /* Hide Interface */
    .input-pane, header, hr, button, .app-footer {
        display: none !important;
    }

    .app-container {
        display: block;
        border: none;
        margin: 0;
        padding: 0;
    }

    .preview-pane {
        height: auto;
        min-height: 0;
        background: none;
        display: block;
        padding: 0;
    }

    .sticky-wrapper {
        border: 4px solid black;
        box-shadow: none;
        max-width: 100%;
        width: 100%;
        padding: 4rem;
        position: static;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    #qr-container {
        border: none;
        width: 400px;
        height: 400px;
        margin-bottom: 2rem;
    }

    /* Print Timestamp/Watermark */
    .sticky-wrapper::after {
        content: "GENERATED OUTPUT // DO NOT FOLD";
        display: block;
        margin-top: 2rem;
        font-family: var(--font-mono);
        font-size: 1rem;
        font-weight: bold;
        letter-spacing: 2px;
        text-transform: uppercase;
        border-top: 2px solid black;
        padding-top: 1rem;
        width: 100%;
        text-align: center;
    }
}

/* Styling the Number Input */
input[type="number"] {
    -moz-appearance: textfield; /* Remove Firefox spinner */
}
/* Remove Webkit spinners if you prefer a cleaner look */
input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}

/* Color Group Layout */
.color-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.color-input label {
    margin-bottom: 0.5rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    background: #fff;
}

/* The Color Swatch Itself */
input[type="color"] {
    border: none;
    width: 2rem;
    height: 2rem;
    padding: 0;
    margin-right: 1rem;
    background: none;
    cursor: pointer;
}

/* Color Swatch Internal (Webkit) */
input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 0; /* Square swatch */
}

/* The Hex Code Text next to it */
.input-wrapper span {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-transform: uppercase;
}
