@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700;800&display=swap');

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    background-color: #0b0f19;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Приховування скролбару для горизонтальних стрічок */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Кнопки верхньої панелі */
.top-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #1f2937;
    border: 1px solid #374151;
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    cursor: pointer;
    flex-shrink: 0;
}
.top-icon-btn:hover {
    background: #374151;
    color: #38bdf8;
    transform: translateY(-1px);
}
.top-icon-btn.active {
    background: #0c4a6e;
    border-color: #38bdf8;
    color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.cad-action-btn {
    padding: 6px 10px;
    border-radius: 9px;
    background: #1f2937;
    border: 1px solid #374151;
    font-size: 11px;
    font-weight: 700;
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    cursor: pointer;
    flex-shrink: 0;
}
.cad-action-btn:hover {
    background: #374151;
    border-color: #4b5563;
}
.cad-action-btn.active {
    background: #78350f;
    border-color: #f59e0b;
    color: #fde68a;
}

.hud-circle-btn {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: #1f2937;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    cursor: pointer;
}
.hud-circle-btn:hover {
    background: #374151;
    color: #38bdf8;
}

/* Нижня панель інструментів на полотні */
.world-tool-btn {
    padding: 6px 10px;
    border-radius: 11px;
    background: #1e293b;
    border: 1px solid transparent;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.world-tool-btn:hover {
    background: #334155;
    color: #f8fafc;
}
.world-tool-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.5);
}

/* Бокові ярлики (Tabs) */
.side-tab-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #192233;
    border: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-tab-btn:hover {
    background: #223049;
    border-color: #38bdf8;
    transform: scale(1.05);
}
.side-tab-btn.active {
    background: #0f2744;
    border-color: #0284c7;
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.45);
}
.side-tab-btn .tab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #10b981;
    color: #020617;
    font-size: 8px;
    font-weight: 900;
    font-family: 'JetBrains Mono', monospace;
    padding: 1px 4px;
    border-radius: 6px;
}

/* Висувні праві панелі */
.bio-drawer {
    position: absolute;
    right: 44px;
    top: 0;
    bottom: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    transform: translateX(0);
    opacity: 1;
}
@media (min-width: 640px) {
    .bio-drawer {
        right: 48px;
    }
}
.bio-drawer.drawer-closed {
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
}

/* Панель конструктора: на мобільних знизу, на ПК зліва */
.builder-expanded {
    height: 39dvh;
    max-height: 330px;
}
.builder-collapsed {
    height: 44px !important;
}
.builder-collapsed #builderBody {
    display: none !important;
}

@media (min-width: 1024px) {
    .builder-expanded {
        height: 100%;
        max-height: none;
    }
    .builder-collapsed {
        display: none !important;
    }
}

/* Дозволяємо скрол усередині панелей, незважаючи на touch-action: none на body */
#partsPaletteContainer,
#partCategories,
#inspectorBody,
#encyclopediaBody,
#eventLogList,
aside {
    touch-action: pan-x pan-y;
}

/* Категорії органел */
.cat-pill {
    padding: 4px 8px;
    border-radius: 8px;
    background: #1e293b;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid #334155;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.cat-pill:hover {
    color: #ffffff;
    border-color: #475569;
}
.cat-pill.active {
    background: #0c4a6e;
    color: #38bdf8;
    border-color: #0284c7;
}

/* Картка органели в палітрі */
.part-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 11px;
    padding: 7px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}
.part-card:hover {
    background: #17233a;
    border-color: #38bdf8;
    transform: translateY(-1px);
}
.part-card:active {
    transform: scale(0.97);
}
.part-card.used-in-bp {
    border-color: rgba(16, 185, 129, 0.45);
}

.cad-slider {
    accent-color: #0284c7;
    height: 5px;
    border-radius: 4px;
    background: #334155;
    outline: none;
    cursor: pointer;
}

/* Скролбар */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: #0b0f19;
}
::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #374151;
}

@supports (height: 100dvh) {
    body {
        height: 100dvh !important;
    }
}


.table-scale-btn {
    padding: 5px 0;
    border-radius: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}
.table-scale-btn:hover {
    color: #ffffff;
    border-color: #38bdf8;
}
.table-scale-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(2, 132, 199, 0.45);
}

@media (max-width: 1023px) {
    .builder-expanded {
        height: 43dvh;
        max-height: 360px;
    }
}