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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

#noiseCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.3;
}

/* App Layout */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.graph-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a2a;
    background: rgba(15, 15, 15, 0.95);
    transition: all 0.3s ease;
    position: relative;
    min-width: 0; /* Important for flex child to shrink */
}

.results-panel {
    width: 400px;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 10, 0.95);
    transition: transform 0.3s ease, width 0.3s ease;
    position: relative;
    flex-shrink: 0; /* Don't shrink in flex layout */
}

.results-panel.collapsed {
    transform: translateX(100%);
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 400px; /* Maintain width but position absolute */
    z-index: 100;
}

/* Toggle Button */
.results-toggle {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid #2a2a2a;
    border-right: none;
    border-radius: 8px 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.2s ease;
    z-index: 102;
    color: #4ade80;
    user-select: none;
}

.results-toggle:hover {
    background: rgba(20, 20, 20, 0.95);
    left: -42px;
    color: #22c55e;
}

.results-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.results-panel.collapsed .results-toggle {
    left: -40px;
}

/* Header */
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a2a;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0;
}

.subtitle {
    font-size: 0.8rem;
    color: #888;
}

/* Controls Bar */
.controls-bar {
    padding: 12px 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.node-count {
    font-size: 0.8rem;
    color: #888;
    font-weight: 500;
}

.node-count span {
    color: #4ade80;
    font-weight: 600;
}

.control-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 6px 12px;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.control-btn:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
}

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

.control-btn.danger {
    color: #ef4444;
}

.control-btn.danger:hover {
    background: rgba(220, 38, 38, 0.2);
    border-color: #ef4444;
}

/* Graph Container */
.graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0f0f0f;
}

#graphCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

#graphNoiseCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.3;
}

.nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

/* Node Styles - Made Much Smaller */
.node {
    position: absolute;
    background: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.2s ease;
    min-width: 70px;
    max-width: 140px;
    user-select: none;
    font-size: 0.75rem;
}

.node:hover {
    border-color: #4a4a4a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.node.selected {
    border-color: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.node.dragging {
    opacity: 0.8;
    cursor: grabbing;
}

.node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.node-type {
    font-size: 0.6rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.node-actions {
    display: flex;
    gap: 2px;
}

.node-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 1px 3px;
    transition: color 0.2s ease;
}

.node-btn:hover {
    color: #e0e0e0;
}

.node-btn.delete:hover {
    color: #ef4444;
}

.node-content {
    font-size: 0.7rem;
    color: #d0d0d0;
    line-height: 1.2;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.node-icon {
    font-size: 0.9rem;
    margin-bottom: 3px;
}

.node.text-node {
    border-color: #3b82f6;
}

.node.text-node.selected {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
}

.node.image-node {
    border-color: #a855f7;
}

.node.image-node.selected {
    border-color: #c084fc;
    box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.3);
}

.node.audio-node {
    border-color: #f59e0b;
}

.node.audio-node.selected {
    border-color: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.3);
}

.node-image-preview {
    width: 100%;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    margin-top: 4px;
}

/* Mode Indicator */
.mode-indicator {
    padding: 10px 20px;
    border-top: 1px solid #2a2a2a;
    background: #0a0a0a;
    text-align: center;
}

.mode-indicator span {
    font-size: 0.8rem;
    color: #888;
}

/* Generate Section */
.generate-section {
    padding: 12px 20px;
    border-top: 1px solid #2a2a2a;
}

.generate-button {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    background: #4ade80;
    color: #0a0a0a;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.generate-button:hover:not(:disabled) {
    background: #22c55e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.generate-button:active:not(:disabled) {
    transform: translateY(0);
}

.generate-button:disabled {
    background: #2a2a2a;
    color: #666;
    cursor: not-allowed;
}

/* Results Panel */
.results-header {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.icon-btn:hover {
    color: #ef4444;
}

.results-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.help-text {
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
    padding: 16px;
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
}

.help-text h4 {
    color: #e0e0e0;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.help-text ol {
    padding-left: 18px;
}

.help-text li {
    margin-bottom: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Result Card */
.result-card {
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.result-timestamp {
    font-size: 0.7rem;
    color: #666;
}

.result-content {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #d0d0d0;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.result-content strong {
    color: #ffffff;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.result-btn {
    padding: 6px 10px;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.result-btn:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
}

.result-btn.primary {
    background: #4ade80;
    color: #0a0a0a;
    border-color: #4ade80;
}

.result-btn.primary:hover {
    background: #22c55e;
}

.result-steps {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #2a2a2a;
}

.result-steps h4 {
    font-size: 0.85rem;
    color: #e0e0e0;
    margin-bottom: 10px;
}

.steps-content {
    font-size: 0.8rem;
    line-height: 1.6;
    color: #b0b0b0;
    white-space: pre-wrap;
}

.steps-loading {
    text-align: center;
    padding: 16px;
    color: #666;
}

.spinner-small {
    width: 20px;
    height: 20px;
    margin: 0 auto 8px;
    border: 2px solid #2a2a2a;
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlide 0.3s ease;
}

.modal-content.small {
    max-width: 300px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 16px;
}

.editor-section {
    margin-bottom: 16px;
}

.editor-section label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #b0b0b0;
    margin-bottom: 6px;
}

textarea {
    width: 100%;
    padding: 10px;
    background: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: all 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: #4a4a4a;
    background: #0f0f0f;
}

textarea::placeholder {
    color: #555;
}

/* File upload option for text node */
.file-upload-option {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #2a2a2a;
}

.file-hint {
    font-size: 0.7rem;
    color: #666;
    margin-top: 6px;
    font-style: italic;
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

input[type="file"] {
    display: none;
}

.file-button {
    padding: 8px 16px;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.file-button:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
}

.file-name {
    font-size: 0.8rem;
    color: #666;
    flex: 1;
}

.preview-container {
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2a2a2a;
}

.preview-container img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    background: #0a0a0a;
}

.record-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.record-button {
    padding: 8px 16px;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.record-button:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
}

.record-button.recording {
    background: #dc2626;
    border-color: #ef4444;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.record-icon {
    font-size: 0.9rem;
}

.record-timer {
    font-size: 0.8rem;
    color: #888;
}

.record-timer.active {
    color: #ef4444;
    font-weight: 500;
}

.waveform {
    width: 100%;
    height: 60px;
    margin-top: 10px;
    border-radius: 6px;
    border: 1px solid #2a2a2a;
    background: #0a0a0a;
}

.audio-playback {
    margin-top: 10px;
}

.audio-playback audio {
    width: 100%;
    height: 40px;
}

.weight-editor {
    margin-bottom: 16px;
}

.weight-editor label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #b0b0b0;
    margin-bottom: 10px;
}

.weight-editor input[type="range"] {
    width: 100%;
    height: 6px;
    background: #2a2a2a;
    border-radius: 3px;
    outline: none;
    margin-bottom: 8px;
}

.weight-editor input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4ade80;
    border-radius: 50%;
    cursor: pointer;
}

.weight-editor input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4ade80;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#weightValue {
    display: block;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #4ade80;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.action-button {
    flex: 1;
    padding: 10px;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.action-button:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
}

.action-button.primary {
    background: #4ade80;
    color: #0a0a0a;
    border-color: #4ade80;
}

.action-button.primary:hover {
    background: #22c55e;
}

.action-button.danger {
    background: rgba(220, 38, 38, 0.2);
    color: #ef4444;
    border-color: rgba(220, 38, 38, 0.3);
}

.action-button.danger:hover {
    background: rgba(220, 38, 38, 0.3);
    border-color: #ef4444;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #2a2a2a;
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 0.9rem;
    color: #888;
}

.hidden {
    display: none !important;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3a3a;
}

/* Mobile Blocker - Show warning on mobile/tablet devices */
.mobile-blocker {
    display: none;
}

@media (max-width: 1024px) {
    .mobile-blocker {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #000000;
        z-index: 999999;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .mobile-blocker-content {
        text-align: center;
        color: #e0e0e0;
        max-width: 500px;
    }
    
    .mobile-blocker-icon {
        font-size: 4rem;
        margin-bottom: 20px;
    }
    
    .mobile-blocker h2 {
        font-size: 1.5rem;
        margin-bottom: 16px;
        color: #4ade80;
    }
    
    .mobile-blocker p {
        font-size: 1rem;
        line-height: 1.6;
        color: #b0b0b0;
    }
    
    /* Hide main content on mobile */
    .app-container,
    #noiseCanvas {
        display: none !important;
    }
}