/* Course map section only. The public site's DESIGN.md tokens own its theme. */
.course-map { min-width: 0; margin-block: 20px; font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif; font-size: 14px; line-height: 1.7; }
.course-map [hidden] { display: none !important; }
.cm-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cm-filters, .cm-years { display: flex; gap: 4px; }
.course-map button { min-height: 44px; min-width: 44px; padding: 8px 12px; border: 1px solid transparent; border-radius: 0; background: transparent; color: var(--theme-color-foreground); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.course-map button:hover, .course-map button[aria-pressed="true"], .course-map button[aria-current="true"] { background: var(--theme-color-surface-selected); color: var(--theme-color-primary); }
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .course-map button:focus-visible, :where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .cm-viewport:focus-visible { outline: var(--theme-focus-ring-width) solid var(--theme-color-focus); outline-offset: var(--theme-focus-ring-gap); }
.cm-count { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.cm-locator { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--theme-color-border); padding: 4px 0; color: var(--theme-color-muted); font-size: 12px; }
.cm-years button { padding: 8px; font-size: 12px; }
/* Always allocate a classic scrollbar; overlay scrollbars need no extra gutter.
   An additional stable gutter can disagree with Chrome's actual scrollport. */
.cm-viewport { position: relative; width: 100%; height: 640px; max-height: 72vh; min-height: 400px; overflow: auto; overflow-y: scroll; overscroll-behavior: contain; border: 1px solid var(--theme-color-border-strong); scrollbar-color: var(--theme-color-border-strong) var(--theme-color-surface-muted); background: var(--theme-color-surface-muted); }
.cm-canvas { position: relative; isolation: isolate; min-height: 100%; }
.cm-axis { position: sticky; top: 0; z-index: 5; height: 52px; display: flex; background: var(--theme-color-surface); border-bottom: 1px solid var(--theme-color-border-strong); }
.cm-axis-cell { flex: none; display: flex; align-items: center; justify-content: center; border-inline-end: 1px solid var(--theme-color-border); color: var(--theme-color-primary); font-size: 14px; font-weight: 500; box-sizing: border-box; }
.cm-grid-line { position: absolute; top: 52px; bottom: 0; width: 1px; background: var(--theme-color-border); z-index: -1; }
.cm-lane-label { position: absolute; left: 16px; margin: 0; padding-right: 12px; background: var(--theme-color-surface-muted); color: var(--theme-color-muted); font-size: 12px; font-weight: 400; line-height: 20px; }
.cm-lane-rule { position: absolute; height: 1px; background: var(--theme-color-border); }
.cm-course { position: absolute; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; padding: 10px 10px 8px; box-sizing: border-box; border: 1px solid var(--theme-color-border-strong); background: var(--theme-color-surface); color: var(--theme-color-foreground); cursor: default; border-radius: 0; box-shadow: none; text-align: left; z-index: 2; }
.cm-group .cm-course { background: var(--theme-color-surface-muted); border-color: var(--theme-color-border); }
@media (hover: hover) and (pointer: fine) {
    .cm-course:hover, .cm-group .cm-course:hover, .cm-fallback-course:hover { background: var(--theme-color-surface-selected); }
    .cm-corequisite-option:has(.cm-fallback-course:hover, .cm-corequisite-gap:hover) .cm-fallback-course,
    .cm-related-option:has(.cm-fallback-course:hover) .cm-fallback-course { background: var(--theme-color-surface-selected); }
}
.cm-course.cm-linked-active, .cm-group .cm-course.cm-linked-active { background: var(--theme-color-surface-selected); }
.cm-name { display: block; max-height: 40px; overflow: hidden; font-size: 14px; font-weight: 500; line-height: 20px; overflow-wrap: anywhere; }
.cm-name-overflow { mask-image: linear-gradient(#000, #000), linear-gradient(to right, #000 65%, transparent); mask-size: 100% 20px, 100% 20px; mask-position: left top, left bottom; mask-repeat: no-repeat; }
.cm-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 12px; line-height: 18px; white-space: nowrap; font-weight: 400; }
.cm-category { color: var(--theme-color-muted); display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.cm-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-height: 22px; margin-block: 12px; font-size: 12px; color: var(--theme-color-muted); }
.cm-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.cm-mark { display: inline-block; flex: none; width: 8px; height: 8px; border: 1px solid var(--theme-color-primary); background: var(--theme-color-primary); box-sizing: border-box; }
.cm-mark[data-category="restricted_choice"] { background: var(--theme-color-surface-selected); }
.cm-mark[data-category="elective"], .cm-mark[data-category="unknown"] { background: transparent; }
.cm-mark[data-category="unknown"] { border-color: var(--theme-color-muted); }
.cm-credit { margin-left: auto; text-align: right; color: var(--theme-color-muted); }
.cm-group { position: absolute; box-sizing: border-box; border: 1px solid var(--theme-color-border-strong); background: var(--theme-color-surface); z-index: 1; }
.cm-group-head { min-height: 50px; padding: 12px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--theme-color-border); }
.cm-group-head > strong, .cm-group-head > p, .cm-group-head > ul { max-inline-size: min(100%, var(--cm-readable-width, 100%)); box-sizing: border-box; }
.cm-group-head strong { display: block; color: var(--theme-color-primary); font-size: 14px; font-weight: 500; line-height: 22px; overflow-wrap: anywhere; }
.cm-group-head p { margin: 4px 0 0; font-size: 12px; line-height: 18px; color: var(--theme-color-muted); }
.cm-candidate-references { margin: 8px 0 0; padding-inline-start: 20px; color: var(--theme-color-foreground); font-size: 14px; font-weight: 400; line-height: 1.7; overflow-wrap: anywhere; }
.cm-fallback-group { margin-block-start: 16px; padding-block-start: 12px; border-top: 1px solid var(--theme-color-border); }
.cm-fallback-group h4, .cm-fallback-group p { margin: 0 0 8px; }
.cm-option { position: absolute; box-sizing: border-box; border: 1px dashed var(--theme-color-border-strong, var(--theme-color-muted)); background: var(--theme-color-surface-muted); }
.cm-option-label { margin: 6px 8px; font-size: 12px; line-height: 18px; color: var(--theme-color-muted); }
.cm-option-head > .cm-candidate-references { margin: 8px; max-inline-size: min(calc(100% - 16px), var(--cm-readable-width, 100%)); box-sizing: border-box; }
.cm-option-head strong { font-weight: 500; }
.cm-header-scroll { min-width: 0; max-width: 100%; box-sizing: border-box; overflow-x: auto; overflow-y: hidden; white-space: nowrap; text-overflow: clip; scrollbar-width: thin; overscroll-behavior-inline: contain; }
/* Intrinsic height reserves scrollbar space only when the single line overflows. */
.cm-group-head.cm-header-scroll { display: block; min-height: 0; line-height: 22px; }
.cm-option-head.cm-header-scroll { padding: 6px 8px; line-height: 18px; }
.cm-fallback-header.cm-header-scroll { padding: 8px 0; line-height: 22px; }
.cm-header-scroll > :not(.cm-sr-only), .cm-header-scroll .cm-candidate-references:not(.cm-sr-only), .cm-header-scroll li:not(.cm-sr-only) { display: inline; max-inline-size: none; margin: 0; padding: 0; white-space: inherit; overflow-wrap: normal; line-height: inherit; }
.cm-header-scroll > :not(.cm-sr-only) + :not(.cm-sr-only), .cm-header-scroll li:not(.cm-sr-only) + li:not(.cm-sr-only) { margin-inline-start: 12px; }
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .cm-header-scroll:focus-visible { outline: var(--theme-focus-ring-width) solid var(--theme-color-focus); outline-offset: var(--theme-focus-ring-gap); }
.cm-group-head li strong { display: inline; }
.cm-fallback-group[data-condition-group] { border: 1px solid var(--theme-color-border-strong); padding: 12px; }
.cm-fallback-group[data-condition-group] > .cm-candidate-references { margin-block-end: 12px; }
.course-map .cm-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.cm-corequisite-option, .cm-related-option { border: 0; background: transparent; }
.cm-choice-subset, .cm-course-limit { border: 1px solid var(--theme-color-border); }
.cm-fallback-option.cm-choice-subset, .cm-fallback-option.cm-course-limit { padding: 8px; margin-block: 12px; }
.cm-corequisite-set { position: absolute; background: var(--theme-color-surface-muted); }
.cm-corequisite-set::after { content: ""; position: absolute; inset: 0; box-sizing: border-box; border: 1px solid var(--theme-color-border); pointer-events: none; z-index: 4; }
/* The set owns its single outline, including wrapped rows and their spacing. */
.cm-corequisite-set > .cm-course { border-width: 0; padding: 11px 11px 9px; background: transparent; }
.cm-corequisite-set > .cm-course-with-year { gap: 4px; }
.cm-source-year { display: block; font-size: 11px; line-height: 16px; color: var(--theme-color-muted); }
.cm-course-note { display: block; font-size: 12px; line-height: 16px; color: var(--theme-color-muted); overflow-wrap: anywhere; }
.cm-scope-heading { position: absolute; margin: 0; padding: 8px 12px; color: var(--theme-color-primary); font-size: 14px; font-weight: 500; line-height: 22px; border-block-end: 1px solid var(--theme-color-border-strong); }
.cm-sequence-alternative { position: absolute; box-sizing: border-box; }
.cm-fallback-scope-heading { margin-block: 20px 8px; font-size: 14px; font-weight: 500; line-height: 22px; color: var(--theme-color-primary); }
.cm-corequisite-set.cm-linked-active,
.cm-corequisite-set.cm-linked-active > .cm-course { background: var(--theme-color-surface-selected); }
.cm-corequisite-gap { position: absolute; display: flex; align-items: center; justify-content: center; width: 12px; font-size: 12px; line-height: 12px; color: var(--theme-color-muted); cursor: default; z-index: 3; }
.cm-corequisite-bridge { box-sizing: border-box; border-block: 1px solid var(--theme-color-border-strong); background: var(--theme-color-surface); }
.cm-group .cm-corequisite-bridge { border-color: var(--theme-color-border); background: var(--theme-color-surface-muted); }
.cm-corequisite-set > .cm-corequisite-gap { border: 0; background: transparent; }
.cm-corequisite-bridge.cm-linked-active { background: var(--theme-color-surface-selected); }
.cm-bundle-status { margin: 0; padding: 4px 8px; color: var(--theme-color-muted); font-size: 12px; line-height: 18px; }
.cm-fallback-bundle { margin-block: 12px; }
.cm-fallback-bundle-grid { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cm-fallback-bundle-grid.cm-corequisite-set > .cm-fallback-course { border-width: 0; padding: 13px; background: transparent; }
.cm-fallback-bundle-grid.cm-corequisite-set .cm-corequisite-gap { border: 0; top: 0; height: 100%; }
.cm-fallback-bundle-grid.cm-corequisite-set .cm-corequisite-row-gap { top: -12px; left: calc(50% - 6px); height: 12px; }
@media (hover: hover) and (pointer: fine) {
    .cm-fallback-bundle-grid.cm-corequisite-set:hover,
    .cm-fallback-bundle-grid.cm-corequisite-set:hover > .cm-fallback-course { background: var(--theme-color-surface-selected); }
}
.cm-fallback-bundle-grid > .cm-fallback-course { position: relative; min-width: 0; overflow-wrap: anywhere; }
.cm-fallback-bundle-grid .cm-corequisite-gap { box-sizing: border-box; left: 100%; top: -1px; height: calc(100% + 2px); border-block: 1px solid var(--theme-color-border); background: inherit; }
.cm-empty { padding: 32px 16px; font-size: 14px; }
.cm-fallback-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.cm-fallback-course { display: flex; flex-direction: column; padding: 12px; border: 1px solid var(--theme-color-border); font-size: 14px; }
.cm-fallback-course span { font-size: 12px; color: var(--theme-color-muted); }
/* The 12px bridge completes one continuous surface; padding replaces inner borders. */
.cm-corequisite-option .cm-join-next { border-right-width: 0; }
.cm-corequisite-option .cm-join-previous { border-left-width: 0; }
.cm-course.cm-join-next { padding-right: 11px; }
.cm-course.cm-join-previous { padding-left: 11px; }
.cm-fallback-course.cm-join-next { padding-right: 13px; }
.cm-fallback-course.cm-join-previous { padding-left: 13px; }
.cm-foot { display: flex; justify-content: flex-end; padding: 4px 0; font-size: 12px; }
.cm-foot .cm-source-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--theme-color-primary); text-decoration: underline; text-underline-offset: 4px; white-space: nowrap; }
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .cm-foot .cm-source-link:focus-visible { outline: var(--theme-focus-ring-width) solid var(--theme-color-focus); outline-offset: var(--theme-focus-ring-gap); }
@media (max-width: 767px) {
    .cm-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .cm-filters { flex-wrap: wrap; } .cm-filters button { flex: 1; }
    .cm-legend { gap: 12px; margin-block: 8px; }
    .cm-locator { gap: 4px; flex-wrap: wrap; padding: 0; } .cm-locator > span { margin-right: 4px; }
    .cm-years { gap: 0; flex-wrap: wrap; }
    .cm-viewport { max-height: none; height: 540px; min-height: 0; }
}
.cm-variant-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-block: 16px; }
.cm-variant-form .ui-field { flex: 1 1 240px; min-width: 0; max-width: 100%; min-height: 44px; }
.cm-variant-form label { flex: 0 0 100%; }
