.app-container {
    display: grid;
    grid-template-columns: 1fr auto var(--sidebar-width, 450px);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #121212;
}


.reader-pane {
    background: #F9F9F9;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 5;
    height: 100vh;
}

main {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.intelligence-sidebar {
    display: grid;
    grid-template-columns: 50px 1fr;
    width: 100%; /* controlled by grid */
    height: 100%;
    background: #0d0d0d;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    z-index: 10;
}

.resizer {
    width: 4px;
    cursor: col-resize;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s, width 0.2s;
    z-index: 20;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.resizer:hover, .app-container.is-resizing .resizer {
    background: var(--nexus-neon);
    width: 6px;
    box-shadow: 0 0 10px var(--nexus-neon);
}

.app-container.is-resizing {
    user-select: none;
}


.app-container.focus-mode-active {
    grid-template-columns: 1fr 0px 50px;
}

.app-container.focus-mode-active .intelligence-sidebar {
    grid-template-columns: 50px 0px;
}

.app-container.focus-mode-active .resizer {
    display: none;
}

.app-container.focus-mode-active .intelligence-content {
    opacity: 0;
    pointer-events: none;
}



.intelligence-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.intelligence-header {
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--nexus-font-sans);
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.intelligence-header .close-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
}

.intelligence-scroll-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Platform Specifics */
.platform-mobile .intelligence-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80%;
    z-index: 100;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.quiz-available {
    animation: quiz-pulse 1.5s infinite;
    color: var(--nexus-neon) !important;
}

@keyframes quiz-pulse {
    0% { filter: drop-shadow(0 0 2px var(--nexus-neon)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 10px var(--nexus-neon)); transform: scale(1.1); }
    100% { filter: drop-shadow(0 0 2px var(--nexus-neon)); transform: scale(1); }
}

/* Contextual Intelligence Panel Layout */
.stacked-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.visual-workspace {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.contextual-intelligence-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(13, 13, 13, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.01);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.neon-accent-icon {
    color: var(--nexus-neon, #00f0ff);
    filter: drop-shadow(0 0 5px var(--nexus-neon, #00f0ff));
}

.panel-title {
    font-family: var(--nexus-font-sans, "Outfit", sans-serif);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.no-node-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 150px;
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
    padding: 2rem;
}

.placeholder-glow {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.15) 0%, transparent 70%);
    animation: glow-pulse 2s infinite ease-in-out;
    margin-bottom: 1rem;
}

@keyframes glow-pulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.5; }
}

.placeholder-text {
    font-size: 0.85rem;
    line-height: 1.4;
    font-weight: 300;
}

.node-details {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.node-header-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

.node-group-badge {
    align-self: flex-start;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.08em;
    border: 1px solid transparent;
}

/* Badge specific styling matching category theme colors */
.node-group-badge.rule {
    background: rgba(244, 63, 94, 0.1);
    color: #f43f5e;
    border-color: rgba(244, 63, 94, 0.3);
}

.node-group-badge.definition {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
    border-color: rgba(234, 179, 8, 0.3);
}

.node-group-badge.table {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    border-color: rgba(168, 85, 247, 0.3);
}

.node-group-badge.section {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

.node-group-badge.bridge {
    background: rgba(236, 72, 153, 0.1);
    color: #ec4899;
    border-color: rgba(236, 72, 153, 0.3);
}

.node-group-badge.current {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.node-group-badge.concept {
    background: rgba(0, 240, 255, 0.1);
    color: #00f0ff;
    border-color: rgba(0, 240, 255, 0.3);
}

.node-label {
    font-family: var(--nexus-font-sans, "Outfit", sans-serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.detail-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
    color: rgba(255, 255, 255, 0.4);
}

.neon-sub-header {
    border-left: 2px solid var(--nexus-neon, #00f0ff);
    padding-left: 0.5rem;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.node-description {
    font-size: 0.85rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

.node-summary {
    font-size: 0.82rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.02);
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: 0 4px 4px 0;
    margin: 0;
}

.key-terms-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.key-term-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.8);
}

.term-bullet {
    color: var(--nexus-neon, #00f0ff);
    filter: drop-shadow(0 0 3px var(--nexus-neon, #00f0ff));
    font-weight: bold;
}

.term-text {
    line-height: 1.4;
}

/* Sidebar Footer & Open Quiz Button */
.sidebar-footer {
    padding: 1rem 1.25rem;
    background: rgba(13, 13, 13, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.open-quiz-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: var(--nexus-font-sans, "Outfit", sans-serif);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--nexus-neon, #00f0ff);
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.05);
}

.open-quiz-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: var(--nexus-neon, #00f0ff);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
    transform: translateY(-2px);
}

.open-quiz-btn:active {
    transform: translateY(0);
}

.quiz-pulse-btn {
    animation: quiz-pulse-glow 2s infinite ease-in-out;
}

@keyframes quiz-pulse-glow {
    0% { border-color: rgba(0, 240, 255, 0.3); box-shadow: 0 0 5px rgba(0, 240, 255, 0.1); }
    50% { border-color: var(--nexus-neon, #00f0ff); box-shadow: 0 0 25px rgba(0, 240, 255, 0.3); }
    100% { border-color: rgba(0, 240, 255, 0.3); box-shadow: 0 0 5px rgba(0, 240, 255, 0.1); }
}

/* Quiz Navigation Header */
.quiz-layout {
    display: flex;
    flex-direction: column;
}

.quiz-nav {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.01);
}

.back-to-graph-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.back-to-graph-btn:hover {
    color: var(--nexus-neon, #00f0ff);
    background: rgba(255, 255, 255, 0.02);
}

/* Mobile-First Platform Customization */
.platform-mobile {
    grid-template-columns: 1fr !important;
    height: 100vh !important;
    position: relative;
    overflow: hidden;
}

.platform-mobile .reader-pane {
    width: 100vw !important;
    height: calc(100vh - 60px) !important; /* reserve bottom nav height */
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    z-index: 10;
}

/* Three-tab mobile views depending on the active mobile tab class */
.app-container.platform-mobile.active-mobile-tab-reader .reader-pane {
    display: flex;
}

.app-container.platform-mobile.active-mobile-tab-graph .nexus-mobile-reader-tabs .graph-tab {
    display: block;
}

.app-container.platform-mobile.active-mobile-tab-insight .nexus-mobile-reader-tabs .insight-tab {
    display: block;
}

/* Mobile full-bleed tabs container */
.nexus-mobile-reader-tabs {
    display: none;
}

.platform-mobile .nexus-mobile-reader-tabs {
    display: none; /* Keep hidden by default */
    width: 100vw;
    height: calc(100vh - 60px);
    position: absolute;
    top: 0;
    left: 0;
    background: #0d0d0d;
    overflow: hidden;
    z-index: 15;
}

.app-container.platform-mobile.active-mobile-tab-graph .nexus-mobile-reader-tabs,
.app-container.platform-mobile.active-mobile-tab-insight .nexus-mobile-reader-tabs {
    display: block; /* Show only when graph or insight tabs are active */
}

.nexus-mobile-tab-content {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Active tab display with smooth slide-up / fade-in transition */
.nexus-mobile-tab-content.active {
    display: flex;
    flex-direction: column;
    animation: tab-transition 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Inside Mobile Graph Tab: full bleed and responsive */
.nexus-mobile-tab-content.graph-tab {
    background: #09090b;
}

.nexus-mobile-tab-content.graph-tab :deep(svg) {
    width: 100% !important;
    height: 100% !important;
}

/* Mobile Insight container & tabs */
.mobile-insight-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.mobile-insight-header {
    background: rgba(13, 13, 13, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    flex-shrink: 0;
}

.mobile-insight-nav {
    display: flex;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 2px;
}

.mobile-insight-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--nexus-font-sans, "Outfit", sans-serif);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-insight-nav-btn.active {
    background: rgba(0, 240, 255, 0.1);
    color: var(--nexus-neon, #00f0ff);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.mobile-insight-nav-btn.quiz-btn.quiz-pulse {
    animation: quiz-pulse-btn-anim 1.5s infinite;
}

@keyframes quiz-pulse-btn-anim {
    0% { color: rgba(255, 255, 255, 0.5); }
    50% { color: #f43f5e; text-shadow: 0 0 8px rgba(244, 63, 94, 0.6); }
    100% { color: rgba(255, 255, 255, 0.5); }
}

.mobile-insight-body {
    flex: 1;
    overflow-y: auto;
    background: #09090b;
}

.mobile-insight-body .contextual-intelligence-panel {
    background: transparent;
    border: none;
}

.mobile-insight-body .contextual-intelligence-panel .panel-body {
    padding: 1.25rem;
}

.mobile-quiz-wrapper {
    padding: 1.25rem;
    height: 100%;
    overflow-y: auto;
}

/* Three-Tab Bottom Navigation Bar styling */
.nexus-mobile-bottom-nav {
    display: none;
}

.platform-mobile .nexus-mobile-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 60px;
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 100%;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-family: var(--nexus-font-sans, "Outfit", sans-serif);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-item.active {
    color: var(--nexus-neon, #00f0ff);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.bottom-nav-item.active :deep(svg) {
    filter: drop-shadow(0 0 5px var(--nexus-neon, #00f0ff));
}

.insight-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-quiz-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background-color: #f43f5e;
    border-radius: 50%;
    box-shadow: 0 0 8px #f43f5e;
    animation: indicator-flash 1.5s infinite ease-in-out;
}

@keyframes indicator-flash {
    0% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.6; }
}

/* Assistant FAB styling inside ReaderCanvas */
:global(.nexus-mobile-assistant-fab) {
    position: fixed;
    bottom: 75px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.15) 0%, rgba(0, 100, 255, 0.15) 100%);
    border: 1px solid rgba(0, 240, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99;
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:global(.nexus-mobile-assistant-fab:hover) {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 240, 255, 0.4);
    border-color: var(--nexus-neon, #00f0ff);
}

:global(.nexus-mobile-assistant-fab:active) {
    transform: scale(0.95);
}

:global(.nexus-mobile-assistant-fab.has-new-quiz) {
    border-color: #f43f5e;
    box-shadow: 0 4px 20px rgba(244, 63, 94, 0.3);
}

:global(.nexus-mobile-assistant-fab .fab-badge) {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: #f43f5e;
    border-radius: 50%;
    box-shadow: 0 0 10px #f43f5e;
    animation: indicator-flash 1.5s infinite ease-in-out;
}