#hid-webapp .extra-inputs-board {
    margin-bottom: 1.5rem;
}

/* The scale fits the Settings tab's height; a margin under the last board would overflow it. */
#hid-webapp .extra-inputs-board:last-child {
    margin-bottom: 0;
}

#hid-webapp .board-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

#hid-webapp .board-title {
    font-family: "Orbitron", sans-serif;
    font-size: 1.3rem;
    color: var(--accent-color);
    margin: 0;
    letter-spacing: 0.05em;
}

#hid-webapp .board-title-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#hid-webapp .hide-unused-switch {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#hid-webapp .clear-board-btn {
    font-size: 0.875rem;
    padding: 0.25rem 0.65rem;
}

#hid-webapp .button-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    max-width: 40rem;
    margin: 0 auto;
}

#hid-webapp .input-btn {
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background-color: #6b7280;
    border: 2px solid transparent;
    position: relative;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
    transform: none;
}

#hid-webapp .input-btn .btn-index {
    position: absolute;
    top: 4px;
    left: 5px;
    font-size: 0.6rem;
    font-weight: 600;
    opacity: 0.7;
    line-height: 1;
}

#hid-webapp .input-btn:hover {
    background-color: #4b5563;
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    filter: none;
}

#hid-webapp .input-btn:active {
    transform: translateY(1px) scale(0.96);
    box-shadow: none;
}

#hid-webapp .input-btn.active-btn {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.3);
}

#hid-webapp.dark-mode .input-btn {
    background-color: #374151;
    color: #e5e7eb;
}

#hid-webapp.dark-mode .input-btn:hover {
    background-color: #4b5563;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

#hid-webapp.dark-mode .input-btn.active-btn {
    background-color: var(--accent-color);
    color: #fff;
}

#hid-webapp .btn-binding {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
    width: 90%;
    pointer-events: none;
    line-height: 1.4;
}

/* Tooltip with the full binding above a key. */
#hid-webapp .input-btn[data-binding]:hover::after {
    content: attr(data-binding);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 0.3125rem 0.625rem;
    border-radius: 0.375rem;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#hid-webapp .input-btn[data-binding]:hover::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 0.375rem solid transparent;
    border-top-color: #1f2937;
    pointer-events: none;
    z-index: 100;
}

#hid-webapp .key-binding-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    background-color: #fff;
    border-radius: 0.75rem;
    padding: 2rem 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
    outline: none;
}

#hid-webapp.dark-mode .key-binding-modal {
    background-color: #1a1d24;
}

#key-binding-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

#key-binding-preview {
    min-height: 2rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 0.03em;
}

#key-binding-actions {
    display: flex;
    gap: 0.75rem;
}

#key-binding-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
