/* ==========================================================================
   3D Concept Map Styles
   Glowing abstract spheres with luminous connections
   ========================================================================== */

/* Container */
.concept-map-3d-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary, #1a1520);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .concept-map-3d-wrapper {
    background: #faf8f9;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.concept-map-3d-graph {
    width: 100%;
    height: 100%;
}

.concept-map-3d-graph canvas {
    border-radius: 12px;
}

/* Connect Mode Active State - Green Glow Border */
.concept-map-3d-wrapper.connect-mode-active {
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 0 0 2px rgba(16, 185, 129, 0.6),
        0 0 20px rgba(16, 185, 129, 0.3),
        0 0 40px rgba(16, 185, 129, 0.15);
    animation: connectModeGlow 2s ease-in-out infinite;
}

[data-theme="light"] .concept-map-3d-wrapper.connect-mode-active {
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.1),
        inset 0 0 0 2px rgba(16, 185, 129, 0.7),
        0 0 20px rgba(16, 185, 129, 0.25),
        0 0 40px rgba(16, 185, 129, 0.1);
}

@keyframes connectModeGlow {
    0%, 100% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.3),
            inset 0 0 0 2px rgba(16, 185, 129, 0.6),
            0 0 20px rgba(16, 185, 129, 0.3),
            0 0 40px rgba(16, 185, 129, 0.15);
    }
    50% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.3),
            inset 0 0 0 2px rgba(16, 185, 129, 0.9),
            0 0 30px rgba(16, 185, 129, 0.5),
            0 0 60px rgba(16, 185, 129, 0.25);
    }
}

[data-theme="light"] .concept-map-3d-wrapper.connect-mode-active {
    animation: connectModeGlowLight 2s ease-in-out infinite;
}

@keyframes connectModeGlowLight {
    0%, 100% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.1),
            inset 0 0 0 2px rgba(16, 185, 129, 0.7),
            0 0 20px rgba(16, 185, 129, 0.25),
            0 0 40px rgba(16, 185, 129, 0.1);
    }
    50% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.1),
            inset 0 0 0 2px rgba(16, 185, 129, 1),
            0 0 30px rgba(16, 185, 129, 0.4),
            0 0 60px rgba(16, 185, 129, 0.2);
    }
}

/* Loading State */
.concept-map-3d-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    gap: 16px;
    color: var(--text-muted, #888);
}

.concept-map-3d-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 45, 85, 0.2);
    border-top-color: #ff2d55;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.concept-map-3d-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    gap: 12px;
    text-align: center;
    padding: 24px;
    color: var(--text-muted, #888);
}

.concept-map-3d-empty svg {
    opacity: 0.4;
}

.concept-map-3d-empty .text-muted {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Controls Overlay */
.concept-map-3d-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
}

.concept-map-3d-controls > * {
    pointer-events: auto;
}

.cm3d-zoom-controls {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary, rgba(15, 10, 18, 0.9));
    border-radius: 8px;
    padding: 4px;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

[data-theme="light"] .cm3d-zoom-controls {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

.cm3d-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-primary, #f5f0f2);
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .cm3d-btn {
    color: #0d0d0d;
}

.cm3d-btn:hover {
    background: rgba(255, 45, 85, 0.2);
    color: #ff2d55;
}

/* Search */
.cm3d-search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary, rgba(15, 10, 18, 0.9));
    border-radius: 8px;
    padding: 6px 12px;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    max-width: 240px;
}

[data-theme="light"] .cm3d-search {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

.cm3d-search-icon {
    flex-shrink: 0;
    color: var(--text-muted, #888);
}

.cm3d-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.8125rem;
    color: var(--text-primary, #f5f0f2);
    padding: 4px 8px;
    min-width: 0;
}

[data-theme="light"] .cm3d-search-input {
    color: #0d0d0d;
}

.cm3d-search-input::placeholder {
    color: var(--text-muted, #888);
}

.cm3d-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    border-radius: 4px;
}

.cm3d-search-clear:hover {
    background: rgba(255, 45, 85, 0.2);
    color: #ff2d55;
}

/* Tooltips */
.concept-map-3d-tooltip {
    position: absolute;
    background: var(--bg-secondary, rgba(15, 10, 18, 0.95));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    padding: 12px 16px;
    max-width: 280px;
    z-index: 100;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: tooltipFadeIn 0.2s ease;
}

[data-theme="light"] .concept-map-3d-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-header {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.tooltip-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tooltip-badge.transcript {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.tooltip-badge.recent {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

.tooltip-title {
    font-family: var(--font-serif, 'Source Serif 4', Georgia, serif);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #f5f0f2);
    margin-bottom: 4px;
    line-height: 1.3;
}

[data-theme="light"] .tooltip-title {
    color: #0d0d0d;
}

.tooltip-meta {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-bottom: 10px;
}

.tooltip-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.keyword-tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 45, 85, 0.15);
    color: #ff6b8a;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
}

[data-theme="light"] .keyword-tag {
    background: rgba(255, 45, 85, 0.1);
    color: #d63d5c;
}

.tooltip-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
}

.tooltip-stat {
    display: flex;
    flex-direction: column;
}

.tooltip-stat-value {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary, #f5f0f2);
}

[data-theme="light"] .tooltip-stat-value {
    color: #0d0d0d;
}

.tooltip-stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tooltip-hint {
    font-size: 0.6875rem;
    color: var(--text-muted, #666);
    padding-top: 8px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

[data-theme="light"] .tooltip-hint {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Link Tooltip */
.link-tooltip {
    text-align: center;
}

.link-tooltip-header {
    margin-bottom: 8px;
}

.link-similarity {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 1.5rem;
    font-weight: 600;
    color: #ff2d55;
}

.link-similarity-label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.link-episodes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.link-episode {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #f5f0f2);
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

[data-theme="light"] .link-episode {
    color: #0d0d0d;
    background: rgba(0, 0, 0, 0.05);
}

.link-shared-keywords {
    margin-bottom: 10px;
}

.shared-label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted, #888);
    margin-bottom: 6px;
}

/* Connection Panel */
.concept-map-3d-connection-panel,
.concept-map-3d-panel {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: var(--bg-secondary, rgba(15, 10, 18, 0.95));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    padding: 20px;
    z-index: 100;
    backdrop-filter: blur(16px);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    animation: panelSlideUp 0.3s ease;
    max-height: 60%;
    overflow-y: auto;
}

[data-theme="light"] .concept-map-3d-connection-panel,
[data-theme="light"] .concept-map-3d-panel {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1);
}

@keyframes panelSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: var(--text-muted, #888);
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .panel-close {
    background: rgba(0, 0, 0, 0.05);
}

.panel-close:hover {
    background: rgba(255, 45, 85, 0.2);
    color: #ff2d55;
}

.connection-header {
    text-align: center;
    margin-bottom: 16px;
}

.connection-similarity-badge {
    display: inline-block;
    padding: 6px 16px;
    background: linear-gradient(135deg, rgba(255, 45, 85, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(255, 45, 85, 0.3);
    border-radius: 20px;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.875rem;
    font-weight: 500;
    color: #ff6b8a;
}

.connection-episodes {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.connection-episode-card {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
}

[data-theme="light"] .connection-episode-card {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

.connection-episode-card:hover {
    background: rgba(255, 45, 85, 0.1);
    border-color: rgba(255, 45, 85, 0.3);
}

.connection-episode-card .ep-number {
    display: block;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-bottom: 4px;
}

.connection-episode-card .ep-title {
    display: block;
    font-family: var(--font-serif, 'Source Serif 4', Georgia, serif);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #f5f0f2);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

[data-theme="light"] .connection-episode-card .ep-title {
    color: #0d0d0d;
}

.connection-divider {
    flex-shrink: 0;
    color: var(--text-muted, #666);
}

.connection-keywords {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

[data-theme="light"] .connection-keywords {
    background: rgba(0, 0, 0, 0.02);
}

.keywords-label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.connection-summary h4 {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.summary-content {
    font-family: var(--font-serif, 'Source Serif 4', Georgia, serif);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary, #f5f0f2);
}

[data-theme="light"] .summary-content {
    color: #0d0d0d;
}

.summary-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted, #888);
    font-size: 0.875rem;
}

.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 45, 85, 0.2);
    border-top-color: #ff2d55;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.summary-error {
    color: var(--text-muted, #888);
    font-style: italic;
}

/* Mobile Panel */
.concept-map-3d-panel-mobile {
    max-height: 70%;
}

.panel-badges {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.panel-title {
    font-family: var(--font-serif, 'Source Serif 4', Georgia, serif);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #f5f0f2);
    margin-bottom: 6px;
    padding-right: 40px;
}

[data-theme="light"] .panel-title {
    color: #0d0d0d;
}

.panel-meta {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-bottom: 12px;
}

.panel-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.panel-connections {
    margin-bottom: 16px;
}

.panel-connections h4 {
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.panel-connections-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-connection {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

[data-theme="light"] .panel-connection {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

.panel-connection:hover {
    background: rgba(255, 45, 85, 0.1);
    border-color: rgba(255, 45, 85, 0.3);
}

.connection-ep {
    flex-shrink: 0;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.75rem;
    color: var(--text-muted, #888);
}

.connection-title {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary, #f5f0f2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="light"] .connection-title {
    color: #0d0d0d;
}

.connection-similarity {
    flex-shrink: 0;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.75rem;
    color: #ff6b8a;
    font-weight: 500;
}

.panel-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.panel-cta {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: linear-gradient(135deg, #ff2d55, #d63d5c);
    border: none;
    border-radius: 10px;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.panel-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 45, 85, 0.4);
}

.panel-center-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
    border-radius: 10px;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #f5f0f2);
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .panel-center-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0d0d0d;
}

.panel-center-btn:hover {
    background: rgba(255, 45, 85, 0.2);
    border-color: rgba(255, 45, 85, 0.4);
}

.panel-hint {
    font-size: 0.6875rem;
    color: var(--text-muted, #666);
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

[data-theme="light"] .panel-hint {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .concept-map-3d-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .cm3d-search {
        max-width: none;
        width: 100%;
    }

    .concept-map-3d-connection-panel,
    .concept-map-3d-panel {
        padding: 16px;
    }

    .connection-episodes {
        flex-direction: column;
    }

    .connection-divider {
        transform: rotate(90deg);
    }
}

/* Scrollbar styling for panels */
.concept-map-3d-connection-panel::-webkit-scrollbar,
.concept-map-3d-panel::-webkit-scrollbar {
    width: 6px;
}

.concept-map-3d-connection-panel::-webkit-scrollbar-track,
.concept-map-3d-panel::-webkit-scrollbar-track {
    background: transparent;
}

.concept-map-3d-connection-panel::-webkit-scrollbar-thumb,
.concept-map-3d-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

[data-theme="light"] .concept-map-3d-connection-panel::-webkit-scrollbar-thumb,
[data-theme="light"] .concept-map-3d-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

/* Connect Mode Button */
.cm3d-connect-btn.active {
    background: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.cm3d-connect-btn.active:hover {
    background: rgba(16, 185, 129, 0.4);
}

/* Connect Hint */
.concept-map-3d-connect-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(16, 185, 129, 0.95);
    color: white;
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 0.8125rem;
    font-weight: 500;
    z-index: 50;
    animation: hintSlideUp 0.3s ease;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

@keyframes hintSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.hint-message {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hint-cancel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.hint-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modal Overlay */
.concept-map-3d-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.concept-map-3d-modal {
    position: relative;
    background: var(--bg-secondary, #1a1520);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 20px;
    padding: 28px;
    max-width: 480px;
    width: 90%;
    animation: modalSlideIn 0.3s ease;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .concept-map-3d-modal {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.concept-map-3d-modal .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: var(--text-muted, #888);
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .concept-map-3d-modal .modal-close {
    background: rgba(0, 0, 0, 0.05);
}

.concept-map-3d-modal .modal-close:hover {
    background: rgba(255, 45, 85, 0.2);
    color: #ff2d55;
}

.modal-title {
    font-family: var(--font-serif, 'Source Serif 4', Georgia, serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #f5f0f2);
    margin-bottom: 20px;
    text-align: center;
}

[data-theme="light"] .modal-title {
    color: #0d0d0d;
}

.modal-episodes {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-episode {
    flex: 1;
    padding: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    text-align: center;
}

[data-theme="light"] .modal-episode {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

.modal-episode .ep-number {
    display: block;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    margin-bottom: 6px;
}

.modal-episode .ep-title {
    display: block;
    font-family: var(--font-serif, 'Source Serif 4', Georgia, serif);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #f5f0f2);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

[data-theme="light"] .modal-episode .ep-title {
    color: #0d0d0d;
}

.modal-arrow {
    flex-shrink: 0;
    color: #10b981;
}

.modal-form {
    margin-bottom: 20px;
}

.modal-form label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary, #f5f0f2);
    margin-bottom: 8px;
}

[data-theme="light"] .modal-form label {
    color: #0d0d0d;
}

.modal-form textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 12px;
    padding: 12px 14px;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.875rem;
    color: var(--text-primary, #f5f0f2);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
}

[data-theme="light"] .modal-form textarea {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.15);
    color: #0d0d0d;
}

.modal-form textarea:focus {
    outline: none;
    border-color: #10b981;
}

.modal-form textarea::placeholder {
    color: var(--text-muted, #666);
}

.modal-char-count {
    text-align: right;
    font-size: 0.6875rem;
    color: var(--text-muted, #666);
    margin-top: 6px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 12px;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    color: var(--text-primary, #f5f0f2);
}

[data-theme="light"] .modal-btn-cancel {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0d0d0d;
}

.modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .modal-btn-cancel:hover {
    background: rgba(0, 0, 0, 0.1);
}

.modal-btn-submit {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: white;
}

.modal-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-btn-submit:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

/* Toast Notifications */
.concept-map-3d-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 2000;
    animation: toastSlideIn 0.3s ease, toastFadeOut 0.3s ease 2.7s forwards;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.concept-map-3d-toast.success {
    background: #10b981;
    color: white;
}

.concept-map-3d-toast.error {
    background: #ef4444;
    color: white;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* User Connection Badge */
.user-connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.user-connection-badge svg {
    width: 12px;
    height: 12px;
}

/* User Description Styles */
.user-description {
    font-style: italic;
    color: var(--text-primary, #f5f0f2);
    padding: 8px 12px;
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid #10b981;
    border-radius: 0 8px 8px 0;
    margin-bottom: 8px;
}

[data-theme="light"] .user-description {
    color: #0d0d0d;
    background: rgba(16, 185, 129, 0.08);
}

.more-descriptions {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    text-align: center;
    padding-top: 8px;
}

/* AI Subnote Styles */
.connection-summary.ai-analysis {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

[data-theme="light"] .connection-summary.ai-analysis {
    border-color: rgba(0, 0, 0, 0.1);
}

.connection-summary.ai-analysis h4 {
    color: #a78bfa;
}

[data-theme="light"] .connection-summary.ai-analysis h4 {
    color: #7c3aed;
}

.ai-subnote {
    font-style: normal;
    color: var(--text-primary, #f5f0f2);
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(168, 85, 247, 0.08));
    border-left: 3px solid #a78bfa;
    border-radius: 0 8px 8px 0;
    margin-bottom: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
}

[data-theme="light"] .ai-subnote {
    color: #0d0d0d;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(168, 85, 247, 0.04));
    border-left-color: #7c3aed;
}

/* Connect Button Label */
.cm3d-btn-label {
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 4px;
}

.cm3d-connect-btn {
    width: auto;
    padding: 0 12px;
    gap: 4px;
}

/* Enhanced Hint Bar Styles */
.concept-map-3d-connect-hint {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 10px;
}

.hint-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hint-icon svg {
    width: 20px;
    height: 20px;
}

.hint-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.hint-title {
    font-weight: 600;
    font-size: 0.8125rem;
}

.hint-message {
    font-size: 0.75rem;
    opacity: 0.9;
    white-space: normal;
    max-width: none;
}

.hint-tip {
    font-size: 0.6875rem;
    opacity: 0.7;
}

.hint-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Modal Header Styles */
.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    border-radius: 16px;
    margin-bottom: 12px;
    color: #10b981;
}

.modal-header .modal-title {
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted, #888);
}

/* Episode Keywords in Modal */
.ep-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    justify-content: center;
}

.ep-keyword {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 45, 85, 0.1);
    color: #ff6b8a;
    border-radius: 8px;
    font-size: 0.625rem;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
}

[data-theme="light"] .ep-keyword {
    background: rgba(255, 45, 85, 0.08);
    color: #d63d5c;
}

/* Modal Arrow with Similarity */
.modal-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
}

.modal-arrow-line {
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 1px;
}

.modal-similarity {
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 0.6875rem;
    font-weight: 600;
    color: #10b981;
}

/* Shared Topics Section */
.modal-shared-topics {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 10px;
}

.shared-label {
    font-size: 0.6875rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.shared-keyword {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-weight: 500;
}

/* Existing Connection Notice */
.modal-existing-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.8125rem;
    color: #a78bfa;
}

[data-theme="light"] .modal-existing-notice {
    background: rgba(139, 92, 246, 0.08);
    color: #7c3aed;
}

.modal-existing-notice svg {
    flex-shrink: 0;
}

/* Suggestion Chips */
.modal-suggestions {
    margin-bottom: 20px;
}

.suggestions-label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.suggestion-chip {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 16px;
    font-family: var(--font-sans, system-ui, sans-serif);
    font-size: 0.75rem;
    color: var(--text-primary, #f5f0f2);
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .suggestion-chip {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0d0d0d;
}

.suggestion-chip:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

/* Button Loading State */
.btn-text {
    display: inline;
}

.btn-loading {
    display: none;
    align-items: center;
    gap: 8px;
}

.spinner {
    animation: spin 1s linear infinite;
}

/* Form Footer */
.modal-form-footer {
    display: flex;
    justify-content: flex-end;
}

/* Footer Note */
.modal-footer-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    font-size: 0.6875rem;
    color: var(--text-muted, #666);
}

[data-theme="light"] .modal-footer-note {
    border-color: rgba(0, 0, 0, 0.1);
}

.modal-footer-note svg {
    flex-shrink: 0;
    color: #10b981;
}

/* Responsive modal adjustments */
@media (max-width: 480px) {
    .modal-episodes {
        flex-direction: column;
    }

    .modal-arrow {
        transform: rotate(90deg);
    }

    .concept-map-3d-connect-hint {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding: 14px 20px;
    }

    .hint-content {
        align-items: center;
    }

    .hint-cancel {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .suggestions-list {
        justify-content: center;
    }
}
