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

:root {
    --bg: #0b0d12;
    --panel: #11141b;
    --panel-light: #171b24;
    --border: #292e39;
    --text: #f5f7fb;
    --muted: #8d95a5;
    --accent: #7c5cff;
    --accent-light: #a894ff;
    --success: #49d17d;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(
            circle at 20% 10%,
            rgba(124, 92, 255, 0.14),
            transparent 30%
        ),
        radial-gradient(
            circle at 80% 80%,
            rgba(75, 130, 255, 0.08),
            transparent 30%
        ),
        var(--bg);

    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* =========================
   HEADER
========================= */

header {
    height: 72px;

    padding: 0 32px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid var(--border);

    background: rgba(11, 13, 18, 0.82);

    backdrop-filter: blur(14px);

    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    font-size: 20px;
    font-weight: 700;

    letter-spacing: -0.4px;
}

.header-badge {
    font-size: 11px;

    color: var(--accent-light);

    border: 1px solid rgba(124, 92, 255, 0.35);

    background: rgba(124, 92, 255, 0.08);

    padding: 8px 12px;

    border-radius: 999px;

    letter-spacing: 0.7px;
}


/* =========================
   MAIN
========================= */

main {
    width: min(1400px, 94%);

    margin: 0 auto;

    padding: 42px 0;

    display: grid;

    grid-template-columns:
        minmax(340px, 440px)
        minmax(500px, 1fr);

    gap: 24px;
}


/* =========================
   PANELS
========================= */

.control-panel,
.viewer-panel {
    background: rgba(17, 20, 27, 0.88);

    border: 1px solid var(--border);

    border-radius: 22px;

    padding: 28px;

    box-shadow:
        0 20px 70px rgba(0, 0, 0, 0.25);
}


/* =========================
   TITLE
========================= */

h1 {
    font-size: clamp(30px, 4vw, 46px);

    line-height: 1.05;

    letter-spacing: -1.8px;

    margin-bottom: 16px;
}

h1 span {
    color: var(--accent-light);
}

.description {
    color: var(--muted);

    line-height: 1.6;

    margin-bottom: 28px;

    max-width: 380px;
}


/* =========================
   UPLOAD
========================= */

.upload-box {
    border: 1px dashed #414858;

    background: rgba(255, 255, 255, 0.015);

    border-radius: 18px;

    padding: 28px 20px;

    text-align: center;

    transition: 0.25s ease;
}

.upload-box:hover {
    border-color: var(--accent);

    background: rgba(124, 92, 255, 0.04);
}

.upload-icon {
    width: 54px;
    height: 54px;

    display: grid;
    place-items: center;

    margin: 0 auto 14px;

    border-radius: 15px;

    background: rgba(124, 92, 255, 0.12);

    font-size: 25px;
}

.upload-box h3 {
    font-size: 16px;

    margin-bottom: 6px;
}

.upload-box p {
    color: var(--muted);

    font-size: 13px;

    margin-bottom: 18px;
}

.upload-box button,
.download-area button {
    border: 1px solid var(--border);

    background: var(--panel-light);

    color: var(--text);

    padding: 11px 16px;

    border-radius: 11px;

    cursor: pointer;

    font-weight: 600;

    transition: 0.2s ease;
}

.upload-box button:hover,
.download-area button:hover:not(:disabled) {
    border-color: var(--accent);

    background: rgba(124, 92, 255, 0.12);
}


/* =========================
   IMAGE PREVIEW
========================= */

.image-preview-container {
    display: none;

    margin-top: 18px;

    border: 1px solid var(--border);

    border-radius: 16px;

    overflow: hidden;

    background: #090b0f;
}

.preview-title {
    padding: 10px 14px;

    color: var(--muted);

    font-size: 12px;

    border-bottom: 1px solid var(--border);
}

#imagePreview {
    width: 100%;

    max-height: 240px;

    object-fit: contain;

    display: block;
}


/* =========================
   TRIANGLE CONTROL
========================= */

.triangle-section {
    margin-top: 28px;

    padding: 20px;

    border: 1px solid var(--border);

    border-radius: 17px;

    background: rgba(255, 255, 255, 0.015);
}

.triangle-header {
    display: flex;

    align-items: center;

    justify-content: space-between;

    margin-bottom: 18px;
}

.triangle-header label {
    font-weight: 600;
}

.triangle-value {
    color: var(--accent-light);

    font-size: 22px;

    font-weight: 700;
}

.triangle-value small {
    font-size: 11px;

    color: var(--muted);

    margin-left: 2px;
}


/* RANGE SLIDER */

#triangleSlider {
    width: 100%;

    appearance: none;

    height: 6px;

    border-radius: 20px;

    background:
        linear-gradient(
            to right,
            var(--accent) 0%,
            var(--accent) 49.5%,
            #303540 49.5%,
            #303540 100%
        );

    outline: none;
}

#triangleSlider::-webkit-slider-thumb {
    appearance: none;

    width: 20px;
    height: 20px;

    border-radius: 50%;

    background: white;

    border: 4px solid var(--accent);

    cursor: pointer;

    box-shadow:
        0 0 0 4px rgba(124, 92, 255, 0.12);
}

#triangleSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;

    border-radius: 50%;

    background: white;

    border: 4px solid var(--accent);

    cursor: pointer;
}

.slider-labels {
    display: flex;

    justify-content: space-between;

    margin-top: 9px;

    color: var(--muted);

    font-size: 10px;
}


/* =========================
   TRIANGLE INFO
========================= */

.triangle-info {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 8px;

    margin-top: 20px;
}

.triangle-info div {
    text-align: center;

    padding: 10px 5px;

    background: rgba(255, 255, 255, 0.025);

    border-radius: 10px;
}

.triangle-info strong {
    display: block;

    font-size: 14px;
}

.triangle-info span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 10px;
}


/* =========================
   GENERATE
========================= */

.generate-button {
    width: 100%;

    margin-top: 20px;

    border: none;

    padding: 16px;

    border-radius: 13px;

    background: var(--accent);

    color: white;

    font-size: 15px;

    font-weight: 700;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
}

.generate-button:hover {
    transform: translateY(-1px);

    box-shadow:
        0 10px 30px rgba(124, 92, 255, 0.28);
}

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

.generate-button:disabled {
    opacity: 0.55;

    cursor: not-allowed;

    transform: none;

    box-shadow: none;
}


/* =========================
   STATUS
========================= */

.status {
    text-align: center;

    color: var(--muted);

    font-size: 12px;

    margin-top: 13px;

    min-height: 18px;
}


/* =========================
   VIEWER
========================= */

.viewer-panel {
    min-width: 0;
}

.viewer-header {
    display: flex;

    align-items: flex-start;

    justify-content: space-between;

    gap: 20px;

    margin-bottom: 18px;
}

.viewer-header h2 {
    font-size: 19px;

    margin-bottom: 5px;
}

.viewer-header p {
    color: var(--muted);

    font-size: 12px;
}

.model-stats {
    display: flex;

    gap: 8px;
}

.model-stats div {
    min-width: 85px;

    padding: 9px 11px;

    border: 1px solid var(--border);

    border-radius: 11px;

    background: rgba(255, 255, 255, 0.02);
}

.model-stats span {
    display: block;

    color: var(--muted);

    font-size: 9px;
}

.model-stats strong {
    display: block;

    margin-top: 3px;

    font-size: 13px;
}


/* =========================
   3D VIEWER
========================= */

.viewer {
    position: relative;

    width: 100%;

    min-height: 560px;

    overflow: hidden;

    border-radius: 17px;

    border: 1px solid var(--border);

    background:
        radial-gradient(
            circle at center,
            #1b202b,
            #0b0e14 70%
        );
}

.viewer canvas {
    width: 100%;

    height: 100%;

    display: block;
}

.viewer-placeholder {
    position: absolute;

    inset: 0;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    text-align: center;

    pointer-events: none;
}

.placeholder-icon {
    font-size: 54px;

    margin-bottom: 15px;

    opacity: 0.7;
}

.viewer-placeholder h3 {
    font-size: 17px;

    margin-bottom: 7px;
}

.viewer-placeholder p {
    color: var(--muted);

    font-size: 12px;
}


/* =========================
   DOWNLOAD
========================= */

.download-area {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 10px;

    margin-top: 15px;
}

.download-area button {
    width: 100%;
}

.download-area button:disabled {
    opacity: 0.35;

    cursor: not-allowed;
}


/* =========================
   FOOTER
========================= */

footer {
    width: min(1400px, 94%);

    margin: 0 auto;

    padding: 0 0 30px;

    display: flex;

    justify-content: space-between;

    color: var(--muted);

    font-size: 11px;
}


/* =========================
   RESPONSIVE
========================= */

@media (max-width: 950px) {

    main {
        grid-template-columns: 1fr;

        width: min(720px, 94%);
    }

    .viewer {
        min-height: 500px;
    }

}


@media (max-width: 600px) {

    header {
        padding: 0 18px;
    }

    .header-badge {
        display: none;
    }

    main {
        padding: 22px 0;
    }

    .control-panel,
    .viewer-panel {
        padding: 20px;

        border-radius: 17px;
    }

    .viewer-header {
        flex-direction: column;
    }

    .model-stats {
        width: 100%;
    }

    .model-stats div {
        flex: 1;
    }

    .viewer {
        min-height: 420px;
    }

    .download-area {
        grid-template-columns: 1fr;
    }

    footer {
        flex-direction: column;

        gap: 6px;
    }
}
