/* ===== Design Tokens ===== */
:root {
    --navy: #203240;
    --navy-light: #2a4258;
    --navy-dark: #1a2830;
    --copper: #c19274;
    --copper-light: #d4a98e;
    --copper-dark: #a87a5e;
    --white: #ffffff;
    --off-white: #f7f6f4;
    --gray-50: #fafaf9;
    --gray-100: #f0efed;
    --gray-200: #e2e0dc;
    --gray-300: #c8c5bf;
    --gray-400: #9e9a93;
    --gray-500: #6e6b65;
    --gray-600: #4a4843;
    --text: #1a1a1a;
    --text-muted: #6e6b65;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(32,50,64,0.08);
    --shadow-md: 0 4px 12px rgba(32,50,64,0.1);
    --shadow-lg: 0 8px 30px rgba(32,50,64,0.12);
    --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--off-white);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    height: 64px;
    width: auto;
}

.nav-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ===== Main ===== */
main {
    flex: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--navy);
    color: var(--white);
}
.btn-primary:hover {
    background: var(--navy-light);
}

.btn-accent {
    background: var(--copper);
    color: var(--white);
}
.btn-accent:hover {
    background: var(--copper-dark);
}

.btn-outline {
    background: transparent;
    color: var(--navy);
    border: 1.5px solid var(--gray-200);
}
.btn-outline:hover {
    border-color: var(--navy);
    background: var(--gray-50);
}

/* ===== Upload Section ===== */
.section-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding-top: 2rem;
}

.upload-hero {
    text-align: center;
    max-width: 520px;
}

.upload-hero h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.upload-hero p {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.upload-card {
    background: var(--white);
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    width: 100%;
    max-width: 540px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.upload-card:hover,
.upload-card.dragover {
    border-color: var(--copper);
    background: #fcfaf8;
    box-shadow: var(--shadow-md);
}

.upload-icon {
    color: var(--copper);
    margin-bottom: 1rem;
}

.upload-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.35rem;
}

.upload-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.file-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 1rem;
}

/* ===== Progress ===== */
.progress-card {
    max-width: 540px;
    margin: 4rem auto;
    text-align: center;
    background: var(--white);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.progress-bar {
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.progress-fill {
    height: 100%;
    background: var(--copper);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

#progress-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Results ===== */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.result-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.image-container {
    position: relative;
    background: var(--gray-50);
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container img {
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
    display: block;
}

.card-actions {
    padding: 1rem 1.25rem;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    border-top: 1px solid var(--gray-100);
}

/* ===== Edit Section ===== */
.edit-section {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--gray-100);
}

.edit-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.edit-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.edit-input-row textarea {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-family: inherit;
    resize: vertical;
    min-height: 44px;
    line-height: 1.4;
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition);
}

.edit-input-row textarea:focus {
    outline: none;
    border-color: var(--copper);
    box-shadow: 0 0 0 3px rgba(193,146,116,0.12);
}

.edit-input-row .btn {
    white-space: nowrap;
    align-self: stretch;
}

/* ===== Loader ===== */
.loader {
    position: absolute;
    inset: 0;
    background: rgba(247,246,244,0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.loader.hidden {
    display: none;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--copper);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Error ===== */
.error-card {
    max-width: 480px;
    margin: 4rem auto;
    background: var(--white);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
    border-top: 3px solid #d94f4f;
}

.error-icon {
    color: #d94f4f;
    margin-bottom: 0.75rem;
}

.error-card h3 {
    color: #d94f4f;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.error-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Footer ===== */
footer {
    background: var(--navy);
    color: var(--gray-300);
    margin-top: auto;
}

.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner {
        padding: 0.6rem 1rem;
    }

    .logo-img {
        height: 50px;
    }

    .nav-label {
        font-size: 0.75rem;
    }

    main {
        padding: 1.25rem 1rem;
    }

    .upload-hero h2 {
        font-size: 1.35rem;
    }

    .upload-hero p {
        font-size: 0.9rem;
    }

    .upload-card {
        padding: 2rem 1.5rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .image-container {
        min-height: 200px;
    }

    .image-container img {
        max-height: 400px;
    }

    .card-actions {
        flex-direction: column;
    }

    .card-actions .btn {
        width: 100%;
    }

    .edit-input-row {
        flex-direction: column;
    }

    .edit-input-row .btn {
        width: 100%;
    }

    .progress-card {
        margin: 2rem auto;
    }
}

@media (max-width: 480px) {
    .upload-hero h2 {
        font-size: 1.2rem;
    }

    .upload-card {
        padding: 1.5rem 1rem;
    }

    .upload-card h3 {
        font-size: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    .card-actions,
    .edit-section {
        padding: 0.75rem 1rem;
    }
}
