:root {
    --bg: #f2efe8;
    --card: rgba(255, 255, 255, 0.9);
    --ink: #1e1b18;
    --muted: #6a6259;
    --accent: #0d7a66;
    --accent-soft: #daf2ed;
    --border: rgba(30, 27, 24, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, #fff8ea, transparent 35%),
        linear-gradient(135deg, #ece6db 0%, #dbe8e4 100%);
    min-height: 100vh;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.hero,
.viewer-card,
.picker-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 24px 28px;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1,
h2,
.subcopy,
.picker-header p {
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 48px);
    line-height: 1.05;
}

.subcopy,
.picker-header p,
.status {
    color: var(--muted);
}

.subcopy {
    max-width: 700px;
    margin-top: 10px;
    line-height: 1.5;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    padding: 14px 22px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.primary-button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.file-button {
    text-align: center;
}

.viewer-card,
.picker-card {
    padding: 18px;
}

.viewer-stage {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 18px;
}

#sourceImage,
#overlay {
    display: block;
    width: 100%;
    max-width: min(600px, calc(80vw - 80px));
    height: auto;
}

#sourceImage {
    display: none;
}

#overlay {
    position: relative;
    z-index: 1;
}

.status {
    position: absolute;
    left: 16px;
    bottom: 16px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 14px;
}

.picker-card {
    margin-top: 20px;
}

.picker-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    margin-bottom: 18px;
}

h2 {
    font-size: 22px;
}

.accessory-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.accessory-option {
    background: white;
    border: 2px solid transparent;
    border-radius: 18px;
    padding: 14px 20px;
    cursor: pointer;
    min-width: 130px;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.accessory-option.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.d-none {
    display: none !important;
}

.glasses-library-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.glasses-library-container h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--ink);
}

.glasses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
}

.glass-item {
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.glass-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-soft);
}

.glass-item.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.glass-item img,
.hat-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.hat-library-container {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.hat-library-container h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--ink);
}

.hat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
}

.hat-item {
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.hat-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-soft);
}

.hat-item.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

@media (max-width: 780px) {
    .hero,
    .picker-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-shell {
        width: min(100% - 20px, 1120px);
        padding-top: 20px;
    }
}
