.controls-groups {
    display: flex;
    flex-direction: column;
    background: var(--group-bg);
    border: var(--group-border);
    border-radius: 12px;
    padding: 14px;
    gap: var(--ui-button-gap);
}

.controls-groups.hidden {
    display: none;
}

.control-category {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-category-title {
    font-family: var(--font-header);
    color: var(--primary-dark);
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-left: 10px;
    margin-bottom: -22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-section {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--ui-button-gap);
}

.controls-section.controls-section-system {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.volume-state {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

#volumeStateInline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: initial;
    gap: 12px;
}

.volume-state-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86em;
    font-weight: 600;
    color: var(--text-1);
    min-width: 0;
}

.volume-state-label-icon {
    font-size: 0.9em;
    color: inherit;
    flex: 0 0 auto;
}

.volume-state-controls {
    display: grid;
    grid-template-columns: 34px minmax(0, auto) 34px;
    align-items: center;
    gap: 8px;
    background: var(--secondary);
}

.volume-state-icon {
    font-size: 14px;
    flex: 0 0 auto;
}

.volume-bars {
    display: flex;
    align-items: center;
    gap: 5px;
    width: auto;
    min-height: 16px;
    max-width: 100%;
}

.volume-bar {
    width: 4px;
    height: 16px;
    border-radius: 999px;
    background: var(--tertiary-dark);
    transition: background 0.15s ease, opacity 0.15s ease;
    flex: 0 0 auto;
}

.volume-bar.filled {
    background: var(--primary);
}

.volume-state.unknown{
    color: #99a3c7;
}

.volume-state.unknown .volume-bar {
    background: #d7deef;
}

.volume-state.disabled {
    opacity: 0.6;
}

.volume-state.disabled .volume-state-label,
.volume-state.disabled .volume-state-icon {
    color: #a7afcc;
}

.volume-state.disabled .screen-scale-btn,
.volume-state.disabled .screen-scale-btn:hover,
.volume-state.disabled .screen-scale-btn i {
    color: #a7afcc;
    background: transparent;
}

.volume-state.disabled .volume-bar,
.volume-state.disabled .volume-bar.filled {
    background: #d6dced;
}

.screen-scale-state {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--secondary);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.screen-scale-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86em;
    font-weight: 600;
    color: var(--text-1);
    min-width: 0;
}

.screen-scale-label-icon {
    font-size: 0.9em;
    color: inherit;
    flex: 0 0 auto;
}

.screen-scale-controls {
    display: grid;
    grid-template-columns: 34px minmax(64px, auto) 34px;
    align-items: center;
    gap: 8px;
    justify-content: end;
    background: var(--secondary);
}

.screen-scale-value {
    min-width: 64px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 700;
    color: var(--text-1);
    background: var(--secondary);
    border: 1px solid transparent;
    border-radius: 8px;
}

.screen-scale-btn {
    border: 1px solid transparent;
    background: var(--secondary);
    color: var(--text-1);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.screen-scale-btn:hover {
    background: var(--secondary-dark);
    border-color: transparent;
}

.screen-scale-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.screen-scale-btn:disabled:hover {
    background: var(--secondary);
    border-color: transparent;
}

.screen-scale-state.disabled {
    opacity: 0.6;
}

.screen-scale-state.disabled .screen-scale-controls {
    background: transparent;
}

.screen-scale-state.disabled .screen-scale-label,
.screen-scale-state.disabled .screen-scale-value,
.screen-scale-state.disabled .screen-scale-btn,
.screen-scale-state.disabled .screen-scale-btn i {
    color: #a7afcc;
}

.screen-scale-state.disabled .screen-scale-value,
.screen-scale-state.disabled .screen-scale-btn,
.screen-scale-state.disabled .screen-scale-btn:hover {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

@media (max-width: 560px) {
    #volumeStateInline {
        grid-template-columns: 1fr;
        justify-items: stretch;
        gap: 10px;
    }

    .volume-state-label {
        text-align: center;
    }

    .volume-state-controls {
        width: 100%;
        grid-template-columns: minmax(42px, 1fr) minmax(0, auto) minmax(42px, 1fr);
    }


    .screen-scale-state {
        grid-template-columns: 1fr;
        justify-items: stretch;
        gap: 10px;
    }

    .screen-scale-label {
        text-align: center;
    }

    .screen-scale-controls {
        width: 100%;
        grid-template-columns: minmax(42px, 1fr) minmax(76px, auto) minmax(42px, 1fr);
    }

    .screen-scale-btn,
    .screen-scale-value {
        height: 40px;
    }

    .screen-scale-btn {
        width: 100%;
    }
}

.controls-section.controls-section-survey {
    grid-template-columns: 1fr;
    margin-bottom: 0px;
}

.btn-control.survey {
    display: block;
}

.btn-control {
    background: var(--tertiary);
    padding: 12px 6px;
    border-radius: 12px;
    transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    flex-direction: column;
    font-size: 0.88em;
    -webkit-tap-highlight-color: transparent;
    line-height: 0.5em;
}

.btn-control i {
    font-size: 1.5em;
    margin-bottom: 4px;
}

/* ── Mobile overrides ───────────────────────────────────────────────────── */
@media (hover: hover) {
    .btn-control:hover {
        background: var(--primary);
        color: white;
        transform: translateY(-3px);
        box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
    }

    .btn-control:hover i {
        color: white;
    }

    .btn-control:disabled:hover,
    .btn-control:disabled:hover i {
        background: #ECEAF3;
        color: #9AA0B5;
        transform: none;
    }
}

.btn-control:disabled,
.btn-control:disabled:hover,
.btn-control:disabled:active {
    background: #ECEAF3;
    color: #9AA0B5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.65;
}

.btn-control:disabled i,
.btn-control:disabled:hover i {
    color: inherit !important;
}

.btn-control:focus {
    outline: none;
}

@media (hover: none) {
    .btn-control:active {
        background: var(--primary);
        color: white;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(102, 126, 234, 0.15);
    }

    .btn-control:active i {
        color: white;
    }

    .btn-control:disabled:active,
    .btn-control:disabled:active i {
        background: #ECEAF3;
        color: #9AA0B5;
        transform: none;
        box-shadow: none;
    }

    .btn-control:focus {
        background: #ECEAF3;
        color: #333;
        box-shadow: none;
        transform: none;
    }

    .btn-control:focus i {
        color: inherit;
    }
}

.btn-control:active {
    transform: translateY(-1px);
}

.btn-control.touched {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.15);
}

.btn-control.touched i {
    color: white;
}

.btn-control:disabled.touched,
.btn-control:disabled.touched i {
    background: var(--tertiary);
    color: var(--tertiary-dark) !important;
    transform: none;
    box-shadow: none;
}

.btn-control.play i {
    color: #4caf50 !important;
}

.btn-control.mute i {
    color: #f44336 !important;
}

.btn-control.survey i {
    color: #ff9800 !important;
}

.btn-control:disabled i {
    color: var(--text-3) !important;
}

.world-segment-toggle {
    position: relative;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    width: 100%;
    padding: 5px;
    min-height: 50px;
    border: 1px solid #d6dbef;
    border-radius: 999px;
    background: #eceaf3;
    overflow: hidden;
    transition: all 0.25s ease;
}

.world-segment-toggle:hover {
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.16);
}

.world-segment-toggle:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}

.world-toggle-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: 999px;
    background: var(--primary);
    transition: transform 0.25s ease;
}

.world-segment-toggle.virtual-selected .world-toggle-thumb {
    transform: translateX(100%);
}

.world-toggle-option {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 0.95em;
    font-weight: 700;
    color: #5f6783;
    transition: color 0.25s ease;
}

.world-segment-toggle.real-selected .world-toggle-option-real,
.world-segment-toggle.virtual-selected .world-toggle-option-virtual {
    color: #ffffff;
}

.device-list {
    list-style: none;
    margin-bottom: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.pairing-section {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
}

.pairing-panel {
    margin-top: 12px;
    background: #f7f8fc;
    border: 1px solid #e6e8f2;
    border-radius: 12px;
    padding: 14px;
}

.pairing-help {
    color: #4f5670;
    font-size: 0.92em;
    margin-bottom: 10px;
}

.pairing-form {
    display: flex;
    gap: var(--ui-button-gap);
    align-items: stretch;
    flex-wrap: wrap;
}

.pairing-message {
    margin-top: 10px;
    min-height: 1.2em;
    color: #4f5670;
    font-size: 0.9em;
}

.pairing-message.error {
    color: var(--error);
}

.pairing-message.success {
    color: #216c3a;
}

.device-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--group-bg);
    border-radius: 8px;
    cursor: default;
    border: var(--group-border);
    transition: all 0.2s;
}

.device-item.empty {
    padding: 16px;
    color: var(--text-3);
    text-align: center;
}

.device-item.can-select {
    cursor: pointer;
}

.device-item.online {
    border-color: var(--tertiary-dark);
}

.device-item.offline {
    opacity: 0.75;
}

.device-item.selected {
    background: var(--secondary);
    border-color: var(--primary);
    box-shadow: var(--input-shadow);
}

.device-item.editing {
    background: #fff8ea;
    border-color: #f1c16c;
    box-shadow: 0 0 0 1px rgba(241, 193, 108, 0.45) inset;
}

.device-info {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    min-width: 0;
}

.device-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.device-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.device-header-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--ui-button-gap);
}

.device-name-editor {
    display: flex;
    align-items: center;
    gap: var(--ui-button-gap);
}

.device-name-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #cfd6ea;
    border-radius: 8px;
    font-size: 0.92em;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.device-name-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.device-name-actions {
    display: inline-flex;
    gap: var(--ui-button-gap);
}

.device-model {
    font-weight: bold;
}

.btn-device-name {
    width: 30px;
    height: 30px;
    border: 1px solid #cfd6ea;
    border-radius: 8px;
    background: #eef1fb;
    color: #3d4665;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-device-name:hover {
    background: #dfe5f8;
    border-color: #bcc8eb;
}

.btn-device-name.save {
    background: #e8f8ee;
    border-color: #bde4ca;
    color: #216c3a;
}

.btn-device-name.save:hover {
    background: #d6f1e1;
}

.btn-device-name.cancel {
    background: #fff1f3;
    border-color: #f0c8cf;
    color: #9f2f3f;
}

.btn-device-name.cancel:hover {
    background: #ffe4e8;
}

.btn-device-delete {
    background: #fff1f3;
    border-color: #f0c8cf;
    color: #9f2f3f;
}

.btn-device-delete:hover:not(:disabled) {
    background: #ffe4e8;
}

.btn-device-delete.armed {
    background: #d73a49;
    border-color: #b02a37;
    color: #ffffff;
}

.btn-device-delete:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #f4f5f8;
    border-color: #d7dbe7;
    color: #8b91a4;
}

.device-id {
    font-size: 0.85em;
    color: #666;
}

.device-lastseen {
    font-size: 0.85em;
    color: #999;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.device-battery {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
    font-weight: 600;
    color: #4f5670;
}

.device-battery.low {
    color: #b45a1d;
}

.device-battery.critical {
    color: #b02a37;
}

.device-now-playing {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    width: 100%;
    min-width: 0;
    font-size: 0.85em;
    color: #667eea;
    font-weight: 500;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.device-now-playing .now-playing-playlist,
.device-now-playing .now-playing-video {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-now-playing .now-playing-time {
    flex-shrink: 0;
    color: #8a96cc;
}

.device-now-playing .now-playing-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-now-playing .now-playing-playlist {
    color: #8a96cc;
    font-weight: 400;
}

.device-now-playing i {
    font-size: 0.75em;
    flex-shrink: 0;
}

.controller-message {
    min-height: 0;
    font-size: 0.9em;
    color: var(--text-2, #4f5670);
}

.controller-message:empty {
    display: none;
}

.controller-message.info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--info-bg, #eef1fb);
    border: 1px solid var(--info-border, #d6ddee);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--info-text, #3d4665);
    font-weight: 600;
    margin-bottom: 14px;
}

.controller-message.info::before {
    content: '\f021';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.85em;
    flex-shrink: 0;
    color: var(--primary, #667eea);
}

.controller-message.error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--error-bg, #ffeef0);
    border: 1px solid var(--error-border, #f5c0c8);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--error, #b00020);
    font-weight: 600;
    margin-bottom: 14px;
}

.btn-settings {
    background: #ECEAF3;
    color: #333;
    padding: 10px 12px;
    min-width: unset;
}

.btn-settings:hover {
    background: #d9d5e8;
}

/* Shared modal layout (save URL / offline / delete confirm) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 20px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.modal-message {
    color: #4f5670;
    font-size: 1rem;
    line-height: 1.5;
    margin: 0;
}

.modal-message .fas {
    color: #667eea;
    margin-right: 6px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-actions .btn {
    min-width: 120px;
}

