* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        :root {
            --bg: #0a0a0f;
            --surface: #12121a;
            --border: #2a2a3a;
            --text: #e0e0e0;
            --accent: #6366f1;
            --accent2: #8b5cf6;
            --post-color: #22c55e;
            --reply-color: #f59e0b;
        }
        
        body {
            font-family: 'SF Mono', 'Fira Code', monospace;
            background: var(--bg);
            color: var(--text);
            overflow: hidden;
            height: 100vh;
        }
        
        #app {
            display: grid;
            grid-template-columns: 280px 1fr 350px;
            height: 100vh;
        }
        
        /* User List Panel */
        #user-panel {
            background: var(--surface);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        #user-panel-header {
            padding: 15px;
            border-bottom: 1px solid var(--border);
        }
        
        #user-panel-header h2 {
            font-size: 14px;
            margin-bottom: 10px;
            color: var(--accent);
        }
        
        #add-user-form {
            display: flex;
            gap: 8px;
            margin-bottom: 10px;
        }
        
        #add-user-form input {
            flex: 1;
            background: var(--bg);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 8px 12px;
            border-radius: 6px;
            font-family: inherit;
            font-size: 11px;
        }
        
        #add-user-form input:focus {
            outline: none;
            border-color: var(--accent);
        }
        
        #add-user-form button {
            padding: 8px 12px;
            width: auto;
            margin: 0;
        }
        
        .sort-options {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }
        
        .sort-btn {
            padding: 5px 10px;
            font-size: 10px;
            background: var(--bg);
            border: 1px solid var(--border);
            color: #888;
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.2s;
        }
        
        .sort-btn:hover, .sort-btn.active {
            border-color: var(--accent);
            color: var(--accent);
        }
        
        #user-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
        }
        
        .user-card {
            background: var(--bg);
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 8px;
            cursor: pointer;
            transition: all 0.2s;
            border: 2px solid transparent;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .user-card:hover {
            border-color: var(--border);
        }
        
        .user-card.selected {
            border-color: var(--accent);
            box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--accent), var(--accent2));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            flex-shrink: 0;
            overflow: hidden;
        }
        
        .user-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .user-info {
            flex: 1;
            min-width: 0;
        }
        
        .user-name {
            font-size: 12px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .user-npub {
            font-size: 9px;
            color: #666;
            margin-top: 2px;
        }
        
        .user-stats {
            font-size: 9px;
            color: var(--accent);
            margin-top: 4px;
        }
        
        .user-remove {
            background: none;
            border: none;
            color: #666;
            cursor: pointer;
            font-size: 16px;
            padding: 4px;
            opacity: 0;
            transition: opacity 0.2s;
        }
        
        .user-card:hover .user-remove {
            opacity: 1;
        }
        
        .user-remove:hover {
            color: #f87171;
        }
        
        /* Canvas - Timeline Visualization */
        #canvas-container {
            position: relative;
            overflow: hidden;
            background: 
                radial-gradient(circle at center, #15151f 0%, #0a0a0f 100%);
        }
        
        #timeline-canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        
        #timeline-header {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 50px;
            background: linear-gradient(to bottom, var(--surface), transparent);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 15px;
            z-index: 10;
        }
        
        #selected-user-info {
            font-size: 14px;
            color: var(--accent);
        }
        
        #timeline-legend {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--surface);
            padding: 10px 20px;
            border-radius: 20px;
            display: flex;
            gap: 20px;
            font-size: 11px;
        }
        
        .legend-item {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .legend-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }
        
        .legend-dot.post { background: var(--post-color); }
        .legend-dot.reply { background: var(--reply-color); }
        
        /* Event node on timeline */
        .event-node {
            position: absolute;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.2s;
            transform: translate(-50%, -50%);
        }
        
        .event-node.post {
            background: var(--post-color);
            box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
        }
        
        .event-node.reply {
            background: var(--reply-color);
            box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
        }
        
        .event-node:hover {
            transform: translate(-50%, -50%) scale(1.5);
            z-index: 100;
        }
        
        .event-node.selected {
            transform: translate(-50%, -50%) scale(1.8);
            z-index: 101;
        }
        
        /* Animation styles */
        .event-node.animated-in {
            animation: nodeAppear 0.4s ease-out forwards;
        }
        
        .event-node.hidden {
            opacity: 0;
            transform: translate(-50%, -50%) scale(0);
        }
        
        @keyframes nodeAppear {
            0% {
                opacity: 0;
                transform: translate(-50%, -50%) scale(0);
            }
            50% {
                transform: translate(-50%, -50%) scale(1.5);
            }
            100% {
                opacity: 1;
                transform: translate(-50%, -50%) scale(1);
            }
        }
        
        /* Timeline toolbar container */
        #timeline-toolbar {
            position: absolute;
            bottom: 60px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 10px;
            z-index: 15;
        }
        
        /* Playback controls */
        #playback-controls {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 25px;
            padding: 8px 16px;
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .playback-btn {
            background: none;
            border: none;
            color: var(--text);
            cursor: pointer;
            font-size: 18px;
            padding: 4px 8px;
            border-radius: 4px;
            transition: all 0.2s;
            width: auto;
            margin: 0;
        }
        
        .playback-btn:hover {
            background: var(--border);
        }
        
        .playback-btn.active {
            color: var(--accent);
        }
        
        #playback-progress {
            width: 120px;
            height: 4px;
            background: var(--border);
            border-radius: 2px;
            overflow: hidden;
            cursor: pointer;
        }
        
        #playback-progress-bar {
            height: 100%;
            background: linear-gradient(90deg, var(--accent), var(--accent2));
            width: 0%;
            transition: width 0.1s linear;
        }
        
        #playback-time {
            font-size: 10px;
            color: #888;
            min-width: 45px;
            text-align: center;
        }
        
        #playback-speed {
            font-size: 9px;
            color: var(--accent);
            cursor: pointer;
            padding: 2px 6px;
            background: var(--bg);
            border-radius: 4px;
        }
        
        /* Hour markers */
        .hour-marker {
            position: absolute;
            font-size: 9px;
            color: #444;
            transform: translateX(-50%);
        }
        
        /* Sidebar - Event Details */
        #sidebar {
            background: var(--surface);
            border-left: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        .panel {
            padding: 15px;
            border-bottom: 1px solid var(--border);
        }
        
        .panel h3 {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: #666;
            margin-bottom: 12px;
        }
        
        #view-toggle {
            display: flex;
            gap: 8px;
        }
        
        .toggle-btn {
            flex: 1;
            padding: 10px;
            font-size: 11px;
            background: var(--bg);
            border: 1px solid var(--border);
            color: #888;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.2s;
        }
        
        .toggle-btn:hover {
            border-color: var(--accent);
        }
        
        .toggle-btn.active {
            background: linear-gradient(135deg, var(--accent), var(--accent2));
            border-color: transparent;
            color: white;
        }
        
        #event-detail {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
        }
        
        .event-card {
            background: var(--bg);
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 12px;
            border-left: 3px solid var(--accent);
        }
        
        .event-card.post {
            border-left-color: var(--post-color);
        }
        
        .event-card.reply {
            border-left-color: var(--reply-color);
        }
        
        .event-time {
            font-size: 10px;
            color: var(--accent);
            margin-bottom: 8px;
        }
        
        .event-content {
            font-size: 12px;
            line-height: 1.6;
            color: var(--text);
            word-break: break-word;
        }
        
        .event-meta {
            font-size: 9px;
            color: #666;
            margin-top: 10px;
            display: flex;
            gap: 12px;
        }
        
        #stats-panel {
            padding: 15px;
            background: var(--bg);
            margin: 15px;
            border-radius: 8px;
        }
        
        .stat-row {
            display: flex;
            justify-content: space-between;
            font-size: 11px;
            margin-bottom: 6px;
        }
        
        .stat-label { color: #666; }
        .stat-value { color: var(--accent); }
        
        /* Buttons */
        button {
            background: linear-gradient(135deg, var(--accent), var(--accent2));
            border: none;
            color: white;
            padding: 10px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-family: inherit;
            font-size: 12px;
            width: 100%;
            margin-bottom: 8px;
            transition: opacity 0.2s;
        }
        
        button:hover {
            opacity: 0.85;
        }
        
        button.secondary {
            background: var(--border);
        }
        
        /* Toast */
        #toast {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: var(--accent);
            color: white;
            padding: 12px 24px;
            border-radius: 8px;
            font-size: 12px;
            opacity: 0;
            transition: opacity 0.3s;
            z-index: 1000;
        }
        
        #toast.show {
            opacity: 1;
        }
        
        /* Loading */
        .loading {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            color: #666;
            font-size: 12px;
        }
        
        .spinner {
            width: 20px;
            height: 20px;
            border: 2px solid var(--border);
            border-top-color: var(--accent);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-right: 10px;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* Empty state */
        .empty-state {
            text-align: center;
            color: #666;
            padding: 40px 20px;
            font-size: 12px;
        }
        
        .empty-state .icon {
            font-size: 48px;
            margin-bottom: 15px;
            opacity: 0.5;
        }
        
        /* Relay status bar */
        #relay-bar {
            position: absolute;
            top: 50px;
            left: 10px;
            right: 10px;
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            z-index: 5;
        }
        
        .relay-chip {
            background: var(--surface);
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 9px;
            display: flex;
            align-items: center;
            gap: 5px;
            border: 1px solid var(--border);
        }
        
        .relay-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #666;
        }
        
        .relay-dot.connecting { background: #f59e0b; animation: pulse 1s infinite; }
        .relay-dot.connected { background: #22c55e; }
        .relay-dot.error { background: #ef4444; }
        .relay-dot.closed { background: #666; }
        
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        
        /* Relay manager panel */
        #relay-manager {
            position: absolute;
            top: 50px;
            right: 10px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 12px;
            z-index: 20;
            width: 280px;
            display: none;
        }
        
        #relay-manager.show { display: block; }
        
        #relay-manager h4 {
            font-size: 11px;
            color: var(--accent);
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        #relay-manager .close-btn {
            background: none;
            border: none;
            color: #666;
            cursor: pointer;
            font-size: 16px;
            padding: 0;
            width: auto;
            margin: 0;
        }
        
        .relay-list {
            max-height: 200px;
            overflow-y: auto;
            margin-bottom: 10px;
        }
        
        .relay-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 0;
            border-bottom: 1px solid var(--border);
            font-size: 10px;
        }
        
        .relay-item:last-child { border-bottom: none; }
        
        .relay-item .relay-url {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        
        .relay-item .relay-toggle {
            background: var(--bg);
            border: 1px solid var(--border);
            color: #888;
            padding: 2px 8px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 9px;
            width: auto;
            margin: 0;
        }
        
        .relay-item .relay-toggle.active {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }
        
        #add-relay-form {
            display: flex;
            gap: 6px;
        }
        
        #add-relay-form input {
            flex: 1;
            background: var(--bg);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 6px 10px;
            border-radius: 4px;
            font-size: 10px;
            font-family: inherit;
        }
        
        #add-relay-form button {
            padding: 6px 10px;
            width: auto;
            margin: 0;
            font-size: 10px;
        }
        
        /* Relay toggle button */
        #relay-toggle-btn {
            position: absolute;
            top: 12px;
            right: 12px;
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 6px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 10px;
            z-index: 15;
            display: flex;
            align-items: center;
            gap: 6px;
            width: auto;
            margin: 0;
        }
        
        #relay-toggle-btn:hover {
            border-color: var(--accent);
        }
        
        .relay-count {
            background: var(--accent);
            padding: 2px 6px;
            border-radius: 10px;
            font-size: 9px;
        }
        
        /* Time range selector */
        #time-range {
            display: flex;
            gap: 4px;
            margin-top: 10px;
            flex-wrap: nowrap;
            align-items: center;
        }
        
        .time-btn {
            padding: 5px 10px;
            font-size: 10px;
            background: var(--bg);
            border: 1px solid var(--border);
            color: #888;
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.2s;
        }
        
        .time-btn:hover, .time-btn.active {
            border-color: var(--accent);
            color: var(--accent);
        }
        
        #custom-time-input {
            width: 42px;
            padding: 5px 6px;
            font-size: 9px;
            background: var(--bg);
            border: 1px solid var(--border);
            color: var(--text);
            border-radius: 4px;
            font-family: inherit;
        }
        
        .time-btn {
            padding: 5px 8px;
        }
        
        #custom-time-input:focus {
            outline: none;
            border-color: var(--accent);
        }
        
        /* Connection lines SVG */
        #connections-svg, #compare-connections-svg {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 1;
        }
        
        .connection-line {
            fill: none;
            stroke-width: 2;
            opacity: 0.6;
            transition: opacity 0.3s;
        }
        
        .connection-line.thread {
            stroke: url(#threadGradient);
            stroke-dasharray: 4 2;
        }
        
        .connection-line.compare-thread {
            stroke: url(#compareThreadGradient);
            stroke-dasharray: 4 2;
        }
        
        .connection-line.self-reply {
            stroke: url(#selfReplyGradient);
        }
        
        .connection-line.highlighted {
            opacity: 1;
            stroke-width: 3;
        }
        
        .connection-line.dimmed {
            opacity: 0.15;
        }
        
        /* Thread toggle button */
        #thread-toggle {
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 8px 12px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 11px;
            display: flex;
            align-items: center;
            gap: 6px;
            width: auto;
            margin: 0;
            white-space: nowrap;
        }
        
        #thread-toggle:hover {
            border-color: var(--accent);
        }
        
        #thread-toggle.active {
            background: var(--accent);
            border-color: var(--accent);
        }
        
        /* Event node with thread indicator */
        .event-node.has-thread::after {
            content: '';
            position: absolute;
            width: 6px;
            height: 6px;
            background: var(--accent);
            border-radius: 50%;
            top: -3px;
            right: -3px;
        }
        
        /* Thread info in event card */
        .thread-info {
            font-size: 9px;
            color: var(--accent);
            margin-top: 6px;
            padding: 4px 8px;
            background: rgba(99, 102, 241, 0.1);
            border-radius: 4px;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .thread-info .thread-icon {
            font-size: 12px;
        }
        
        /* Identity panel */
        #identity-panel {
            padding: 12px;
            background: var(--bg);
            border-radius: 8px;
            margin: 10px;
        }
        
        #identity-info {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }
        
        #identity-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--accent), var(--accent2));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            overflow: hidden;
        }
        
        #identity-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        #identity-details {
            flex: 1;
            min-width: 0;
        }
        
        #identity-name {
            font-size: 12px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        #identity-npub {
            font-size: 9px;
            color: #666;
        }
        
        .identity-btn {
            padding: 8px 12px;
            font-size: 10px;
            margin: 0;
            margin-bottom: 6px;
        }
        
        .identity-btn.login {
            background: linear-gradient(135deg, #f7931a, #ff6b00);
        }
        
        .identity-btn.small {
            padding: 6px 10px;
            font-size: 9px;
        }
        
        #identity-actions {
            display: flex;
            gap: 6px;
        }
        
        #identity-actions button {
            flex: 1;
        }
        
        /* NIP-07 indicator */
        .nip07-badge {
            font-size: 8px;
            background: #f7931a;
            color: black;
            padding: 2px 6px;
            border-radius: 10px;
            margin-left: 6px;
        }
        
        /* Comparison Mode */
        #app.compare-mode {
            grid-template-columns: 280px 1fr 1fr 350px;
        }
        
        #compare-container {
            display: none;
            position: relative;
            overflow: hidden;
            background: 
                radial-gradient(circle at center, #15151f 0%, #0a0a0f 100%);
            border-left: 1px solid var(--border);
            min-width: 0; /* Prevent grid blowout */
        }
        
        #app.compare-mode #compare-container {
            display: block;
        }
        
        #canvas-container {
            min-width: 0; /* Prevent grid blowout */
        }
        
        #compare-canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        
        #compare-header {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 50px;
            background: linear-gradient(to bottom, var(--surface), transparent);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 15px;
            z-index: 10;
        }
        
        #compare-user-info {
            font-size: 14px;
            color: var(--accent2);
        }
        
        #compare-legend {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--surface);
            padding: 10px 20px;
            border-radius: 20px;
            display: flex;
            gap: 20px;
            font-size: 11px;
        }
        
        /* Compare node layer */
        #compare-nodes {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 5;
        }
        
        #compare-nodes .event-node {
            pointer-events: auto;
            width: 18px;
            height: 18px;
            box-shadow: 0 0 14px rgba(139, 92, 246, 0.7);
            border: 2px solid rgba(255, 255, 255, 0.3);
        }
        
        #compare-nodes .event-node.post {
            background: #34d399;
            box-shadow: 0 0 14px rgba(52, 211, 153, 0.8);
        }
        
        #compare-nodes .event-node.reply {
            background: #fbbf24;
            box-shadow: 0 0 14px rgba(251, 191, 36, 0.8);
        }
        
        /* Compare toggle button */
        #compare-toggle {
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 8px 12px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 11px;
            display: flex;
            align-items: center;
            gap: 6px;
            width: auto;
            margin: 0;
            white-space: nowrap;
        }
        
        #compare-toggle:hover {
            border-color: var(--accent2);
        }
        
        #compare-toggle.active {
            background: var(--accent2);
            border-color: var(--accent2);
        }
        
        /* User card compare button */
        .user-compare-btn {
            background: transparent;
            border: 1px solid var(--accent2);
            color: var(--accent2);
            cursor: pointer;
            font-size: 12px;
            padding: 4px 6px;
            border-radius: 4px;
            opacity: 0.7;
            transition: all 0.2s;
            flex-shrink: 0;
            width: 50px;
            margin-left: 100px;

        }
        
        .user-card:hover .user-compare-btn {
            opacity: 1;
        }
        
        .user-compare-btn:hover {
            background: var(--accent2);
            color: white;
        }
        
        .user-compare-btn.active {
            opacity: 1;
            background: var(--accent2);
            color: white;
        }
        
        /* Compare stats panel */
        #compare-stats {
            padding: 15px;
            background: var(--bg);
            margin: 15px;
            border-radius: 8px;
            border-left: 3px solid var(--accent2);
        }
        
        #compare-stats h4 {
            font-size: 10px;
            color: var(--accent2);
            margin-bottom: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .compare-stat-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 10px;
            margin-bottom: 6px;
        }
        
        .compare-stat-row .stat-label {
            color: #666;
            flex: 1;
        }
        
        .compare-stat-row .stat-user1 {
            color: var(--accent);
            width: 50px;
            text-align: right;
        }
        
        .compare-stat-row .stat-user2 {
            color: var(--accent2);
            width: 50px;
            text-align: right;
        }
        
        .compare-bar {
            display: flex;
            height: 4px;
            background: var(--border);
            border-radius: 2px;
            overflow: hidden;
            margin-top: 4px;
        }
        
        .compare-bar .bar-user1 {
            background: var(--accent);
            transition: width 0.3s;
        }
        
        .compare-bar .bar-user2 {
            background: var(--accent2);
            transition: width 0.3s;
        }