/* Same CSS as before, but ensuring no AR button styles and correct overlay positioning */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --success-color: #10b981;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    animation: fadeInDown 0.6s ease-out;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

.controls-panel {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.6s ease-out;
}

.file-section {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.file-label {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}

.file-label:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.file-label:active {
    transform: translateY(0);
}

.btn {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.viewer-container {
    position: relative;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

model-viewer {
    width: 100%;
    height: 85vh;
    border-radius: 12px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

model-viewer.measurement-mode {
    cursor: crosshair !important;
}

model-viewer.gray-mode {
    filter: grayscale(100%) brightness(0.9);
}

model-viewer.negative-mode {
    filter: invert(100%) hue-rotate(180deg);
}

model-viewer.red-to-purple-mode {
    filter: hue-rotate(270deg);
}

.placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.placeholder-content p {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.placeholder-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Overlay Controls */
.viewer-controls-overlay {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    right: 2rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    animation: fadeInUp 0.6s ease-out 0.3s both;
    pointer-events: auto;
}

.viewer-controls-overlay .control-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.viewer-controls-overlay .control-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.viewer-controls-overlay input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-dark);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.viewer-controls-overlay input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.viewer-controls-overlay input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

.viewer-controls-overlay input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.viewer-controls-overlay input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

.viewer-controls-overlay input[type="range"]:disabled {
    opacity: 0.5;
}

.info-panel {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.info-item {
    flex: 1;
    min-width: 250px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.icon {
    font-size: 1.2rem;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    model-viewer {
        height: 500px;
    }

    .file-section {
        flex-direction: column;
    }

    .file-label {
        min-width: 100%;
    }

    .viewer-controls-overlay {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Technical HUD Styling */
model-viewer {
    background-color: transparent;
}

/* Unified Bottom Toolbar */
.bottom-toolbar {
    /* Layout positioning is now handled by the flex container order, 
       but we keep it 'absolute' relative to viewer OR just part of the flow.
       Given the container flow, let's make it an overlay at the bottom for maximum screen space 
       OR a dedicated bar. Overlay is cooler (`position: absolute`). Dedicated is safer.
       Let's stick to Overlay for that "Immersive" feel. */
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    padding: 0.75rem 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10;

    /* Responsive Scroll */
    max-width: 95%;
    flex-wrap: wrap; /* Allow wrapping on narrow screens */
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dimensions-group {
    display: flex;
    gap: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    animation: fadeInRight 0.3s ease-out both;
}

/* Streamlined Buttons */
.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateY(-1px);
}

.btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    padding: 0.5rem;
}

/* Compact Dimension Values */
.dim-item {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.dim-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 0.5rem;
}

.dim-label {
    font-size: 0.75rem;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
}

.dim-value-compact {
    font-size: 1rem;
    font-weight: 600;
    color: #f8fafc;
    font-family: 'Courier New', monospace;
    min-width: 4ch;
}

.dim-ft {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-left: 0.25rem;
}

/* Color Coding */
.dim-label.x-axis {
    color: #ef4444;
}

/* Red */
.dim-label.y-axis {
    color: #10b981;
}

/* Green */
.dim-label.z-axis {
    color: #3b82f6;
}

/* Blue */


/* Human Hotspot Styling */
.hotspot-human {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    width: auto;
    height: auto;
    transform-origin: bottom center;
    /* Scale from feet up */
    pointer-events: none;
    /* Let clicks pass through */
    display: none;
    /* Hidden by default */
}

.human-silhouette {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(16, 185, 129, 0.9);
    /* Matrix/Tech Green */
    filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.5));
}

.human-silhouette svg {
    height: 180px;
    /* Base height, scaled by JS */
    width: auto;
    display: block;
}

.hotspot-label {
    margin-top: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: sans-serif;
    white-space: nowrap;
}

/* Axis Gizmo Styling */
.axis-gizmo {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
}

.axis-arrow {
    position: absolute;
    bottom: 0;
    left: 0;
    transform-origin: bottom left;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.axis-arrow span {
    padding-left: 5px;
}

/* X Axis - Red - Points Right */
.axis-x {
    width: 60px;
    height: 3px;
    background: #ef4444;
    color: #ef4444;
}

/* Y Axis - Green - Points Up */
.axis-y {
    width: 3px;
    height: 60px;
    background: #10b981;
    color: #10b981;
    flex-direction: column;
    justify-content: flex-start;
}

.axis-y span {
    padding-left: 0;
    padding-bottom: 5px;
}

/* Z Axis - Blue - Points "Forward" (Perspective hint) */
/* Since it's 2D overlay, we slant it to fake 3D depth */
.axis-z {
    width: 45px;
    height: 3px;
    background: #3b82f6;
    color: #3b82f6;
    transform: rotate(135deg);
    /* Slant down/left for "forward" or up/right for "back" */
    transform-origin: left center;
}

/* Point Measurement Overlay */
.measurement-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.measurement-point {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
    animation: pulse-point 1.5s ease-in-out infinite;
}

@keyframes pulse-point {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
    }

    50% {
        box-shadow: 0 0 16px rgba(59, 130, 246, 1);
    }
}

.measurement-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transform-origin: left center;
    box-shadow: 0 0 4px rgba(59, 130, 246, 0.6);
}

.measurement-label {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(59, 130, 246, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.measurement-label-metric {
    color: #3b82f6;
}

.measurement-label-imperial {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-left: 8px;
}

/* Precision Zoom Slider Control */
.zoom-slider-container {
    position: absolute;
    bottom: 2.3rem;
    right: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
    transition: all 0.3s ease;
}

.zoom-slider-container:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(99, 102, 241, 0.3);
}

.zoom-slider-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zoom-slider {
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    width: 8px;
    height: 120px;
    background: linear-gradient(to top, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.zoom-slider:hover {
    background: linear-gradient(to top, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: grab;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.6);
    transition: all 0.2s ease;
    border: 2px solid white;
}

.zoom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.8);
}

.zoom-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.zoom-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    cursor: grab;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.6);
    transition: all 0.2s ease;
}

.zoom-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.8);
}

.zoom-slider::-moz-range-thumb:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.zoom-slider-markers {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #94a3b8;
    user-select: none;
}

.zoom-marker {
    line-height: 1;
    font-weight: 600;
}

.zoom-marker-center {
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* Numbered Markers */
.numbered-marker {
    position: absolute;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.6);
    cursor: pointer;
    user-select: none;
    animation: marker-appear 0.3s ease-out;
    z-index: 60;
}

.numbered-marker:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.8);
}

@keyframes marker-appear {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ========== RESPONSIVE MOBILE STYLES ========== */
@media (max-width: 768px) {
    .container {
        padding: 0;
    }

    header {
        padding: 0.5rem 1rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        background: rgba(15, 23, 42, 0.95);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 20;
        flex-shrink: 0;
    }

    header h1 {
        font-size: 1.1rem;
        margin: 0;
    }

    header p {
        display: none;
    }

    .controls-panel {
        margin: 0;
        padding: 0.5rem;
        background: var(--bg-card);
        border-radius: 0;
        display: flex;
        justify-content: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        z-index: 15;
        flex-shrink: 0;
    }

    .file-section {
        width: 100%;
        display: flex;
        gap: 0.5rem;
        justify-content: center;
    }

    .file-label {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        flex: 1;
        max-width: 200px;
    }

    #reset-btn {
        padding: 0.5rem;
        width: auto;
    }

    /* Fixed Bottom Toolbar */
    .bottom-toolbar {
        position: relative;
        bottom: 1rem;
        width: 95%;
        padding: 0.5rem;
        gap: 0.5rem;
        border-radius: 12px;
        justify-content: flex-start;
        margin: 0 auto;
    }

    .btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .zoom-slider-container {
        background: rgba(15, 23, 42, 0.6);
        bottom: 5rem;
        transform: scale(0.9);
    }
}

/ *   N u m b e r e d   M a r k e r   H o t s p o t s   ( f o r   3 D   p o s i t i o n i n g )   * /  ?????????????????/???????????????????????4? †???????????††???????††???›??? †??????????????????(???????????????††???›?8???????????? †???????›???††???????? †??????›???††??????????††?????????????††?????›‰?8?8?????????????††???›?????††??????????††?????? †??????›??? †???????????††????????????????????????????????????????††?????›‰?8??????????????? †?????›?????????? ????????
/* Dimensions Modal Dialog */
.dimensions-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(99, 102, 241, 0.5);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: none;
    min-width: 300px;
}

.dimensions-modal.active {
    display: block;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.dimensions-modal h3 {
    margin: 0 0 1.5rem 0;
    color: var(--primary-color);
    font-size: 1.3rem;
    text-align: center;
}

.dimensions-modal .dim-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dimensions-modal .dim-row:last-child {
    border-bottom: none;
}

.dimensions-modal .dim-label {
    font-size: 1.1rem;
    font-weight: 600;
}

.dimensions-modal .dim-values {
    display: flex;
    gap: 1rem;
    font-family: 'Courier New', monospace;
}

.dimensions-modal .dim-value {
    font-size: 1rem;
}

/* FORCE FIX FOR MODAL */
.dimensions-modal { position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; z-index: 2147483647 !important; display: none; }
.dimensions-modal.active { display: block !important; }
