@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #070b14;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

@supports (height: 100dvh) {
    body {
        height: 100dvh !important;
    }
}

code, pre, .font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Компактні кнопки верхнього меню */
.top-nav-btn {
    padding: 6px 9px;
    border-radius: 10px;
    border-width: 1px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 800;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.top-nav-btn:active {
    transform: scale(0.95);
}

/* Примусовий темний стиль для випадаючих списків */
select, select option {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Навігація категорій зліва */
.cat-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    padding: 5px 0;
    border-radius: 10px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}
.cat-nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}
.cat-nav-btn.active {
    background: rgba(255, 255, 255, 0.1);
}
.cat-icon-box {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.cat-nav-btn.active .cat-icon-box {
    box-shadow: 0 0 10px currentColor;
}

/* ВИСУВНІ ПАНЕЛІ (DRAWERS) */
.scratch-drawer-left {
    position: absolute;
    left: 48px; /* поруч із смугою категорій w-12 */
    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) {
    .scratch-drawer-left {
        left: 56px;
    }
}
.scratch-drawer-left.drawer-closed {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}

.scratch-drawer-right {
    position: absolute;
    right: 0;
    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;
}
.scratch-drawer-right.drawer-closed {
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
}

/* Scratch-кольори категорій */
.block-cat-motion { background-color: #4c97ff; border-color: #3373cc; }
.block-cat-looks { background-color: #9966ff; border-color: #774dc1; }
.block-cat-sound { background-color: #cf63cf; border-color: #bd42bd; }
.block-cat-events { background-color: #ffbf00; border-color: #cc9900; }
.block-cat-control { background-color: #ffab19; border-color: #cf8717; }
.block-cat-pen { background-color: #0fbd8c; border-color: #0b8e6b; }

/* Фірмові Scratch-блоки з пазами */
.scratch-magnetic-block {
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    user-select: none;
    cursor: grab;
    min-height: 38px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    border-width: 1.5px;
    touch-action: none;
    transition: margin 0.15s cubic-bezier(0.2, 0, 0.2, 1);
}
.scratch-magnetic-block:active {
    cursor: grabbing;
}

/* Розсування блоків */
.drop-gap-bottom { margin-bottom: 42px !important; }
.drop-gap-top { margin-top: 42px !important; }

/* Підсвітка прилипання */
.drop-snap-glow {
    outline: 2.5px solid #22d3ee !important;
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.9), inset 0 0 10px rgba(34, 211, 238, 0.3) !important;
    z-index: 40 !important;
}

/* Верхній паз */
.scratch-magnetic-block::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 16px;
    width: 20px;
    height: 5px;
    background: inherit;
    border-top: inherit;
    border-left: inherit;
    border-right: inherit;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    z-index: 2;
}

/* Нижній виступ */
.scratch-magnetic-block::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 16px;
    width: 20px;
    height: 5px;
    background: inherit;
    border-bottom: inherit;
    border-left: inherit;
    border-right: inherit;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    z-index: 3;
}

.scratch-magnetic-block.hat-block::before { display: none; }
.scratch-magnetic-block.hat-block {
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

/* C-ПОДІБНІ БЛОКИ КЕРУВАННЯ */
.scratch-c-block {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 210px;
    user-select: none;
    cursor: grab;
    transition: margin 0.15s cubic-bezier(0.2, 0, 0.2, 1);
}
.scratch-c-block:active { cursor: grabbing; }

.scratch-c-header {
    border-radius: 8px 8px 0 0;
    min-height: 36px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-width: 1.5px 1.5px 0 1.5px;
    border-style: solid;
}
.scratch-c-body {
    border-left: 18px solid;
    border-left-color: inherit;
    min-height: 48px;
    padding: 6px 4px 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1.5px dashed rgba(255, 255, 255, 0.2);
    transition: background 0.15s, border-color 0.15s;
}

.scratch-c-divider {
    min-height: 26px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 800;
    color: #ffffff;
    background-color: inherit;
    border-left: 18px solid;
    border-left-color: inherit;
    position: relative;
}

.scratch-c-body.c-drop-target {
    background: rgba(34, 211, 238, 0.25) !important;
    outline: 2.5px dashed #22d3ee !important;
    box-shadow: inset 0 0 16px rgba(34, 211, 238, 0.4) !important;
}

.scratch-c-footer {
    border-radius: 0 0 8px 8px;
    height: 14px;
    border-width: 0 1.5px 1.5px 1.5px;
    border-style: solid;
    position: relative;
}

.btn-add-c-child {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.12);
    padding: 2.5px 7px;
    border-radius: 6px;
    border: 1px dashed rgba(255, 255, 255, 0.4);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-add-c-child:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: scale(1.05);
}

.c-child-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.c-child-actions:hover { opacity: 1; }

.c-child-btn {
    width: 18px;
    height: 18px;
    font-size: 9px;
    font-weight: 900;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.c-child-btn:hover { background: rgba(255, 255, 255, 0.3); color: #fff; }
.c-child-btn.btn-del:hover { background: #ef4444; color: #fff; }

.dragging-stack {
    pointer-events: none !important;
    opacity: 0.92;
    z-index: 1000;
}

/* Інпути в блоках */
.scratch-block-input {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    border: none;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    outline: none;
    text-align: center;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.scratch-block-select {
    background: #0f172a;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    outline: none;
}

/* Слайдери в інспекторі */
.cad-slider {
    accent-color: #0284c7;
    height: 4px;
    border-radius: 4px;
    background: #334155;
    outline: none;
}

/* Хмарка мовлення */
.scratch-speech-bubble {
    position: absolute;
    background: #ffffff;
    color: #0f172a;
    font-weight: 800;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 14px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    border: 2px solid #0f172a;
    transform: translate(-50%, -100%);
    pointer-events: none;
    white-space: nowrap;
    z-index: 25;
}
.scratch-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #ffffff transparent;
    display: block;
    width: 0;
}

.obs-shape-btn.active {
    border-color: #f43f5e;
    background-color: rgba(225, 29, 72, 0.25);
    color: #fff;
}

@keyframes scaleUp {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.animate-scale-up {
    animation: scaleUp 0.18s ease-out forwards;
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Скролбари */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #090e1c; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }


/* Ефект активного кошика при перетягуванні блоків на планшеті */
#trashDropZone.trash-active .cat-icon-box {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.9) !important;
    transform: scale(1.15) !important;
}
#trashDropZone.trash-active span {
    color: #f43f5e !important;
    font-weight: 900 !important;
}

/* Кольори категорій */
.block-cat-sensing   { background-color: #29b5e8; border-color: #1b8fb8; }
.block-cat-operators { background-color: #59c059; border-color: #389438; }

/* Шестикутна форма для датчиків та операторів */
.scratch-boolean-block {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 12px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    clip-path: polygon(8px 0%, calc(100% - 8px) 0%, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0% 50%);
    cursor: grab;
    user-select: none;
    min-height: 28px;
    vertical-align: middle;
}

/* Порожнє гніздо (куди вставляється умова) */
.boolean-socket {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 24px;
    background: rgba(0, 0, 0, 0.4);
    border: 1.5px dashed rgba(255, 255, 255, 0.5);
    clip-path: polygon(6px 0%, calc(100% - 6px) 0%, 100% 50%, calc(100% - 6px) 100%, 6px 100%, 0% 50%);
    padding: 2px 8px;
    margin: 0 4px;
    vertical-align: middle;
}
.boolean-socket.socket-hover {
    background: rgba(255, 255, 255, 0.4) !important;
    border-color: #fff !important;
}


/* 1. Привид блоку ніколи не повинен блокувати події миші */
#dragGhostBlock, 
#dragGhostBlock * {
    pointer-events: none !important;
}

/* 2. Обгортка для шестикутних блоків у бічній палітрі, щоб вони завжди були в стовпчик */
.palette-boolean-row {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
}

/* 3. Шестикутний блок у палітрі */
.palette-boolean-row .scratch-boolean-block {
    width: auto;
    min-width: 130px;
    justify-content: center;
}