﻿:root {
    --bg: #f4f1ea;
    --panel: #fffdf8;
    --line: #d9cdbb;
    --ink: #1e1a14;
    --muted: #5a5147;
    --accent: #2f4f77;
    --warn: #c84b31;
    --neon: #fff200;
    --graph-top: #fffefb;
    --graph-bottom: #fbf6ee;
    --chip-bg: #f6efe1;
    --chip-bg-soft: #faf5eb;
    --table-line: #eadfce;
    --loading-track: #efe8dc;
    --loading-track-border: #d7c9b6;
    --term-stroke: #efe6d7;
    --term-label: #2d2923;
    --course-label: #ffffff;
}

html.mud-theme-dark {
    --bg: #12181b;
    --panel: #1a2226;
    --line: #2a3439;
    --ink: #e8e4dc;
    --muted: #a8a094;
    --accent: #7eb6c9;
    --warn: #e07a6c;
    --neon: #fff200;
    --graph-top: #151c20;
    --graph-bottom: #10161a;
    --chip-bg: #243036;
    --chip-bg-soft: #1e282c;
    --table-line: #2a3439;
    --loading-track: #243036;
    --loading-track-border: #2a3439;
    --term-stroke: #2a3439;
    --term-label: #1a1612;
    --course-label: #f2f0eb;
}

.diagram-page {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    background: transparent;
    color: var(--ink);
}

.wrap {
    max-width: 1920px;
    margin: 0 auto;
    padding: 40px 18px 56px;
}

.toolbar,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
}

.toolbar {
    display: none;
}

.diagram-filter-pair {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 8px;
}

.diagram-select,
.diagram-input {
    box-sizing: border-box;
    width: 100%;
    min-height: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--mud-palette-lines-default, var(--line));
    background: var(--mud-palette-surface, var(--panel));
    color: var(--mud-palette-text-primary, var(--ink));
    padding: 4px 8px;
    font: inherit;
    font-size: 0.8125rem;
    line-height: 1.25;
}

.diagram-select:focus,
.diagram-input:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
    outline-offset: 1px;
}

.panel {
    padding: 12px;
}

.panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 12px;
}

#graphWrap {
    min-height: 760px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--graph-top), var(--graph-bottom));
    overflow: hidden;
}

#graphSvg {
    width: 100%;
    height: 760px;
    display: block;
}

.meta {
    color: var(--muted);
    font-size: 14px;
}

.hint {
    color: var(--muted);
    font-size: 13px;
    margin-top: 10px;
}

.diagram-legend-panel {
    align-self: start;
    max-height: calc(760px + 48px);
    overflow: auto;
}

.diagram-legend-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.diagram-legend-heading {
    margin: 14px 0 6px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.diagram-legend-lead {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink);
}

.diagram-legend-note {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.diagram-legend-tips {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink);
}

.diagram-legend-tips li {
    margin-bottom: 6px;
}

.diagram-guide .legend {
    margin-bottom: 4px;
}

.legend {
    display: grid;
    gap: 10px;
    font-size: 14px;
}

.legend-compact {
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.legend-item-muted {
    opacity: 0.45;
}

.legend-label {
    font-weight: 700;
    line-height: 1.25;
}

.legend-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    margin-top: 2px;
}

.legend-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
    color: var(--muted);
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
    margin-top: 3px;
}

.swatch-term {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

html.mud-theme-dark .swatch-term {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.legend-line {
    width: 18px;
    height: 0;
    border-top: 3px solid #7a6a57;
    display: inline-block;
    flex: 0 0 auto;
    margin-top: 10px;
    border-radius: 2px;
}

.detail {
    border-top: 1px solid var(--line);
    margin-top: 12px;
    padding-top: 12px;
    font-size: 14px;
}

.detail.detail-only {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.detail-kicker {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 2px;
}

.detail-lead {
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink);
}

.detail-fact {
    margin: 4px 0;
    font-size: 13px;
}

.detail-section-title {
    margin: 12px 0 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
}

.detail-group-head {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.detail strong {
    display: block;
    margin-bottom: 4px;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 12px;
}

.detail-table th,
.detail-table td {
    text-align: left;
    padding: 5px 4px;
    border-bottom: 1px solid var(--table-line);
    vertical-align: top;
}

.detail-table th {
    color: var(--muted);
    font-weight: 600;
}

.detail ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

.type-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 700;
    background: var(--chip-bg);
    color: var(--muted);
}

.origin-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 600;
    background: var(--chip-bg-soft);
    color: var(--muted);
}

.loading-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 26, 20, 0.42);
    z-index: 9999;
    backdrop-filter: blur(2px);
}

html.mud-theme-dark .loading-modal {
    background: rgba(8, 12, 14, 0.65);
}

.loading-modal[hidden] {
    display: none;
}

.loading-card {
    width: min(520px, calc(100vw - 32px));
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    padding: 16px;
}

.loading-title {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--ink);
}

.loading-bar {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    border: 1px solid var(--loading-track-border);
    background: var(--loading-track);
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2f4f77, #4f8a8b);
    transition: width 160ms linear;
}

.loading-text {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.node.dim,
.edge.dim,
.label.dim {
    opacity: 0.18;
}

.node.selected-term,
.node.selected-course-node,
.node.selected-course-term {
    stroke: var(--neon);
    stroke-width: 4;
}

.edge.selected-edge,
.edge.selected-course-edge {
    stroke: var(--neon);
    stroke-width: 5;
    opacity: 1;
}

@media (max-width: 1200px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .wrap {
        padding: 16px 10px 28px;
    }

    .diagram-filter-pair {
        grid-template-columns: 1fr;
    }

    #graphWrap {
        min-height: 55vh;
    }

    #graphSvg {
        height: 55vh;
    }
}
