:root {
    --bg: #0b1220;
    --bg-elev: #111a2e;
    --bg-input: #0f1729;
    --border: #1f2a44;
    --text: #e6edf7;
    --muted: #8a98b3;
    --accent: #22c55e;
    --accent-soft: rgba(34, 197, 94, 0.18);
    --danger: #ef4444;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.app {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100vh;
}

.sidebar {
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar__head h1 {
    font-size: 20px;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.sidebar__head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px 14px;
    margin: 0;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group legend {
    padding: 0 6px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--muted);
}

label.toggle {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
}

input[type="text"],
input[type="number"],
select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.swatches {
    display: flex;
    gap: 8px;
}

.swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
}

button, .primary, .secondary, .ghost {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.primary {
    background: var(--accent);
    color: #0b1220;
    padding: 12px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary:hover { filter: brightness(1.05); }
.primary:disabled { opacity: 0.6; cursor: progress; }

.buy {
    background: #f97316;
    color: #0b1220;
    border: none;
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.buy:hover { filter: brightness(1.05); }
.buy:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.secondary {
    background: var(--bg-input);
    color: var(--text);
    border-color: var(--border);
    padding: 9px 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.secondary:hover { border-color: var(--accent); }

.ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
    padding: 9px 14px;
}

.ghost:hover { border-color: var(--accent); color: var(--accent); }

.viewer {
    position: relative;
    background: radial-gradient(ellipse at top, #14213d 0%, #0b1220 70%);
    display: flex;
    align-items: center;
    justify-content: center;
}

#viewer3d {
    width: 100%;
    height: 100%;
    position: relative;
}

#viewer3d canvas { display: block; }

.placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    pointer-events: none;
}

.placeholder h2 {
    margin: 0 0 6px;
    color: var(--text);
    font-weight: 600;
}

.viewer__actions {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
}

.loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(11, 18, 32, 0.3);
    border-top-color: #0b1220;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.hint {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
}

/* Segmented product toggle */
.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}

.seg {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}

.seg input { display: none; }
.seg--on { background: var(--accent); color: #0b1220; }

/* File upload */
.filedrop {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.filedrop:hover { border-color: var(--accent); color: var(--text); }
.filedrop input[type="file"] { display: none; }

.imgpreview {
    display: block;
    max-width: 100%;
    max-height: 120px;
    margin: 4px auto 0;
    border-radius: 6px;
    background: #fff;
    padding: 4px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .sidebar { max-height: 50vh; }
}
