:root {
    /* Color Palette - Cura Inspired */
    --bg-deep: #1A1A1A;
    --bg-panel: rgba(36, 36, 36, 0.85);
    /* Glass effect */
    --accent-blue: #4D90FE;
    --accent-cyan: #00E5FF;
    --text-primary: #FFFFFF;
    --text-muted: #B0B0B0;


    /* Typography */
    --font-main: 'Inter', system-ui, Avenir, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

body {
    margin: 0;
    overflow: hidden;
    /* Fullscreen 3D */
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-main);
    user-select: none;
    /* App-like feel */
}

#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

canvas {
    display: block;
    outline: none;
}

/* UI Overlay Container */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
    /* Let clicks pass to canvas where no UI */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
}

/* Common UI Panel */
.panel {
    /* Restore background for visibility - REMOVED for line style */
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;

    /* Vital for interaction */
    pointer-events: auto;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.panel:hover {
    transform: translateY(-2px);
    border-color: rgba(77, 144, 254, 0.3);
}

/* Header / Top Bar */
.header {
    align-self: flex-start;
    display: flex;
    gap: 20px;
    align-items: center;
}

h1 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.brand-accent {
    color: var(--accent-cyan);
}

/* Slider Container (Right Side) */
.slider-container {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    height: auto;
    display: flex;
    flex-direction: row;
    /* Side by side */
    align-items: center;
    gap: 20px;

    /* Restore background for visibility */
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

/* Fix for conflicting transforms on hover */
.slider-container:hover {
    border-color: rgba(77, 144, 254, 0.3);
}

/* Custom Slider Styles */
/* Robust Vertical Slider using Transform */
/* Custom Slider Styles */
/* Robust Vertical Slider using Transform */
.slider-wrapper {
    position: relative;
    width: 60px;
    /* Increased interactive width */
    height: 50vh;
    /* Fixed height for the interactive area */
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto !important;
    /* Vital for interaction */
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;

    /* Dimensions are for the HORIZONTAL state before rotation */
    width: 50vh !important;
    /* Visual Height */
    height: 60px;
    /* Visual Width / Hit Area - Increased for easier touch */

    /* Rotate to make vertical */
    transform: rotate(-90deg);
    transform-origin: center;

    /* Fix layout focus outline */
    outline: none;
    margin: 0;
    padding: 0;
    flex-shrink: 0;

    border: none;
    box-shadow: none;
    border-radius: 0;
    pointer-events: auto !important;
}

input[type=range]:focus::-webkit-slider-runnable-track {
    background: #00E5FF;
}

/* Track Styling (Thin Line) */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    /* Thin line */
    background: #00E5FF;
    /* Cyan Neon */
    box-shadow: 0 0 8px #00E5FF;
    border-radius: 0;
    border: none;
    pointer-events: auto !important;
}

/* Thumb Styling */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #FFFFFF;
    border: 2px solid #00E5FF;
    box-shadow: 0 0 10px #00E5FF;
    margin-top: -9px;
    /* Center on 2px track */
    pointer-events: auto !important;
    cursor: pointer;
}

/* Firefox Support */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 2px;
    background: #00E5FF;
    box-shadow: 0 0 8px #00E5FF;
    border-radius: 0;
    border: none;
}

input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border: 2px solid #00E5FF;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 0 10px #00E5FF;
    cursor: pointer;
}

/* Fallback for standard range inputs rotated if needed, 
   but for now we'll use a wrapper if standard vertical isn't supported perfectly.
   Let's stick to standard vertical for simplicity first, or CSS transform. */

.upload-btn {
    background: transparent;
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    pointer-events: auto;
}

.upload-btn:hover {
    background: rgba(77, 144, 254, 0.1);
    box-shadow: 0 0 15px rgba(77, 144, 254, 0.4);
}

.slice-counter {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent-cyan);
    font-weight: 700;
    white-space: nowrap;
    /* Rotated text to match vertical slider */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

/* Slice Preview Panel */
.slice-preview-panel {
    position: absolute;
    left: 20px;
    top: 100px;
    background: var(--bg-panel);
    border: 1px solid var(--accent-cyan);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.slice-preview-panel h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#sliceCanvas {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
    border-radius: 4px;
}

/* Modal Styles */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto;
}

.modal-content {
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid var(--accent-cyan);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 400px;
}

.modal-content h2 {
    margin: 0;
    text-align: center;
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.modal-body {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.input-group input {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--accent-cyan);
    border-radius: 12px;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 2.5rem;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus {
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
    background: rgba(0, 229, 255, 0.05);
}

.input-group label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.primary-btn,
.secondary-btn {
    padding: 10px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    border: none;
    transition: all 0.2s;
}

.primary-btn {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.primary-btn:hover {
    background: #fff;
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.6);
}

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
}

.secondary-btn:hover {
    color: #fff;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* Chrome/Safari/Edge input spinner removal */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Bubble Panel */
.bubble-panel {
    position: absolute;
    left: 20px;
    bottom: 20px;
    /* positioned at bottom left */
    background: var(--bg-panel);
    border: 1px solid var(--accent-cyan);
    padding: 20px;
    width: 320px;
    border-radius: 8px;
    z-index: 1000;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.bubble-panel h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bubble-settings {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    gap: 8px;
}

.value-input {
    width: 60px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
}

.value-input:focus {
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
    background: rgba(0, 229, 255, 0.05);
}

.value-input::-webkit-inner-spin-button,
.value-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=range].horizontal-slider {
    width: 100%;
    transform: none !important;
    height: 5px !important;
    width: 80% !important;
    margin: 10px auto !important;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.2s;
}

.action-btn:hover {
    background: rgba(0, 229, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #00E5FF;
}

input:focus+.slider {
    box-shadow: 0 0 1px #00E5FF;
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}