:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #667085;
    --line: #303744;
    --green: #17bf3d;
    --cyan: #1d9fe8;
    --blue: #326ff0;
    --soft: #eef9ff;
    --soft-border: #d5eefb;
    --canvas: #f8fbff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #eef3f9;
    color: var(--ink);
}

.prototype-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.prototype-toolbar {
    display: none;
    min-height: 72px;
    padding: 14px 24px;
    /*display: flex;*/
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: #ffffff;
    border-bottom: 1px solid #d9e2ec;
}

.prototype-toolbar h1 {
    margin: 0 0 4px;
    font-size: 19px;
    line-height: 1.25;
    font-weight: 750;
}

.prototype-toolbar p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.prototype-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #475467;
    font-size: 13px;
    white-space: nowrap;
}

.prototype-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot--green {
    background: var(--green);
}

.legend-dot--cyan {
    background: var(--cyan);
}

.legend-dot--soft {
    background: var(--soft-border);
    border: 1px solid #9bd8f4;
}

.flow-viewport {
    flex: 1;
    overflow: auto;
    padding: 28px 36px 44px;
}

.flow-viewport--map {
    padding: 12px 16px 18px;
    background: #eef3f9;
}

.flow-canvas {
    position: relative;
    min-width: 100%;
    border: 1px solid #d7e2ee;
    border-radius: 8px;
    background:
        linear-gradient(#ffffff 0 0) padding-box,
        radial-gradient(circle at 1px 1px, rgba(50, 111, 240, 0.16) 1px, transparent 0) 0 0 / 24px 24px;
    box-shadow: 0 18px 42px rgba(23, 32, 51, 0.08);
}

.connector-layer {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
}

.connector-path {
    fill: none;
    stroke: var(--line);
    stroke-width: 2;
}

.flow-node,
.flow-group-card,
.flow-relation-row {
    position: absolute;
}

.flow-relation-row {
    display: block;
    overflow: visible;
}

.flow-node {
    max-width: 300px;
    min-height: 42px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 5px 12px rgba(29, 159, 232, 0.18);
    overflow: visible;
}

.flow-node--has-items {
    padding-right: 34px;
}

.flow-node__label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flow-node__toggle {
    position: absolute;
    z-index: 2;
    right: -4px;
    top: -10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(50, 111, 240, 0.2);
    border-radius: 50%;
    background: #ffffff;
    color: var(--blue);
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(50, 111, 240, 0.16);
}

.flow-node__toggle:hover {
    background: #f8fbff;
}

.flow-node--primary {
    background: linear-gradient(180deg, #3b79ff, var(--blue));
    box-shadow: 0 0 0 3px rgba(50, 111, 240, 0.14), 0 6px 14px rgba(50, 111, 240, 0.25);
}

.flow-node--green {
    background: var(--green);
    box-shadow: 0 5px 12px rgba(23, 191, 61, 0.18);
}

.flow-node--cyan {
    background: var(--cyan);
}

.flow-group-card {
    /*width: 300px;*/
    padding: 12px;
    border: 1px solid var(--soft-border);
    border-radius: 8px;
    background: rgba(238, 249, 255, 0.82);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.86), 0 7px 18px rgba(29, 159, 232, 0.08);
    overflow: visible;
}

.flow-group-card--children {
    padding: 12px;
    border-color: #d4e9f5;
    background: rgba(247, 252, 255, 0.96);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.95), 0 10px 24px rgba(29, 159, 232, 0.08);
}

.flow-group-card--children .flow-node {
    box-shadow: 0 4px 10px rgba(29, 159, 232, 0.12);
}

/*.flow-group-card--compact {*/
/*    width: 500px;*/
/*}*/

/*.flow-group-card--wide {*/
/*    width: 1040px;*/
/*}*/

.flow-group-card .flow-node__toggle {
    right: -4px;
    top: -10px;
    border-color: rgba(50, 111, 240, 0.2);
    background: #ffffff;
    color: var(--blue);
    box-shadow: 0 4px 10px rgba(50, 111, 240, 0.16);
}

.flow-group-card--blue {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 10px;
}

.flow-group-card__title {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border-radius: 999px;
    background: linear-gradient(180deg, #3b79ff, #2f66dc);
    color: #ffffff;
    font-weight: 750;
    line-height: 1.4;
    text-align: center;
    writing-mode: vertical-rl;
    letter-spacing: 0;
}

.flow-group-card--soft .flow-group-card__title {
    display: none;
}

.flow-group-card--soft.flow-group-card--name-card {
    padding: 0 34px 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: rgba(19, 123, 183, 0.22);
    background: var(--cyan);
    color: #ffffff;
    box-shadow: 0 5px 12px rgba(29, 159, 232, 0.18);
}

.flow-group-card__name {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    color: inherit;
    font-size: 15px;
    font-weight: 750;
    line-height: 1.35;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-card {
    width: 100%;
    height: 100%;
    display: grid;
    gap: 10px;
    align-content: center;
}

.flow-group-card--soft .group-card {
    grid-auto-flow: column;
    grid-auto-columns: 210px;
    gap: 24px;
    justify-content: start;
}

.group-card__item {
    width: 210px;
    min-width: 0;
    min-height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    background: var(--cyan);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 3px 8px rgba(29, 159, 232, 0.16);
}

a.group-card__item:hover {
    filter: brightness(1.04);
}

.group-card__item--disabled {
    border: 1px dashed #b8c3cf;
    background: #e8edf3;
    color: #8a97a6;
    cursor: not-allowed;
    box-shadow: none;
}

.flow-group-card--blue .group-card__item {
    width: 120px;
}

.group-card__item-label {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.child-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.4);
}

.child-modal__panel {
    position: relative;
    width: min(920px, 100%);
    min-height: 300px;
    max-height: min(760px, calc(100vh - 80px));
    overflow: auto;
    border: 1px solid rgba(226, 235, 244, 0.9);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 28px 76px rgba(23, 32, 51, 0.24);
}

.child-modal__header {
    min-height: 72px;
    padding: 20px 72px 18px 30px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e3edf6;
}

.child-modal__header h2 {
    max-width: 760px;
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 20px;
    line-height: 1.28;
    font-weight: 820;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.child-modal__close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 1;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border: 1px solid #d2e2ef;
    border-radius: 50%;
    background: #ffffff;
    color: #475467;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(23, 32, 51, 0.08);
}

.child-modal__close:hover {
    color: var(--blue);
    border-color: rgba(50, 111, 240, 0.36);
}

.child-modal__grid {
    min-height: 226px;
    padding: 32px 30px 34px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.child-modal-card {
    position: relative;
    min-height: 168px;
    padding: 0;
    display: flex;
    flex-direction: column;
    /*justify-content: center;*/
    gap: 16px;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
}

.child-modal-card__title {
    min-height: 22px;
    overflow: hidden;
    color: var(--ink);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.child-modal-card__items {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-content: flex-start;
}

.child-modal-card__item {
    width: 260px;
    flex: 0 0 260px;
    min-width: 0;
    max-width: 100%;
    min-height: 48px;
    padding: 0 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 1px solid rgba(19, 123, 183, 0.28);
    background: linear-gradient(180deg, #26a8ec, #178fd4);
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(29, 159, 232, 0.16);
    white-space: normal;
}

a.child-modal-card__item:hover {
    filter: brightness(1.05);
}

.child-modal-card__item-label {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.child-modal-card__item--disabled {
    border-style: dashed;
    border-color: #b8c3cf;
    background: #e8edf3;
    color: #8a97a6;
    cursor: not-allowed;
    box-shadow: none;
}

.child-modal__empty {
    padding: 42px 20px;
    border: 1px dashed #bddff1;
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
    background: rgba(238, 249, 255, 0.7);
}

.curriculum-map {
    --menu-width: 176px;
    --lane-gap: 16px;
    width: 100%;
    min-width: 0;
    padding: 12px 16px 16px;
    overflow: visible;
    border: 1px solid #d9e7f0;
    border-radius: 8px;
    background:
        linear-gradient(#ffffff 0 0) padding-box,
        radial-gradient(circle at 1px 1px, rgba(50, 111, 240, 0.16) 1px, transparent 0) 0 0 / 24px 24px;
    box-shadow: 0 18px 42px rgba(23, 32, 51, 0.1);
}

.curriculum-map__header,
.curriculum-map__row {
    display: grid;
    grid-template-columns: minmax(0, var(--menu-width)) repeat(6, minmax(0, 1fr));
    column-gap: var(--lane-gap);
}

.curriculum-map__header > *,
.curriculum-map__row > * {
    min-width: 0;
}

.curriculum-map__header {
    position: relative;
    align-items: stretch;
    margin-bottom: 10px;
}

.curriculum-map .flow-node {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: auto;
    max-width: none;
    min-height: 30px;
    padding: 5px 8px;
    white-space: normal;
}

.curriculum-map-node {
    z-index: 1;
    align-self: stretch;
    overflow: visible;
}

.curriculum-map-node--blank {
    background: #b8e4f7;
    box-shadow: none;
    pointer-events: none;
}

.curriculum-map__root-node,
.curriculum-map__column-node {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 14px;
    line-height: 1.25;
}

.curriculum-map__root-node {
    min-height: 40px;
    position: relative;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px 6px 10px;
    overflow: hidden;
}

.curriculum-map__root-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.curriculum-map__column-node {
    border: 0;
    color: #ffe600;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.curriculum-map__column-node:hover {
    filter: brightness(1.05);
}

.curriculum-map__drawer-toggle {
    flex: 0 0 auto;
    position: relative;
    min-width: 46px;
    height: 24px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #225bd8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 820;
    line-height: 1;
    box-shadow: inset 0 -1px 0 rgba(50, 111, 240, 0.08), 0 4px 10px rgba(15, 36, 88, 0.16);
}

.curriculum-map__drawer-toggle::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    position: relative;
    top: -2px;
}

.curriculum-map__drawer-toggle:hover {
    background: #f8fbff;
    border-color: rgba(255, 255, 255, 0.92);
}

.curriculum-map__drawer-toggle--open {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.54);
    background: #225bd8;
}

.curriculum-map__drawer-toggle--open::before {
    transform: rotate(225deg);
    top: 2px;
}

.curriculum-map__drawer-toggle--open:hover {
    background: #1f50c0;
}

.curriculum-map__row {
    position: relative;
    align-items: stretch;
    grid-auto-rows: minmax(38px, auto);
    row-gap: 5px;
    margin-top: 8px;
}

.curriculum-map__row + .curriculum-map__row {
    margin-top: 12px;
}

.curriculum-map > .curriculum-map__row:first-child {
    margin-bottom: 14px;
}

.curriculum-map__row-tab {
    min-height: 58px;
    height: 100%;
    padding: 6px 8px;
    flex-direction: column;
    gap: 4px;
    line-height: 1.24;
}

.curriculum-map__row-tab strong,
.curriculum-map__row-tab span {
    display: block;
}

.curriculum-map__row-tab span {
    font-size: 12px;
    opacity: 0.94;
}

.curriculum-map__lane {
    position: relative;
    min-height: 38px;
    height: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.curriculum-map__lane--empty {
    min-height: 38px;
}

.curriculum-map__lane--center {
    justify-content: flex-start;
}

.curriculum-map__lane--equal-columns {
    display: grid;
    align-items: stretch;
}

.curriculum-map__lane--equal-columns .curriculum-map-node {
    width: 100%;
    min-width: 0;
}

.curriculum-map__lane--grouped {
    border: 2px dashed #b0bec5;
    border-radius: 6px;
    padding: 4px;
}

.curriculum-map__row--green .curriculum-map__row-tab {
    background: #4c8428;
}

.curriculum-map-node--with-children {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
    color: #ffffff;
}

.curriculum-map-node__label {
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
}

.curriculum-map-node > .curriculum-map-node__label {
    display: block;
    width: 100%;
    text-align: left;
    -webkit-text-align-last: left;
    text-align-last: left;
}

.curriculum-map-node > .curriculum-map-node__label.is-multiline {
    -webkit-text-align-last: center;
    text-align-last: center;
}

.curriculum-map-node > .curriculum-map-node__label--align-center {
    text-align: center;
    -webkit-text-align-last: center;
    text-align-last: center;
}

.curriculum-map-child-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.curriculum-map-child-node {
    display: block;
    width: 100%;
    min-height: 18px;
    padding: 2px 18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffe466;
    font-size: 12px;
    font-weight: 760;
    line-height: 1.35;
    text-align: left;
    -webkit-text-align-last: left;
    text-align-last: left;
    overflow-wrap: anywhere;
}

.curriculum-map-child-node.is-multiline {
    -webkit-text-align-last: center;
    text-align-last: center;
}

.curriculum-drawer {
    width: calc(100% - var(--menu-width) - var(--lane-gap));
    margin-left: calc(var(--menu-width) + var(--lane-gap));
}

.curriculum-drawer--inline {
    margin-top: -4px;
    margin-right: 0;
    margin-bottom: 6px;
    animation: curriculumDrawerDrop 180ms ease-out;
}

.curriculum-drawer__panel {
    width: 100%;
    max-height: min(560px, calc(100vh - 150px));
    overflow: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.curriculum-drawer__body {
    padding: 0;
}

.curriculum-map--drawer {
    --menu-width: 0px;
    min-width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

/* ============================================================
   修复：大学课标抽屉中卡片高度由内容决定，6.1 向 6.2 看齐
   ============================================================ */
.curriculum-map--drawer .curriculum-map__lane {
    display: grid;
    grid-template-rows: auto;        /* 由内容决定高度，不再固定拉伸 */
    grid-auto-rows: auto;
    align-items: start;              /* 顶部对齐，高度由内容撑开 */
    gap: 5px;
}

.curriculum-map--drawer .curriculum-map-node {
    height: auto;                    /* 高度由内容决定 */
    min-height: 38px;               /* 最小高度与普通卡片一致 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 10px;
}

/* 有子节点的卡片：内容垂直分布，但高度由内容撑开 */
.curriculum-map--drawer .curriculum-map-node--with-children {
    justify-content: flex-start;
    padding-top: 6px;
    height: auto;
}

.curriculum-map--drawer .curriculum-map-node--with-children .curriculum-map-child-list {
    flex: 0;                        /* 不拉伸，按内容高度 */
}

/* 没有子节点的卡片：文本居中 */
.curriculum-map--drawer .curriculum-map-node:not(.curriculum-map-node--with-children) .curriculum-map-node__label {
    text-align: center;
    -webkit-text-align-last: center;
    text-align-last: center;
}

/* 让有子节点的卡片内的 label 保持左对齐 */
.curriculum-map--drawer .curriculum-map-node--with-children .curriculum-map-node__label {
    text-align: left;
    -webkit-text-align-last: left;
    text-align-last: left;
}

.curriculum-map__row--no-label {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

@keyframes curriculumDrawerDrop {
    from {
        transform: translateY(-14px);
        opacity: 0.85;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 860px) {
    .prototype-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .prototype-legend {
        flex-wrap: wrap;
        white-space: normal;
    }

    .flow-viewport {
        padding: 18px;
    }

    .child-modal {
        padding: 18px;
    }

    .child-modal__grid {
        grid-template-columns: 1fr;
    }

    .curriculum-map {
        --menu-width: 132px;
        --lane-gap: 16px;
        padding: 18px;
    }

    .curriculum-drawer__body {
        padding: 14px;
    }
}