* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 500px;
    width: 100%;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.status {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    text-align: center;
}

.status.disconnected {
    background: #fee;
    color: #c33;
}

.status.connected {
    background: #efe;
    color: #3c3;
}

.status.scanning {
    background: #eef;
    color: #33c;
}

button {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.channel-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.btn-channel {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: #f0f0f0;
    color: #555;
    transition: all 0.2s;
}

.btn-channel:hover {
    border-color: #667eea;
    background: #e8eaf6;
    color: #333;
}

.btn-channel.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.input-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: white;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

#volumeValueDisplay {
    margin-left: 6px;
    font-weight: 600;
    color: #667eea;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e0e0e0;
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.octave-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.octave-control .btn-octave {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.octave-control .btn-octave:hover {
    border-color: #667eea;
    background: #f5f3ff;
}

.octave-control #octaveValueDisplay {
    min-width: 1.5em;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.row-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.row-fields .input-group {
    margin-bottom: 0;
}

/* Первая строка: инструмент на всю ширину */
.row-fields .input-group:nth-child(1) {
    flex: 1 1 100%;
    width: 100%;
}

/* Вторая строка: громкость 2/3, октава 1/3 */
.row-fields .input-group:nth-child(2) {
    flex: 2 1 0;
    min-width: 0;
}

.row-fields .input-group:nth-child(3) {
    flex: 1 1 0;
    min-width: 0;
}

/* Мобильные: инструмент на всю ширину, громкость и октава на следующей строке */
@media (max-width: 640px) {
    body {
        padding: 10px;
        align-items: flex-start;
        overflow-x: hidden;
    }

    .container {
        padding: 24px 20px;
    }

    .bayan-image {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(-50vw + 50%);
        margin-right: calc(-50vw + 50%);
        border-radius: 0;
        max-height: min(55vh, 420px);
    }

    .row-fields {
        flex-wrap: wrap;
    }

    .row-fields .input-group:nth-child(1) {
        flex: 1 1 100%;
        width: 100%;
    }

    .row-fields .input-group:nth-child(1) select {
        width: 100%;
        min-height: 48px;
        padding: 14px 16px;
        font-size: 16px;
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 14px center;
        padding-right: 40px;
        border-radius: 10px;
        border: 2px solid #e0e0e0;
        background-color: #fafafa;
    }

    .row-fields .input-group:nth-child(1) select:focus {
        border-color: #667eea;
        background-color: white;
    }

    .row-fields .input-group:nth-child(2) {
        flex: 2 1 0;
        min-width: 0;
    }

    .row-fields .input-group:nth-child(3) {
        flex: 1 1 0;
        min-width: 0;
    }

    /* Октава: кнопки − и + по бокам от значения, помещаются в 1/3 ширины */
    .octave-control {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        width: 100%;
        min-width: 0;
    }

    .octave-control .btn-octave {
        min-width: 32px;
        width: 32px;
        height: 40px;
        padding: 0;
        font-size: 20px;
        flex-shrink: 0;
    }

    .octave-control #octaveValueDisplay {
        font-size: 18px;
        flex-shrink: 0;
        min-width: 1.2em;
    }
}

.value-display {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    min-height: 50px;
    word-break: break-all;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #333;
}

.value-display.empty {
    color: #999;
    font-style: italic;
}

.bayan-image {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    max-height: min(50vh, 400px);
    margin: 0 auto 20px;
    border-radius: 12px;
    object-fit: contain;
}

.screen {
    display: block;
}

.screen.screen-hidden {
    display: none;
}

.style-tempo-line {
    margin-top: 16px;
    text-align: center;
    color: #444;
    font-size: 17px;
}

.style-tempo-line span {
    font-weight: 700;
    color: #333;
}
