.frontier-multimodal {
    --frontier-algo-blue: #2563eb;
    --frontier-algo-cyan: #0891b2;
    --frontier-algo-violet: #6d28d9;
}

.frontier-multimodal .multimodal-pipeline,
.frontier-multimodal .multimodal-stepper {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.multimodal-modality-toggles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mm-stage-layout {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: row dense;
    align-items: start;
    gap: 10px;
}

.mm-stage-layout .frontier-stage-card {
    transition: border-color 0.32s var(--frontier-algo-motion), box-shadow 0.32s var(--frontier-algo-motion), transform 0.32s var(--frontier-algo-motion);
}

.mm-stage-layout[data-step="inputs"] .mm-input-panel,
.mm-stage-layout[data-step="encoders"] .mm-encoder-panel,
.mm-stage-layout[data-step="alignment"] .mm-alignment-panel,
.mm-stage-layout[data-step="fusion"] .mm-fusion-panel,
.mm-stage-layout[data-step="task"] .mm-task-panel,
.mm-stage-layout[data-step="evaluation"] .mm-eval-panel {
    border-color: #67e8f9;
    box-shadow: 0 16px 34px rgba(8, 145, 178, 0.12);
    transform: translateY(-2px);
}

.mm-architecture-panel {
    grid-column: 1 / -1;
    grid-row: 1;
}

.mm-input-panel {
    grid-column: 1 / span 5;
    grid-row: 2 / span 2;
}

.mm-encoder-panel {
    grid-column: 6 / span 7;
    grid-row: 2;
}

.mm-alignment-panel {
    grid-column: 6 / span 7;
    grid-row: 3;
}

.mm-fusion-panel {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 4;
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
    align-items: start;
}

.mm-fusion-panel .frontier-section-headline {
    grid-column: 1 / -1;
}

.mm-task-panel {
    grid-column: 1 / span 7;
    grid-row: 5;
}

.mm-eval-panel {
    grid-column: 8 / span 5;
    grid-row: 5;
}

.mm-input-grid {
    display: grid;
    gap: 6px;
    padding: 8px;
}

.mm-modality-card {
    position: relative;
    display: grid;
    gap: 4px;
    min-height: 58px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--mm-color) 42%, #dbeafe);
    border-radius: 14px;
    padding: 8px 8px 8px 52px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    animation: mmCardIn 0.48s var(--frontier-algo-motion) both;
    animation-delay: var(--mm-delay, 0ms);
}

.mm-modality-card::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 14px;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: var(--mm-color);
    box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.25);
}

.mm-modality-card span {
    color: var(--mm-color);
    font-size: 10px;
    font-weight: 950;
    text-transform: uppercase;
}

.mm-modality-card strong {
    color: #172554;
    font-size: 13px;
    font-weight: 950;
}

.mm-modality-card small {
    color: #64748b;
    font-size: 10px;
    font-weight: 850;
}

.mm-encoder-lane {
    display: grid;
    gap: 6px;
    padding: 8px;
}

.mm-encoder-lane article {
    display: grid;
    grid-template-columns: 112px 56px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 8px;
    background: #ffffff;
    animation: mmCardIn 0.46s var(--frontier-algo-motion) both;
    animation-delay: var(--mm-delay, 0ms);
}

.mm-encoder-lane span,
.mm-encoder-lane strong {
    color: #172554;
    font-size: 11px;
    font-weight: 950;
}

.mm-encoder-lane strong {
    color: var(--mm-color);
}

.mm-encoder-lane i {
    display: block;
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #dbeafe;
}

.mm-encoder-lane b {
    display: block;
    width: 74%;
    height: 100%;
    border-radius: inherit;
    background: var(--mm-color);
    animation: mmBarGrow 0.7s var(--frontier-algo-motion) both;
}

.mm-alignment-space {
    position: relative;
    min-height: 184px;
    margin: 8px;
    overflow: hidden;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background:
        radial-gradient(circle at 50% 48%, rgba(37, 99, 235, 0.12), transparent 30%),
        linear-gradient(90deg, rgba(219, 234, 254, 0.7) 1px, transparent 1px),
        linear-gradient(180deg, rgba(219, 234, 254, 0.7) 1px, transparent 1px),
        #f8fbff;
    background-size: auto, 32px 32px, 32px 32px;
}

.mm-alignment-space span {
    position: absolute;
    left: var(--x);
    top: var(--y);
    border: 1px solid color-mix(in srgb, var(--mm-color) 55%, #dbeafe);
    border-radius: 999px;
    padding: 5px 9px;
    color: #172554;
    background: #ffffff;
    font-size: 11px;
    font-weight: 950;
    transform: translate(-50%, -50%);
    animation: mmAlignMove 0.75s var(--frontier-algo-motion) both;
    animation-delay: var(--mm-delay, 0ms);
}

.mm-alignment-space strong {
    position: absolute;
    left: 50%;
    top: 50%;
    display: grid;
    width: 112px;
    height: 112px;
    place-items: center;
    border: 1px dashed #67e8f9;
    border-radius: 50%;
    color: #0e7490;
    background: rgba(236, 254, 255, 0.72);
    font-size: 12px;
    line-height: 1.25;
    text-align: center;
    transform: translate(-50%, -50%);
}

.mm-fusion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
}

.mm-fusion-grid article {
    display: grid;
    gap: 5px;
    min-height: 104px;
    border: 1px solid #dbeafe;
    border-radius: 13px;
    padding: 8px;
    background: #ffffff;
    animation: mmCardIn 0.46s var(--frontier-algo-motion) both;
    animation-delay: var(--mm-delay, 0ms);
}

.mm-fusion-grid article.is-active {
    border-color: #7c3aed;
    background: #f5f3ff;
}

.mm-fusion-grid span {
    color: #172554;
    font-size: 12px;
    font-weight: 950;
}

.mm-fusion-grid strong,
.mm-fusion-grid small {
    color: #64748b;
    font-size: 10px;
    line-height: 1.35;
    font-weight: 850;
}

.mm-mini-flow {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    align-items: center;
}

.mm-mini-flow i,
.mm-mini-flow b {
    display: block;
    height: 18px;
    border-radius: 8px;
    background: #dbeafe;
}

.mm-mini-flow b {
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    animation: mmBarGrow 0.7s var(--frontier-algo-motion) both;
}

.mm-fusion-matrix {
    display: grid;
    grid-template-columns: repeat(var(--mm-cols), minmax(42px, 1fr));
    gap: 4px;
    padding: 8px;
    align-self: start;
}

.mm-fusion-matrix strong,
.mm-fusion-matrix i {
    display: grid;
    min-height: 28px;
    place-items: center;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 950;
}

.mm-fusion-matrix strong {
    color: #475569;
    background: #f8fafc;
}

.mm-fusion-matrix i {
    color: #172554;
    background:
        linear-gradient(180deg, rgba(124, 58, 237, 0.18), rgba(8, 145, 178, 0.13)) left bottom / var(--score) 100% no-repeat,
        #ffffff;
    border: 1px solid #dbeafe;
    font-style: normal;
    animation: mmCardIn 0.38s var(--frontier-algo-motion) both;
    animation-delay: var(--mm-delay, 0ms);
}

.mm-task-output {
    display: grid;
    gap: 8px;
    margin: 8px;
    border: 1px solid #dbeafe;
    border-radius: 15px;
    padding: 10px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.mm-task-output span {
    color: #0891b2;
    font-size: 10px;
    font-weight: 950;
    text-transform: uppercase;
}

.mm-task-output strong {
    color: #172554;
    font-size: 15px;
    line-height: 1.45;
    font-weight: 950;
}

.mm-task-output small {
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
}

.mm-output-visual {
    position: relative;
    min-height: 66px;
    border: 1px dashed #93c5fd;
    border-radius: 14px;
    background: #eff6ff;
}

.mm-output-visual i {
    position: absolute;
    display: block;
    width: 30%;
    height: 16px;
    border-radius: 999px;
    background: #2563eb;
    animation: mmOutputPulse 0.86s var(--frontier-algo-motion) infinite;
}

.mm-output-visual i:nth-child(1) { left: 14%; top: 22%; }
.mm-output-visual i:nth-child(2) { left: 48%; top: 42%; background: #10b981; }
.mm-output-visual i:nth-child(3) { left: 25%; top: 65%; background: #7c3aed; }
.mm-output-visual b {
    position: absolute;
    right: 14%;
    top: 20%;
    width: 25%;
    height: 45%;
    border: 2px solid #f59e0b;
    border-radius: 10px;
}

.mm-metric-chips,
.multimodal-concept-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
}

.mm-metric-chips span,
.multimodal-concept-chips i {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    padding: 0 9px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 10px;
    font-style: normal;
    font-weight: 950;
    animation: mmCardIn 0.4s var(--frontier-algo-motion) both;
    animation-delay: var(--mm-delay, 0ms);
}

.mm-metric-chips span.is-active {
    border-color: #10b981;
    color: #047857;
    background: #ecfdf5;
}

@keyframes mmCardIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes mmBarGrow {
    from { width: 0; }
    to { width: 74%; }
}

@keyframes mmAlignMove {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.78); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes mmOutputPulse {
    0%, 100% { opacity: 0.55; transform: scaleX(0.92); }
    50% { opacity: 1; transform: scaleX(1); }
}

@media (max-width: 1120px) {
    .mm-stage-layout {
        grid-template-columns: 1fr;
    }

    .mm-fusion-panel {
        grid-template-columns: 1fr;
    }

    .mm-fusion-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mm-architecture-panel,
    .mm-input-panel,
    .mm-encoder-panel,
    .mm-alignment-panel,
    .mm-fusion-panel,
    .mm-task-panel,
    .mm-eval-panel {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

@media (max-width: 720px) {
    .frontier-multimodal .multimodal-pipeline,
    .frontier-multimodal .multimodal-stepper,
    .mm-fusion-grid,
    .multimodal-modality-toggles {
        grid-template-columns: 1fr;
    }

    .mm-encoder-lane article {
        grid-template-columns: 1fr;
    }
}
