.explore-body {
    margin: 0;
    padding: 0;
    font-family: var(--sans);
    background: var(--bg);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

.explore-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

.explore-rail {
    flex: 0 0 auto;
    background: var(--ink);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 12px;
    gap: 8px;
    z-index: 30;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rail-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--bg);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.rail-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    border-bottom: none;
}

.rail-btn-primary {
    background: var(--bg);
    color: var(--accent);
    font-size: 28px;
    font-weight: 500;
}

.rail-btn-primary:hover {
    background: var(--bg2);
}

.rail-btn-link {
    font-size: 16px;
}

.rail-spacer {
    flex: 1 1 auto;
}

.explore-workspace {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.explore-canvas-wrap {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0);
    background-size: 24px 24px;
    background-color: var(--bg);
    cursor: grab;
    min-height: 0;
}

.explore-canvas-wrap:active {
    cursor: grabbing;
}

.explore-canvas-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink3);
    font-size: 14px;
    font-weight: 300;
    pointer-events: none;
    z-index: 1;
    padding: 16px;
    text-align: center;
}

.explore-canvas-empty.hidden {
    display: none;
}

.graph-transform {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    overflow: visible;
}

.graph-edges {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.graph-edges line {
    stroke: var(--line);
    stroke-width: 1.5;
    stroke-opacity: 0.85;
}

.graph-nodes {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
}

.graph-node {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    will-change: transform;
}

.graph-node:active {
    cursor: grabbing;
}

.graph-node.selected .graph-event-card {
    box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(28, 45, 74, 0.18);
}

.graph-event-card {
    width: 220px;
    min-height: unset;
    cursor: pointer;
}

.graph-event-card:hover {
    transform: none;
}

.graph-event-card.saved {
    border-color: #e6c200;
    box-shadow: inset 0 0 0 0 transparent;
    animation: graph-saved-glow 2.2s ease-in-out infinite;
}

@keyframes graph-saved-glow {
    0%, 100% {
        box-shadow:
            0 0 6px 2px rgba(255, 210, 0, 0.45),
            0 0 14px 4px rgba(255, 190, 0, 0.25);
    }
    50% {
        box-shadow:
            0 0 12px 4px rgba(255, 220, 0, 0.75),
            0 0 26px 10px rgba(255, 200, 0, 0.4);
    }
}

.graph-event-card .course-card-header {
    min-height: 72px;
    padding: 10px 12px 12px;
}

.graph-event-card .course-card-title {
    font-size: 14px;
    line-height: 1.25;
}

.graph-event-card .course-card-title span {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.graph-event-card .course-card-body {
    padding: 8px 12px 10px;
}

.graph-event-card .course-card-footer {
    margin-top: 4px;
    justify-content: flex-end;
}

.graph-event-card .course-save-button {
    font-size: 18px;
    line-height: 1;
    padding: 4px 10px;
    min-width: 36px;
}

.graph-keyword-node {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 2px;
    font-size: 13px;
    font-weight: 300;
    line-height: 1.3;
    border: 1px solid transparent;
    white-space: nowrap;
    max-width: 220px;
    transition: opacity 0.2s ease, box-shadow 0.15s ease;
    opacity: 0.45;
    cursor: pointer;
}

.graph-keyword-node.expanded {
    opacity: 1;
    box-shadow: 0 2px 10px rgba(28, 45, 74, 0.12);
}

.graph-keyword-node.keyword-tfidf {
    background: #fff3cd;
    color: #7a5d00;
    border-color: #f0c84b;
}

.graph-keyword-node.keyword-llm {
    background: #d7ecff;
    color: #0b4f8a;
    border-color: #6eb5ff;
}

.keyword-method-badge {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: 2px;
    flex-shrink: 0;
}

.keyword-tfidf .keyword-method-badge {
    background: #7a5d00;
    color: #fff;
}

.keyword-llm .keyword-method-badge {
    background: var(--accent);
    color: var(--bg);
}

.keyword-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Detail panel: mobile bottom sheet ── */
.explore-detail-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    background: var(--surface-solid);
    border-top: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 32px rgba(28, 45, 74, 0.12);
    display: flex;
    flex-direction: column;
    max-height: 72vh;
    transform: translateY(calc(100% - 44px));
    transition: transform 0.28s ease;
}

.explore-detail-panel.sheet-hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.explore-detail-panel.sheet-collapsed {
    transform: translateY(calc(100% - 44px));
}

.explore-detail-panel.sheet-open {
    transform: translateY(0);
}

.detail-sheet-handle {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 8px;
    cursor: pointer;
    border: none;
    background: var(--surface);
    border-radius: 12px 12px 0 0;
    width: 100%;
}

.detail-sheet-grab {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
}

.detail-sheet-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent2);
}

.detail-dock-toggle {
    display: none;
}

.detail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.detail-panel-title {
    margin: 0;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 400;
    color: var(--ink);
}

.detail-close-btn {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: var(--ink3);
    cursor: pointer;
    padding: 0 4px;
}

.detail-close-btn:hover {
    color: var(--accent);
}

.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 20px;
    min-height: 0;
}

.detail-empty {
    color: var(--ink3);
    font-style: italic;
    font-weight: 300;
    margin: 24px 0;
    text-align: center;
}

.explore-detail-content .section-title {
    font-family: var(--serif);
    font-size: 16px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.explore-detail-content .course-card-detail {
    max-width: 300px;
}

.explore-detail-content .description-section {
    margin-bottom: 24px;
}

.explore-detail-content .description-content {
    color: var(--ink2);
    font-weight: 300;
    line-height: 1.7;
    font-size: 14px;
}

.explore-detail-content .person-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    background: var(--surface);
}

.explore-detail-content .person-name {
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 400;
    color: var(--ink);
}

.explore-detail-content .person-name a {
    color: var(--ink);
    border-bottom-color: var(--line);
}

.explore-detail-content .person-avatar {
    float: left;
    margin-right: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    width: 56px;
    height: 56px;
    object-fit: cover;
}

.explore-detail-content .person-bio-preview {
    color: var(--ink3);
    font-size: 13px;
    font-weight: 300;
    margin-top: 8px;
}

.explore-detail-content .keywords-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.explore-detail-header {
    margin-bottom: 12px;
}

.explore-detail-full-link {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.explore-detail-full-link:hover {
    border-color: var(--accent);
}

.search-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28, 45, 74, 0.35);
    z-index: 100;
}

.search-modal {
    position: fixed;
    top: 56px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(28, 45, 74, 0.18);
    z-index: 101;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.search-modal[hidden],
.search-modal-backdrop[hidden] {
    display: none !important;
}

.search-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.search-modal-header h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 400;
    color: var(--ink);
}

.search-close-btn {
    border: none;
    background: transparent;
    font-size: 24px;
    color: var(--ink3);
    cursor: pointer;
}

.search-close-btn:hover {
    color: var(--accent);
}

.search-modal-body {
    padding: 14px 16px 16px;
    overflow-y: auto;
    box-sizing: border-box;
    min-width: 0;
}

.search-modal .search-modal-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 2px;
    font-size: 15px;
    font-weight: 300;
    font-family: var(--sans);
    background: var(--surface-solid);
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s;
}

.search-modal .search-modal-input:focus {
    border-color: var(--accent2);
}

.search-modal-status {
    min-height: 20px;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 300;
    color: var(--ink3);
}

.search-modal-status.error {
    color: #a33;
}

.search-results {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}

.search-result-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    background: var(--surface);
}

.search-result-item:hover {
    border-color: var(--accent2);
    background: var(--bg2);
}

.search-result-title {
    font-family: var(--serif);
    font-weight: 400;
    color: var(--ink);
    font-size: 14px;
    margin-bottom: 4px;
}

.search-result-meta {
    font-size: 12px;
    font-weight: 300;
    color: var(--ink3);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.search-result-meta .similarity-meter {
    margin: 0;
}

.search-result-meta .similarity-label {
    font-size: 11px;
}

.explore-body .saved-basket-fab {
    top: auto;
    bottom: 56px;
    right: 12px;
}

.explore-body.saved-basket-open .saved-basket-fab {
    z-index: 230;
}

/* ── Desktop layout ── */
@media (min-width: 769px) {
    .explore-shell {
        flex-direction: row;
    }

    .explore-rail {
        flex: 0 0 56px;
        flex-direction: column;
        align-items: center;
        padding: 12px 0;
        gap: 10px;
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
    }

    .rail-spacer {
        display: none;
    }

    .explore-workspace {
        flex-direction: row;
        flex: 1 1 auto;
    }

    .explore-canvas-wrap {
        flex: 1 1 auto;
    }

    .explore-detail-panel {
        position: relative;
        flex: 0 0 380px;
        max-height: none;
        border-top: none;
        border-left: 1px solid var(--line);
        border-radius: 0;
        box-shadow: -4px 0 16px rgba(28, 45, 74, 0.06);
        transform: none;
        transition: flex-basis 0.25s ease, opacity 0.2s ease;
    }

    .explore-detail-panel.sheet-hidden,
    .explore-detail-panel.sheet-collapsed,
    .explore-detail-panel.sheet-open {
        transform: none;
        pointer-events: auto;
    }

    .explore-detail-panel.docked-closed {
        flex: 0 0 0;
        width: 0;
        min-width: 0;
        overflow: visible;
        border-left: none;
    }

    .explore-detail-panel.docked-closed .detail-panel-header,
    .explore-detail-panel.docked-closed .detail-panel-body,
    .explore-detail-panel.docked-closed .detail-sheet-handle {
        display: none;
    }

    .detail-sheet-handle {
        display: none;
    }

    .detail-dock-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: -28px;
        top: 50%;
        transform: translateY(-50%);
        width: 28px;
        height: 56px;
        padding: 0;
        border: 1px solid var(--line);
        border-right: none;
        border-radius: var(--radius) 0 0 var(--radius);
        background: var(--surface-solid);
        color: var(--accent);
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
        z-index: 12;
        box-shadow: -2px 0 8px rgba(28, 45, 74, 0.08);
    }

    .detail-dock-toggle:hover {
        background: var(--bg2);
    }

    .explore-detail-panel.docked-closed .detail-dock-toggle {
        left: -28px;
    }

    .search-modal {
        top: 16px;
        left: calc(56px + 24px);
        right: auto;
        width: min(480px, calc(100vw - 480px));
        max-height: calc(100vh - 32px);
    }

    .explore-body .saved-basket-fab {
        top: 12px;
        bottom: auto;
        right: 12px;
    }
}

@media (max-width: 768px) {
    .explore-body .saved-basket-fab {
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .explore-detail-panel.sheet-open ~ .explore-workspace .explore-canvas-wrap,
    .explore-detail-panel.sheet-collapsed ~ .explore-workspace .explore-canvas-wrap {
        /* canvas stays full height under sheet */
    }
}
