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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
}

.desktop {
    height: calc(100vh - 40px);
    position: relative;
    padding: 20px;
}

.icon {
    width: 80px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.icon-image {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 8px;
    margin: 0 auto 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.icon-label {
    color: white;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.icon:hover .icon-image {
    background: #e0e0e0;
}

.window {
    position: absolute;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    min-width: 400px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.window-header {
    background: #f0f0f0;
    padding: 10px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.window-header-small {
    padding: 3px 10px;
    min-height: 15px;
    font-size: 12px;
}

.window-title {
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.window-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    background: #e0e0e0;
}

.window-btn:hover {
    background: #d0d0d0;
}

.window-btn.close:hover {
    background: #e81123;
    color: white;
}

.address-bar {
    background: white;
    padding: 0;
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease, padding 0.3s ease;
}

.window-header:hover + .address-bar,
.address-bar:hover {
    height: 40px;
    padding: 8px;
}

.address-bar input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}

.address-bar input:focus {
    outline: none;
    border-color: #0078d4;
}

.nav-btn {
    padding: 6px 12px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.nav-btn:hover {
    background: #e0e0e0;
}

.window-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.folder-content {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    overflow: auto;
    position: relative;
    padding: 20px;
}

.window-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

.window-content iframe.resizing {
    pointer-events: none;
}

body.resizing {
    cursor: nwse-resize !important;
    user-select: none;
}

body.resizing * {
    cursor: nwse-resize !important;
}

body.dragging {
    cursor: move !important;
    user-select: none;
}

body.dragging * {
    cursor: move !important;
}

.window-content iframe.dragging {
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: nwse-resize;
    z-index: 10;
}

.resize-handle::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 10px 10px;
    border-color: transparent transparent #999 transparent;
}

.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 5px;
}

.start-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.start-btn img {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

.start-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.start-menu {
    position: fixed;
    bottom: 50px;
    left: 10px;
    width: 300px;
    height: 500px;
    background: #252525;
    backdrop-filter: blur(20px);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 10000;
    padding: 10px;
    overflow-y: auto;
    flex-direction: column;
}

.start-menu.open {
    display: flex;
}

.widget-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.widget-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.widget-item img {
    width: 32px;
    height: 32px;
}

.widget-item span {
    color: white;
    font-size: 14px;
}

#taskbarItems {
    display: flex;
    gap: 5px;
    align-items: center;
}

.taskbar-item {
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.taskbar-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.taskbar-item:hover {
    background: rgba(255,255,255,0.2);
}

.taskbar-item.active {
    background: rgba(255,255,255,0.3);
}

.widget-tray {
    margin-left: auto;
    position: relative;
}

.widget-tray-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 12px;
    padding: 8px 12px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.widget-tray-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.widget-tray-popup {
    display: none;
    position: absolute;
    bottom: 45px;
    right: 0;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    min-width: 120px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.widget-tray-popup.active {
    display: grid;
    grid-template-columns: repeat(auto-fill, 36px);
    gap: 6px;
}

.widget-tray-popup.empty::after {
    content: 'No minimized widgets';
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    white-space: nowrap;
}

.widget-tray-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.widget-tray-item:hover {
    background: rgba(255,255,255,0.1);
}

.widget-tray-item img {
    width: 24px;
    height: 24px;
}

.taskbar-clock {
    padding: 4px 12px;
    text-align: center;
    color: #fff;
    font-size: 12px;
    cursor: default;
    user-select: none;
}

.taskbar-clock .clock-time {
    font-weight: 500;
}

.taskbar-clock .clock-date {
    font-size: 11px;
    opacity: 0.8;
}

/* App Icons */
.app-icon {
    position: absolute;
    width: 80px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s;
}

.app-icon:hover {
    transform: scale(1.05);
}

.app-icon.dragging {
    opacity: 0.7;
    transition: none;
}

.app-icon.drop-target {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.app-icon.selected::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -4.5px;
    bottom: -4.5px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    pointer-events: none;
    z-index: -1;
}

/* Drag selection rectangle */
.selection-box {
    position: absolute;
    border: 2px solid rgba(100, 150, 255, 0.8);
    background: rgba(100, 150, 255, 0.2);
    pointer-events: none;
    z-index: 9998;
}

.app-icon img {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 8px;
    padding: 8px;
    margin: 0 auto 5px;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.app-label {
    color: white;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    word-wrap: break-word;
    max-width: 80px;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-width: 180px;
    z-index: 10000;
    overflow: hidden;
}

.context-menu-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: #f0f0f0;
}

.context-menu-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

/* Rename Input */
.app-rename-input {
    width: 80px;
    padding: 2px 4px;
    background: white;
    border: 1px solid #0078d4;
    border-radius: 2px;
    font-size: 12px;
    text-align: center;
    outline: none;
    color: #000;
}

/* Delete Modal */
.delete-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.delete-modal {
    background: white;
    border-radius: 8px;
    padding: 24px;
    min-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.delete-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.delete-modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

.delete-modal-message {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
    line-height: 1.5;
}

.delete-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.delete-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.delete-modal-btn.cancel {
    background: #e0e0e0;
    color: #333;
}

.delete-modal-btn.cancel:hover {
    background: #d0d0d0;
}

.delete-modal-btn.delete {
    background: #e81123;
    color: white;
}

.delete-modal-btn.delete:hover {
    background: #c50f1f;
}

/* Style Editor */
.style-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.style-editor-window {
    background: white;
    border-radius: 8px;
    width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.style-editor-header {
    background: #f0f0f0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
}

.style-editor-title {
    font-size: 14px;
    font-weight: 500;
}

.style-editor-close {
    width: 24px;
    height: 24px;
    border: none;
    background: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.style-editor-close:hover {
    background: #e81123;
    color: white;
}

.style-editor-content {
    padding: 20px;
}

.style-editor-field {
    margin-bottom: 20px;
}

.style-editor-field:last-child {
    margin-bottom: 0;
}

.style-editor-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

.style-editor-field input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}

.style-editor-field input[type="text"]:focus {
    outline: none;
    border-color: #0078d4;
}

.color-picker-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-picker-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.color-picker-group input[type="text"] {
    flex: 1;
}

.style-editor-footer {
    padding: 12px 16px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.style-editor-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.style-editor-btn.cancel {
    background: #e0e0e0;
    color: #333;
}

.style-editor-btn.cancel:hover {
    background: #d0d0d0;
}

.style-editor-btn.save {
    background: #0078d4;
    color: white;
}

.style-editor-btn.save:hover {
    background: #106ebe;
}

/* Background Editor */
.background-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.background-editor-window {
    background: white;
    border-radius: 8px;
    width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.background-editor-header {
    background: #f0f0f0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
}

.background-editor-title {
    font-size: 14px;
    font-weight: 500;
}

.background-editor-close {
    width: 24px;
    height: 24px;
    border: none;
    background: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.background-editor-close:hover {
    background: #e81123;
    color: white;
}

.background-editor-content {
    padding: 20px;
}

.background-editor-field {
    margin-bottom: 0;
}

.background-editor-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

.background-editor-field input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}

.background-editor-field input[type="text"]:focus {
    outline: none;
    border-color: #0078d4;
}

.background-editor-footer {
    padding: 12px 16px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.background-editor-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.background-editor-btn.cancel {
    background: #e0e0e0;
    color: #333;
}

.background-editor-btn.cancel:hover {
    background: #d0d0d0;
}

.background-editor-btn.save {
    background: #0078d4;
    color: white;
}

.background-editor-btn.save:hover {
    background: #106ebe;
}

/* Program Configuration Modal */
.program-config-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.program-config-window {
    background: white;
    border-radius: 8px;
    width: 1000px;
    max-width: 95vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}


.program-config-header {
    background: #f0f0f0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ccc;
}

.program-config-title {
    font-size: 14px;
    font-weight: 500;
}

.program-config-close {
    width: 24px;
    height: 24px;
    border: none;
    background: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.program-config-close:hover {
    background: #e81123;
    color: white;
}

.program-config-content {
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.program-config-field {
    margin-bottom: 20px;
}

.program-config-field:last-child {
    margin-bottom: 0;
}

.program-config-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

.program-config-field input[type="text"],
.program-config-field input[type="password"],
.program-config-field textarea,
.program-config-field select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: 'Courier New', monospace;
    background: #fff;
}

.program-config-field select {
    cursor: pointer;
    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 10px center;
    padding-right: 30px;
}

.program-config-field select:focus {
    outline: none;
    border-color: #0078d4;
}

.program-config-field textarea {
    resize: vertical;
    min-height: 60px;
}

/* Terminal-style command textarea (xterm style) */
.program-config-field textarea.terminal-input {
    background-color: #000;
    color: #f0f0f0;
    font-family: 'Menlo', 'DejaVu Sans Mono', 'Consolas', 'Lucida Console', monospace;
    font-size: 13px;
    line-height: 1.2;
    letter-spacing: 0;
    border: none;
    border-radius: 0;
    padding: 8px;
    min-height: 120px;
    resize: vertical;
}

.program-config-field textarea.terminal-input::placeholder {
    color: #666;
}

.program-config-field textarea.terminal-input:focus {
    outline: none;
    border: none;
}

/* Terminal container for maximize button */
.terminal-container {
    position: relative;
}

.terminal-maximize-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.terminal-container:hover .terminal-maximize-btn {
    opacity: 1;
}

.terminal-maximize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Maximized terminal overlay */
.terminal-maximized-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 30000;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.terminal-maximized-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.terminal-maximized-title {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.terminal-minimized-btn {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.terminal-minimized-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.terminal-maximized-overlay textarea {
    flex: 1;
    background-color: #000;
    color: #f0f0f0;
    font-family: 'Menlo', 'DejaVu Sans Mono', 'Consolas', 'Lucida Console', monospace;
    font-size: 14px;
    line-height: 1.3;
    border: none;
    border-radius: 0;
    padding: 12px;
    resize: none;
    outline: none;
}

.terminal-maximized-overlay textarea::placeholder {
    color: #666;
}

.program-config-field input[type="text"]:focus,
.program-config-field input[type="password"]:focus,
.program-config-field textarea:focus {
    outline: none;
    border-color: #0078d4;
}

.program-config-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    user-select: none;
}

.program-config-section-toggle:hover {
    color: #0078d4;
}

.section-toggle-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.program-config-more-section {
    padding-left: 18px;
    border-left: 2px solid #e0e0e0;
    margin-bottom: 15px;
}

.program-config-footer {
    padding: 12px 16px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.program-config-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.program-config-btn.cancel {
    background: #e0e0e0;
    color: #333;
}

.program-config-btn.cancel:hover {
    background: #d0d0d0;
}

.program-config-btn.save {
    background: #0078d4;
    color: white;
}

.program-config-btn.save:hover {
    background: #106ebe;
}

.program-config-btn.run {
    background: #22c55e;
    color: white;
}

.program-config-btn.run:hover {
    background: #16a34a;
}

.program-config-btn.saverun {
    background: #7c3aed;
    color: white;
}

.program-config-btn.saverun:hover {
    background: #6d28d9;
}

/* Program Mode Toggle */
.program-mode-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
}

.mode-btn {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid #444;
    background: #2d2d2d;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.mode-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.mode-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.mode-btn:hover {
    background: #3d3d3d;
    color: #ccc;
}

.mode-btn.active {
    background: #0078d4;
    border-color: #0078d4;
    color: white;
}

.mode-description {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* Command Type Toggle (orangish pill buttons) */
.command-type-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
}

.command-type-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #444;
    background: #2d2d2d;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.command-type-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.command-type-btn:last-child {
    border-radius: 0;
}

.command-type-btn.last-visible {
    border-radius: 0 6px 6px 0;
}

.command-type-btn:not(:first-child) {
    border-left: none;
}

.command-type-btn:hover {
    background: #3d3d3d;
    color: #ccc;
}

.command-type-btn.active {
    background: #e07020;
    border-color: #e07020;
    color: white;
}

.command-type-btn.active:hover {
    background: #f08030;
    border-color: #f08030;
}

/* Custom Commands Hamburger Button */
.custom-commands-btn {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #444;
    background: #2d2d2d;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s;
    border-left: none;
}
.custom-commands-btn img {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    transition: opacity .15s;
}
.custom-commands-btn:hover { background: #3d3d3d; }
.custom-commands-btn:hover img { opacity: 0.85; }
.custom-commands-btn.active { background: #e07020; border-color: #e07020; }
.custom-commands-btn.active img { opacity: 1; filter: brightness(10); }

/* No command-type-btn gets right radius — the hamburger button owns it */
.command-type-toggle .command-type-btn.last-visible { border-radius: 0; }

/* Custom Commands Panel */
.custom-commands-panel {
    margin-bottom: 8px;
    padding: 6px 0 0 0;
}

/* Expandable Combobox Module Styles */
.ecb-field { display: flex; flex-direction: column; gap: 6px; }
.ecb-label { font-size: 13px; color: #cdd6f4; font-weight: 500; }
.ecb-row { display: flex; gap: 4px; align-items: center; }
.ecb-combo-col { position: relative; flex: 1; }
.ecb-combo {
    width: 100%; background: #11111e; border: 1px solid #2a2a45; border-radius: 4px;
    padding: 8px 12px; color: #cdd6f4; cursor: pointer; user-select: none;
    display: flex; justify-content: space-between; align-items: center; transition: border-color .15s;
}
.ecb-combo:hover:not(.ecb-disabled) { border-color: #3a3a60; }
.ecb-combo.ecb-disabled { cursor: default; opacity: 0.4; }
.ecb-combo.ecb-open { border-color: #3b82f6; }
.ecb-arrow { color: #555; font-size: 10px; transition: .2s; }
.ecb-combo.ecb-open .ecb-arrow { transform: rotate(180deg); }
.ecb-text {
    flex: 1; outline: none; min-width: 0; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.ecb-text[contenteditable=true] { caret-color: #3b82f6; border-bottom: 1px solid #3b82f6; }
.ecb-dropdown {
    position: absolute; top: calc(100% + 3px); left: 0; right: 0;
    background: #11111e; border: 1px solid #2a2a45; border-radius: 4px;
    overflow: hidden; display: none; z-index: 10; box-shadow: 0 6px 20px #00000077;
}
.ecb-dropdown.ecb-open { display: block; }
.ecb-opt {
    padding: 8px 12px; color: #cdd6f4; cursor: pointer; outline: none; font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}
.ecb-opt:hover { background: #1e1e3a; }
.ecb-opt.ecb-selected { background: #1d3461; color: #93c5fd; }
.ecb-opt-icon { width: 16px; height: 16px; flex-shrink: 0; object-fit: contain; }
.ecb-opt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ecb-icon { width: 16px; height: 16px; flex-shrink: 0; object-fit: contain; margin-right: 8px; }
.ecb-edit-row {
    display: flex; gap: 4px;
}
.ecb-edit-icon, .ecb-edit-name {
    background: #11111e; border: 1px solid #3b82f6; border-radius: 4px;
    padding: 8px 10px; color: #cdd6f4; font-size: 13px; font-family: inherit; outline: none;
}
.ecb-edit-icon { flex: 1; min-width: 0; }
.ecb-edit-name { flex: 1; min-width: 0; }
.ecb-add, .ecb-remove {
    background: #11111e; border: 1px solid #2a2a45; border-radius: 4px;
    width: 30px; height: 34px; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: .15s; flex-shrink: 0; color: #3b82f6;
}
.ecb-add:hover { border-color: #3b82f6; background: rgba(59,130,246,0.07); }
.ecb-remove { color: #555; cursor: default; opacity: 0.35; }
.ecb-remove.ecb-active { color: #ef4444; cursor: pointer; opacity: 1; }
.ecb-remove.ecb-active:hover { border-color: #ef4444; background: rgba(239,68,68,0.07); }

/* Pill Toggle */
.pill-toggle {
    width: 50px;
    height: 26px;
    background: #3d3d3d;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
    margin: 8px 0;
}

.pill-toggle.active {
    background: #0078d4;
}

.pill-slider {
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform 0.2s ease;
}

.pill-toggle.active .pill-slider {
    transform: translateX(24px);
}

/* Program Loading Overlay */
.program-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.program-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #0078d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.program-loading-text {
    color: #d4d4d4;
    font-size: 14px;
    margin-top: 20px;
}

.program-loading-terminal {
    margin-top: 20px;
    max-width: 80%;
    max-height: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    padding: 0 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #00ff00;
    text-align: left;
    opacity: 0;
    transition: all 0.3s ease-out;
}

.program-loading-terminal.has-output {
    max-height: 200px;
    padding: 10px;
    opacity: 1;
    overflow-y: auto;
}

.program-loading-terminal pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Hover-to-reveal terminal */
.program-loading-overlay .loading-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.3s ease;
}

.program-loading-overlay .loading-terminal-hover {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1e1e1e;
    padding: 15px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #d4d4d4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.program-loading-overlay .loading-terminal-hover pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.program-loading-overlay.show-terminal .loading-status {
    opacity: 0;
}

.program-loading-overlay.show-terminal .loading-terminal-hover {
    opacity: 1;
    pointer-events: auto;
}

/* Hold-to-End Close Button */
.close-btn-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
}

.close-btn-wrapper .window-btn.close {
    position: relative;
    z-index: 1;
}

.close-progress-ring {
    position: absolute;
    top: -1px;
    left: -1px;
    width: 26px;
    height: 26px;
    z-index: 2;
    transform: rotate(-90deg);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.close-progress-ring.active {
    opacity: 1;
}

.close-progress-ring circle {
    fill: none;
    stroke-width: 2.5;
}

.close-progress-ring .progress-bg {
    stroke: rgba(120, 60, 70, 0.3);
}

.close-progress-ring .progress-bar {
    stroke: #8b5a5a;
    stroke-dasharray: 72;
    stroke-dashoffset: 72;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

.close-progress-ring.animating .progress-bar {
    animation: closeProgressFill 3s linear forwards;
}

@keyframes closeProgressFill {
    0% {
        stroke-dashoffset: 72;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.window-btn.close.holding {
    background: #8b5a5a;
    color: white;
    transform: scale(1.05);
}

/* Night Mode */
body.night-mode .taskbar {
    background: rgba(0, 0, 0, 0.9);
}

body.night-mode .taskbar-item {
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
}

body.night-mode .taskbar-item:hover {
    background: rgba(255, 255, 255, 0.18);
}

body.night-mode .taskbar-item.active {
    background: rgba(255, 255, 255, 0.25);
}

body.night-mode .start-menu {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e0e0e0;
}

body.night-mode .start-menu-item {
    color: #e0e0e0;
}

body.night-mode .start-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.night-mode .context-menu {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.night-mode .context-menu-item {
    color: #e0e0e0;
}

body.night-mode .context-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.night-mode .window-header {
    background: #1e1e2e !important;
    color: #e0e0e0;
}

body.night-mode .window-title {
    color: #e0e0e0;
}

body.night-mode .window-title span {
    color: #e0e0e0;
}

body.night-mode .window-btn {
    background: #3a3a4e;
    color: #e0e0e0;
}

body.night-mode .window-btn:hover {
    background: #4a4a5e;
    color: #ffffff;
}

body.night-mode .window-btn.close {
    background: #3a3a4e;
    color: #e0e0e0;
}

body.night-mode .window-btn.close:hover {
    background: #c42b1c;
    color: #ffffff;
}

body.night-mode .address-bar {
    background: #0d1117;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .address-bar input {
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .address-bar input::placeholder {
    color: #707070;
}

body.night-mode .window {
    background: #1e1e2e;
}

body.night-mode .window-content {
    background: #1e1e2e;
}

body.night-mode .nav-btn {
    background: #2a2a3e;
    color: #b0b0b0;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .nav-btn:hover {
    background: #3a3a4e;
    color: #e0e0e0;
}

body.night-mode .widget-tray-popup {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.night-mode .widget-tray-btn {
    color: #b0b0b0;
}

body.night-mode .widget-tray-btn:hover {
    color: #e0e0e0;
}

body.night-mode .start-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

body.night-mode .delete-modal {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.night-mode .delete-modal-title {
    color: #e0e0e0;
}

body.night-mode .delete-modal-message {
    color: #b0b0b0;
}

body.night-mode .delete-modal-btn {
    background: #2a2a3e;
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .delete-modal-btn:hover {
    background: #3a3a4e;
}

body.night-mode .delete-modal-btn.delete {
    background: #c42b1c;
    color: #fff;
}

body.night-mode .delete-modal-btn.delete:hover {
    background: #d43b2c;
}

body.night-mode .style-editor-btn,
body.night-mode .background-editor-btn,
body.night-mode .program-config-btn {
    background: #2a2a3e;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.night-mode .style-editor-btn:hover,
body.night-mode .background-editor-btn:hover,
body.night-mode .program-config-btn:hover {
    background: #3a3a4e;
}

body.night-mode .style-editor-btn.save,
body.night-mode .background-editor-btn.save,
body.night-mode .program-config-btn.save {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

body.night-mode .style-editor-btn.save:hover,
body.night-mode .background-editor-btn.save:hover,
body.night-mode .program-config-btn.save:hover {
    background: #3b82f6;
}

body.night-mode .program-config-btn.run {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

body.night-mode .program-config-btn.run:hover {
    background: #16a34a;
}

body.night-mode .program-config-btn.saverun {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
}

body.night-mode .program-config-btn.saverun:hover {
    background: #6d28d9;
}

body.night-mode .mode-btn {
    background: #2a2a3e;
    color: #b0b0b0;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .mode-btn:hover {
    background: #3a3a4e;
    color: #e0e0e0;
}

body.night-mode .mode-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

body.night-mode .command-type-btn {
    background: #2a2a3e;
    color: #b0b0b0;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .command-type-btn:hover {
    background: #3a3a4e;
    color: #e0e0e0;
}

body.night-mode .command-type-btn.active {
    background: #c2410c;
    color: #fff;
    border-color: #c2410c;
}

body.night-mode .custom-commands-btn {
    background: #2a2a3e;
    border-color: rgba(255, 255, 255, 0.15);
}
body.night-mode .custom-commands-btn:hover { background: #3a3a4e; }
body.night-mode .custom-commands-btn.active { background: #c2410c; border-color: #c2410c; }

/* Night mode for editor modals */
body.night-mode .style-editor-window,
body.night-mode .background-editor-window,
body.night-mode .program-config-window {
    background: #1e1e2e;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .style-editor-header,
body.night-mode .background-editor-header,
body.night-mode .program-config-header {
    background: #161622;
    border-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .style-editor-title,
body.night-mode .background-editor-title,
body.night-mode .program-config-title {
    color: #e0e0e0;
}

body.night-mode .style-editor-close,
body.night-mode .background-editor-close,
body.night-mode .program-config-close {
    color: #b0b0b0;
    background: #3a3a4a;
}

body.night-mode .style-editor-close:hover,
body.night-mode .background-editor-close:hover,
body.night-mode .program-config-close:hover {
    color: #f56565;
}

body.night-mode .style-editor-field label,
body.night-mode .background-editor-field label,
body.night-mode .program-config-field label {
    color: #b0b0b0;
}

body.night-mode .style-editor-field input[type="text"],
body.night-mode .background-editor-field input[type="text"],
body.night-mode .program-config-field input[type="text"],
body.night-mode .program-config-field input[type="password"],
body.night-mode .program-config-field textarea,
body.night-mode .program-config-field select {
    background: #0d1117;
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .style-editor-field input[type="text"]:focus,
body.night-mode .background-editor-field input[type="text"]:focus,
body.night-mode .program-config-field input[type="text"]:focus,
body.night-mode .program-config-field input[type="password"]:focus,
body.night-mode .program-config-field textarea:focus,
body.night-mode .program-config-field select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

body.night-mode .style-editor-field input[type="text"]::placeholder,
body.night-mode .background-editor-field input[type="text"]::placeholder,
body.night-mode .program-config-field input[type="text"]::placeholder,
body.night-mode .program-config-field input[type="password"]::placeholder,
body.night-mode .program-config-field textarea::placeholder {
    color: #606060;
}

body.night-mode .style-editor-footer,
body.night-mode .background-editor-footer,
body.night-mode .program-config-footer {
    background: #161622;
    border-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .program-config-section-toggle {
    color: #888;
}

body.night-mode .program-config-section-toggle:hover {
    color: #4da6ff;
}

body.night-mode .program-config-more-section {
    border-left-color: #333;
}
