/* CrabScholar — Premium Knowledge Graph Viewer */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-deep: #080c18;
    --bg-panel: rgba(12, 16, 32, 0.92);
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-input: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #f0f0f5;
    --text-secondary: #8b8fa3;
    --text-muted: #50546b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-2: #06b6d4;
    --accent-3: #a78bfa;
    --success: #34d399;
    --warning: #fbbf24;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Control Panel === */
#crab-controls {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 999;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    width: 310px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.02);
    max-height: calc(100vh - 28px);
    overflow-y: auto;
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
}

#crab-controls::-webkit-scrollbar {
    width: 3px;
}

#crab-controls::-webkit-scrollbar-track {
    background: transparent;
}

#crab-controls::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

#crab-controls::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* === Header === */
.rc-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.rc-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
    background-size: 300% 100%;
    animation: gradient-slide 4s linear infinite;
}

@keyframes gradient-slide {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 300% 50%;
    }
}

.rc-title {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.rc-title .rc-logo {
    font-size: 20px;
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4));
}

.rc-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

/* === Sections === */
.rc-section {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

.rc-section:last-child {
    border-bottom: none;
}

.section-header {
    font-weight: 600;
    margin: 0 0 8px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-header .section-icon {
    font-size: 12px;
    opacity: 0.6;
}

/* === Search === */
#search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    box-sizing: border-box;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: all var(--transition);
}

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

#search-input::placeholder {
    color: var(--text-muted);
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-muted);
    pointer-events: none;
}

/* === Slider === */
.slider-group {
    margin-top: 10px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.slider-value {
    color: var(--accent);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* === Type Rows === */
.type-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 1px 0;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.type-row:hover {
    background: var(--bg-hover);
}

.type-row input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
}

.type-row input[type="color"] {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
    transition: border-color var(--transition);
}

.type-row input[type="color"]:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.type-label {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    font-weight: 500;
    color: var(--text-secondary);
}

.type-count {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(255, 255, 255, 0.04);
    padding: 1px 6px;
    border-radius: 4px;
}

/* === Stats Footer === */
.rc-stats {
    padding: 12px 18px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.rc-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rc-stat-num {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 12px;
}

/* === Detail Panel === */
#detail-panel {
    position: fixed;
    top: 0;
    right: -360px;
    z-index: 998;
    width: 350px;
    height: 100vh;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#detail-panel.open {
    right: 0;
}

#detail-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.01);
}

#detail-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 270px;
    letter-spacing: -0.2px;
}

#detail-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

#detail-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

#detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

#detail-body::-webkit-scrollbar {
    width: 3px;
}

#detail-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.d-field {
    margin-bottom: 12px;
}

.d-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.d-val {
    font-size: 13px;
    color: var(--text-primary);
    word-wrap: break-word;
    line-height: 1.5;
}

.d-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: var(--shadow-sm);
}

/* === Connection Rows === */
.d-conn {
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    transition: background var(--transition);
}

.d-conn:last-child {
    border-bottom: none;
}

.d-conn-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    cursor: pointer;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
}

.d-conn-header:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.d-conn-summary {
    flex: 1;
    min-width: 0;
}

.d-conn-summary span:first-child {
    font-size: 9px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.d-conn-nav {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent);
    cursor: pointer;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    flex-shrink: 0;
    font-weight: 500;
    transition: all var(--transition);
}

.d-conn-nav:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
    transform: translateX(2px);
}

.d-conn.expanded .d-conn-detail {
    display: block;
}

.d-conn-detail {
    display: none;
    padding: 4px 6px 10px;
    animation: slideDown 0.2s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.d-edge-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin: 4px 0;
    border-left: 3px solid var(--accent);
    transition: background var(--transition);
}

.d-edge-card:hover {
    background: var(--bg-hover);
}

.d-edge-card .d-label {
    font-size: 9px;
    margin-bottom: 2px;
}

.d-edge-card .d-val {
    font-size: 11px;
    color: var(--text-secondary);
}

.d-evidence {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border-left: 3px solid var(--accent-2);
    white-space: pre-wrap;
    font-family: 'Inter', sans-serif;
}

.d-conn-group-header {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 10px 0 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
    font-weight: 600;
}

/* === Edge Tooltip === */
#edge-tooltip {
    display: none;
    position: fixed;
    pointer-events: none;
    background: var(--bg-panel);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    z-index: 9999;
    max-width: 300px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
    white-space: nowrap;
}

/* === Animations === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#crab-controls {
    animation: fadeIn 0.4s ease-out;
}