/* =========================================
1. БАЗОВЫЕ НАСТРОЙКИ И ФОН
========================================= */
:root {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-dark: #4f46e5;
    --glass: rgba(20, 20, 30, 0.75);
    --glass-light: rgba(30, 30, 40, 0.85);
    --border: rgba(255, 255, 255, 0.15);
    --border-light: rgba(255, 255, 255, 0.25);
    --text: #f1f5f9;
    --text-muted: #cbd5e1;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #1e1e1e;
    font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont,
        sans-serif;
    user-select: none;
    -webkit-user-select: none;
    color: var(--text);
    position: relative;
}

/* Анимированные пятна на фоне */
body::before,
body::after {
    content: "";
    position: fixed;
    width: 50vw;
    height: 50vw;
    max-width: 500px;
    max-height: 500px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    z-index: -2;
    animation: floatGlow 25s infinite alternate ease-in-out;
    pointer-events: none;
}
body::before {
    top: -10%;
    left: -10%;
    background: radial-gradient(
        circle,
        rgba(99, 102, 241, 0.6) 0%,
        rgba(0, 0, 0, 0) 70%
    );
}
body::after {
    bottom: -10%;
    right: -10%;
    background: radial-gradient(
        circle,
        rgba(139, 92, 246, 0.5) 0%,
        rgba(0, 0, 0, 0) 70%
    );
    animation-delay: -10s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    100% {
        transform: translate(50px, 50px) scale(1.05);
    }
}

/* Шум (зернистость) для текстуры */
.noise-overlay {
    position: fixed;
    inset: 0;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160"%3E%3Crect width="1" height="1" fill="rgba(255,255,255,0.04)"/%3E%3C/svg%3E');
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

/* =========================================
   2. ЗАГРУЗЧИК И DRAG-DROP
   ========================================= */
#loader {
    position: absolute;
    inset: 0;
    background: #1e1e1e;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s ease-out;
    pointer-events: none;
}
.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 24px;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#drop-zone {
    position: absolute;
    inset: 20px;
    background: rgba(99, 102, 241, 0.08);
    z-index: 1500;
    border: 2px dashed var(--primary);
    border-radius: 24px;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: inset 0 0 40px rgba(99, 102, 241, 0.1), 0 0 60px rgba(99, 102, 241, 0.2);
}
#drop-zone.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1.02);
    border-color: var(--primary-hover);
    box-shadow: inset 0 0 60px rgba(99, 102, 241, 0.15), 0 0 80px rgba(99, 102, 241, 0.3);
}

/* =========================================
3. UI КОМПОНЕНТЫ (ОБЩИЕ)
========================================= */
.ui-panel {
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}


.circle-btn {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    overflow: hidden;
}

.circle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.circle-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

.circle-btn:hover::before {
    opacity: 1;
}

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

.circle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.circle-btn.active::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
}

/* Tooltips для кнопок левой панели */
.tooltip-container {
    position: relative;
}

.tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--glass-light);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 300;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) translateX(-10px);
}

.tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--border);
}

.tooltip::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--glass-light);
    margin-right: -1px;
}

.tooltip-container:hover .tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    pointer-events: auto;
}

#langBtn span {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    filter: grayscale(0.2);
}

#langBtn:hover span {
    filter: grayscale(0);
}

/* Выпадающие меню (Язык и Справка) */
.lang-menu,
.info-content {
    position: absolute;
    left: 88px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 200;
    background: var(--glass-light);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.lang-menu {
    top: 8px;
    width: 160px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.info-content {
    top: 0;
    width: 280px;
    padding: 20px;
}

.lang-menu.visible,
.info-content.visible {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.lang-opt {
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.lang-opt::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.lang-opt:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(4px);
}

.lang-opt:hover::before {
    transform: scaleY(1);
}

/* Содержимое справки */
.info-content > div[style*="font-weight: bold"] {
    margin-bottom: 16px !important;
    margin-top: 0 !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    font-size: 14px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.info-content > div[style*="font-weight: bold"]:not(:first-of-type) {
    margin-top: 20px !important;
}

.shortcut {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
    transition: color 0.2s ease;
}
.shortcut:last-child {
    border: none;
    margin-bottom: 0;
}
.shortcut:hover {
    color: var(--text);
}
.key {
    background: rgba(99, 102, 241, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
    color: white;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-weight: 600;
    font-size: 11px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* =========================================
   5. НИЖНЯЯ ПАНЕЛЬ (DOCK) - ОБНОВЛЕННАЯ
   ========================================= */
.bottom-bar {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    animation: floatPanel 20s ease-in-out infinite;
    background: var(--glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
@keyframes floatPanel {
    0%, 100% {
        transform: translate3d(-50%, 0, 0);
    }
    50% {
        transform: translate3d(-50%, -6px, 0);
    }
}

.divider {
    width: 1px;
    height: 32px;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        rgba(255, 255, 255, 0.2) 20%, 
        rgba(255, 255, 255, 0.2) 80%, 
        transparent 100%);
    margin: 0 4px;
}

.action-group {
    display: flex;
    gap: 10px;
}

/* Кнопки */
.btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0 24px;
    height: 48px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-3px);
    color: white;
    border-color: var(--border-light);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    padding: 0 32px;
    position: relative;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 14px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    box-shadow: var(--shadow-glow), 0 0 30px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

.btn-primary:hover::after {
    opacity: 1;
}

input[type="file"] {
    display: none;
}

/* =========================================
   6. НАВИГАЦИЯ (КУБ СПРАВА)
   ========================================= */
.view-cube {
    position: absolute;
    top: 50%;
    left: 24px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    z-index: 90;
    padding: 8px;
    width: 60px; /* Фиксированная ширина для всех панелей */
    box-sizing: border-box;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.view-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.view-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.view-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.view-btn:hover::before {
    opacity: 1;
}

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

/* =========================================
   7. TOAST И LIL-GUI
   ========================================= */
#toast {
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 28px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 13px;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 2000;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.3);
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lil-gui {
    --background-color: rgba(20, 20, 30, 0.85);
    --text-color: #f1f5f9;
    --title-background-color: #6366f1;
    --widget-color: #444;
    font-size: 12px;
    font-family: inherit;
}
.lil-gui.root {
    position: absolute;
    top: 24px;
    right: 24px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 110;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    border-radius: 16px;
    border: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}
/* Скроллбар для GUI */
.lil-gui.root::-webkit-scrollbar {
    width: 4px;
}
.lil-gui.root::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* =========================================
   ЛЕВАЯ ПАНЕЛЬ (Справка, Z-Up и Габариты)
   ========================================= */
.z-up-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 8px;
    width: 60px; /* Фиксированная ширина для всех панелей */
    box-sizing: border-box;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Кнопка Z-UP использует стили circle-btn */
.z-up-float {
    display: flex;
}

/* На мобильных устройствах */
@media (max-width: 600px) {
    .z-up-panel {
        top: 16px;
        left: 16px;
        padding: 6px;
        width: 56px; /* Немного меньше на мобильных */
    }
}

/* =========================================
   8. МОБИЛЬНАЯ АДАПТАЦИЯ
   ========================================= */
@media (max-width: 600px) {
    .circle-btn {
        width: 40px;
        height: 40px;
        font-size: 15px;
    }

    /* Нижняя панель - улучшенный дизайн */
    .bottom-bar {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 32px);
        max-width: 420px;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        border-radius: 24px;
        background: var(--glass);
        backdrop-filter: blur(24px) saturate(180%);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.1);
        animation: floatPanel 20s ease-in-out infinite;
    }

    .divider {
        display: none;
    }

    .action-group,
    .main-action,
    .tools-action {
        width: 100%;
    }

    .main-action .btn {
        width: 100%;
        height: 52px;
        font-size: 14px;
        letter-spacing: 1px;
        border-radius: 16px;
    }

    .main-action .btn-primary {
        box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    .tools-action {
        display: flex;
        gap: 12px;
    }

    .tools-action .btn {
        flex: 1;
        height: 48px;
        font-size: 12px;
        padding: 0 16px;
        border-radius: 14px;
        letter-spacing: 0.8px;
    }

    /* Панель ракурсов - улучшенный дизайн */
    .view-cube {
        top: auto;
        bottom: 280px;
        left: 16px;
        right: auto;
        transform: none;
        flex-direction: column;
        align-items: center;
        padding: 6px;
        width: 56px; /* Немного меньше на мобильных */
        background: var(--glass);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }

    .view-btn {
        width: 38px;
        height: 38px;
        font-size: 10px;
    }

    /* Lil GUI на мобилках */
    .lil-gui.root {
        top: 16px;
        right: 16px;
        width: 260px;
        max-height: 65vh;
        border-radius: 16px;
        border: 1px solid var(--border);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }

    /* Меню и справка - улучшенный дизайн */
    .lang-menu,
    .info-content {
        left: 72px;
        top: 0;
    }

    .lang-menu {
        top: 8px;
        width: 160px;
    }

    .info-content {
        width: calc(100vw - 100px);
        max-width: 280px;
        padding: 18px;
    }


    /* Toast для мобильных */
    #toast {
        top: 16px;
        left: 50%;
        transform: translateX(-50%);
        padding: 10px 20px;
        font-size: 12px;
        max-width: calc(100% - 32px);
        white-space: normal;
        text-align: center;
    }

    /* Загрузчик для мобильных */
    .spinner {
        width: 44px;
        height: 44px;
        margin-bottom: 20px;
    }

    /* Drop zone для мобильных */
    #drop-zone {
        inset: 16px;
        border-radius: 20px;
        font-size: 16px;
        letter-spacing: 1.5px;
    }

    /* Улучшенные touch-цели для мобильных */
    .btn,
    .circle-btn,
    .view-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Скрываем tooltips на мобильных устройствах */
    .tooltip {
        display: none;
    }

    /* Улучшенная читаемость текста на мобильных */
    .btn {
        font-weight: 700;
    }

    /* Адаптивные отступы для мобильных */
    body {
        padding: 0;
    }
}

/* Стили для десктопа */
@media (min-width: 601px) {
    .lang-menu,
    .info-content {
        left: 88px;
    }
    
    .view-cube {
        left: 24px;
    }

    .z-up-panel {
        top: 24px;
        left: 24px;
    }
}

/* Дополнительные улучшения для планшетов */
@media (min-width: 601px) and (max-width: 1024px) {
    .bottom-bar {
        padding: 12px 20px;
    }

    .btn {
        padding: 0 20px;
        height: 46px;
    }

    .btn-primary {
        padding: 0 28px;
    }

    .top-left-controls {
        top: 20px;
        left: 20px;
        width: 60px; /* Явно задаем ширину для планшетов */
    }

    .view-cube {
        left: 20px;
        width: 60px; /* Явно задаем ширину для планшетов */
    }

    .z-up-panel {
        left: 20px;
        width: 60px; /* Явно задаем ширину для планшетов */
    }

    .lil-gui.root {
        top: 20px;
        right: 20px;
    }
}

/* Улучшения для очень маленьких экранов */
@media (max-width: 360px) {
    .bottom-bar {
        width: calc(100% - 24px);
        padding: 14px;
        gap: 10px;
    }

    .main-action .btn {
        height: 50px;
        font-size: 13px;
    }

    .tools-action .btn {
        height: 46px;
        font-size: 11px;
        padding: 0 12px;
    }

    .z-up-panel {
        top: 12px;
        left: 12px;
        padding: 5px;
        width: 52px; /* Еще меньше на очень маленьких экранах */
    }

    .view-cube {
        width: 52px; /* Еще меньше на очень маленьких экранах */
    }

    .circle-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }

    .view-cube {
        left: 12px;
        bottom: 260px;
        padding: 5px;
        width: 52px; /* Еще меньше на очень маленьких экранах */
    }

    .view-btn {
        width: 42px;
        height: 42px;
        font-size: 9px;
    }

    .info-content {
        width: calc(100vw - 80px);
        max-width: 260px;
        padding: 16px;
    }

    .lang-menu {
        width: 150px;
    }
}

.flag-icon {
    width: 22px;
    height: 16px;
    object-fit: cover;
    border-radius: 3px;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    margin-right: 6px; /* Отступ от текста в меню */
}

/* Поправка для круглой кнопки, чтобы флаг был по центру */
#currentFlag .flag-icon {
    margin-right: 0;
}

/* Контейнер для меток (поверх Canvas) */
.dim-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Пропускаем клики сквозь текст */
    overflow: hidden;
    z-index: 50;
    display: none; /* Скрыто по умолчанию */
}
.dim-overlay.visible {
    display: block;
}

/* Сами метки с размерами */
.dim-tag {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: #00b894; /* Яркий цвет для контраста */
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%); /* Центрируем относительно точки */
    white-space: nowrap;
    text-shadow: 0 1px 2px black;
}

/* Активное состояние кнопки линейки */
#dimBtn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: var(--primary);
}

/* Улучшенные метки размеров */
.dim-tag {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #34d399;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(52, 211, 153, 0.3);
    box-shadow: var(--shadow-md), 0 0 10px rgba(52, 211, 153, 0.2);
}