body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    margin: 0;
    height: 100vh;
    background-color: #eef2f5;
    user-select: none;
    overflow: hidden;
    overscroll-behavior: none;
}

/* --- ZOOM BEREICH --- */
#canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 50px;
    position: relative;
}

#zoom-wrapper {
    position: relative;
    transform-origin: center center;
    will-change: transform;
}

#zoom-wrapper.animate-zoom {
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#rect {
    position: relative;
    border: 4px solid #2c3e50;
    background-color: #ffffff;
    box-sizing: border-box;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    border-radius: 4px;
}

/* --- MOBILE TOP BAR --- */
#mobile-topbar {
    display: none;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 105;
}

#mobile-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: #27ae60;
    background: rgba(255,255,255,0.95);
    padding: 8px 15px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    backdrop-filter: blur(5px);
}

#btn-settings-toggle {
    font-size: 1.5rem;
    background: rgba(255,255,255,0.95);
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: transform 0.2s;
}

#btn-settings-toggle:active {
    transform: scale(0.9);
}

/* --- EINSTELLUNGS-PANEL --- */
#settings-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
    z-index: 100;
    width: 260px;
    backdrop-filter: blur(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#price {
    font-size: 1.8rem;
    font-weight: bold;
    color: #27ae60;
    text-align: center;
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #34495e;
    font-weight: 600;
}

.setting-row input[type="number"] {
    width: 70px;
    padding: 6px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    text-align: right;
    font-weight: bold;
    outline: none;
    transition: border-color 0.2s;
}

.setting-row input[type="number"]:focus {
    border-color: #3498db;
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

#btn-share {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#btn-share:hover {
    background-color: #219a52;
}

#btn-share:active {
    transform: scale(0.97);
}

#btn-reset {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

#btn-reset:hover {
    background-color: #c0392b;
}

#btn-reset:active {
    transform: scale(0.97);
}

/* --- ZOOM CONTROLS --- */
#zoom-controls {
    position: absolute;
    bottom: 140px;
    left: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border-radius: 8px;
    border: 1px solid #ddd;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

#zoom-controls button {
    background: none;
    border: none;
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    cursor: pointer;
    color: #2c3e50;
    transition: background 0.2s;
    font-weight: bold;
}

#zoom-controls button:hover {
    background: #eef2f5;
}

#zoom-controls button:active {
    background: #ddd;
}

#zoom-level {
    font-weight: bold;
    font-size: 0.9rem;
    width: 55px;
    text-align: center;
    color: #2c3e50;
}

/* --- TOR & RAUM ELEMENTE --- */
#door {
    position: absolute;
    bottom: -4px;
    height: 8px;
    background-color: #ffffff;
    border-left: 3px solid #e74c3c;
    border-right: 3px solid #e74c3c;
    box-sizing: border-box;
    z-index: 10;
    cursor: grab;
    touch-action: none;
}

#door:active {
    cursor: grabbing;
}

.door-handle {
    position: absolute;
    top: -6px;
    width: 16px;
    height: 20px;
    background-color: #c0392b;
    cursor: ew-resize;
    border-radius: 4px;
    z-index: 15;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    touch-action: none;
    transition: transform 0.2s;
}

.door-handle:hover {
    transform: scale(1.2);
}

#door-handle-left { left: -8px; }
#door-handle-right { right: -8px; }

#door-label {
    position: absolute;
    top: -22px;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: #e74c3c;
    font-weight: bold;
    pointer-events: none;
}

.label {
    position: absolute;
    font-size: 1.2rem;
    font-weight: bold;
    color: #34495e;
    white-space: nowrap;
}

#label-width { bottom: -35px; left: 50%; transform: translateX(-50%); }
#label-length-left { left: -60px; top: 50%; transform: translateY(-50%); }
#label-length-right { right: -60px; top: 50%; transform: translateY(-50%); }

#drag-handle {
    position: absolute;
    bottom: -14px;
    right: -14px;
    width: 28px;
    height: 28px;
    background-color: #3498db;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: se-resize;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 20;
    touch-action: none;
    transition: transform 0.2s, background 0.2s;
}

#drag-handle:hover {
    background-color: #2980b9;
    transform: scale(1.15);
}

/* --- PALETTE UNTEN --- */
#palette {
    height: 120px;
    background: #ffffff;
    border-top: 2px solid #bdc3c7;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 15px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.08);
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.palette-item {
    width: 90px;
    height: 100px;
    border: 2px dashed #bdc3c7;
    border-radius: 10px;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.65rem;
    font-weight: bold;
    color: #333;
    cursor: grab;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 5px;
    box-sizing: border-box;
}

.palette-item:hover {
    background: #f1f2f6;
    border-color: #95a5a6;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.palette-item:active {
    transform: translateY(0) scale(0.95);
}

.palette-item .preview-img {
    width: 45px;
    height: 45px;
    margin-bottom: 5px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.2));
}

/* --- PLATZIERTE OBJEKTE --- */
.workspace-item {
    position: absolute;
    cursor: grab;
    box-sizing: border-box;
    z-index: 5;
    transform-origin: center center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid transparent;
    touch-action: none;
    transition: filter 0.3s ease, border-color 0.3s ease;
    filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.4));
}

.workspace-item:active {
    cursor: grabbing;
}

.workspace-item.selected {
    border: 2px dashed #f1c40f;
    z-index: 15;
    filter: drop-shadow(0px 10px 15px rgba(0,0,0,0.5)) drop-shadow(0px 0px 8px rgba(241, 196, 15, 0.8));
}

.workspace-item.colliding {
    border: 2px dashed #e74c3c !important;
    filter: drop-shadow(0px 0px 15px rgba(231, 76, 60, 0.9)) !important;
}

.rot-handle {
    position: absolute;
    top: -50px;
    left: 50%;
    margin-left: -20px;
    width: 40px;
    height: 40px;
    background-color: #f39c12;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 1.5rem;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: grab;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    z-index: 20;
    touch-action: none;
}

.rot-handle:active {
    cursor: grabbing;
    background-color: #e67e22;
}

.rot-handle::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 18px;
    width: 4px;
    height: 18px;
    background-color: #f39c12;
}

/* --- KONTEXTMENÜ --- */
#context-menu {
    position: absolute;
    flex-direction: column;
    background: #2c3e50;
    padding: 10px;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-origin: bottom center;
}

#context-menu.show {
    opacity: 1;
    pointer-events: auto;
}

#item-info {
    color: #ecf0f1;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 8px;
}

#item-name {
    font-weight: bold;
    color: #f1c40f;
    margin-bottom: 4px;
}

#item-cm {
    font-size: 0.85rem;
    opacity: 0.8;
}

#context-menu-actions {
    display: flex;
    gap: 8px;
}

#context-menu button {
    background: #ecf0f1;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.1s;
}

#context-menu button:hover { background: #bdc3c7; }
#context-menu button:active { transform: scale(0.95); }
#context-menu .btn-danger { background: #e74c3c; color: white; }
#context-menu .btn-danger:hover { background: #c0392b; }

#btn-move {
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    padding: 0 12px;
    cursor: move;
    font-weight: bold;
    touch-action: none;
}

/* --- ABSTANDSLINIEN --- */
.dist-line { position: absolute; background-color: #3498db; z-index: 50; pointer-events: none; display: none; }
.dist-line.h { height: 2px; }
.dist-line.v { width: 2px; }

.dist-label {
    position: absolute;
    background: #2980b9;
    color: white;
    font-size: 0.8rem;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.dist-line.h .dist-label { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.dist-line.v .dist-label { top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* --- RESPONSIVE MOBILE CSS --- */
@media (max-width: 768px) {
    #mobile-topbar { display: flex; }
    
    #settings-panel {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-20px);
        top: 65px;
        right: 10px;
        width: 240px;
        display: block;
    }
    
    #settings-panel.show-mobile {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
    
    #price { display: none; }
    #zoom-controls { bottom: 135px; left: 10px; }
    
    .rot-handle {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        top: -55px;
        margin-left: -20px;
    }
    
    .rot-handle::after {
        height: 20px;
        bottom: -20px;
        left: 18px;
    }
    
    #context-menu button, #btn-move {
        padding: 8px 12px;
        font-size: 1rem;
    }
}