@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;600;700&family=Fira+Code:wght@400;500&display=swap');

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

:root {
    --navy: #0F2E3D;
    --navy-hover: #1a4a5e;
    --gold: #CA981A;
    --white: #FFFFFF;
    --light-gray: #f1f3f5;
    --text-primary: rgba(0, 0, 0, 1.0);
    --text-secondary: rgba(0, 0, 0, 0.8);
    --text-muted: rgba(0, 0, 0, 0.6);
    --text-light: rgba(255, 255, 255, 0.8);
    --border-radius: 4px;
    --transition: 0.2s ease;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--white);
    color: var(--text-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 1.06rem;
    line-height: 1.6;
}

header {
    background: var(--navy);
    padding: 14px 20px;
}

header .header-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.back-link {
    color: var(--gold);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--white);
}

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

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--white);
}

.header-title .subtitle {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--text-light);
    margin-top: 2px;
}

.header-controls {
    min-width: 100px;
}

main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.step-panel {
    background: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 24px;
}

.step-panel h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--navy);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    font-weight: 700;
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* Upload */
.file-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    max-width: 100%;
    background: var(--white);
    color: var(--navy);
    border: 2px solid var(--gold);
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.file-label:hover {
    background: var(--gold);
}

.file-label > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-label input[type="file"] {
    display: none;
}

/* Framing controls */
.mode-row {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 500;
}

.radio input[type="radio"] {
    accent-color: var(--gold);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.colour-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.colour-picker input[type="color"] {
    width: 40px;
    height: 28px;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    background: var(--white);
    cursor: pointer;
    padding: 0;
}

.colour-picker.hidden {
    display: none;
}

/* Cropper host */
.cropper-wrap {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 8px;
    overflow: hidden;
}

.cropper-wrap img {
    display: block;
    max-width: 100%;
}

/* When letterbox mode is active the img is shown inline without Cropper */
.cropper-wrap.letterbox img {
    max-height: 480px;
    margin: 0 auto;
}

/* Preview */
.preview-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.preview-row figure {
    background: var(--white);
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
}

.preview-row canvas {
    width: 320px;
    height: 240px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
    display: block;
    margin: 0 auto;
}

.preview-row figcaption {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: 'Fira Code', monospace;
}

@media (min-width: 760px) {
    .preview-row canvas {
        width: 400px;
        height: 300px;
    }
}

/* Download button */
.download-btn {
    display: inline-block;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Lato', sans-serif;
    border: none;
    border-radius: var(--border-radius);
    background: var(--navy);
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 12px;
}

.download-btn:hover:not(:disabled) {
    background: var(--navy-hover);
}

.download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
footer {
    background: var(--navy);
    padding: 20px;
    text-align: center;
    margin-top: 30px;
}

footer p {
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 300;
}

footer strong {
    color: var(--gold);
}

@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }

    header .header-content {
        flex-direction: column;
        text-align: center;
    }

    .back-link {
        order: -1;
    }

    .header-title h1 {
        font-size: 1.25rem;
    }

    .header-controls {
        display: none;
    }

    main {
        padding: 24px 16px;
    }

    .preview-row canvas {
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
    }
}
