:root {
    /* Colors */
    --bg-deep: #030508;
    --bg-surface: #0B0F19;
    --bg-surface-glass: rgba(11, 15, 25, 0.7);
    --bg-card: #131824;
    --bg-card-hover: #1A202E;
    
    --primary: #6366F1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #A855F7;
    --accent: #14B8A6;
    --accent-glow: rgba(20, 184, 166, 0.4);
    
    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;
    --text-dim: #4B5563;
    
    --border: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.05);
    
    /* Gradients */
    --gradient-main: linear-gradient(135deg, #6366F1 0%, #A855F7 100%);
    --gradient-glow: radial-gradient(circle at top left, rgba(99, 102, 241, 0.15), transparent 40%);
    
    /* Typography */
    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-deep);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 20%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Layout */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-surface-glass);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
}

.brand-logo {
    font-size: 24px;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px;
    position: relative;
}

.view-header {
    margin-bottom: 32px;
    animation: fadeIn 0.4s ease-out;
}

.view-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.view-subtitle {
    color: var(--text-muted);
    font-size: 15px;
}

/* Glass Cards */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.glass-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }

/* Stats */
.stat-value {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    margin: 8px 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-trend {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up { color: #10B981; }
.trend-down { color: #EF4444; }
.trend-neutral { color: var(--text-dim); }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 16px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 16px;
    color: var(--text-main);
    border-bottom: 1px solid var(--glass-border);
    font-size: 14px;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.data-table th.sortable:hover {
    background: rgba(255, 255, 255, 0.05);
}
.data-table th.sortable i {
    vertical-align: middle;
    margin-left: 4px;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-thriving { background: rgba(16, 185, 129, 0.1); color: #10B981; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-stable { background: rgba(59, 130, 246, 0.1); color: #3B82F6; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-outlier { background: rgba(168, 85, 247, 0.1); color: #A855F7; border: 1px solid rgba(168, 85, 247, 0.2); }
.badge-declining { background: rgba(249, 115, 22, 0.1); color: #F97316; border: 1px solid rgba(249, 115, 22, 0.2); }

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: #4F46E5;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Utilities */
.text-mono { font-family: var(--font-mono); }
.text-accent { color: var(--accent); }
.text-primary { color: var(--primary); }

.search-bar {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-main);
    width: 100%;
    font-family: var(--font-ui);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-bar:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Search Component Styles */
.search-container {
    margin-bottom: 24px;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 36px 10px 40px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.search-input::placeholder {
    color: var(--text-dim);
}

.search-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-clear {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.search-clear i {
    width: 16px;
    height: 16px;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-header {
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--glass-border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
    background: rgba(99, 102, 241, 0.1);
}

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

.search-result-title {
    font-weight: 500;
    color: var(--text-main);
    font-size: 14px;
    flex: 1;
}

.search-result-title mark {
    background: rgba(99, 102, 241, 0.3);
    color: var(--primary);
    border-radius: 2px;
    padding: 1px 2px;
}

.search-result-preview {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-preview mark {
    background: rgba(99, 102, 241, 0.2);
    color: var(--text-main);
    border-radius: 2px;
    padding: 1px 2px;
}

.search-result-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-dim);
}

.search-no-results,
.search-error {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.search-no-results i,
.search-error i {
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

.search-error {
    color: #EF4444;
}

/* Markdown Content */
.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3 {
    color: var(--text-main);
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.markdown-content p {
    margin-bottom: 16px;
}

.markdown-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
    transition: all 0.2s;
}

.markdown-content a:hover {
    border-bottom-color: var(--primary);
}

.markdown-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: #E5E7EB;
}

.markdown-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.markdown-content ul, 
.markdown-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.markdown-content li {
    margin-bottom: 8px;
}

.markdown-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    margin-left: 0;
    margin-bottom: 16px;
    color: var(--text-dim);
    font-style: italic;
}

/* Slide-out Panel */
.slide-out-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 500px;
    background: var(--bg-surface-glass);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.slide-out-panel.open {
    transform: translateX(0);
}

.slide-out-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slide-out-title {
    font-weight: 600;
    color: var(--text-main);
}

.slide-out-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

/* Shadow Tweet Renderer */
.shadow-tweet {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #e7e9ea;
    max-width: 550px;
    margin: 0 auto;
}

.shadow-tweet-header {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.shadow-tweet-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #333;
    object-fit: cover;
}

.shadow-tweet-author {
    display: flex;
    flex-direction: column;
}

.shadow-tweet-name {
    font-weight: 700;
    color: #e7e9ea;
    font-size: 15px;
}

.shadow-tweet-handle {
    color: #71767b;
    font-size: 15px;
}

.shadow-tweet-text {
    font-size: 17px;
    line-height: 1.5;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.shadow-tweet-image {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12px;
    max-height: 400px;
    object-fit: cover;
}

.shadow-tweet-meta {
    color: #71767b;
    font-size: 15px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
}

.shadow-tweet-metrics {
    display: flex;
    gap: 24px;
    color: #71767b;
    font-size: 14px;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shadow-reply {
    margin-top: 12px;
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    position: relative;
}

.shadow-thread-connector {
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 auto;
    height: 20px;
}

/* Shadow Enriched Content */
.shadow-enriched-section {
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

.enriched-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.enriched-title {
    font-weight: 600;
    font-size: 14px;
    color: #e7e9ea;
}

.enriched-content {
    padding: 16px;
}

.enriched-content h3 {
    font-size: 18px;
    font-weight: 700;
    color: #e7e9ea;
    margin-bottom: 8px;
}

.enriched-content p {
    color: #71767b;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.enriched-authors {
    font-style: italic;
    font-size: 13px;
    color: #8b8f95;
}

.enriched-meta {
    display: flex;
    gap: 16px;
    margin: 12px 0;
    font-size: 14px;
    color: #71767b;
}

.enriched-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Organism link buttons */
.organism-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.link-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.link-button i {
  width: 16px;
  height: 16px;
}

.tweet-link:hover {
  border-color: #1DA1F2;
  color: #1DA1F2;
}

.github-link:hover {
  border-color: #6e5494;
  color: #6e5494;
}

.website-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}
