.cutshape-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 6px;
}

.cutshape-btn {
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: linear-gradient(135deg, rgba(255,0,77,0.9), rgba(255,138,0,0.9));
    color: #f4f4f6;
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-size: 0.85rem;
    border-radius: 0;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.35);
}

.cutshape-btn:not(.active) {
    opacity: 0.45;
}

.cutshape-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 32px rgba(0,0,0,0.4);
}

.action-toggle-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.18);
    background: linear-gradient(135deg, rgba(255,0,77,0.9), rgba(255,138,0,0.9));
    color: #f4f4f6;
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.85rem;
    border-radius: 0;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.35);
    margin-top: 6px;
}

.action-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 30px rgba(0,0,0,0.4);
}

.action-toggle-btn.active {
    background: linear-gradient(135deg, #00ffa3, #00d9ff);
    color: #03121a;
    box-shadow: 0 18px 35px rgba(0,217,255,0.35);
}

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');

:root {
    --bg-gradient: radial-gradient(circle at top, rgba(255,255,255,0.08), rgba(0,0,0,0.85)), linear-gradient(135deg, #05010c, #0b1c2c 45%, #010305 100%);
    --glass-bg: rgba(10, 14, 27, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 25px 50px rgba(2, 5, 20, 0.55);
    --accent: #ff004d;
    --accent-2: #ffd75f;
    --text-primary: #f4f4f6;
    --text-secondary: rgba(244, 244, 246, 0.75);
    --muted-border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(255, 255, 255, 0.08);
}

/* Fonts will be automatically loaded from fonts folder */

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

html, body {
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
    background: #020409;
}

body {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.06em;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 40px 80px;
    overflow-x: hidden;
    position: relative;
}

body::before,
body::after {
    content: '';
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(90px);
    z-index: 0;
    opacity: 0.35;
}

body::before {
    top: -120px;
    left: -60px;
    background: #ff004d;
}

body::after {
    bottom: -160px;
    right: -80px;
    background: #01e5ff;
}

/* Main layout */
.container {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 20px;
    background: transparent;
    min-height: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

.main-content {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    width: 100%;
    min-width: auto;
}

.left-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
}

.control-panel {
    border-radius: 5px;
    padding: 26px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(22px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-self: start;
    width: 100%;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.control-item label {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0;
    letter-spacing: 0.08em;
}

.control-item input,
.control-item select {
    padding: 8px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 5px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    transition: all 0.25s ease;
}

.control-item input:focus,
.control-item select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    background: rgba(255, 255, 255, 0.12);
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #e0e0e0;
    outline: none;
    border: none;
    flex: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #666666;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #666666;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: linear-gradient(135deg, #ff004d, #ff8a00);
    color: #0b0c16;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 12px 25px rgba(255, 0, 77, 0.35);
}

.quantity-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 18px 35px rgba(255, 0, 77, 0.4);
}

.quantity-btn:active {
    transform: translateY(0) scale(0.95);
}

.quantity-input {
    width: 60px;
    height: 30px;
    text-align: center;
    border: 1px solid #444444;
    background: #ffffff;
    color: #2a2a2a;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    padding: 0;
}

.slider-value {
    text-align: center;
    font-size: 0.85rem;
    color: #2a2a2a;
    font-weight: 600;
    background: #e0e0e0;
    padding: 4px 8px;
    border-radius: 5px;
    min-width: 40px;
    flex-shrink: 0;
}

.material-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.material-controls select {
    flex: 1;
    min-width: 120px;
}

.material-controls input[type="color"] {
    width: 40px;
    height: 35px;
    padding: 0;
    border: 1px solid #cccccc;
    border-radius: 4px;
    cursor: pointer;
}

/* Material, quantity, and checkout container */
.material-quantity-checkout-container {
    background: var(--glass-bg);
    padding: 20px;
    border-radius: 5px;
    margin-top: 0px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
    margin-left: 0;
    height: auto;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(20px);
}

.preview-area {
    border: none;
    border-radius: 0;
    padding: 40px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 700px;
    min-height: 680px;
    max-width: none;
    overflow: hidden;
    align-self: start;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(18px);
}

/* Canvas and preview styling */
#canvasWrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 0 24px 0;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    background: transparent;
    border-radius: 0;
    box-sizing: border-box;
    min-width: 150px;
    min-height: 150px;
    border: none;
    box-shadow: none;
    overflow: hidden;
}

#previewCanvas, #materialOverlay {
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    max-width: 500px;
    max-height: 500px;
    aspect-ratio: 1 / 1;
    border-radius: 0;
    box-sizing: border-box;
    display: block;
}

#svgOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#previewCanvas {
    position: relative;
    z-index: 2;
}

#materialOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    mix-blend-mode: color-burn;
    opacity: 0.85;
    transition: opacity 0.3s ease;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    display: none;
}

#uploadPrompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 18px;
    text-align: center;
    pointer-events: none;
    z-index: 1;
    font-weight: 500;
    width: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 90%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255,255,255,0.2);
    border-radius: 5px;
    padding: 40px 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

#fileInput {
    display: none;
}

/* Control groups and sections */
.control-group,
.dimensions-display,
.pricing-section,
.notes-section {
    width: 100%;
    margin-bottom: 18px;
    padding: 18px;
    border-radius: 5px;
    box-sizing: border-box;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(18px);
}

.pricing-section,
.pricing-section * {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.08em;
}

.notes-section {
    margin-bottom: 0;
}

.control-group:last-child, .dimensions-display:last-child, .pricing-section:last-child, .notes-section:last-child {
    margin-bottom: 0;
}

.control-row, .size-controls {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.size-controls {
    gap: 16px;
}

.size-input-group {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 90px;
    margin-bottom: 4px;
    letter-spacing: 0.06em;
}

input[type="number"], select, textarea {
    width: 100%;
    font-size: 0.9rem;
    padding: 8px 10px;
    border-radius: 5px;
    box-sizing: border-box;
    margin-bottom: 0;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-primary);
    letter-spacing: 0.03em;
}

input[type="number"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: rgba(255,255,255,0.45);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
    background: rgba(255,255,255,0.12);
}

input[type="number"]::placeholder,
textarea::placeholder {
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.05em;
}

/* Dimension display */
.dimension-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 0, 0, 0.1);
}

.dimension-item:last-child {
    border-bottom: none;
}

.dimension-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.dimension-value {
    font-weight: 700;
    color: var(--accent-2);
    font-size: 1.2rem;
}

/* Pricing section */
.price-display {
    font-size: 24px;
    font-weight: 700;
    margin: 6px 0;
    color: var(--text-primary);
}

#priceBreakdown {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    letter-spacing: 0.05em;
}

.pricing-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.08em;
}

.quantity-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    width: 100%;
}

.qty-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

.qty-button:hover, .qty-button.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255,255,255,0.45);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.35);
}

/* DPI display */
.dpi-display {
    padding: 8px 12px;
    border-radius: 6px;
    margin: 0;
    font-weight: 600;
    text-align: left;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    max-width: 200px;
    backdrop-filter: blur(4px);
}

.dpi-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-top: 6px;
    font-weight: 500;
    font-size: 11px;
    color: white;
}

/* Mobile DPI display - smaller and less intrusive */
@media (max-width: 768px) {
    .dpi-display {
        padding: 4px 8px;
        font-size: 10px;
        max-width: 120px;
        bottom: 5px;
        left: 5px;
    }
    
    .dpi-controls {
        gap: 4px;
        margin-top: 4px;
    }
    
    .dpi-controls label {
        font-size: 9px;
    }
}

.dpi-controls input[type="checkbox"] {
    margin: 0;
    transform: scale(1.2);
}

.dpi-controls label {
    color: white !important;
}

/* DPI warning states */
.dpi-critical {
    background: #dc2626 !important; /* Deep red */
    color: white;
}

.dpi-warning {
    background: #ea580c !important; /* Orange */
    color: white;
}

.dpi-good {
    background: #16a34a !important; /* Green */
    color: white;
}

.dpi-perfect {
    background: #059669 !important; /* Bright green */
    color: white;
}

.dpi-upscaled-good {
    background: #7c3aed !important; /* Purple for upscaled */
    color: white;
}

.dpi-low {
    background: #990000;
    color: white;
}

.dpi-mid {
    background: #cc0000;
    color: white;
}

.dpi-high {
    background: #ff0000;
    color: white;
}

.original-size {
    font-size: 14px;
    color: #667eea;
    margin-bottom: 16px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
    text-align: center;
}

/* Export buttons */
.export-btn {
    background: linear-gradient(135deg, rgba(255, 0, 77, 0.9), rgba(255, 138, 0, 0.9));
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
    font-family: 'Bebas Neue', sans-serif;
    cursor: pointer;
    padding: 8px 14px;
    width: auto;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    border-radius: 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.35);
    text-transform: uppercase;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 32px rgba(0,0,0,0.4);
}

/* Notes section */
.notes-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.08em;
}

.notes-section textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 5px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.notes-section textarea:focus {
    outline: none;
    border-color: rgba(255,255,255,0.4);
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

/* Cart flyout */
.cart-flyout-icon {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 1001;
    background: linear-gradient(135deg, #ff004d, #ff8a00);
    color: #08090f;
    border: none;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    font-size: 2rem;
    box-shadow: 0 25px 45px rgba(255, 0, 77, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cart-flyout-icon:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 35px 55px rgba(255, 0, 77, 0.55);
}

.cart-flyout {
    position: fixed;
    bottom: 100px;
    right: 32px;
    width: 420px;
    max-width: 98vw;
    background: rgba(8,10,18,0.92);
    color: #fff;
    border-radius: 5px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 30px 65px rgba(1,2,8,0.65);
    z-index: 1002;
    padding: 0 0 18px 0;
    display: flex;
    flex-direction: column;
    transform: translateY(120%) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(.4,2,.6,1);
    backdrop-filter: blur(28px);
}

.cart-flyout.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.cart-flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 26px 14px 26px;
    font-size: 1.3rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    letter-spacing: 0.08em;
}

.cart-flyout-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.8rem;
    cursor: pointer;
    margin-left: 8px;
    transition: color 0.2s ease;
}

.cart-flyout-close:hover {
    color: #fff;
}

.cart-flyout-items {
    max-height: 260px;
    overflow-y: auto;
    padding: 10px 20px 0 20px;
    font-size: 1rem;
    overflow-x: hidden;
}

.cart-flyout-item {
    background: rgba(255,255,255,0.04);
    border-radius: 5px;
    padding: 18px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
    letter-spacing: 0.05em;
}

.cart-flyout-item:last-child {
    margin-bottom: 0;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* Marching ants animation */
@keyframes marching-ants {
    to {
        stroke-dashoffset: 0;
    }
}

.marching-ants {
    stroke: #FF0000;
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 6, 4;
    stroke-dashoffset: 10;
    animation: marching-ants 0.5s linear infinite;
}

/* Zoom control */
.preview-scale-control {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 15px;
    border-radius: 0;
    backdrop-filter: blur(5px);
}

.zoom-icon {
    color: #ffffff;
    flex-shrink: 0;
}

.preview-scale-control input[type="range"] {
    width: 120px;
    height: 4px;
    background: #ffffff;
    outline: none;
    border: none;
    border-radius: 2px;
    cursor: pointer;
}

.preview-scale-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: 2px solid #2a2a2a;
}

.preview-scale-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: 2px solid #2a2a2a;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        gap: 20px;
        align-items: center;
        padding: 16px 0;
    }
    
    .main-content {
        flex-direction: column;
        width: 100%;
        max-width: 600px;
        gap: 20px;
    }
    
    .canvas-section, .controls-section {
        width: 100%;
        max-width: 600px;
        min-width: 0;
        min-height: 480px;
        height: auto;
        margin: 0 auto;
    }
    
    #canvasWrapper, #previewCanvas, #materialOverlay {
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        height: auto;
        aspect-ratio: 1 / 1;
        min-height: 240px;
        max-height: 100vw;
    }
}

/* Full page layout - adjustable height like tablet but keep original width */
@media (min-width: 1101px) {
    .container {
        height: 100vh; /* Use full viewport height */
        align-items: flex-start;
    }
    
    .main-content {
        height: 100vh; /* Full viewport height */
    }
    
    .preview-area {
        height: 100% !important; /* Override base 654px height */
        min-height: 0 !important; /* Override base 654px min-height */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #canvasWrapper {
        height: 100%;
        width: 100%;
        max-height: 100%;
        min-height: 150px !important; /* Reduced minimum height for full view */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #previewCanvas, #materialOverlay {
        object-fit: contain;
        display: block;
    }
}

/* Tablet layout - maintain desktop positioning but scale preview height */
@media (max-width: 1100px) and (min-width: 769px) {
    .container {
        flex-direction: row !important; /* Force side-by-side layout */
        gap: 0; /* Remove gap between panels */
        align-items: flex-start;
        padding: 0; /* Remove top/bottom padding */
        height: 100vh; /* Use full viewport height */
        width: 100vw; /* Use full viewport width */
        max-width: 100vw; /* Prevent growing beyond viewport */
        box-sizing: border-box;
        overflow-x: hidden; /* Hide any overflow */
    }
    
    .main-content {
        flex-direction: row !important; /* Force side-by-side layout */
        width: 100%;
        max-width: none;
        gap: 0; /* Remove gap between panels */
        height: 100vh; /* Full viewport height */
    }
    
    .preview-area {
        height: 100% !important; /* Override base 654px height */
        min-height: 0 !important; /* Override base 654px min-height */
        flex: 1; /* Take remaining space after left and right panels */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .right-panel {
        width: 225px !important; /* Force 225px width in tablet view */
        flex: 0 0 225px !important; /* Prevent flex growth/shrink */
        max-width: 225px !important; /* Ensure it doesn't exceed 225px */
    }
    
    #canvasWrapper {
        height: 100%;
        width: 100%;
        max-height: 100%;
        min-height: 150px !important; /* Reduced minimum height for tablet - override mobile rule */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #previewCanvas, #materialOverlay {
        object-fit: contain;
        display: block;
    }
    
    .left-panel {
        height: 100%; /* Use full available height */
        overflow-y: auto; /* Allow scrolling if content is too tall */
        flex-shrink: 0; /* Prevent shrinking */
        flex-grow: 0; /* Prevent growing */
        width: 25%; /* Left panel takes 25% of width */
        min-width: 300px; /* Prevent getting smaller than 300px */
        display: flex;
        flex-direction: column;
    }
    
    
    
    .control-panel {
        height: 100%;
        overflow-y: auto;
        flex: 1;
    }
    
    .material-quantity-checkout-container {
        height: 100%;
        overflow-y: auto;
        flex: 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 8px 0;
        gap: 16px;
    }
    
    .main-content {
        flex-direction: column;
        width: 100%;
        max-width: 100vw;
        gap: 16px;
        padding: 0 8px;
    }
    
    .preview-area {
        order: 1;
        width: 100%;
        max-width: 100vw;
        padding: 12px;
        border-radius: 8px;
        min-height: 0;
        height: auto;
    }
    
    .left-panel {
        order: 2;
        width: 100%;
        max-width: 100vw;
        padding: 12px;
        border-radius: 8px;
        min-height: 0;
        height: auto;
    }
    
    .control-panel {
        width: 100% !important;
        max-width: 100% !important;
        padding: 16px;
        margin: 0;
        border-radius: 8px;
    }
    
    .control-item {
        width: 100%;
        margin-bottom: 12px;
    }
    
    .control-item input,
    .control-item select {
        width: 100%;
        box-sizing: border-box;
    }
    
    .padding-buttons {
        width: 100% !important;
        display: flex;
        gap: 8px;
        justify-content: stretch;
    }
    
    .padding-btn {
        flex: 1;
        min-width: 0;
    }
    
    .material-tiles {
        width: 100%;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .right-panel {
        order: 3;
        width: 100%;
        max-width: 100vw;
        padding: 12px;
        border-radius: 8px;
        min-height: 0;
        height: auto;
    }
    
    #canvasWrapper {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        min-height: 150px;
        max-height: 80vw;
        position: relative;
    }
    
    #previewCanvas, #materialOverlay {
        width: 100% !important;
        height: 100% !important;
        min-width: 0;
        min-height: 0;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        display: block;
    }
    
    .cart-flyout-icon {
        position: fixed;
        top: 16px;
        right: 16px;
        bottom: auto;
        z-index: 1001;
        background: #8B0000;
        color: #fff;
        border: none;
        border-radius: 50%;
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
        box-shadow: 0 4px 16px rgba(0,0,0,0.25);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
    }
    
    .cart-flyout-icon:hover {
        background: #A52A2A;
    }
    
    .cart-flyout {
        position: fixed;
        top: 80px;
        right: 16px;
        bottom: auto;
        width: calc(100vw - 32px);
        max-width: 400px;
        background: #18181a;
        border: 1px solid #333;
        border-radius: 5px;
        padding: 16px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.3);
        z-index: 1000;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 4px 0;
        gap: 12px;
    }
    
    .main-content {
        gap: 12px;
        padding: 0 4px;
    }
    
    .preview-area, .left-panel, .right-panel {
        padding: 8px;
        border-radius: 6px;
    }
    
    .control-panel {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px;
        margin: 0;
        border-radius: 6px;
    }
    
    .control-item {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .control-item input,
    .control-item select {
        width: 100%;
        box-sizing: border-box;
    }
    
    .padding-buttons {
        width: 100% !important;
        display: flex;
        gap: 6px;
        justify-content: stretch;
    }
    
    .padding-btn {
        flex: 1;
        min-width: 0;
    }
    
    .material-tiles {
        width: 100%;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    #canvasWrapper {
        min-height: 120px;
        max-height: 70vw;
    }
    
    #previewCanvas, #materialOverlay {
        width: 100% !important;
        height: 100% !important;
        min-width: 0;
        min-height: 0;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        display: block;
    }
    
    .cart-flyout-icon {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
    
    .cart-flyout {
        top: 70px;
        right: 12px;
        width: calc(100vw - 24px);
        padding: 12px;
        max-height: calc(100vh - 90px);
    }
    
    .control-group, .dimensions-display, .pricing-section, .notes-section {
        padding: 8px;
        border-radius: 0;
    }
    
    input[type="number"], select, textarea {
        font-size: 14px;
        padding: 8px 8px;
        border-radius: 4px;
    }
    
    .export-btn {
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 4px;
        width: calc(100% - 24px);
        margin: 0 12px;
    }
}

/* Material Tiles Styles */
.material-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
    width: 100%;
}

.material-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 2px solid #444;
    border-radius: 8px;
    background: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 90px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.material-tile:hover {
    border-color: #667eea;
    background: #444;
    transform: translateY(-2px);
}

.material-tile.selected {
    border-color: #764ba2;
    background: #4a4a4a;
    box-shadow: 0 0 10px rgba(118, 75, 162, 0.3);
}

/* Sold out state */
.material-tile.sold-out {
    background: #7f1d1d;
    border-color: #b91c1c;
    position: relative;
}
.material-tile.sold-out .material-name {
    color: #ffdada;
}
.sold-out-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.material-preview {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #555;
    margin-bottom: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #666;
    flex-shrink: 0;
}

.material-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.material-name {
    font-size: 11px;
    color: #ccc;
    text-align: center;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
