* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    color: #fff;
    user-select: all;
}

.centered {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.cs-dialog {
    position: relative;
    display: inline-flex;
    width: 50vw;
    max-width: 95vw;
    border: 0;
    flex-direction: column;
    align-items: center;
    flex-wrap: nowrap;
}

.cs-dialog__header {
    padding: 5px 10px;
    font: bold 13px tahoma, sans-serif;
    display: flex;
    align-items: center;
    background: linear-gradient(to right, #000080, #1084d0);
    color: #fff;
}

.content-wrapper {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #ece9d8;
    color: #000;
}

.config-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
    height: 100%;
    align-items: start;
}

.config-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cs-fieldset {
    border: 1px solid #aca899;
    padding: 10px;
    margin: 0;
    height: 100%;
}

.cs-fieldset legend {
    margin-left: 10px;
    padding: 0 5px;
}

.form-group {
    margin-bottom: 10px;
}

.cs-input__label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-align: left;
}

.val-label {
    float: right;
    color: #000080;
    font-weight: bold;
}

.cs-input,
.cs-select {
    width: 100% !important;
}

.color-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.color-input-group .pickr-target {
    width: 30px;
    height: 22px;
}

.color-input-group .pickr-target .pcr-button {
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0;
    background: none;
    box-shadow: none;
    border-radius: 0;
    position: relative;
    z-index: 10;
}

.color-input-group .cs-input {
    flex-grow: 1;
    height: 22px;
    padding: 0 5px;
    font-size: 12px;
    text-transform: lowercase;
}

.cs-slider {
    position: relative;
    padding-top: 5px;
}

.cs-ruler {
    position: absolute;
    top: 28px;
    margin-left: 4px;
    height: 6px;
    width: calc(100% + 1px);
    background-image: linear-gradient(to right, #aca899 1px, transparent 1px);
    background-size: 10%;
    z-index: 0;
}

.cs-slider input[type="range"] {
    position: relative;
    z-index: 1;
    width: 100%;
    margin: 0;
}

.nested-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: -20px;
}

.full-width {
    grid-column: 1 / -1;
    width: 100%;
}

.preview-fieldset {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.preview-wrapper {
    position: relative;
    flex: 1;
    min-height: 375.01px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    object-fit: cover;
    transform: translate(-50%, -50%);
    pointer-events: none;
    filter: blur(4px) brightness(0.7);
}

.preview-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 10;
}

.link-container {
    display: flex;
    gap: 5px;
    transition-duration: 1s;
}

.link-container.hint {
    box-shadow: #c4b55075 0px 0px 20px 2px;
    transition-duration: 0.1s;
}

.cs-btn.copied {
    color: green;
    font-weight: bold;
}

.overlay-container {
    padding: 20px;
    display: none;
}

.overlay-container.show {
    display: block;
}

.container {
    display: flex;
    gap: 15px;
    max-width: 800px;
    flex-direction: column;
}

.top-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    max-width: 350px;
}

.keyboard-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.key-row {
    display: flex;
    gap: 8px;
}

.key {
    width: var(--key-width, 50px);
    min-width: var(--key-width, 50px);
    max-width: var(--key-width, 50px);
    background: linear-gradient(135deg, #1e1e1e, #141414);
    border: 2px solid #ffffff33;
    border-radius: 8px;
    padding: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.key.w-1u { --key-width: 50px; }
.key.w-1-25u { --key-width: 62.5px; }
.key.w-1-5u,
.key.wide { --key-width: 75px; }
.key.w-1-75u { --key-width: 87.5px; }
.key.w-2u,
.key.extra-wide { --key-width: 100px; }
.key.w-2-25u { --key-width: 112.5px; }
.key.w-2-75u { --key-width: 137.5px; }
.key.w-6-25u { --key-width: 312.5px; }
.key.super-wide { --key-width: 167px; }

.key.invisible {
    visibility: hidden;
}

.key.dummy {
    display: none;
}

.mouse-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mouse-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    height: 52px;
}

.mouse-btn,
.scroll-display {
    background: linear-gradient(135deg, #1e1e1e, #141414);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.mouse-btn {
    flex: 1;
    padding: 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.mouse-btn.mouse-wide {
    flex: 1.5;
}

.mouse-btn.mouse-side {
    display: grid;
}

.mouse-btn.mouse-side span {
    display: flex;
    align-items: center;
    height: 100%;
}

.mouse-btn.mouse-side span.active {
    border-color: var(--active-color) !important;
    box-shadow: 0 0 5px var(--active-color) !important;
}

.scroll-display {
    width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible !important;
}

.scroll-arrow {
    font-size: 80%;
    line-height: 1;
}

.scroll-count {
    font-size: 64px;
    line-height: 1;
    position: absolute;
    opacity: 0;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #000c;
    pointer-events: none;
    z-index: 9999;
}

.scroll-count.scroll-up {
    top: -30px;
    left: -20px;
    transform: rotate(-45deg);
}

.scroll-count.scroll-down {
    bottom: -30px;
    right: -20px;
    transform: rotate(-45deg);
}

.scroll-count.animate.scroll-up {
    animation: scrollbounce-up 0.1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.scroll-count.animate.scroll-down {
    animation: scrollbounce-down 0.1s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scrollbounce-up {
    0% {
        opacity: 1;
        transform: rotate(-15deg) scale(0.7);
    }
    100% {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

@keyframes scrollbounce-down {
    0% {
        opacity: 1;
        transform: rotate(-15deg) scale(0.7);
    }
    100% {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

.status {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 20px;
    color: #fff;
    font-size: 18px;
    position: fixed;
    bottom: 20px;
    left: 20px;
    max-width: 500px;
}

.status.connected {
    display: none;
}

.status.error {
    border-color: rgba(239, 68, 68, 0.5);
}

.status.connecting {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.side-by-side-group {
    display: flex;
    gap: 15px;
    width: 100%;
}

.custom-layout-fieldset {
    flex: 0 0 45%;
    min-width: 300px;
}

.preview-fieldset {
    flex: 1 1 50%;
}

@media (max-width: 800px) {
    .side-by-side-group {
        flex-direction: column;
    }
    .custom-layout-fieldset,
    .preview-fieldset {
        flex: 1 1 100%;
    }
}

.fullscreen-details[open] {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    color: #fff;
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
}

.fullscreen-details[open] summary {
    cursor: pointer;
    position: sticky;
    top: 0;
    z-index: 10000;
    display: block;
    padding-bottom: 20px;
}

.fullscreen-details[open] summary.close-btn {
    width: 55px;
    height: 55px;
    padding: 15px;
    left: 100%;
    text-align: center;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    background: #f00;
    color: #fff;
    border: 0;
    padding: 5px 10px;
    border-radius: 0;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 1;
}

.key-list-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    table-layout: fixed;
}

.key-list-table th,
.key-list-table td {
    border: 1px solid #4f4f4f;
    padding: 8px;
    text-align: left;
}

.key-list-table th {
    background: #202020;
}

.key-list-table th:first-child,
.key-list-table td:first-child {
    width: 35%;
}