.course-detail-scene {
    position: relative;
    min-height: calc(100vh - 120px);
}

.course-detail-scene[data-scene-kind="course-detail"] {
    min-height: 0;
}

.course-graph-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    opacity: 1;
    transition: opacity .35s ease;
}

.course-detail-scene:not(.graph-mode) .course-graph-layer {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.course-detail-scene.graph-mode .course-graph-layer {
    z-index: 1060;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.course-detail-scene[data-scene-kind="learning-hall"].graph-mode .course-graph-layer {
    top: 64px;
    z-index: 900;
}

.course-detail-scene[data-scene-kind="learning-hall"] .course-graph-shell {
    padding-top: 2rem;
}

.course-detail-scene[data-scene-kind="learning-hall"] .course-graph-status,
.course-detail-scene[data-scene-kind="learning-hall"] .course-graph-toolbar {
    top: 24px;
}

.course-graph-layer::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
        radial-gradient(circle at bottom right, rgba(208, 217, 255, 0.32), transparent 26%),
        linear-gradient(135deg, #f6f7fb 0%, #e6ebf4 45%, #d8dfeb 100%);
}

.course-graph-shell {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 6.5rem 1rem 2rem;
}

.course-graph-status {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    max-width: min(560px, calc(100vw - 32px));
    border-radius: 999px;
    backdrop-filter: blur(10px);
}

.course-detail-scene[data-scene-kind="course-detail"] .course-graph-layer {
    display: none;
    opacity: 0;
    pointer-events: none;
    z-index: 1060;
}

.course-detail-scene[data-scene-kind="course-detail"]:not(.graph-mode) .course-graph-canvas {
    pointer-events: none;
}

.course-detail-scene[data-scene-kind="course-detail"]:not(.graph-mode) .course-graph-status,
.course-detail-scene[data-scene-kind="course-detail"]:not(.graph-mode) .course-graph-toolbar,
.course-detail-scene[data-scene-kind="course-detail"]:not(.graph-mode) .course-graph-legend,
.course-detail-scene[data-scene-kind="course-detail"]:not(.graph-mode) .course-graph-legend-restore,
.course-detail-scene[data-scene-kind="course-detail"]:not(.graph-mode) .course-graph-callout {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.course-detail-scene[data-scene-kind="course-detail"].graph-mode .course-graph-layer {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.course-graph-toolbar {
    position: absolute;
    top: 104px;
    right: 24px;
    z-index: 3;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity .35s ease, transform .35s ease;
}

.course-graph-toolbar .btn {
    pointer-events: auto;
}

.course-graph-search-panel {
    position: relative;
    width: min(320px, calc(100vw - 180px));
    pointer-events: auto;
}

.course-graph-search-panel .input-group {
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .14);
}

.course-graph-search-panel .form-control:focus {
    box-shadow: none;
}

.course-graph-search-results {
    margin-top: .55rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 18px 42px rgba(15, 23, 42, .14);
    overflow: hidden;
    max-height: min(44vh, 360px);
    overflow-y: auto;
}

.course-graph-search-result {
    width: 100%;
    padding: .8rem .95rem;
    border: 0;
    background: transparent;
    text-align: left;
    display: block;
    transition: background .18s ease;
}

.course-graph-search-result:hover,
.course-graph-search-result:focus-visible {
    background: #eef3fb;
}

.course-graph-search-result + .course-graph-search-result {
    border-top: 1px solid rgba(226, 232, 240, .85);
}

.course-graph-search-result-name {
    display: block;
    color: #0f172a;
    font-weight: 700;
    line-height: 1.35;
}

.course-graph-search-result-meta {
    display: block;
    margin-top: .15rem;
    color: #64748b;
    font-size: .78rem;
}

.course-detail-scene.graph-mode .course-graph-toolbar {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.course-graph-canvas {
    position: absolute;
    inset: 0;
    pointer-events: auto;
}

.course-graph-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

.course-graph-svg.is-panning {
    cursor: grabbing;
}

.course-stage-panels {
    position: relative;
    z-index: 2;
    transition: transform .9s cubic-bezier(.22, 1, .36, 1), opacity .45s ease;
}

.course-detail-scene[data-scene-kind="course-detail"] .course-stage-panels {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
}

.course-detail-scene.graph-mode .course-stage-panels {
    transform: translateY(115vh) scale(.96);
    opacity: 0;
    pointer-events: none;
}

.course-detail-scene[data-scene-kind="course-detail"].graph-mode .course-stage-panels {
    transform: translateY(calc(100% + 140px)) scale(.96);
}

.course-graph-legend {
    position: absolute;
    left: 24px;
    bottom: 28px;
    z-index: 2;
    width: min(250px, calc(100vw - 32px));
    padding: .9rem 1rem;
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.76);
    box-shadow: 0 18px 42px rgba(15, 23, 42, .12);
    backdrop-filter: blur(16px);
    opacity: .9;
    pointer-events: auto;
}

.course-graph-legend.is-hidden {
    display: none;
}

.course-graph-legend-restore {
    position: absolute;
    left: 24px;
    bottom: 28px;
    z-index: 2;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .55rem .9rem;
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 999px;
    background: rgba(255, 255, 255, .42);
    color: #64748b;
    backdrop-filter: blur(16px) saturate(.9);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
    font-size: .83rem;
    transition: opacity .18s ease, background .18s ease, color .18s ease, filter .18s ease;
    filter: blur(.2px) saturate(.88);
    opacity: .78;
}

.course-graph-legend-restore:hover {
    background: rgba(255, 255, 255, .62);
    color: #334155;
    opacity: .96;
    filter: blur(0) saturate(1);
}

.course-graph-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .55rem;
}

.course-graph-legend-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(226, 232, 240, .9);
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, color .18s ease;
}

.course-graph-legend-close:hover {
    background: rgba(203, 213, 225, .95);
    color: #334155;
}

.course-graph-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    background: #a5adb8;
    border: 1px solid rgba(15, 23, 42, .12);
}

.course-graph-legend-dot.in-progress {
    background: #d5b556;
}

.course-graph-legend-dot.mastered {
    background: #4ea673;
}

.course-graph-callout {
    position: absolute;
    min-width: 220px;
    max-width: min(360px, 72vw);
    padding: 1rem 1rem .9rem;
    border-radius: 1.1rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 48px rgba(15, 23, 42, .18);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, .2);
    z-index: 4;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.course-graph-callout-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .6rem;
}

.course-graph-callout-badge {
    border-radius: 999px;
    background: #eef2f7;
    color: #475569;
    font-size: .72rem;
    font-weight: 700;
    padding: .2rem .55rem;
}

.course-graph-callout-close {
    border: 0;
    background: transparent;
    color: #64748b;
}

.course-graph-callout-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: .85rem;
}

.course-graph-callout-action {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #e5e7eb;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.course-graph-callout-action:hover {
    background: #d1d5db;
    color: #374151;
    transform: translateX(1px);
}

.course-graph-note {
    color: #64748b;
    font-size: .85rem;
}

.kg-edge {
    stroke: rgba(99, 112, 125, .26);
    stroke-width: 1.4;
    transition: stroke .18s ease, stroke-width .18s ease, opacity .18s ease;
}

.kg-edge.cross-chapter {
    stroke: rgba(71, 85, 105, .42);
    stroke-dasharray: 5 5;
}

.kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
    stroke: rgba(71, 85, 105, .42);
    stroke-width: 1.5;
    transition: fill .18s ease, stroke .18s ease, transform .18s ease, opacity .18s ease;
}

.kg-node.section .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
    stroke: rgba(71, 85, 105, .48);
    stroke-width: 2;
}

.kg-node.topic .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
    stroke: rgba(71, 85, 105, .45);
    stroke-width: 1.8;
}

.kg-node.mastery-unseen {
    --kg-fill: #adb5bf;
}

.kg-node.mastery-involved {
    --kg-fill: #f2d98a;
}

.kg-node.mastery-mastered {
    --kg-fill: #5ab57a;
}

.kg-node text {
    fill: #475569;
    font-size: 12px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.kg-node.section text {
    font-size: 13px;
    fill: #0f172a;
}

.kg-node.topic text {
    font-size: 11px;
    fill: #334155;
}

.kg-node.section .kg-chapter-index {
    font-size: 12px;
    font-weight: 700;
}

.kg-node.section .kg-chapter-title {
    font-size: 11px;
    font-weight: 600;
}

.kg-node.active .kg-node-circle,
.kg-node:hover .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
    stroke: rgba(37, 99, 235, .96);
    stroke-width: 2.8;
    transform: scale(1.18);
    transform-origin: center;
    transform-box: fill-box;
}

.kg-node.section.active .kg-node-circle,
.kg-node.section:hover .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
}

.kg-node.topic.active .kg-node-circle,
.kg-node.topic:hover .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
}

.kg-node.related .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
    stroke: rgba(59, 130, 246, .72);
    stroke-width: 2.2;
}

.kg-node.search-match .kg-node-circle {
    fill: var(--kg-fill, #adb5bf);
    stroke: rgba(37, 99, 235, .9);
    stroke-width: 2.6;
}

.kg-node.dimmed,
.kg-edge.dimmed {
    opacity: .18;
}

.kg-edge.related {
    stroke: rgba(74, 85, 104, .7);
    stroke-width: 2.1;
}

.kg-edge.active {
    stroke: rgba(37, 99, 235, .96);
    stroke-width: 2.8;
}

.kg-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    color: #64748b;
    text-align: center;
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .course-graph-toolbar {
        top: auto;
        right: 16px;
        bottom: 20px;
        left: 16px;
        justify-content: space-between;
    }

    .course-graph-search-panel {
        width: min(100%, 320px);
    }

    .course-graph-shell {
        padding-top: 5.75rem;
    }

    .course-graph-legend {
        left: 16px;
        right: 16px;
        bottom: 88px;
        width: auto;
    }

    .course-graph-callout {
        left: 50% !important;
        top: auto !important;
        bottom: 110px;
        transform: translateX(-50%);
        max-width: calc(100vw - 32px);
    }

}
