:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-card: #2d2d2d;
    --bg-hover: #3a3a3a;
    --primary: #00bcd4;
    --primary-dark: #008ba3;
    --secondary: #ff4081;
    --text: #e0e0e0;
    --text-muted: #aaaaaa;
    --border: #444;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}
body {
    background-color: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
}
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    overflow-x: hidden;
}
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}
.logo h1 {
    font-size: 2.2rem;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.logo i {
    font-size: 2.5rem;
    color: var(--primary);
}
.status-bar {
    display: flex;
    gap: 20px;
    align-items: center;
}
.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.status-item i {
    font-size: 1.2rem;
}
.connected .status-dot {
    background-color: var(--success);
}
.disconnected .status-dot {
    background-color: var(--danger);
}
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.battery {
    color: var(--warning);
}
.emergency-stop {
    background-color: var(--danger);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.emergency-stop:hover {
    background-color: #d32f2f;
}
.main-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}
.panel {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.panel h2 {
    margin-bottom: 20px;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.panel h2 i {
    font-size: 1.3rem;
}
.timeline {
    min-height: 400px;
}
.timeline-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-dark);
}
.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text);
}
.btn-secondary:hover {
    background-color: var(--bg-hover);
}
.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-warning {
    background-color: var(--warning);
    color: white;
}
.btn-danger {
    background-color: var(--danger);
    color: white;
}
.steps-list {
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.step-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    transition: background 0.3s;
}
.step-item:hover {
    background: var(--bg-hover);
}
.step-item.step-active {
    background: rgba(0, 188, 212, 0.2);
    border-left: 4px solid var(--primary);
    animation: pulse-step 1.5s ease-in-out infinite;
}
@keyframes pulse-step {
    0%, 100% {
        background: rgba(0, 188, 212, 0.2);
    }
    50% {
        background: rgba(0, 188, 212, 0.35);
    }
}
.step-item:last-child {
    border-bottom: none;
}
.step-handle {
    cursor: move;
    color: var(--text-muted);
    margin-right: 15px;
    font-size: 1.2rem;
}
.step-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}
.step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.move-left { background-color: #2196f3; }
.move-right { background-color: #3f51b5; }
.wait { background-color: #ff9800; }
.speed { background-color: #4caf50; }
.loop { background-color: #9c27b0; }
.step-details {
    flex: 1;
}
.step-title {
    font-weight: bold;
    margin-bottom: 5px;
}
.step-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.step-actions {
    display: flex;
    gap: 15px;
}
.step-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    transition: color 0.3s;
}
.step-actions button:hover {
    color: var(--primary);
}
.manual-controls .control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
.control-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}
.control-btn:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}
.control-btn i {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--primary);
}
.speed-selector {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}
.speed-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    color: var(--text);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}
.speed-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
/* Acceleration section */
.accel-heading {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary);
}

.accel-selector {
    display: flex;
    gap: 10px;
}

.accel-selector .accel-btn {
    flex: 1;
}

.accel-hint {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Acceleration buttons */
.accel-btn {
    border: 2px solid var(--border);
    transition: all 0.3s;
}
.accel-btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}
.accel-btn:hover:not(.active) {
    border-color: var(--primary);
}
/* Step icon for acceleration */
.accel { background-color: #e91e63; }
.preset-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}
.preset-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
}
.preset-icon {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 10px;
}
.preset-title {
    font-weight: bold;
    margin-bottom: 5px;
}
.preset-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.sequencer-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}
.sequencer-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}
.play-btn {
    background: var(--success);
    color: white;
}
.play-btn:hover:not(:disabled) {
    background: #388e3c;
}
.pause-btn {
    background: var(--warning);
    color: white;
}
.pause-btn:hover:not(:disabled) {
    background: #f57c00;
}
.stop-btn {
    background: var(--danger);
    color: white;
}
.stop-btn:hover:not(:disabled) {
    background: #d32f2f;
}
/* Disabled button states */
.sequencer-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(50%);
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(50%);
}
footer {
    margin-top: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}
/* Preset Actions Bar */
.preset-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.preset-search {
    flex: 1;
    position: relative;
}

.preset-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.preset-search input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
}

.preset-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.preset-action-buttons {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Preset Categories */
.preset-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.category-tab {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s;
    white-space: nowrap;
}

.category-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.category-tab .count {
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
}

/* Enhanced Preset Cards */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    padding-right: 5px;
    padding-top: 10px;
}

.presets-grid::-webkit-scrollbar {
    width: 6px;
}

.presets-grid::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 3px;
}

.presets-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.presets-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.preset-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.preset-card:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.preset-card.custom {
    border-left: 3px solid var(--warning);
}

.preset-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.preset-info {
    flex: 1;
    min-width: 0;
}

.preset-title {
    font-weight: bold;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preset-meta {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.preset-meta span {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.preset-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.preset-card:hover .preset-actions {
    opacity: 1;
}

.preset-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s;
}

.preset-action-btn:hover {
    background: var(--bg-dark);
    color: var(--primary);
}

.preset-action-btn.delete:hover {
    color: var(--danger);
}

/* Empty preset state */
.presets-grid .empty-state {
    padding: 40px 20px;
}

.presets-grid .empty-state i {
    font-size: 2.5rem;
}

/* Save Preset Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 25px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal h3 {
    margin-bottom: 20px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body {
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Tags Input */
.tags-input {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 42px;
}

.tags-input:focus-within {
    border-color: var(--primary);
}

.tag-item {
    background: var(--primary);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tag-item button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    font-size: 0.8rem;
}

.tags-input input {
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
    flex: 1;
    min-width: 100px;
    padding: 3px;
}

@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* Mobile responsive styles */
@media (max-width: 600px) {
    /* Force all elements to respect viewport */
    *:not(i):not(.fas):not(.fab):not(.far) {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .container {
        padding: 10px;
        max-width: 100%;
        width: 100%;
        overflow-x: hidden;
    }
    
    .left-column,
    .right-column {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 0;
    }
    
    .logo {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }
    
    .logo h1 {
        font-size: 1.3rem;
        word-break: break-word;
    }
    
    .logo i {
        font-size: 1.6rem;
    }
    
    .status-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }
    
    .status-item {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .status-item span {
        white-space: nowrap;
    }
    
    .emergency-stop {
        padding: 10px 15px;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }
    
    .main-layout {
        gap: 15px;
    }
    
    .panel {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .panel p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .panel h2 {
        font-size: 1rem;
        margin-bottom: 12px;
        flex-wrap: wrap;
    }
    
    .panel h2 i {
        font-size: 1.1rem;
    }
    
    .timeline {
        min-height: auto;
    }
    
    .timeline-controls {
        gap: 6px;
    }
    
    .timeline-controls .btn {
        padding: 8px 10px;
        font-size: 0.75rem;
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        justify-content: center;
        white-space: nowrap;
    }
    
    .timeline-controls .btn i {
        font-size: 0.85rem;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .sequencer-controls {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 20px;
    }
    
    .sequencer-btn {
        padding: 10px 8px;
        font-size: 0.8rem;
        flex: 1 1 30%;
        min-width: 0;
        justify-content: center;
    }
    
    .sequencer-btn i {
        font-size: 0.9rem;
    }
    
    /* Hide button text on small screens, show only icons */
    .sequencer-btn span,
    .sequencer-btn:not(:has(i))::after {
        display: inline;
    }
    
    .manual-controls .control-grid {
        gap: 8px;
        width: 100%;
    }
    
    .control-btn {
        padding: 12px 6px;
        min-width: 0;
    }
    
    .control-btn i {
        font-size: 1.3rem;
        margin-bottom: 6px;
    }
    
    .control-btn span {
        font-size: 0.7rem;
    }
    
    .speed-selector {
        gap: 4px;
        justify-content: space-around;
        flex-wrap: wrap;
    }
    
    .speed-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
        flex-shrink: 0;
    }
    
    .accel-selector {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .accel-btn {
        font-size: 0.85rem !important;
        width: 100% !important;
        flex: none !important;
    }
    
    .accel-hint {
        font-size: 0.8rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    .preset-actions-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .preset-search {
        width: 100%;
    }
    
    .preset-search input {
        font-size: 0.9rem;
    }
    
    .preset-action-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .preset-categories {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .category-tab {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .presets-grid {
        max-height: 280px;
    }
    
    .preset-card {
        padding: 10px;
    }
    
    .preset-icon {
        width: 35px;
        height: 35px;
        font-size: 0.95rem;
    }
    
    .preset-info {
        overflow: hidden;
    }
    
    .preset-title {
        font-size: 0.9rem;
    }
    
    .preset-desc {
        font-size: 0.8rem;
    }
    
    .preset-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .preset-meta span {
        font-size: 0.7rem;
    }
    
    .step-item {
        padding: 10px;
    }
    
    .step-handle {
        margin-right: 10px;
        font-size: 1rem;
    }
    
    .step-content {
        gap: 8px;
        min-width: 0;
        flex: 1;
    }
    
    .step-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        flex-shrink: 0;
    }
    
    .step-details {
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }
    
    .step-title {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .step-desc {
        font-size: 0.75rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .step-actions {
        gap: 5px;
    }
    
    .step-actions button {
        font-size: 0.9rem;
        padding: 4px;
    }
    
    .empty-state {
        padding: 40px 15px;
    }
    
    .empty-state i {
        font-size: 3rem;
    }
    
    .empty-state h3 {
        font-size: 1rem;
    }
    
    .empty-state p {
        font-size: 0.85rem;
    }
    
    .info p {
        font-size: 0.9rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .info ul {
        padding-left: 15px;
        font-size: 0.85rem;
    }
    
    .info ul li {
        margin-bottom: 5px;
        word-wrap: break-word;
    }
    
    footer {
        margin-top: 15px;
        padding-top: 12px;
        font-size: 0.75rem;
    }
    
    footer p {
        word-break: break-word;
    }
    
    /* Modal adjustments */
    .modal {
        padding: 15px;
        width: 95%;
    }
    
    .modal h3 {
        font-size: 1rem;
    }
    
    .form-group label {
        font-size: 0.85rem;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    /* Override inline styles */
    [style*="display: flex"][style*="gap"] {
        gap: 8px !important;
    }
    
    [style*="flex: 1"] {
        flex: none !important;
        width: 100% !important;
    }
    
    /* Fix manual controls paragraph */
    .manual-controls p[style] {
        font-size: 0.8rem !important;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .container {
        padding: 8px;
    }
    
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .status-item {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
    
    .timeline-controls .btn {
        flex: 1 1 100%;
        padding: 10px;
    }
    
    .speed-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    
    .control-btn span {
        display: none;
    }
    
    .control-btn i {
        margin-bottom: 0;
    }
}

/* Drag and drop styles for timeline steps */
.step-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.step-item.drag-over {
    background-color: rgba(0, 188, 212, 0.1);
    border-left: 3px solid var(--primary);
}