:root{
    --bg-page:#F1F3F4;
    --bg-card:#9AA0A6;
    --bg-header:#F3F6FA;

    --white:#FFFFFF;
    --black:#000000;
    --primary: #0078b8;
    --primary-hover:#006da5;
    --primary-dark:#16324D;
    --primary-light:#E3ECF5;
    --accent:#6F9BC2;
    --accent-hover:#5D89B2;
    --accent-light:#E7F0F8;
    
    --secondary:#E5F2FB;
    
    --border:#cecece;
    --text:#172535;
    --text-secondary:#607080;
    --muted:#6D7B89;
    --success:#4F8A5B;
    --warning:#C7932B;
    --danger:#C94B4B;
    --red:#D95757;
    --green:#4F8A5B;
    --orange:#D18A32;
    --purple:#7563A8;
    --chart1-border:#527A9E;
    --chart1-fill:#D9E5F0;
    --chart2-border:#6F9BC2;
    --chart2-fill:#E0EBF5;
    --surface-muted:#F5F8FB;
    --surface-hover:#EDF3F8;
    --surface-active:#E3ECF5;
    --surface-soft:#E8F0F7;
    --surface-dark:#D8E3ED;
    --danger-light:#FCE8E8;
    --danger-text:#B94A48;
    --event-body-bg:#E8EEF488;
    --overlay-page:rgba(232,237,244,.35);
    --overlay-modal:rgba(15,23,42,.55);
    --overlay-dark:rgba(0,0,0,.45);
    --overlay-dark-light:rgba(0,0,0,.08);
    --overlay-dark-medium:rgba(0,0,0,.25);
    --overlay-event-number:rgba(0,0,0,.65);
    --overlay-active:rgba(35,75,115,.12);
    --overlay-active-strong:rgba(35,75,115,.16);
    --overlay-white:rgba(255,255,255,.18);
    --focus-ring:rgba(35,75,115,.08);
    --focus-ring-strong:rgba(35,75,115,.10);

    --shadow: 0 4px 6px rgba(0,0,0,0.20);
    --shadow-small:0 2px 3px rgba(0,0,0,0.20);
    
    --shadow-soft:0 2px 5px rgba(28,52,75,.08);
    --shadow-hover:0 4px 10px rgba(28,52,75,.12);
    --shadow-modal:0 20px 30px rgba(0,0,0,.25);

    --grey-dark: #5F6368;
    --grey-medium: #9AA0A6;
    --grey-light: #F1F3F4;
}

* {
    box-sizing: border-box;
}

::-webkit-scrollbar {
    margin: 0px;
    width: 10px;
    height:10px !important;
    background-color:transparent;
    border: none;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: none;
    background-color:var(--bg-header);
    border-radius:0px;
    border: none;
}

::-webkit-scrollbar-thumb{
    background-color:var(--border)!important;
    margin:5px;
    padding:5px;
    border-radius:0px;
}

body{
    height:100vh;
    margin:0;
    font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    background:var(--bg-page);
    color:var(--text);
    position:relative;
    overflow:hidden;
}

body::before{
    content:"";
    position:fixed;
    inset:-5px;
    background:url("../images/back.jpg") center center/cover no-repeat;
    filter: grayscale(50%) brightness(1.2);
    transform:scale(1.02);
    z-index:-2;
}

body::after{
    content:"";
    position:fixed;
    inset:0;
    z-index:-1;
}

.app{
    height:100vh;
    max-width:1600px;
    margin:0 auto;
    padding:10px;
    display:flex;
    flex-direction:column;
    min-height:0;
}
.header{
    display:flex;
    align-items:center;
    gap:20px;
    margin-bottom:10px
}
.header h1{
    margin:0;
    font-size:25px;
    font-weight:600
}
.loop-name{
    flex:1;
    max-width:500px
}
.loop-name input{
    width:100%;
    padding:12px 14px;
    border:1px solid var(--border);
    border-radius:0px;
    background:var(--white);
    font-size:12px;
    outline:none
}
.loop-name input:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 3px var(--focus-ring-strong)
}
.header-buttons{
    margin-left:auto;
    display:flex;
    gap:8px
}
button{
    border:0;
    cursor:pointer;
    font-family:inherit
}
.button{
    padding:8px 16px;
    border-radius:5px;
    font-size:12px;
    font-weight:500
}
.button-primary{
    background:var(--primary);
    color:var(--white)
}
.button-primary:hover{
    filter:brightness(.94)
}
.button-secondary{
    background:var(--white);
    color:var(--text);
    border:1px solid var(--border)
}
.button-secondary:hover{
    background:var(--secondary);
}
.workspace{
    display:grid;
    grid-template-columns:290px 1fr;
    gap:20px;
    flex:1;
    min-height:0;
}

.panel-header{
    height: 40px;
    padding:17px 18px;
    color: var(--text);
    display:flex;
    justify-content:space-between;
    align-items:center
}
.panel-header h2{
    font-size:14px;
    margin:0;
    font-weight:600
}
.panel-header span{
    font-size:12px
}
.image-library{
    min-height:0;
    overflow-y:auto;
}



.image-item{
    position:relative;
    display:flex;
    align-items:center;
    gap:10px;
    padding:7px;
    border:1px solid var(--border);
    border-radius:0px;
    background: #fefefe;
    cursor:grab;
    user-select:none;
    transition:.15s;
    margin-bottom: 2px
}

.image-item.dragging{
    opacity:.45
}
.image-thumb{
    width:70px;
    height:44px;
    object-fit:cover;
    border-radius:0px;
    background:var(--surface-muted);
    flex-shrink:0
}
.image-info{
    min-width:0
}
.image-name{
    font-size:13px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis
}
.image-drag{
    margin-left:auto;
    color:var(--muted);
    font-size:16px
}
.loop-panel{
    min-width:0;
    min-height:0;
    display:flex;
    flex-direction:column;
}
.loop-toolbar{
    height: 50px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:0px 18px;
    border-bottom:1px solid var(--border)
}
.loop-title{
    font-size:15px;
    font-weight:600
}
.loop-stats{
    margin-left: 120px;
    color:var(--muted);
    font-size:13px
}
.loop-container {
    padding:20px;
    flex:1;
    min-height:0;
    overflow-y:auto;
    overflow-x:hidden;
}

.loop-events {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    align-items: start;
    padding-bottom: 15px;
    min-height: 100%;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: max-content;
    align-content: start;
}
.event{
    position:relative;
    width:220px;
    flex:0 0 220px;
    background:var(--white);
    border:1px solid var(--border);
    border-radius:5px;
    overflow:hidden;
    cursor:grab
}
.event.dragging{

}
.event.drag-over{
    border:2px solid var(--primary)
}
.event-number{
    position:absolute;
    top:8px;
    left:8px;
    width:25px;
    height:25px;
    border-radius:0px;
    background:var(--primary);
    color:var(--white);
    font-size:12px;
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:2
}
.event-image{
    width:100%;
    height:124px;
    object-fit:cover;
    display:block;
    background:var(--surface-muted)
}
.event-body{
    padding:12px
}
.event-name{
    font-size:12px;
    color:var(--muted);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    margin-bottom:12px
}
.duration-row{
    display:flex;
    align-items:center;
    gap:6px
}
.duration-button{
    width:30px;
    height:30px;
    border-radius:0px;
    background:var(--surface-muted);
    color:var(--text);
    font-size:17px
}
.duration-button:hover{
    background:var(--border-light)
}
.duration-input{
    width:65px;
    height:30px;
    text-align:center;
    border:1px solid var(--border);
    border-radius:0px;
    font-size:14px;
    outline:none
}
.duration-input:focus{
    border-color:var(--primary)
}
.duration-unit{
    font-size:12px;
    color:var(--muted)
}
.event-actions{
    display:flex;
    justify-content:flex-end;
    margin-top:11px
}
.delete-event{
    color:var(--danger);
    background:none;
    font-size:12px;
    padding:4px
}
.delete-event:hover{
    text-decoration:underline
}
.handle{
    position:absolute;
    top:9px;
    right:9px;
    color:var(--white);
    font-size:17px;
    text-shadow:0 1px 3px var(--black);
    z-index:2
}
.empty-loop{
    width:100%;
    min-height:280px;
    border:2px dashed var(--border);
    border-radius:0px;
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    color:var(--muted);
    padding:30px
}
.empty-loop.drag-over{
    border-color:var(--primary);
    background:var(--primary-light);
    color:var(--primary)
}
.empty-loop strong{
    display:block;
    color:var(--text);
    margin-bottom:6px
}
.loop-footer{
    border-top:1px solid var(--border);
    padding:14px 18px;
    display:flex;
    align-items:center;
    justify-content:space-between
}
.total-duration{
    font-size:14px;
    font-weight:600
}
.total-duration span{
    color:var(--primary)
}
.status{
    font-size:12px;
    color:var(--muted)
}
.modal{
    display:none;
    position:fixed;
    inset:0;
    z-index:1000;
    align-items:center;
    justify-content:center
}
.modal.open{
    display:flex
}

.image-editor-modal{
    position:relative;
    z-index:1;
    width:min(1100px,94vw);
    max-height:92vh;
    overflow:auto;
    background:var(--white);
    border-radius:5px;
    box-shadow:0 20px 60px var(--overlay-dark-medium)
}
.modal-box {
    position: relative;
    background: var(--white);
    width: min(420px, calc(100vw - 32px));
    border-radius: 5px;
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}

.modal-header {
    box-sizing: border-box;
    height: 58px;
    padding: 0 18px;
    color: #f8fbff;
    display: flex;
    align-items: center;
    background: #2b3947;
    border-radius: 5px 5px 0 0;
}
.modal-header h2{
    margin:0;
    font-size:18px
}
.modal-content{
    padding : 20px;
}

.modal-close{
    margin-left: auto;
    width:34px;
    height:34px;
    padding:0;
    border-radius:0px;
    background: transparent;
    color: white;
    font-size:24px;
    line-height:1
}

.image-editor-layout{
    display:grid;
    grid-template-columns:minmax(0,1fr) 280px;
    gap:20px;
    padding:20px
}
.preview-wrapper{
    position:relative;
    width:100%;
    aspect-ratio:16/9;
    background:var(--surface-dark);
    border-radius:0px;
    overflow:hidden
}
#imageEditorCanvas{
    display:block;
    width:100%;
    height:100%;
    cursor:grab;
    touch-action:none
}
#imageEditorCanvas.dragging{
    cursor:grabbing
}
.editor-empty{
    position:absolute;
    inset:0;
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--muted);
    pointer-events:none
}
.editor-control{
    font-size: 12px;
    margin-bottom:18px
}
.editor-control label{
    display:block;
    margin-bottom:7px;
    font-size:13px;
    font-weight:600
}
.editor-control input[type=file],
.editor-control select{
    width:100%
}
.editor-control select{
    padding:9px;
    border:1px solid var(--border);
    border-radius:0px;
    background:var(--white)
}
.editor-control input[type=color]{
    width:100%;
    height:40px;
    padding:3px;
    border:1px solid var(--border);
    border-radius:0px;
    background:var(--white)
}
.range-row{
    display:flex;
    align-items:center;
    gap:10px
}
.range-row input{
    flex:1
}
.range-row span{
    width:45px;
    text-align:right;
    color:var(--muted);
    font-size:12px
}
.editor-buttons{
    display:flex;
    flex-direction:column;
    gap:8px
}
.editor-status{
    min-height:20px;
    margin-top:10px;
    color:var(--muted);
    font-size:12px
}

.modal-title{
    font-size:20px;
    font-weight:600;
    margin-bottom:10px
}

.save-progress{
    width:100%;
    height:12px;
    background:var(--border-light);
    border-radius:0px;
    overflow:hidden
}

.save-progress-bar{
    width:0%;
    height:100%;
    background:var(--primary);
    border-radius:0px;
    transition:width .2s ease
}

.save-progress-percent{
    margin-top:10px;
    font-size:13px;
    color:var(--muted)
}

@media(max-width:900px){
    .workspace{
        grid-template-columns:1fr
    }
    .image-library{
        min-height:auto
    }
    .images{
        display:grid;
        grid-template-columns:repeat(auto-fill,minmax(180px,1fr))
    }
    .header{
        flex-wrap:wrap
    }
    .header-buttons{
        width:100%;
        margin-left:0
    }
}

.event-settings-modal {
    position: relative;
    z-index: 2;
    width: min(500px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: var(--white);
    border-radius:5px;
    box-shadow: 0 20px 60px var(--overlay-dark-medium);
}

.event-settings-options {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.event-setting-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius:0px;
    cursor: pointer;
    transition: .15s ease;
}

.event-setting-option:hover {
    background: var(--surface-muted);
}

.event-setting-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--overlay-dark-light);
}

.event-setting-option input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.setting-icon {
    width: 32px;
    text-align: center;
    font-size: 22px;
}

.event-setting-option span:last-child {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.event-setting-option small {
    color: var(--muted);
    font-size: 12px;
}

.event-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 20px 20px;
}

.event-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
}

.event-settings-icons {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.event-setting-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    border-radius:0px;
    font-size: 15px;
}

.no-event-settings {
    color: var(--muted);
    font-size: 11px;
}

.event-settings-button {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius:0px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workspace{
    display:grid;
    grid-template-columns:280px 280px minmax(0,1fr);
    gap:5px;
    min-height:0;
    flex:1
}
.loops-panel,.image-library,.loop-panel{
    min-width:0;
    min-height:0
}
.loops-panel,.image-library{
    display:flex;
    flex-direction:column
}
.loops{
    flex:1;
    overflow-y:auto;
    padding:4px
}
.loop-search-input{
    width:calc(100% - 16px);
    box-sizing:border-box;
    margin:0 8px 4px;
    padding:7px 9px;
    border:1px solid #d5d9dd;
    border-radius:0px;
    background:var(--white);
    font:inherit;
    font-size:13px;
    outline:none
}
.loop-search-input:focus{
    border-color:var(--primary)
}
.loop-item{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:12px;
    margin:7px 0;
    padding:9px 10px 9px 9px;
    border:1px solid var(--border-medium);
    border-left:4px solid var(--secondary);
    border-radius:0px;
    box-shadow:0 2px 5px var(--shadow-soft);
    cursor:pointer;
    transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease,background .15s ease
}
.loop-item:hover{
    background:var(--bg-header);
    border-color:var(--border-dark);
    border-left-color:var(--primary);
    box-shadow:0 4px 10px var(--shadow-hover);
    transform:translateY(-1px)
}
.loop-item.active{
    background:var(--surface-active);
    color:var(--primary-dark);
    border-left:4px solid var(--primary);
}

.loop-item-icon{
    width:16px;
    text-align:center;
    opacity:.55;
    flex:0 0 16px;
    font-size:11px
}
.loop-item.active .loop-item-icon{
    background:var(--surface-dark);
    color:var(--primary);
}
.loop-item-name{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    flex:1;
    min-width:0
}
.loop-item-actions{
    display:flex;
    align-items:center;
    gap:1px;
    flex:0 0 auto
}
.loop-item-action{
    width:24px;
    height:24px;
    border:0;
    background:transparent;
    border-radius:0px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    color:inherit;
    opacity:.45;
    font-size:13px;
    padding:0
}
.loop-item-action:hover{
    background:var(--overlay-dark-light);
    opacity:1
}
.loop-item.active .loop-item-action:hover{
    background:var(--overlay-white)
}
.loop-item-action.delete:hover{
    color:var(--danger)
}
.new-loop-button,.new-image-button{
    width:calc(100% - 16px);
    margin:8px;
    flex:0 0 auto
}
.loop-actions{
    display:flex;
    gap:8px;
    align-items:center
}
.loop-toolbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    flex-wrap:wrap
}
.loop-toolbar-left{
    display:flex;
    align-items:center;
    gap:12px;
    min-width:0
}
.loop-toolbar-right{
    display:flex;
    align-items:center;
    gap:8px;
    margin-left:auto
}



.modal {
    position:fixed;
    inset:0;
    display:none;
    align-items:center;
    justify-content:center;
    z-index:1000
}

.modal-image {
    position:fixed;
    inset:0;
    display:none;
    align-items:center;
    justify-content:center;
    z-index:1000
}
.modal-image.open {
    display:flex
}


.modal.open{
    display:flex
}


.modal-box h2{
    margin:0 0 16px
}

.modal label{
    display:block;
    margin-bottom:7px;
    font-weight:600
}

.modal input:not([type="checkbox"]){
    width: 100%;
    height: 36px;
    border: 1px solid var(--border);
    border-radius:0px;
    padding: 0 11px;
    outline: none;
    color: var(--text);
}


.modal-message{
    line-height:1.5;
    color:var(--text-secondary)
}
.modal-actions{
    display:flex;
    justify-content:flex-end;
    gap:8px;
    margin-top:18px
}
.panel-header h2 .count,.loop-title .count{
    font-weight:400;
    color:var(--muted);
    font-size:.8em
}
.loops-empty{
    padding:20px 12px;
    text-align:center;
    color:var(--muted);
    font-size:13px
}

button,input{
    font:inherit
}
.page{
    height:100%;
    display:flex;
    flex-direction:column;
    padding:20px;
    gap:16px;
    min-height:0
}
.topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    flex:0 0 auto
}
.topbar h1{
    font-size:22px;
    margin:0;
    font-weight:600
}
.topbar-sub{
    font-size:13px;
    color:var(--text-secondary);
    margin-top:4px
}
.workspace{
    display:grid;
    grid-template-columns:260px minmax(0,1fr) minmax(0,1fr);
    gap:16px;
    min-height:0;
    flex:1
}
.panel{
    border-radius:5px;
    display:flex;
    flex-direction:column;
    min-width:0;
    min-height:0;
    overflow:hidden;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 3px 12px rgba(20, 35, 50, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.panel-header{
    padding:14px 16px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    flex:0 0 auto
}
.panel-title{
    font-size:16px;
    font-weight:600;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis
}
.panel-count{
    font-size:12px;
    color: var(--text);
    font-weight:400
}
.panel-toolbar{
    padding:12px;
    display:flex;
    flex-direction:column;
    gap:0;
    flex:0 0 auto
}
.search{
    width:100%;
    height:36px;
    border:1px solid var(--border);
    border-radius:0px;
    padding:0 11px;
    outline:none;
    color:var(--text);
    font-size: 11px;
}

.new-group-button{
    width:100%;
    height:34px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:5px;
    background:var(--primary);
    color:var(--white);
    font-size:12px;
    font-weight:500;
    cursor:pointer;
    margin-bottom: 6px;
    transition:background .15s ease,border-color .15s ease
}

.new-group-button:hover{
    background:var(--primary-hover);
    border-color:var(--border-dark)
}

.button-primary{
    background:var(--primary);
    color:var(--white);
    border-color:var(--primary)
}
.button-primary:hover{
    background:var(--primary-hover);
    border-color:var(--primary-hover)
}
.groups{
    overflow-y:auto;
    padding:12px;
    flex:1;
    min-height:0
}
.group-item{
    min-height: 50px;
    display:flex;
    align-items:center;
    gap:8px;
    padding:5px 5px;
    border-radius:0px;
    cursor:pointer;
    border: 1px solid var(--border);
    font-size: 14px;
    background: #fefefe;
    margin-bottom: 2px;
}
.group-item.active{
    color:var(--primary-dark);
    border-left:6px solid var(--primary);
    padding-left:6px
}

/* Group items */
.group-item {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(203, 214, 223, 0.9);
    border-left: 2px solid rgba(177, 192, 205, 0.95);
    padding: 6px 8px;
    gap: 7px;
    box-shadow: 0 1px 2px rgba(29, 51, 69, 0.06);
    transition: background 0.12s ease, border-color 0.12s ease;
}

/* Hover */
.group-item:hover {
    background: rgba(255, 255, 255, 0.97);
    border-color: #b6c8d7;
    box-shadow: 0 2px 5px rgba(29, 51, 69, 0.09);
}

/* Selected group */
.group-item.active {
    background: rgba(229, 242, 251, 0.96);
    border-color: #c1d9e9;
    border-left: 6px solid #087fb9;
    padding-left: 8px;
    color: #20394e;
}


.group-name{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    flex:1;
    min-width:0
}
.group-number{
    color:var(--text-secondary);
    font-size:12px
}
.group-item.active .group-number{
    color:var(--primary)
}
.icon-button{
    width:14px;
    height:28px;
    border:0;
    border-radius:0px;
    display:flex;
    align-items:center;
    background: transparent;
    justify-content:center;
    cursor:pointer;
    color:var(--text);
    padding:0;
    font-size: 11px;
}
.icon-button:hover{
    color : var(--primary);
}
.group-item.active .icon-button:hover{
    background:var(--overlay-active)
}
.group-item-actions{
    display:flex;
    gap:2px;
    flex:0 0 auto
}
.empty{
    color:var(--text-secondary);
    text-align:center;
    padding: 20px 12px;
    font-size:12px
}
.selected-group{
    font-size:12px;
    color: #f8fbff;
    margin-left:auto;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap
}
.footer-note{
    font-size:11px;
    color:var(--text-secondary);
    padding:9px 12px;
    border-top:1px solid var(--border);
    flex:0 0 auto
}
.modal-backdrop{
    position:fixed;
    inset:0;
    background:var(--overlay-dark-light);
    display:none;
    align-items:center;
    justify-content:center;
    padding:20px;
    z-index:1000
}
.modal-backdrop.show{
    display:flex
}
.modal{
    width:100%;
    border:1px solid var(--border);
    border-radius:0px;
    overflow:hidden
}

.modal-body{
    padding:17px
}
.modal-body label{
    display:block;
    font-size:12px;
    color:var(--text-secondary);
    margin-bottom:6px
}
.modal-body input{
    width:100%;
    height:40px;
    border:1px solid var(--border);
    border-radius:0px;
    padding:0 10px;
    outline:none;
    color:var(--text)
}
.modal-body input:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 2px var(--focus-ring)
}

.modal-footer{
    display:flex;
    justify-content:flex-end;
    gap:8px;
    padding:12px 17px;
    border-top:1px solid var(--border)
}
.toast{
    position:fixed;
    right:20px;
    bottom:20px;
    background:var(--text);
    color:var(--white);
    padding:10px 14px;
    border-radius:0px;
    font-size:12px;
    display:none;
    z-index:1100
}
.toast.show{
    display:block
}
@media(max-width:900px){
    .workspace{
        grid-template-columns:220px minmax(0,1fr)
    }
    .available-panel{
        grid-column:1 / -1;
        height:320px
    }
}
@media(max-width:650px){
    .page{
        padding:10px
    }
    .workspace{
        display:flex;
        flex-direction:column
    }
    .panel{
        height:300px
    }
    .groups-panel{
        height:260px
    }
    .available-panel{
        height:300px
    }
    .topbar h1{
        font-size:16px
    }
    .topbar-sub{
        font-size:12px
    }
}

.device-list{
    overflow-y:auto;
    flex:1;
    height:100%;
    padding:7px 10px 10px;
    background:transparent;
    border-radius:0px
}
.device{
    display:grid;
    grid-template-columns:12px minmax(0,1fr);
    grid-template-columns:12px minmax(0,1fr) auto;
    align-items:center;
    gap:4px;
    padding:9px 12px 9px 9px;
    background: #fefefe;
    border-radius:0px;
    cursor:grab;
    margin-bottom: 2px;
    border : 1px solid var(--border);
    transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease,background .15s ease
}

.device:active{
    cursor:grabbing
}
.device.dragging{
    transform:scale(.98)
}
.device-drag{
    width:38px;
    height:38px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:0px;
    background:var(--surface-dark);
    color:var(--secondary);
    border:1px solid var(--border-dark);
    font-size:17px;
    font-weight:700;
    flex:0 0 38px;
    pointer-events:none
}
.device-drag::before{
    content:"⋮⋮";
    letter-spacing:-3px
}
.device-info{
    min-width:0
}
.device-name{
    color:var(--text);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis
}
.device-meta{
    display:flex;
    align-items:center;
    gap:6px;
    margin-top:4px;
    font-size:11px;
    color:var(--text-secondary);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis
}

.device-delete{
    width:30px;
    height:30px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:0px;
    background:transparent;
    color:var(--text);
    font-size:20px;
    cursor:pointer;
}

.device-list.drop-target{
    background:transparent;
    outline:2px dashed var(--secondary);
    outline-offset:-4px;
    border-radius:0px
}
.device-list.drop-target::after{
    content:"Laat apparaat hier los";
    display:block;
    margin:8px;
    padding:10px;
    border:1px dashed var(--secondary);
    border-radius:0px;
    color:var(--primary);
    background:var(--bg-header);
    text-align:center;
    font-size:12px;
    font-weight:500;
    pointer-events:none
}

@media(max-width:1000px){
    .workspace{
        grid-template-columns:190px 240px minmax(0,1fr);
        gap:10px
    }
}
@media(max-width:760px){
    .workspace{
        grid-template-columns:1fr;
        overflow:auto
    }
    .loops-panel,.image-library,.loop-panel{
        min-height:300px
    }
    .loops{
        max-height:260px
    }
}

@media(max-width:800px){
    .image-editor-layout{
        grid-template-columns:1fr
    }
}

/* Loop-editor: shared administration styling */
.loop-editor-workspace{
    display:grid;
    grid-template-columns:260px minmax(280px,1fr) minmax(0,1.8fr);
    gap:16px;
    min-height:0;
    flex:1
}
.loop-editor-workspace .loops-panel,
.loop-editor-workspace .image-library,
.loop-editor-workspace .loop-panel{
    min-width:0;
    min-height:0;
    display:flex;
    flex-direction:column
}
.loop-editor-workspace .loops,
.loop-editor-workspace .images{
    flex:1;
    min-height:0;
    overflow-y:auto
}
.loop-editor-workspace .loops{
    padding:8px
}
.loop-editor-workspace .images{
    padding:7px 10px 10px
}
.loop-editor-workspace .new-group-button{
    margin-top:8px
}
.loop-editor-workspace .image-item.device{
    grid-template-columns:70px minmax(0,1fr);
    padding:9px;
}
.loop-editor-workspace .image-item .image-thumb{
    width:70px;
    height:44px;
    border-radius:0px;
    object-fit:cover;
    background:var(--surface-dark)
}
.loop-editor-workspace .image-item .image-name{
    font-size:12px
}
.loop-editor-workspace .loop-item{
    margin-bottom:2px
}
.loop-editor-workspace .loop-item-icon{
    width:20px;
    flex:0 0 20px;
    color:var(--text-secondary)
}
.loop-editor-workspace .loop-item.active{
    background:var(--surface-active);
    color:var(--primary-dark);
    border-left:4px solid var(--primary);
    padding-left:6px
}
.loop-editor-workspace .loop-item.active .loop-item-icon{
    color:var(--primary);
    opacity:1
}
.loop-editor-workspace .loop-item-action{
    width:28px;
    height:28px
}

.loop-editor-workspace .loop-toolbar-right{
    display:flex;
    align-items:center;
    gap:7px
}
.loop-editor-workspace .loop-container{
    padding:12px;
    flex:1;
    min-height:0;
    overflow-y:auto;
    overflow-x:hidden;
    background:transparent
}
.loop-editor-workspace .loop-events{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
    gap:12px;
    align-items:start;
    min-height:100%;
    padding:2px
}

.loop-editor-workspace .loop-events.is-empty {
    grid-template-columns: 1fr;
}

.loop-editor-workspace .event{
    width:auto;
    min-width:0;
    flex:initial;
    border:1px solid var(--border);
    border-radius:5px;
    overflow:hidden;
    transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease,background .15s ease
}

.loop-editor-workspace .event.drag-over{
    border-color:var(--primary);
    box-shadow:0 0 0 2px var(--overlay-active-strong)
}
.loop-editor-workspace .event-image{
    height:120px
}
.loop-editor-workspace .event-body{
    padding:11px;
    background: #fefefe;
}
.loop-editor-workspace .duration-button{
    background:var(--primary);
    color:white;
}
.loop-editor-workspace .duration-button:hover{
    filter:brightness(.94)
}
.loop-editor-workspace .duration-input{
    border:1px solid var(--border-medium);
    background:var(--white);
    color:var(--text);
    border-radius:0px
}
.loop-editor-workspace .event-settings-button{
    background:var(--primary);
    color:white;
}
.loop-editor-workspace .event-settings-button:hover{
    filter:brightness(.94)
}
.loop-editor-workspace .delete-event{
    color: darkred
}
.loop-editor-workspace .empty-loop{
    border:1px dashed var(--border-medium);
    color:var(--text-secondary);
    border-radius:0px
}
.loop-editor-workspace .empty-loop.drag-over{
    border-color:var(--secondary);
    background:var(--surface-active);
    color:var(--primary)
}
.loop-editor-workspace .loop-footer{
    border-top:1px solid var(--border);
    background:var(--bg-header);
    color:var(--text-secondary);
    padding:10px 14px
}

@media(max-width:1000px){
    .loop-editor-workspace{
        grid-template-columns:220px minmax(260px,1fr);
    }
    .loop-editor-workspace .loop-panel{
        grid-column:1 / -1;
        min-height:420px
    }
}
@media(max-width:760px){
    .loop-editor-workspace{
        grid-template-columns:1fr;
        overflow:auto
    }
    .loop-editor-workspace .loop-panel{
        grid-column:auto;
        min-height:420px
    }
    .loop-editor-workspace .loops-panel,
    .loop-editor-workspace .image-library{
        min-height:300px
    }
}


.hidden{
    display: none !important;
}


.panel-header {
    background: rgba(43, 57, 71, 1);
    color: #f8fbff;
    border-bottom: 1px solid rgba(18, 34, 47, 0.5);
    padding: 10px 13px;
    min-height: 42px;
    display: flex;
    align-items: center;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #7c8da0;
    font-size: 13px;
    pointer-events: none;
}

.search-wrapper .search {
    width: 100%;
    box-sizing: border-box;
    padding-left: 30px;
}
