* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: #d3e3ee;
    color: #183549;
    min-height: 100vh;
}

.customizer-bg {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(145deg, #eef4fb 0%, #dbe7f3 100%);
}

.customizer-stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

#sceneMain {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    background: linear-gradient(145deg, #eef4fb 0%, #dbe7f3 100%);
}

.viewer-footer {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    padding: 0.26rem 0.58rem;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    color: rgba(29, 52, 69, 0.78);
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(123, 152, 171, 0.34);
    backdrop-filter: blur(4px);
    pointer-events: none;
    user-select: none;
}

.view-navigator {
    position: absolute;
    left: 14px;
    top: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 3;
}

#viewCubeCanvas {
    width: 150px;
    height: 150px;
    border-radius: 16px;
    background: radial-gradient(ellipse at 40% 35%, rgba(255,255,255,0.45) 0%, rgba(220,235,248,0.22) 100%);
    filter: drop-shadow(0 2px 10px rgba(20,50,80,0.14));
    transition: filter 0.25s;
    cursor: grab;
    touch-action: none;
}

#viewCubeCanvas:hover {
    filter: drop-shadow(0 4px 16px rgba(20,50,80,0.24));
}

.view-nav-reset-btn {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(105, 131, 149, 0.4);
    background: rgba(255, 255, 255, 0.82);
    color: #34607e;
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
    box-shadow: 0 1px 5px rgba(20,50,80,0.1);
}

.view-nav-reset-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(20,50,80,0.18);
}

.view-nav-reset-btn:active {
    transform: scale(0.95);
}

.right-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: min(320px, 38vw);
    height: 100dvh;
    overflow: hidden;
    padding: 0.55rem;
    border-radius: 12px 0 0 12px;
    border: 1px solid rgba(112, 138, 156, 0.35);
    border-right: 0;
    background: rgba(245, 251, 255, 0.72);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.sidebar-section {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(126, 151, 168, 0.28);
    border-radius: 10px;
    padding: 0.5rem 0.55rem;
    flex-shrink: 0;
}

.sidebar-section[aria-label="Elenco parti"],
.sidebar-section[aria-label="Colori"] {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-section[aria-label="Colori"]:not([hidden]) {
    flex: 3 1 0;
}

.right-sidebar:has(.sidebar-section[aria-label="Colori"]:not([hidden])) .sidebar-section[aria-label="Elenco parti"] {
    flex: 1 1 0;
}

.sidebar-section[aria-label="Elenco parti"] .parts-list,
.sidebar-section[aria-label="Colori"] .colors-palette {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}

.sidebar-section[aria-label="Colori"][hidden] {
    display: none;
}

.sidebar-section h2 {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #19384e;
}

.lang-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.lang-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 1.45rem;
    border: 1px solid rgba(105, 131, 149, 0.45);
    background: rgba(255, 255, 255, 0.86);
    border-radius: 8px;
    padding: 0.12rem;
    cursor: pointer;
}

.lang-flag .fi {
    width: 1.35rem;
    height: 0.95rem;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
}

.lang-flag.is-active {
    border-color: rgba(87, 122, 145, 0.58);
    box-shadow: 0 0 0 2px rgba(129, 165, 188, 0.28);
}

.lang-flag:focus-visible {
    outline: 2px solid rgba(87, 122, 145, 0.8);
    outline-offset: 1px;
}

.sidebar-btn {
    appearance: none;
    border: 1px solid rgba(105, 131, 149, 0.45);
    background: rgba(255, 255, 255, 0.86);
    color: #19384e;
    border-radius: 8px;
    padding: 0.42rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.sidebar-btn.is-active {
    background: rgba(212, 233, 247, 0.95);
    border-color: rgba(87, 122, 145, 0.58);
}

.variant-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.42rem;
    margin-bottom: 0.45rem;
}

.pozzetto-toggle {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.34rem;
    margin-bottom: 0.45rem;
}

.preset-views {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.34rem;
    margin-bottom: 0.45rem;
}

.save-btn {
    width: 100%;
    margin-top: 0.15rem;
}

.save-setup-status {
    margin: 0.25rem 0 0;
    min-height: 0.8rem;
    font-size: 0.68rem;
    color: #2b4c63;
}

.setup-pdf-btn {
    display: block;
    width: 100%;
    margin-top: 0.15rem;
    text-align: center;
    text-decoration: none;
}

.setup-pdf-btn.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.sidebar-label {
    display: block;
    margin-top: 0.25rem;
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #27475d;
}

.parts-list {
    display: grid;
    gap: 0.28rem;
    max-height: none;
    overflow: auto;
    padding-right: 0.12rem;
}

.selected-part-label {
    margin: 0 0 0.3rem;
    font-size: 0.72rem;
    color: #27475d;
    font-weight: 600;
}

.color-search {
    width: 100%;
    border: 1px solid rgba(105, 131, 149, 0.45);
    background: rgba(255, 255, 255, 0.9);
    color: #19384e;
    border-radius: 8px;
    padding: 0.34rem 0.5rem;
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
}

.selected-color-label {
    margin: 0 0 0.3rem;
    min-height: 0.8rem;
    font-size: 0.7rem;
    color: #30506a;
}

.supplement-card-container {
    margin: 0.3rem 0 0.45rem;
}

.supplement-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(214,236,250,0.85), rgba(190,222,244,0.7));
    border: 1px solid rgba(80,130,170,0.35);
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(20,60,100,0.08);
}

.supplement-card:hover {
    background: linear-gradient(135deg, rgba(200,228,248,0.95), rgba(175,215,242,0.85));
    box-shadow: 0 2px 8px rgba(20,60,100,0.14);
    transform: translateY(-1px);
}

.supplement-card-swatch {
    display: block;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 7px;
    border: 2px solid rgba(255,255,255,0.75);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.supplement-card-info {
    flex: 1;
    font-size: 0.68rem;
    line-height: 1.3;
    color: #1e4660;
}

.supplement-card-info strong {
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #14566e;
}

.supplement-card-chevron {
    font-size: 0.62rem;
    color: #3a7599;
    opacity: 0.7;
}

.supplement-card-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
    gap: 4px;
    padding: 0.4rem 0.1rem 0.2rem;
    max-height: 140px;
    overflow: auto;
}

.supplement-apply-btn {
    width: 100%;
    margin: -0.18rem 0 0.45rem;
    font-size: 0.72rem;
}

.colors-palette {
    display: grid;
    gap: 0.4rem;
    max-height: none;
    overflow: auto;
    padding-right: 0.1rem;
}

.palette-section {
    display: grid;
    gap: 0.28rem;
}

.palette-section-title {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    color: #27475d;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.palette-section-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.36rem;
}

.color-swatch-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    border: 1px solid rgba(78, 100, 116, 0.42);
    cursor: pointer;
    padding: 0;
}

.color-swatch-btn.is-active {
    border: 2px solid rgba(25, 56, 78, 0.82);
}

.palette-empty {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.74rem;
    color: #3b5b71;
}

@media (max-width: 860px) {
    .view-navigator {
        left: 8px;
        top: 8px;
        width: min(150px, 42vw);
        padding: 0.34rem;
    }

    .view-nav-btn {
        font-size: 0.62rem;
        padding: 0.28rem 0.22rem;
    }

    .right-sidebar {
        width: min(34vw, 170px);
        left: auto;
        right: 0;
        transform: none;
        top: 0;
        bottom: auto;
        height: 100dvh;
        padding: 0.34rem;
        gap: 0.34rem;
        border-radius: 9px 0 0 9px;
    }

    .sidebar-section {
        padding: 0.34rem;
        border-radius: 8px;
    }

    .sidebar-section h2 {
        font-size: 0.67rem;
        margin-bottom: 0.28rem;
    }

    .lang-switch {
        gap: 0.2rem;
        margin-bottom: 0.3rem;
    }

    .lang-flag {
        height: 1.1rem;
        border-radius: 6px;
    }

    .lang-flag .fi {
        width: 1.02rem;
        height: 0.74rem;
    }

    .sidebar-btn {
        padding: 0.24rem 0.3rem;
        font-size: 0.62rem;
        border-radius: 6px;
    }

    .variant-toggle {
        gap: 0.24rem;
        margin-bottom: 0.24rem;
    }

    .pozzetto-toggle {
        gap: 0.2rem;
        margin-bottom: 0.24rem;
    }

    .preset-views {
        gap: 0.2rem;
        margin-bottom: 0.24rem;
    }

    .sidebar-label,
    .selected-part-label,
    .selected-color-label,
    .save-setup-status,
    .setup-pdf-btn {
        font-size: 0.6rem;
        margin-top: 0.18rem;
        margin-bottom: 0.18rem;
        min-height: 0.72rem;
    }

    .color-search {
        padding: 0.24rem 0.34rem;
        font-size: 0.62rem;
        margin-bottom: 0.24rem;
        border-radius: 6px;
    }

    .parts-list {
        gap: 0.2rem;
    }

    .colors-palette {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.2rem;
    }

    .viewer-footer {
        bottom: 8px;
        padding: 0.18rem 0.38rem;
        font-size: 0.56rem;
    }

    .viewer-hint {
        left: 8px;
        top: 8px;
        font-size: 0.56rem;
        padding: 0.16rem 0.34rem;
    }
}

@media (max-width: 560px) {
    .right-sidebar {
        width: min(42vw, 150px);
        height: 100dvh;
    }

    .colors-palette {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .viewer-footer {
        display: none;
    }
}

.auth-body {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    background:
        radial-gradient(circle at 18% 20%, rgba(173, 209, 243, 0.55), transparent 42%),
        radial-gradient(circle at 78% 80%, rgba(198, 227, 250, 0.44), transparent 46%),
        linear-gradient(165deg, #edf4fb 0%, #d8e7f5 54%, #c9deef 100%);
    overflow: hidden;
}

.auth-card {
    width: min(460px, 92vw);
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 18px;
    padding: 1.35rem 1.2rem 1.15rem;
    box-shadow: 0 24px 48px rgba(22, 47, 68, 0.2);
    backdrop-filter: blur(18px) saturate(138%);
    -webkit-backdrop-filter: blur(18px) saturate(138%);
    animation: auth-fade-up 520ms ease-out;
}

.auth-card h1 {
    margin: 0 0 0.72rem;
    font-size: 1.38rem;
    font-weight: 700;
    color: #1b3548;
    letter-spacing: -0.01em;
}

.auth-card form {
    display: grid;
    gap: 0.55rem;
}

.auth-card input,
.auth-card button {
    width: 100%;
    padding: 0.62rem 0.68rem;
    border-radius: 11px;
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.auth-card input {
    border: 1px solid rgba(117, 146, 170, 0.48);
    background: rgba(255, 255, 255, 0.74);
    color: #1c3a50;
    outline: none;
}

.auth-card input::placeholder {
    color: rgba(55, 83, 104, 0.6);
}

.auth-card input:focus {
    border-color: rgba(78, 133, 173, 0.78);
    box-shadow: 0 0 0 3px rgba(109, 167, 211, 0.18);
}

.auth-card button {
    border: 1px solid rgba(67, 116, 150, 0.65);
    background: linear-gradient(160deg, #86bde6 0%, #4f89b3 100%);
    color: #f7fbff;
    font-weight: 650;
    cursor: pointer;
}

.auth-card button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(46, 95, 130, 0.25);
}

.auth-card button:active {
    transform: translateY(0);
}

.auth-card a {
    color: #2f6d99;
    text-decoration: none;
}

.auth-card a:hover {
    text-decoration: underline;
}

.auth-card label,
.auth-card p,
.auth-card ul,
.auth-card li {
    color: #27465d;
    font-size: 0.9rem;
}

.auth-card p {
    margin: 0.6rem 0 0;
}

.auth-card ul {
    margin: 0;
    padding-left: 1rem;
}

.auth-card .errorlist {
    margin: 0 0 0.36rem;
    padding: 0.38rem 0.56rem;
    list-style: none;
    border-radius: 8px;
    border: 1px solid rgba(178, 86, 86, 0.45);
    background: rgba(255, 232, 232, 0.72);
    color: #8d3737;
}

.messages {
    margin: 0 0 0.8rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgba(191, 97, 97, 0.48);
    background: rgba(255, 232, 232, 0.74);
    border-radius: 8px;
    list-style: none;
    color: #8f3333;
}

.auth-body::before,
.auth-body::after {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(34px);
    z-index: 0;
    opacity: 0.34;
    animation: auth-float 12s ease-in-out infinite;
}

.auth-body::before {
    top: -95px;
    left: -75px;
    background: #8bbde2;
}

.auth-body::after {
    bottom: -110px;
    right: -82px;
    background: #aacfee;
    animation-delay: 1.8s;
}

.auth-card {
    position: relative;
    z-index: 1;
}

@keyframes auth-float {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes auth-fade-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}