.algorithm-trace-widget {
    margin: 1.5rem 0;
    padding: 1.25rem;
    border-radius: 24px;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border: 1px solid #dbeafe;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

.at-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.at-case-btn,
.at-controls button {
    border: none;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.at-case-btn:hover,
.at-controls button:hover {
    transform: translateY(-1px);
    background: #0f172a;
    color: white;
}

.at-case-btn.active {
    background: #5b5fa8;
    color: white;
}

.at-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    gap: 1rem;
}

.at-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.at-card-label {
    display: inline-block;
    margin-bottom: 0.7rem;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.at-code-list {
    margin: 0;
    padding-left: 1.4rem;
}

.at-code-list li {
    margin: 0.45rem 0;
    padding: 0.55rem 0.7rem;
    border-radius: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    background: #f8fafc;
    border: 1px solid transparent;
}

.at-code-list li.active {
    background: #fff7ed;
    border-color: #fdba74;
    color: #7c2d12;
    box-shadow: 0 8px 22px rgba(251, 146, 60, 0.16);
}

.at-construct {
    display: inline-block;
    min-width: 6.4rem;
    margin-right: 0.45rem;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    text-align: center;
}

.at-construct.assignment {
    background: #dbeafe;
    color: #1e3a8a;
}

.at-construct.selection {
    background: #fef3c7;
    color: #92400e;
}

.at-construct.sequence {
    background: #dcfce7;
    color: #166534;
}

.at-trace-table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 14px;
}

.at-trace-table th,
.at-trace-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.at-trace-table th {
    background: #f1f5f9;
    color: #334155;
}

.at-trace-table td:first-child {
    font-weight: 800;
    color: #475569;
}

.at-flow {
    margin: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.at-flow-node {
    padding: 0.65rem 1rem;
    border-radius: 16px;
    background: white;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-weight: 800;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.at-flow-node.active {
    background: #5b5fa8;
    color: white;
    border-color: #5b5fa8;
}

.at-flow-arrow {
    color: #64748b;
    font-weight: 900;
}

.at-step-box {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 1rem 1.15rem;
}

.at-step-count {
    margin: 0;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
}

.at-step-box h3 {
    margin-top: 0.25rem;
}

.at-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.8rem;
}

@media (max-width: 760px) {
    .at-grid {
        grid-template-columns: 1fr;
    }

    .at-construct {
        min-width: auto;
    }
}
