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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Upload Screen */
#upload-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #f5f7fa;
}

#upload-screen.hidden {
    display: none;
}

#dropzone {
    width: 500px;
    padding: 48px;
    border: 3px dashed #d1d5db;
    border-radius: 16px;
    text-align: center;
    background: #ffffff;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

#dropzone:hover,
#dropzone.drag-over {
    border-color: #0088aa;
    background: #e8f7fa;
}

#dropzone.drag-over {
    border-style: solid;
}

.dropzone-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

#dropzone h2 {
    color: #0088aa;
    margin-bottom: 8px;
    font-size: 24px;
}

.dropzone-subtitle {
    color: #6b7280;
    margin-bottom: 24px;
}

#file-input {
    display: none;
}

.required-files {
    text-align: left;
    margin: 24px 0;
    padding: 16px;
    background: #eaecf0;
    border-radius: 8px;
}

.required-files p {
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.file-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.file-status:last-child {
    border-bottom: none;
}

.status-icon {
    font-size: 14px;
    color: #9ca3af;
}

.file-status.loaded .status-icon {
    color: #4ade80;
}

.file-status.loaded .status-icon::before {
    content: '●';
}

.file-name {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #4a5568;
}

.file-status.loaded .file-name {
    color: #4ade80;
}

#btn-load {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    background: #e5e7eb;
    color: #9ca3af;
    font-size: 16px;
    font-weight: bold;
    cursor: not-allowed;
    transition: background 0.2s, color 0.2s;
}

#btn-load:not(:disabled) {
    background: #0088aa;
    color: #ffffff;
    cursor: pointer;
}

#btn-load:not(:disabled):hover {
    background: #006688;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#app.hidden {
    display: none;
}

/* Example Selector */
#example-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid #d1d5db;
}

#example-dropdown {
    flex: 1;
    max-width: 500px;
    padding: 8px 12px;
    font-size: 14px;
    color: #1a1a2e;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}

#example-dropdown:hover {
    border-color: #0088aa;
}

#example-dropdown:focus {
    border-color: #0088aa;
    box-shadow: 0 0 0 2px rgba(0, 136, 170, 0.2);
}

#example-dropdown option {
    background: #ffffff;
    color: #1a1a2e;
}

#btn-load-custom {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: bold;
    color: #ffffff;
    background: #0088aa;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-load-custom:hover {
    background: #006688;
}

/* Color Legend */
#color-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border-bottom: 1px solid #d1d5db;
}

.legend-label {
    font-size: 12px;
    font-weight: bold;
    color: #4a5568;
}

.legend-gradient {
    width: 200px;
    height: 16px;
    border-radius: 3px;
    background: linear-gradient(to right, #b8e994 0%, #079992 100%);
    border: 1px solid #d1d5db;
}

.legend-min, .legend-max {
    font-size: 11px;
    color: #6b7280;
}

.legend-min {
    margin-left: -4px;
}

.legend-max {
    margin-left: auto;
}

/* Grid Section */
#grid-container {
    height: 800px;
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    border-bottom: 2px solid #d1d5db;
    position: relative;
    overflow: hidden;
}

/* Grid edges SVG overlay - fixed over grid, updates on scroll */
#grid-edges-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#grid-edges-svg line {
    pointer-events: stroke;
    cursor: pointer;
}

#layer-labels {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 2px solid #d1d5db;
    flex-shrink: 0;
    width: 125px;
    z-index: 999;
}

.layer-label {
    flex: 1;
    padding: 8px 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #d1d5db;
    width: 100%;
    min-width: 80px;

}

.layer-label:last-child {
    border-bottom: none;
}

#grid-body {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

.grid-row {
    flex: 1;
    display: flex;
    flex-direction: row;
    border-bottom: 1px solid #e5e7eb;
    min-height: 0;
}

.grid-row:last-child {
    border-bottom: none;
}

.grid-cell {
    padding: 6px 10px;
    border-right: 1px solid #c0c4cc;
    border-top: 1px solid #c0c4cc;
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
}

.grid-cell:hover {
    background: rgba(0, 136, 170, 0.08);
}

.latent-box {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    white-space: nowrap;
}

.latent-box:hover {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Sequence Bar */
#sequence-bar {
    background: #ffffff;
    border-bottom: 2px solid #d1d5db;
    overflow-x: auto;
    padding: 8px 0;
    margin-left: 125px; /* Align with grid (layer-labels width + border) */
}

#sequence-content {
    display: flex;
    min-width: max-content;
}

.seq-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    border-right: 1px solid #d1d5db;
    transition: background 0.2s;
    flex-shrink: 0;
    box-sizing: border-box;
}

.seq-item:hover {
    background: rgba(0, 136, 170, 0.1);
}

.seq-item.active {
    background: #e8f7fa;
}

.seq-aa {
    font-weight: bold;
    color: #0088aa;
    font-size: 18px;
}

.seq-pos {
    color: #6b7280;
    font-size: 12px;
}

/* Canvas Section */
#canvas-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    min-height: 300px;
}

#canvas-toolbar {
    padding: 8px;
    background: #ffffff;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #d1d5db;
}

#canvas-toolbar button {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

#btn-delete {
    background: #dc2626;
    color: #fff;
}

#btn-delete:hover {
    background: #b91c1c;
}

#btn-save-canvas {
    background: #059669;
    color: #fff;
}

#btn-save-canvas:hover {
    background: #047857;
}

#btn-load-canvas {
    background: #d97706;
    color: #fff;
}

#btn-load-canvas:hover {
    background: #b45309;
}

#btn-save-svg {
    background: #ea580c;
    color: #fff;
}

#btn-save-svg:hover {
    background: #c2410c;
}

#btn-fullscreen {
    background: #0d9488;
    color: #fff;
    margin-left: auto;
}

#btn-fullscreen:hover {
    background: #0f766e;
}

/* Fullscreen mode */
#canvas-section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    z-index: 1000;
}

#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

#edges-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#edges-svg line {
    stroke: #0088aa;
    stroke-width: 2;
    pointer-events: stroke;
    cursor: pointer;
}

#edges-svg line:hover {
    stroke: #ef4444;
    stroke-width: 3;
}

#edges-svg line.selected {
    stroke: #ef4444;
    stroke-width: 3;
}

#nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.canvas-node {
    position: absolute;
    padding: 8px 12px;
    background: #ffffff;
    border: 2px solid #0088aa;
    border-radius: 6px;
    cursor: grab;
    user-select: none;
    font-size: 12px;
    min-width: 80px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.canvas-node:hover {
    border-color: #006688;
}

.canvas-node.selected {
    border-color: #0088aa;
    box-shadow: 0 0 12px rgba(0, 136, 170, 0.4);
}

.canvas-node.super-node {
    background: #f5f3ff;
    border-color: #7c3aed;
}

.canvas-node.super-node.selected {
    border-color: #7c3aed;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.4);
}

.node-latent {
    font-weight: bold;
    color: #0088aa;
}

.node-info {
    font-size: 10px;
    color: #6b7280;
    margin-top: 2px;
}

.super-node .node-latent {
    color: #7c3aed;
}

/* Activation Detail Panel */
#activation-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100vh;
    background: #ffffff;
    border-left: 2px solid #d1d5db;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}

#activation-panel.hidden {
    transform: translateX(100%);
}

#activation-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f5f7fa;
    border-bottom: 2px solid #d1d5db;
}

#activation-panel-header h2 {
    font-size: 18px;
    color: #0088aa;
    margin: 0;
}

#panel-add-to-canvas {
    padding: 8px 16px;
    background: #533483;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    margin-left: auto;
    margin-right: 12px;
    transition: background 0.2s, transform 0.1s;
}

#panel-add-to-canvas:hover {
    background: #6b44a8;
    transform: scale(1.05);
}

#panel-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

#panel-close:hover {
    color: #ef4444;
}

#activation-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Individual sequence card */
.seq-card {
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.seq-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    background: #f5f7fa;
    border-bottom: 1px solid #d1d5db;
}

.seq-card-title {
    flex: 1;
}

.seq-card-title h3 {
    font-size: 14px;
    color: #0088aa;
    margin: 0 0 4px 0;
}

.seq-card-title .protein-name {
    font-size: 12px;
    color: #4a5568;
    margin: 0;
}

.seq-card-score {
    background: #7c3aed;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    margin-left: 12px;
}

.seq-card-meta {
    padding: 8px 16px;
    font-size: 11px;
    color: #6b7280;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.seq-card-meta span {
    margin-right: 16px;
}

/* Sequence visualization */
.seq-visualization {
    padding: 12px 16px;
    overflow-x: auto;
}

.seq-amino-acids {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    font-family: 'Courier New', monospace;
}

.aa-char {
    width: 18px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border-radius: 2px;
    transition: transform 0.1s;
}

.aa-char:hover {
    transform: scale(1.3);
    z-index: 10;
    position: relative;
}

.aa-char.zero {
    background: transparent;
    color: #9ca3af;
}

/* Amino acid tooltip */
.aa-tooltip {
    position: fixed;
    background: #1f2937;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 3000;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #374151;
}

.aa-tooltip .tooltip-pos {
    color: #9ca3af;
    margin-right: 8px;
}

.aa-tooltip .tooltip-aa {
    color: #38bdf8;
    font-weight: bold;
    margin-right: 8px;
}

.aa-tooltip .tooltip-val {
    color: #f87171;
    font-weight: bold;
}

/* Rank badge */
.rank-badge {
    font-size: 11px;
    color: #6b7280;
    margin-right: 8px;
}

/* Wild Type card styling */
.wild-type-card {
    border: 2px solid #0088aa;
    box-shadow: 0 0 12px rgba(0, 136, 170, 0.2);
}

.wild-type-card .seq-card-header {
    background: linear-gradient(135deg, #e8f7fa 0%, #dbeafe 100%);
}

.wild-type-badge {
    display: inline-block;
    background: #0088aa;
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 3px;
    margin-right: 8px;
    text-transform: uppercase;
}

/* Panel section title */
.panel-section-title {
    font-size: 14px;
    font-weight: bold;
    color: #6b7280;
    padding: 16px 0 8px 0;
    margin-top: 8px;
    border-top: 1px solid #d1d5db;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* No data message */
.no-data-message {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-style: italic;
}

/* Activation list */
.activation-list {
    padding: 8px 16px 16px;
}

.activation-row {
    display: flex;
    padding: 6px 0;
    border-bottom: 1px solid #e5e7eb;
    font-family: 'Courier New', monospace;
}

.activation-row.header {
    font-weight: bold;
    color: #6b7280;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 2px solid #d1d5db;
}

.activation-pos {
    width: 80px;
    color: #4a5568;
}

.activation-aa {
    width: 40px;
    color: #0088aa;
    font-weight: bold;
}

.activation-value {
    flex: 1;
    color: #ef4444;
    text-align: right;
}

/* Clicked position info */
.clicked-position-info {
    padding: 12px 16px;
    background: #e8edf3;
    border-bottom: 1px solid #d1d5db;
}

.clicked-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.clicked-details {
    display: flex;
    gap: 16px;
    align-items: center;
    font-family: 'Courier New', monospace;
}

.clicked-pos {
    color: #4a5568;
    font-size: 14px;
}

.clicked-aa {
    font-size: 20px;
    font-weight: bold;
    color: #0088aa;
    background: #e8f7fa;
    padding: 4px 12px;
    border-radius: 4px;
}

.clicked-activation {
    color: #ef4444;
    font-size: 14px;
    font-weight: bold;
}

/* Clicked amino acid highlight in sequence */
.aa-char.clicked {
    outline: 2px solid #0088aa;
    outline-offset: 1px;
    box-shadow: 0 0 8px rgba(0, 136, 170, 0.6);
}

/* Panel Tabs */
.panel-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f5f7fa;
    border-bottom: 2px solid #d1d5db;
}

.panel-tab {
    padding: 8px 20px;
    border: none;
    border-radius: 4px 4px 0 0;
    background: #ffffff;
    color: #6b7280;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.panel-tab:hover {
    background: #f3f4f6;
    color: #4a5568;
}

.panel-tab.active {
    background: #0088aa;
    color: #ffffff;
}

/* Alignment Container */
.alignment-container {
    background: #f9fafb;
    border-radius: 8px;
    margin: 16px 0;
    overflow: hidden;
}

.alignment-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    padding: 16px;
}

/* Alignment Row */
.alignment-row {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    min-width: max-content;
}

.alignment-row.wild-type-row {
    background: rgba(0, 136, 170, 0.1);
    border-radius: 4px;
    padding: 4px 0;
    margin-bottom: 8px;
}

.alignment-row.ruler-row {
    margin-bottom: 8px;
    border-bottom: 1px solid #d1d5db;
    padding-bottom: 8px;
}

/* Alignment Label */
.alignment-label {
    min-width: 220px;
    max-width: 220px;
    padding-right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #4a5568;
    flex-shrink: 0;
}

.alignment-entry {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Alignment Sequence */
.alignment-sequence {
    display: flex;
    font-family: 'Courier New', monospace;
    gap: 1px;
}

/* Gap character styling */
.aa-char.gap {
    background: transparent;
    color: #d1d5db;
}

/* Max position highlight */
.aa-char.max-pos {
    outline: 2px solid #ef4444;
    outline-offset: 1px;
    z-index: 5;
    position: relative;
}

/* Ruler styling */
.ruler-mark {
    width: 18px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #9ca3af;
    font-family: 'Courier New', monospace;
}

.ruler-tick {
    width: 18px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #6b7280;
}

.ruler-dot {
    width: 18px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #d1d5db;
}

/* Alignment Toolbar */
.alignment-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 12px;
}

.btn-go-to-center {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: #0088aa;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-go-to-center:hover {
    background: #006688;
}

.alignment-info {
    font-size: 12px;
    color: #6b7280;
}

/* Center Line Indicator */
.center-line {
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.6);
}

.center-line::before {
    content: '';
    position: absolute;
    top: -2px;
    bottom: -2px;
    left: 50%;
    width: 1px;
    background: repeating-linear-gradient(
        to bottom,
        #ef4444 0px,
        #ef4444 3px,
        transparent 3px,
        transparent 6px
    );
    z-index: 10;
}

.ruler-row .center-line {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444 !important;
    font-weight: bold;
}

.ruler-row .center-line::before {
    display: none;
}

/* ============================================
   Virtual Weights Styles
   ============================================ */

/* Optional file indicator */
.file-status.optional .file-name {
    color: #9ca3af;
    font-style: italic;
}

.file-status.optional.loaded .file-name {
    color: #4ade80;
    font-style: normal;
}

/* Virtual Weights Toggle Button */
#btn-virtual-weights {
    background: #14b8a6;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 0px;
}

#btn-virtual-weights .btn-icon {
    font-size: 1.1em;
    line-height: 1;
    opacity: 0.8;
}

#btn-virtual-weights:hover:not(:disabled) {
    background: #0d9488;
}

#btn-virtual-weights:hover:not(:disabled) .btn-icon {
    opacity: 1;
}

#btn-virtual-weights:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

#btn-virtual-weights:disabled .btn-icon {
    opacity: 0.4;
}

#btn-virtual-weights.active {
    background: #0088aa;
    color: #ffffff;
    font-weight: bold;
}

#btn-virtual-weights.active .btn-icon {
    opacity: 1;
}

/* Virtual Weight Edges */
.virtual-weight-edge {
    transition: stroke 0.15s, stroke-opacity 0.15s;
    cursor: pointer;
}

.virtual-weight-edge:hover {
    stroke: #fff !important;
    stroke-opacity: 1 !important;
}

/* Edge Tooltip */
.edge-tooltip {
    position: fixed;
    background: #1f2937;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 3000;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #ef4444;
}

.edge-tooltip-weight {
    color: #f87171;
    font-weight: bold;
    margin-bottom: 4px;
}

.edge-tooltip-path {
    color: #9ca3af;
    font-size: 10px;
}

/* Latent box edge highlight */
.latent-box.edge-highlight {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
    z-index: 100;
    position: relative;
}

/* Canvas node highlight pulse (for duplicate prevention) */
.canvas-node.highlight-pulse {
    animation: nodePulse 0.5s ease-out;
}

@keyframes nodePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 136, 170, 0.8);
    }
    50% {
        box-shadow: 0 0 20px 10px rgba(0, 136, 170, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 136, 170, 0);
    }
}

/* Virtual edge styling in canvas */
.virtual-edge {
    transition: stroke 0.15s, stroke-opacity 0.15s;
}

.virtual-edge:hover {
    stroke: #fff !important;
    stroke-opacity: 1 !important;
}

/* ============================================
   Layer Panel Styles
   ============================================ */

#layer-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 50%;
    height: 100vh;
    background: #ffffff;
    border-right: 2px solid #d1d5db;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
    z-index: 9999999999999999;
}

#layer-panel.hidden {
    transform: translateX(-100%);
}

#layer-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f5f7fa;
    border-bottom: 2px solid #d1d5db;
}

#layer-panel-header h2 {
    font-size: 18px;
    color: #0088aa;
    margin: 0;
}

#layer-panel-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

#layer-panel-close:hover {
    color: #ef4444;
}

#layer-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Layer label clickable styling */
.layer-label {
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.layer-label:hover {
    background: #e8f7fa;
    color: #0088aa;
}

/* Latent ranking card */
.latent-rank-card {
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    border: 1px solid #e5e7eb;
}

.latent-rank-card:hover {
    box-shadow: 0 0 12px rgba(0, 136, 170, 0.3);
    transform: translateX(4px);
}

.latent-rank-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #f5f7fa;
    gap: 16px;
}

.latent-rank-number {
    font-size: 14px;
    font-weight: bold;
    color: #6b7280;
    min-width: 30px;
}

.latent-rank-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.latent-rank-idx {
    font-weight: bold;
    color: #0088aa;
    font-size: 14px;
}

.latent-rank-max {
    color: #ef4444;
    font-size: 13px;
    font-weight: bold;
}

.latent-rank-pos {
    color: #4a5568;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

/* Latent rank card actions */
.latent-rank-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.latent-rank-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-add-to-canvas {
    background: #533483;
    color: #fff;
}

.btn-add-to-canvas:hover {
    background: #6b44a8;
    transform: scale(1.05);
}

.btn-feature-info {
    background: #0088aa;
    color: #ffffff;
}

.btn-feature-info:hover {
    background: #006688;
    transform: scale(1.05);
}

/* Latent heatmap */
.latent-heatmap {
    padding: 10px 16px;
    overflow-x: auto;
}

.latent-heatmap .seq-amino-acids {
    display: flex;
    flex-wrap: nowrap;
    gap: 1px;
    font-family: 'Courier New', monospace;
}

/* Max position highlight in heatmap */
.aa-char.max-highlight {
    outline: 2px solid #0088aa;
    outline-offset: 1px;
    z-index: 5;
    position: relative;
}

/* ============================================
   Edge Filter Slider Styles
   ============================================ */

#edge-filter-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    padding-left: 24px;
    border-left: 1px solid #d1d5db;
}

#edge-filter-control.hidden {
    display: none;
}

.filter-label {
    font-size: 12px;
    font-weight: bold;
    color: #4a5568;
}

#edge-threshold-slider {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#edge-threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #0088aa;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

#edge-threshold-slider::-webkit-slider-thumb:hover {
    background: #006688;
}

#edge-threshold-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #0088aa;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

#edge-threshold-input {
    width: 45px;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: bold;
    color: #0088aa;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    text-align: center;
    -moz-appearance: textfield;
}

#edge-threshold-input::-webkit-outer-spin-button,
#edge-threshold-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#edge-threshold-input:focus {
    outline: none;
    border-color: #0088aa;
}

.percent-sign {
    font-size: 12px;
    font-weight: bold;
    color: #0088aa;
}

/* ============================================
   Influences Tab Styles
   ============================================ */

.influence-subtabs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #d1d5db;
    margin-bottom: 16px;
}

.influence-subtab {
    padding: 6px 16px;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    background: transparent;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.influence-subtab:hover {
    border-color: #0088aa;
    color: #4a5568;
}

.influence-subtab.active {
    background: #0088aa;
    border-color: #0088aa;
    color: #ffffff;
}

.influences-header {
    padding: 16px;
    background: #ffffff;
    border-radius: 8px;
    margin-bottom: 16px;
}

.influences-summary {
    display: flex;
    align-items: center;
    gap: 12px;
}

.influences-count {
    font-size: 18px;
    font-weight: bold;
    color: #0088aa;
}

.influences-target {
    font-size: 14px;
    color: #6b7280;
}

.influences-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.influence-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.influence-card:hover {
    border-color: #0088aa;
    transform: translateX(4px);
    box-shadow: 0 0 12px rgba(0, 136, 170, 0.2);
}

.influence-rank {
    font-size: 14px;
    font-weight: bold;
    color: #9ca3af;
    min-width: 30px;
}

.influence-source {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
}

.influence-layer {
    font-size: 12px;
    color: #6b7280;
}

.influence-latent {
    font-size: 16px;
    font-weight: bold;
    color: #0088aa;
}

.influence-weight {
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    min-width: 90px;
    text-align: center;
}

.influence-weight.positive {
    color: #000;
}

.influence-weight.negative {
    color: #fff;
}

.influence-meta {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

.influence-edge-count {
    font-size: 11px;
    color: #9ca3af;
    font-style: italic;
}

.btn-view-source {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #0088aa;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-view-source:hover {
    background: #006688;
    transform: scale(1.05);
}

/* ============================================
   Context Menu Styles
   ============================================ */

.context-menu {
    position: fixed;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 180px;
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    color: #374151;
    font-size: 14px;
}

.context-menu-item:hover {
    background: #f3f4f6;
}

.context-menu-item:first-child {
    border-radius: 4px 4px 0 0;
}

.context-menu-item:last-child {
    border-radius: 0 0 4px 4px;
}

/* ============================================
   Node Name Styles
   ============================================ */

.node-name {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

/* ============================================
   Name Popup Styles
   ============================================ */

.name-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.name-popup.hidden {
    display: none;
}

.name-popup-content {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 20px;
    min-width: 300px;
}

.name-popup-content h3 {
    margin: 0 0 15px 0;
    color: #0088aa;
}

#node-name-input {
    width: 100%;
    padding: 8px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #374151;
    font-size: 14px;
    box-sizing: border-box;
}

#node-name-input:focus {
    outline: none;
    border-color: #0088aa;
}

.name-popup-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.name-popup-buttons button {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#name-popup-cancel {
    background: #e5e7eb;
    border: none;
    color: #374151;
}

#name-popup-cancel:hover {
    background: #d1d5db;
}

#name-popup-save {
    background: #0088aa;
    border: none;
    color: #ffffff;
}

#name-popup-save:hover {
    background: #006688;
}

/* ============================================
   Logo Styling
   ============================================ */

#site-logo {
    width: 280px;
}

/* ============================================
   Button Icon Styles (Lucide)
   ============================================ */

/* Base icon styling for all buttons */
button svg.lucide {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 6px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* Icon-only close buttons */
#panel-close svg.lucide,
#layer-panel-close svg.lucide {
    width: 20px;
    height: 20px;
    margin-right: 0;
}

/* Toolbar buttons flexbox alignment */
#canvas-toolbar button,
#btn-load,
#btn-load-custom,
.name-popup-buttons button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Disabled state icon styling */
button:disabled svg.lucide {
    opacity: 0.5;
}

/* Hover state - subtle icon animation */
button:hover:not(:disabled) svg.lucide {
    transform: scale(1.1);
    transition: transform 0.15s ease;
}

/* Toolbar buttons - consistent sizing */
#canvas-toolbar button svg.lucide {
    width: 14px;
    height: 14px;
}

/* Popup buttons */
.name-popup-buttons button svg.lucide {
    width: 14px;
    height: 14px;
}

/* ============================================
   Selector Action Buttons (Arxiv / Guide)
   ============================================ */

#selector-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
}

#selector-actions button {
    padding: 6px 12px;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    color: #4b5563;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#selector-actions button:hover {
    background: #0088aa;
    color: #ffffff;
    border-color: #0088aa;
}

#selector-actions button svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   Video Guide Popup
   ============================================ */

.video-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.video-popup.hidden {
    display: none;
}

.video-popup-content {
    position: relative;
    width: 80%;
    max-width: 900px;
}

#video-popup-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video-popup-close:hover {
    color: #d1d5db;
}

#video-popup-close svg.lucide {
    width: 24px;
    height: 24px;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
