@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&family=JetBrains+Mono:wght@600;800&display=swap');

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: #070b14;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

code, .font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Координатна сітка робочого столу */
.bg-grid-pattern {
    background-size: 36px 36px;
    background-image: 
        linear-gradient(to right, rgba(34, 211, 238, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(34, 211, 238, 0.04) 1px, transparent 1px);
}

/* Кнопки меню */
.top-nav-btn {
    padding: 6px 11px;
    border-radius: 12px;
    border-width: 1px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.top-nav-btn:active {
    transform: scale(0.96);
}

/* Ліва навігація */
.cat-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    padding: 6px 0;
    border-radius: 12px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}
.cat-nav-btn:hover { background: rgba(255, 255, 255, 0.06); }
.cat-nav-btn.active { background: rgba(255, 255, 255, 0.14); }

.cat-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.cat-nav-btn.active .cat-icon-box {
    box-shadow: 0 0 14px currentColor;
}

/* Висувна шторка блоків */
.drawer-panel {
    position: absolute;
    left: 52px;
    top: 0;
    bottom: 0;
    z-index: 35;
    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) {
    .drawer-panel { left: 64px; }
}
.drawer-panel.drawer-closed {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   МАГНІТНІ ПАЗЛ-БЛОКИ КІБЕРПРОТОКОЛІВ
   ========================================================================== */
.formula-block {
    position: relative;
    min-height: 68px;       /*  Збільшена висота (можна поставити 70px) */
    height: auto;           /*  Дозволяє блоку підлаштовуватися під текст */
    min-width: 68px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;      /*  Більше місця зверху та знизу */
    border-radius: 12px;
    cursor: grab;
    touch-action: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    border-top-width: 1.5px;
    border-bottom-width: 1.5px;
    border-style: solid;
    transition: margin-right 0.12s ease, transform 0.1s ease;
}
.formula-block:active {
    cursor: grabbing;
}

/* Блоки у списку висувної панелі */
.palette-block {
    min-height: 68px !important;
    padding: 8px 14px !important;
    gap: 3px;
    touch-action: pan-y !important;
}

.palette-block .block-symbol {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
    color: #e2e8f0; /* М'який платиново-сірий замість їдкого #fff */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.palette-block .block-label {
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.25;
    color: #94a3b8; /* Спокійний приглушений відтінок */
    text-shadow: none;
}

/* Блоки на робочому столі */
.formula-chain .block-symbol {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
    font-family: 'JetBrains Mono', monospace;
    color: #e2e8f0; /* Спокійний м'який колір */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.formula-chain .block-label {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    color: #cbd5e1; /* Читабельний, але не сліпучий */
    margin-top: 2px;
}

/* Пазли стикування (впуклість зліва і виступ справа) */
.formula-block::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 22px;                 /* Було 18px */
    background-color: #070b14;
    border-right: inherit;
    border-top: inherit;
    border-bottom: inherit;
    border-radius: 0 4px 4px 0;
    z-index: 2;
}

.formula-block::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 22px;                 /* Було 18px */
    background-color: inherit;
    border-right: inherit;
    border-top: inherit;
    border-bottom: inherit;
    border-radius: 0 4px 4px 0;
    z-index: 3;
}

.formula-chain .formula-block:first-child::before,
.palette-block::before {
    display: none;
}

/* Кольорові схеми за категоріями */
.cat-bg-protocols { background-color: #1e293b; border-color: #38bdf8; }
.cat-bg-primary   { background-color: #064e3b; border-color: #10b981; }
.cat-bg-middle    { background-color: #78350f; border-color: #f59e0b; }
.cat-bg-senior    { background-color: #1e3a8a; border-color: #3b82f6; }
.cat-bg-expert    { background-color: #581c87; border-color: #a855f7; }

.drop-gap-right {
    margin-right: 62px !important;
}

.drop-snap-glow {
    outline: 2.5px solid #22d3ee !important;
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.9) !important;
    z-index: 40 !important;
}

.formula-chain {
    position: absolute;
    display: inline-flex;
    align-items: center;
    padding: 3px 5px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 14px;
}

.dragging-chain {
    pointer-events: none !important;
    opacity: 0.92;
    z-index: 1000;
}

/* Плаваючий смітник */
#floatingTrashZone.trash-active {
    background-color: rgba(225, 29, 72, 0.3) !important;
    border-color: #f43f5e !important;
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.6) !important;
    transform: translate(-50%, -6px) scale(1.06) !important;
}
#floatingTrashZone.trash-active .trash-icon-box {
    background-color: #ef4444 !important;
    color: #ffffff !important;
}

/* Ефекти віджета прогресу */
@keyframes cardBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 20px #22d3ee); }
    100% { transform: scale(1); }
}
.card-bounce {
    animation: cardBounce 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes tableShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
.shake-error {
    animation: tableShake 0.4s ease-in-out;
}

/* Літаючі частинки балів */
.flying-particle {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    will-change: transform, opacity;
    font-size: 24px;
    filter: drop-shadow(0 0 10px #38bdf8);
}

/* Вкладки модальних вікон */
.handbook-tab-btn {
    padding: 4px 10px;
    border-radius: 8px;
    color: #94a3b8;
    font-weight: 700;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.handbook-tab-btn:hover { color: #ffffff; background: rgba(255, 255, 255, 0.05); }
.handbook-tab-btn.active { color: #ffffff; background: #0891b2; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Анімація появи челенджу */
@keyframes fadeInSlideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
.animate-fade-in {
    animation: fadeInSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Плавний тач-скрол шторки */
#paletteBlockList {
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}