/* =================================================================
   tools/stl-sequence.css
   Auto-extracted from math.css (2026-05-11).
   Loaded via config/js-manifest.php → templates/partials/head-styles.php.
   ================================================================= */

/* ============================================================
 * STL Sequence — redesign (vector / list / deque)
 * Scope: .math-ds-seq-panel only (does not affect other DS tools)
 * ============================================================ */

.math-ds-seq-panel {
    --seq-grad-a: #818cf8;
    --seq-grad-b: #4f46e5;
    --seq-grad-found-a: #34d399;
    --seq-grad-found-b: #059669;
    --seq-grad-hl-a: #fbbf24;
    --seq-grad-hl-b: #d97706;
    --seq-cell-w: 64px;
    --seq-cell-h: 72px;
    --seq-cell-gap: 6px;
    --seq-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
}
.math-ds-seq-panel.is-busy .math-ds-seq-actions,
.math-ds-seq-panel.is-busy #seqRandomBtn {
    pointer-events: none;
    opacity: 0.6;
}

/* Container type segmented control — two-line buttons */
.math-ds-seq-type-segment .math-mode-segment-btn {
    flex-direction: column;
    padding: 8px 12px;
    line-height: 1.25;
    min-height: 48px;
}
.math-ds-seq-type-segment .seq-seg-title {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.01em;
}
.math-ds-seq-type-segment .seq-seg-sub {
    font-size: 10.5px;
    opacity: 0.72;
    margin-top: 2px;
    font-weight: 500;
}
.math-ds-seq-type-segment .math-mode-segment-btn.active .seq-seg-sub { opacity: 0.92; }

/* Info card — "what is this container" explainer */
.math-ds-seq-info-wrap { position: relative; margin: 10px 0 14px; }
.math-ds-seq-info {
    display: none;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 14px 20px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
    border: 1px solid var(--math-border-light);
    border-radius: var(--math-radius-md);
    animation: seq-fade-in 0.4s ease both;
}
.math-ds-seq-info.active { display: grid; }
.math-ds-seq-info .seq-info-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 14px;
}
.math-ds-seq-info .seq-info-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    color: #fff;
    font-size: 18px;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
    flex-shrink: 0;
}
.math-ds-seq-info .seq-info-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--math-text);
}
.math-ds-seq-info .seq-info-sub {
    font-size: 12.5px;
    color: var(--math-text-soft);
    line-height: 1.55;
    margin-top: 2px;
}
.math-ds-seq-info .seq-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--math-text-soft);
    line-height: 1.5;
}
.math-ds-seq-info .seq-info-list li { padding-left: 2px; }
.math-ds-seq-info .seq-info-memory {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    align-items: center;
    background: var(--math-surface);
    border: 1px dashed var(--math-border);
    border-radius: var(--math-radius-sm);
    padding: 10px 12px;
    min-height: 80px;
}
.math-ds-seq-info .mem-legend {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    color: var(--math-text-muted);
    letter-spacing: 0.02em;
    text-transform: lowercase;
}
.math-ds-seq-info .mem-strip { display: flex; align-items: center; gap: 4px; }
.math-ds-seq-info .mem-strip-contig { gap: 0; }
.math-ds-seq-info .mem-strip-contig .mem-slot {
    width: 22px;
    height: 22px;
    border: 1px solid var(--math-border);
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    margin-right: -1px;
}
.math-ds-seq-info .mem-strip-contig .mem-slot:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.math-ds-seq-info .mem-strip-contig .mem-slot:last-child  { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.math-ds-seq-info .mem-strip-contig .mem-slot.mem-slot-empty {
    background: var(--math-surface-alt);
    border-style: dashed;
    border-color: var(--math-border);
}
.math-ds-seq-info .mem-strip-frag { gap: 4px; }
.math-ds-seq-info .mem-strip-frag .mem-node {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
}
.math-ds-seq-info .mem-strip-frag .mem-arrow { color: var(--math-text-muted); font-size: 14px; }
.math-ds-seq-info .mem-strip-chunks { gap: 10px; }
.math-ds-seq-info .mem-strip-chunks .mem-chunk {
    display: flex;
    padding: 3px;
    border: 1px dashed var(--math-border);
    border-radius: 6px;
    gap: 0;
}
.math-ds-seq-info .mem-strip-chunks .mem-slot {
    width: 18px;
    height: 20px;
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    margin-right: -1px;
}
.math-ds-seq-info .mem-strip-chunks .mem-slot:first-child { border-top-left-radius: 3px; border-bottom-left-radius: 3px; }
.math-ds-seq-info .mem-strip-chunks .mem-slot:last-child  { border-top-right-radius: 3px; border-bottom-right-radius: 3px; }

/* Stats chip bar */
.math-ds-seq-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 30px;
}
.math-ds-seq-stats:empty { display: none; }
.math-ds-seq-stats .seq-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--math-surface-alt);
    border: 1px solid var(--math-border-light);
    border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--math-text-soft);
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.math-ds-seq-stats .seq-chip .chip-k { color: var(--math-text-muted); font-weight: 500; }
.math-ds-seq-stats .seq-chip .chip-v { color: var(--math-text); font-weight: 600; }
.math-ds-seq-stats .seq-chip.seq-chip-accent {
    background: var(--math-primary-soft);
    border-color: transparent;
}
.math-ds-seq-stats .seq-chip.seq-chip-accent .chip-v { color: var(--math-primary); }

/* Action buttons (stl-sequence specific — primary gets gradient treatment) */
.math-ds-seq-actions { row-gap: 10px; }
.math-ds-seq-actions .math-btn-primary {
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    border: none;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
    transition: transform 0.18s ease, box-shadow 0.25s ease;
}
.math-ds-seq-actions .math-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.36);
}
.math-ds-seq-actions .math-btn .math-ds-bigo-chip {
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
}
.math-ds-seq-actions .math-btn-primary .math-ds-bigo-chip {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Random progress chip */
.math-ds-seq-progress {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--math-primary-soft);
    border-radius: var(--math-radius-sm);
    animation: seq-fade-in 0.25s ease both;
}
.math-ds-seq-progress[hidden] { display: none !important; }
.math-ds-seq-progress .seq-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--math-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    margin-bottom: 6px;
}
.math-ds-seq-progress .seq-progress-label { font-weight: 600; }
.math-ds-seq-progress .seq-progress-counter { font-weight: 700; }
.math-ds-seq-progress .seq-progress-track {
    height: 4px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 2px;
    overflow: hidden;
}
.math-ds-seq-progress .seq-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--seq-grad-a), var(--seq-grad-b));
    border-radius: 2px;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Viz container */
.math-ds-seq-viz {
    min-height: 180px;
    padding: 16px 8px 24px;
    position: relative;
}

/* Array-style viz (vector / deque) */
.math-ds-seq-array-scroll {
    overflow-x: auto;
    /* Keep extra headroom above cells so the carrier pill (.math-ds-carrier)
       has space to fly in without being clipped by the scroll container.
       NB: per CSS spec, overflow-x:auto forces overflow-y to behave like
       auto, so we cannot rely on overflow-y:visible. */
    padding-top: 44px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.math-ds-seq-array {
    display: flex;
    align-items: flex-start;
    gap: var(--seq-cell-gap);
    padding: 12px 4px 28px;
    position: relative;
    min-height: calc(var(--seq-cell-h) + 40px);
}
.math-ds-seq-cell {
    position: relative;
    min-width: var(--seq-cell-w);
    width: var(--seq-cell-w);
    height: var(--seq-cell-h);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    color: #fff;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    flex-shrink: 0;
    transition: transform var(--ds-speed) var(--seq-ease), box-shadow var(--ds-speed) ease, background var(--ds-speed) ease;
    will-change: transform;
}
.math-ds-seq-cell .seq-addr {
    font-size: 9px;
    opacity: 0.72;
    text-align: center;
    letter-spacing: 0.04em;
    line-height: 1;
    padding: 1px 4px;
}
.math-ds-seq-cell .seq-val {
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    padding: 0 6px;
    line-height: 1.1;
    word-break: break-all;
}
.math-ds-seq-cell .seq-idx {
    font-size: 10px;
    opacity: 0.82;
    text-align: center;
    letter-spacing: 0.02em;
    line-height: 1;
}
.math-ds-seq-cell.seq-highlight {
    background: linear-gradient(135deg, var(--seq-grad-hl-a), var(--seq-grad-hl-b));
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.35), 0 4px 14px rgba(217, 119, 6, 0.34);
}
.math-ds-seq-cell.seq-found {
    background: linear-gradient(135deg, var(--seq-grad-found-a), var(--seq-grad-found-b));
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.35), 0 4px 14px rgba(5, 150, 105, 0.34);
    animation: seq-found-pulse 0.9s ease;
}
.math-ds-seq-cell.seq-landing { animation: seq-slide-in var(--ds-speed) var(--seq-ease) both; }
.math-ds-seq-cell.seq-leaving {
    pointer-events: none;
    animation: seq-fade-out var(--ds-speed) ease both;
}
.math-ds-seq-cell:not(.seq-landing):not(.seq-leaving):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* Cell marker (↑ pointer) */
.math-ds-seq-cell .seq-pointer {
    position: absolute;
    left: 50%;
    bottom: -22px;
    transform: translateX(-50%);
    color: var(--math-warning);
    font-size: 14px;
    font-weight: 700;
    animation: seq-pointer-bounce 1.2s ease-in-out infinite;
    pointer-events: none;
}
.math-ds-seq-cell.seq-found .seq-pointer { color: var(--math-success); }

/* Index ruler */
.math-ds-seq-ruler {
    display: flex;
    gap: var(--seq-cell-gap);
    padding-left: 4px;
    margin-top: -16px;
}
.math-ds-seq-ruler .tick {
    width: var(--seq-cell-w);
    min-width: var(--seq-cell-w);
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    color: var(--math-text-muted);
    letter-spacing: 0.04em;
}
.math-ds-seq-ruler .tick.on { color: var(--math-primary); font-weight: 700; }

/* Linked list viz */
.math-ds-seq-linked-scroll {
    overflow-x: auto;
    padding: 8px 4px 16px;
}
.math-ds-seq-linked {
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 88px;
    flex-wrap: nowrap;
}
.math-ds-seq-sentinel {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--math-text-muted);
    padding: 0 10px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.math-ds-seq-node {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    height: 48px;
    padding: 0 14px;
    background: linear-gradient(135deg, var(--seq-grad-a), var(--seq-grad-b));
    color: #fff;
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform var(--ds-speed) var(--seq-ease), box-shadow var(--ds-speed) ease, background var(--ds-speed) ease;
    flex-shrink: 0;
}
.math-ds-seq-node::before,
.math-ds-seq-node::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    transform: translateY(-50%);
}
.math-ds-seq-node::before { left: -4px; }
.math-ds-seq-node::after  { right: -4px; }
.math-ds-seq-node.seq-highlight {
    background: linear-gradient(135deg, var(--seq-grad-hl-a), var(--seq-grad-hl-b));
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.35), 0 4px 14px rgba(217, 119, 6, 0.34);
}
.math-ds-seq-node.seq-found {
    background: linear-gradient(135deg, var(--seq-grad-found-a), var(--seq-grad-found-b));
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.35), 0 4px 14px rgba(5, 150, 105, 0.34);
    animation: seq-found-pulse 0.9s ease;
}
.math-ds-seq-node.seq-landing { animation: seq-slide-in var(--ds-speed) var(--seq-ease) both; }
.math-ds-seq-node.seq-leaving { animation: seq-fade-out var(--ds-speed) ease both; }
.math-ds-seq-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 20px;
    margin: 0 2px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--math-text-muted);
    font-size: 16px;
    position: relative;
    flex-shrink: 0;
}
.math-ds-seq-link::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 2px;
    right: 2px;
    height: 2px;
    background: linear-gradient(90deg, rgba(129, 140, 248, 0.4), rgba(129, 140, 248, 0.4));
    transform: translateY(-50%);
    border-radius: 1px;
}
.math-ds-seq-link span {
    position: relative;
    background: var(--math-surface);
    padding: 0 2px;
    line-height: 1;
}

/* Placeholder inside viz */
.math-ds-seq-empty {
    padding: 28px 20px;
    text-align: center;
    color: var(--math-text-muted);
    background: var(--math-surface-alt);
    border: 1px dashed var(--math-border);
    border-radius: var(--math-radius-sm);
    font-size: 13px;
    line-height: 1.6;
}
.math-ds-seq-empty strong { color: var(--math-text-soft); font-weight: 600; }

/* LastOp tuning inside seq panel */
.math-ds-seq-panel .math-ds-lastop {
    background: var(--math-surface-alt);
    border: 1px solid var(--math-border-light);
    box-shadow: var(--math-shadow-xs);
}
.math-ds-seq-panel .math-ds-lastop .op {
    color: var(--math-primary);
    font-weight: 700;
}
.math-ds-seq-panel .math-ds-lastop .args {
    color: var(--math-text);
}
.math-ds-seq-panel .math-ds-lastop .note {
    color: var(--math-text-soft);
    margin-left: 10px;
    padding-left: 10px;
    border-left: 2px solid var(--math-border);
}

/* Keyframes */
@keyframes seq-fade-in {
    0%   { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes seq-slide-in {
    0%   { opacity: 0; transform: translateY(-18px) scale(0.6); }
    60%  { opacity: 1; transform: translateY(3px) scale(1.05); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes seq-fade-out {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.55) translateY(8px); }
}
@keyframes seq-found-pulse {
    0%   { filter: brightness(1); }
    40%  { filter: brightness(1.18); }
    100% { filter: brightness(1); }
}
@keyframes seq-pointer-bounce {
    0%, 100% { transform: translate(-50%, 0); opacity: 0.85; }
    50%      { transform: translate(-50%, -4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .math-ds-seq-cell, .math-ds-seq-node { transition: none !important; }
    .math-ds-seq-cell.seq-landing,
    .math-ds-seq-cell.seq-leaving,
    .math-ds-seq-cell.seq-found,
    .math-ds-seq-node.seq-landing,
    .math-ds-seq-node.seq-leaving,
    .math-ds-seq-node.seq-found { animation: none !important; }
    .math-ds-seq-cell .seq-pointer { animation: none !important; }
    .math-ds-seq-progress .seq-progress-fill { transition: none !important; }
}

/* Mobile */
@media (max-width: 640px) {
    .math-ds-seq-panel {
        --seq-cell-w: 54px;
        --seq-cell-h: 64px;
        --seq-cell-gap: 5px;
    }
    .math-ds-seq-type-segment .math-mode-segment-btn { padding: 6px 8px; min-height: 44px; }
    .math-ds-seq-type-segment .seq-seg-title { font-size: 13px; }
    .math-ds-seq-type-segment .seq-seg-sub { font-size: 9.5px; }
    .math-ds-seq-info { grid-template-columns: 1fr; padding: 12px; }
    .math-ds-seq-info .seq-info-head { gap: 10px; }
    .math-ds-seq-info .seq-info-icon { width: 38px; height: 38px; font-size: 16px; border-radius: 10px; }
    .math-ds-seq-info .seq-info-title { font-size: 14px; }
    .math-ds-seq-info .seq-info-sub { font-size: 12px; }
    .math-ds-seq-info .seq-info-list { font-size: 12.5px; }
    .math-ds-seq-info .seq-info-memory { padding: 8px 10px; min-height: 62px; }
    .math-ds-seq-stats { gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
    .math-ds-seq-stats .seq-chip { font-size: 11px; padding: 3px 8px; white-space: nowrap; flex-shrink: 0; }
    .math-ds-seq-array-scroll { scroll-snap-type: x mandatory; }
    .math-ds-seq-cell { scroll-snap-align: start; }
    .math-ds-seq-cell .seq-val { font-size: 14px; }
    .math-ds-seq-cell .seq-addr { font-size: 8.5px; }
    .math-ds-seq-cell .seq-idx { font-size: 9.5px; }
    .math-ds-seq-ruler .tick { font-size: 9.5px; }
    .math-ds-seq-ruler .tick.off-mobile { visibility: hidden; }
    .math-ds-seq-node { min-width: 54px; height: 44px; font-size: 13px; padding: 0 12px; }
    .math-ds-seq-sentinel { font-size: 10px; padding: 0 6px; }
    .math-ds-seq-actions .math-btn { min-height: 42px; }
    .math-ds-seq-progress .seq-progress-head { font-size: 11px; }
}

/* ──────────────────────────────────────────────────────────
 * STL Sequence — educational redesign (block headers, narrator,
 * capacity bar, deque chunks, list-v2 nodes with prev/next ports,
 * realloc badge). Scoped to .math-ds-seq-panel only.
 * ────────────────────────────────────────────────────────── */

.math-ds-seq-block {
    position: relative;
    padding: 12px 14px 14px;
    background: linear-gradient(180deg, var(--math-bg-soft, rgba(0,0,0,0.02)) 0%, transparent 70%);
    border: 1px solid var(--math-border-subtle, rgba(0,0,0,0.06));
    border-radius: 12px;
    margin-top: 6px;
}
.math-ds-seq-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 11px;
    color: var(--math-text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.math-ds-seq-block-head .seq-block-addr {
    color: var(--math-primary);
    font-weight: 700;
    font-size: 11.5px;
    background: rgba(102, 126, 234, 0.1);
    padding: 3px 8px;
    border-radius: 6px;
}
.math-ds-seq-block-head .seq-block-label {
    color: var(--math-text-soft, var(--math-text));
    font-style: italic;
    text-transform: none;
    letter-spacing: 0;
}

/* Realloc badge */
.math-ds-seq-realloc-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    border-radius: 999px;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.35);
    animation: seq-realloc-flash 1.6s ease-out;
}
.math-ds-seq-realloc-badge i { font-size: 11px; }
@keyframes seq-realloc-flash {
    0% { transform: scale(0.6); opacity: 0; }
    20% { transform: scale(1.08); opacity: 1; }
    40% { transform: scale(1); }
    100% { transform: scale(1); opacity: 1; }
}
/* Subtle frame for the array scroll while a realloc just happened —
   no shake (it fights with FLIP), just a soft outer ring + faint backdrop. */
.math-ds-seq-array-scroll.is-realloc {
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35) inset;
    border-radius: 10px;
    transition: box-shadow 600ms ease-out;
}

/* Reserved/empty capacity slots (vector + last deque chunk) */
.math-ds-seq-cell.seq-reserved {
    background: repeating-linear-gradient(
        45deg,
        var(--math-bg-soft, rgba(0,0,0,0.025)) 0,
        var(--math-bg-soft, rgba(0,0,0,0.025)) 6px,
        transparent 6px,
        transparent 12px
    );
    border: 1.5px dashed var(--math-border, rgba(0,0,0,0.18));
    box-shadow: none;
    color: var(--math-text-muted);
    opacity: 0.7;
}
.math-ds-seq-cell.seq-reserved .seq-val-empty {
    color: var(--math-text-muted);
    font-size: 18px;
    opacity: 0.5;
    font-weight: 400;
}
.math-ds-seq-cell.seq-reserved:hover { transform: none; box-shadow: none; }
.math-ds-seq-cell.seq-reserved-more { min-width: 40px; }
.math-ds-seq-cell.seq-reserved-more .seq-val-empty { font-size: 12px; font-weight: 600; opacity: 0.7; }

/* Capacity usage bar */
.math-ds-seq-capbar {
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    height: 22px;
    background: var(--math-bg-soft, rgba(0,0,0,0.04));
    border-radius: 11px;
    overflow: hidden;
    border: 1px solid var(--math-border-subtle, rgba(0,0,0,0.06));
}
.math-ds-seq-capbar .capbar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, var(--seq-grad-a, var(--math-primary)) 0%, var(--seq-grad-b, var(--math-primary-dark, var(--math-primary))) 100%);
    border-radius: 11px;
    transition: width var(--ds-speed, 0.6s) var(--seq-ease, cubic-bezier(0.4, 0, 0.2, 1));
}
.math-ds-seq-capbar .capbar-label {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--math-text);
    font-family: ui-monospace, "SF Mono", monospace;
    mix-blend-mode: plus-lighter;
}
@media (prefers-color-scheme: dark) {
    .math-ds-seq-capbar .capbar-label { mix-blend-mode: normal; }
}

/* Deque chunks */
.math-ds-seq-chunks-scroll {
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-width: thin;
}
.math-ds-seq-chunks {
    display: flex;
    align-items: stretch;
    gap: 10px;
}
.math-ds-seq-chunk {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px 10px;
    background: var(--math-bg-soft, rgba(0,0,0,0.025));
    border: 1px solid var(--math-border-subtle, rgba(0,0,0,0.08));
    border-radius: 10px;
}
.math-ds-seq-chunk .seq-chunk-head {
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 10.5px;
    color: var(--math-primary);
    font-weight: 700;
    letter-spacing: 0.04em;
}
.math-ds-seq-chunk .seq-chunk-slots {
    display: flex;
    gap: var(--seq-cell-gap, 4px);
}
.math-ds-seq-chunk-leaving { background: transparent; border: none; padding: 8px 0; }
.seq-chunk-gap {
    align-self: center;
    color: var(--math-text-muted);
    font-size: 18px;
    opacity: 0.6;
    padding: 0 4px;
}

/* List V2 — node with addr, prev/next ports, idx label */
.math-ds-seq-linked-v2 {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 6px 2px 14px;
    flex-wrap: nowrap;
}
.seq-sentinel-box {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    color: var(--math-text-muted);
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 11px;
}
.seq-sentinel-box .sent-label { font-weight: 700; }
.seq-sentinel-box .sent-arrow { font-size: 14px; color: var(--math-primary); }
.math-ds-seq-lnode {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 96px;
    background: linear-gradient(135deg, var(--seq-grad-a, var(--math-primary)) 0%, var(--seq-grad-b, var(--math-primary-dark, var(--math-primary))) 100%);
    color: #fff;
    border-radius: 10px;
    padding: 6px 8px 5px;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.22);
    transition: transform var(--ds-speed, 0.6s) var(--seq-ease, cubic-bezier(0.4, 0, 0.2, 1)), box-shadow 200ms ease;
}
.math-ds-seq-lnode .lnode-addr {
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 10px;
    opacity: 0.78;
    text-align: center;
    letter-spacing: 0.04em;
}
.math-ds-seq-lnode .lnode-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 2px;
}
.math-ds-seq-lnode .lnode-port {
    width: 18px;
    height: 22px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    flex-shrink: 0;
}
.math-ds-seq-lnode .lnode-val {
    font-weight: 700;
    font-size: 16px;
    flex: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.math-ds-seq-lnode .lnode-idx {
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 9.5px;
    text-align: center;
    opacity: 0.85;
}
.math-ds-seq-lnode.seq-found {
    background: linear-gradient(135deg, var(--seq-grad-found-a, #16a34a) 0%, var(--seq-grad-found-b, #15803d) 100%);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.22), 0 6px 20px rgba(22, 163, 74, 0.32);
    animation: seq-found-pulse 1.4s var(--seq-ease, ease) infinite;
}
.math-ds-seq-lnode.seq-highlight {
    background: linear-gradient(135deg, var(--seq-grad-hl-a, #f59e0b) 0%, var(--seq-grad-hl-b, #d97706) 100%);
}
.math-ds-seq-lnode.seq-landing { animation: seq-slide-in var(--ds-speed, 0.6s) var(--seq-ease, ease) both; }
.math-ds-seq-lnode.seq-leaving {
    animation: seq-fade-out var(--ds-speed, 0.6s) var(--seq-ease, ease) forwards;
    pointer-events: none;
}

/* Link arrow between list nodes */
.seq-lnode-link {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    color: var(--math-text-muted);
    font-family: ui-monospace, "SF Mono", monospace;
    flex-shrink: 0;
}
.seq-lnode-link .link-lbl {
    font-size: 8.5px;
    opacity: 0.7;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.seq-lnode-link .link-lbl-prev { color: var(--math-text-muted); }
.seq-lnode-link .link-lbl-next { color: var(--math-primary); font-weight: 700; }
.seq-lnode-link .link-arrow {
    font-size: 16px;
    color: var(--math-primary);
    margin: 1px 0;
}

/* Narrator panel */
.math-ds-seq-narrator {
    margin-top: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06) 0%, rgba(102, 126, 234, 0.02) 100%);
    border: 1px solid rgba(102, 126, 234, 0.18);
    border-left: 3px solid var(--math-primary);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--math-text);
}
.math-ds-seq-narrator:empty { display: none; }
.math-ds-seq-narrator .seq-narr-title {
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--math-primary);
    margin-bottom: 6px;
    word-break: break-all;
}
.math-ds-seq-narrator .seq-narr-body {
    color: var(--math-text);
    margin-bottom: 6px;
}
.math-ds-seq-narrator .seq-narr-impact {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 12.5px;
    color: var(--math-text-muted);
    padding-top: 6px;
    border-top: 1px dashed var(--math-border-subtle, rgba(0,0,0,0.08));
}
.math-ds-seq-narrator .seq-narr-impact i { color: var(--math-primary); margin-top: 2px; flex-shrink: 0; }

/* Mobile tweaks for new bits */
@media (max-width: 640px) {
    .math-ds-seq-block { padding: 10px 10px 12px; }
    .math-ds-seq-block-head { font-size: 10px; gap: 6px; }
    .math-ds-seq-block-head .seq-block-addr { font-size: 10.5px; padding: 2px 6px; }
    .math-ds-seq-realloc-badge { font-size: 11px; padding: 5px 10px; }
    .math-ds-seq-capbar { height: 20px; }
    .math-ds-seq-capbar .capbar-label { font-size: 10px; }
    .math-ds-seq-chunk { padding: 6px 8px 8px; }
    .math-ds-seq-chunk .seq-chunk-head { font-size: 9.5px; }
    .math-ds-seq-lnode { min-width: 78px; padding: 5px 6px 4px; }
    .math-ds-seq-lnode .lnode-val { font-size: 14px; }
    .math-ds-seq-lnode .lnode-port { width: 16px; height: 20px; font-size: 10px; }
    .math-ds-seq-lnode .lnode-addr { font-size: 9px; }
    .math-ds-seq-lnode .lnode-idx { font-size: 8.5px; }
    .seq-lnode-link .link-lbl { font-size: 7.5px; }
    .seq-lnode-link .link-arrow { font-size: 14px; }
    .math-ds-seq-narrator { padding: 10px 12px; font-size: 12px; }
    .math-ds-seq-narrator .seq-narr-title { font-size: 12px; }
    .math-ds-seq-narrator .seq-narr-impact { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
    .math-ds-seq-realloc-badge { animation: none; }
    .math-ds-seq-array-scroll.is-realloc .math-ds-seq-array { animation: none; }
    .math-ds-seq-capbar .capbar-fill { transition: none; }
    .math-ds-seq-lnode { transition: none; }
}

/* ──────────────────────────────────────────────────────────
 * STL Sequence — Stage 10c: scanning find, clearer leaving cells,
 * mobile button overflow, robust block sizing.
 * ────────────────────────────────────────────────────────── */

/* Block + scroll constraints — make sure the block hugs the viewport
   and only the inner scroll-strip overflows. */
.math-ds-seq-block { box-sizing: border-box; max-width: 100%; }
.math-ds-seq-array-scroll,
.math-ds-seq-chunks-scroll,
.math-ds-seq-linked-scroll {
    width: 100%;
    box-sizing: border-box;
}

/* Scanning animation for find — pulsing amber ring, bigger pop */
.math-ds-seq-cell.seq-scanning,
.math-ds-seq-lnode.seq-scanning {
    background: linear-gradient(135deg, var(--seq-grad-hl-a, #f59e0b) 0%, var(--seq-grad-hl-b, #d97706) 100%);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.28), 0 6px 18px rgba(245, 158, 11, 0.32);
    transform: scale(1.06);
    z-index: 2;
    animation: seq-scan-pulse 0.6s ease-in-out;
}
@keyframes seq-scan-pulse {
    0% { transform: scale(0.94); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
    100% { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.28), 0 6px 18px rgba(245, 158, 11, 0.32); }
}

/* Clearer leaving cell — red tint + ✕ flag in corner */
.math-ds-seq-cell.seq-leaving {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25), 0 4px 12px rgba(239, 68, 68, 0.32);
}
.math-ds-seq-cell.seq-leaving .seq-addr,
.math-ds-seq-cell.seq-leaving .seq-idx,
.math-ds-seq-cell.seq-leaving .seq-val {
    color: #fff;
}
.math-ds-seq-cell.seq-leaving .seq-idx {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.95;
}
.math-ds-seq-cell .seq-leaving-flag {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

/* Random button — let label truncate gracefully on narrow screens */
#seqRandomBtn {
    max-width: 100%;
    min-width: 0;
}
#seqRandomBtn > * { min-width: 0; }
@media (max-width: 640px) {
    #seqRandomBtn {
        font-size: 12px;
        padding-left: 12px;
        padding-right: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #seqRandomBtn i { margin-right: 4px; }
}
@media (max-width: 380px) {
    /* On very narrow screens, hide the long Armenian label and rely on the icon. */
    #seqRandomBtn .seq-rand-text-long { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .math-ds-seq-cell.seq-scanning,
    .math-ds-seq-lnode.seq-scanning {
        animation: none;
        transform: none;
    }
}

/* ──────────────────────────────────────────────────────────
 * Stage 10d: realloc-aware "just copied" cells, capbar tighter,
 * visible memcpy moment without jerky animation.
 * ────────────────────────────────────────────────────────── */

/* Cells that survived a realloc — pulse with green ring + tiny "↻"
   flag overlay so it reads as "this was just copied to the new block". */
.math-ds-seq-cell.seq-just-copied {
    animation: seq-cell-copied 1.1s ease-out 1;
}
.math-ds-seq-cell.seq-just-copied::after {
    content: "↻";
    position: absolute;
    top: -8px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.4);
    animation: seq-cell-copied-flag 1.1s ease-out 1;
    pointer-events: none;
}
@keyframes seq-cell-copied {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55), 0 4px 12px rgba(0,0,0,0.06); }
    35%  { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.32), 0 4px 12px rgba(0,0,0,0.06); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0), 0 4px 12px rgba(0,0,0,0.06); }
}
@keyframes seq-cell-copied-flag {
    0%   { opacity: 0; transform: scale(0.4); }
    25%  { opacity: 1; transform: scale(1.15); }
    70%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.95); }
}

/* The capbar shouldn't crawl in lock-step with the cell movement —
   keep it short so by the time the user sees the cells settle, the
   bar is already at its new value. */
.math-ds-seq-capbar .capbar-fill { transition: width 280ms cubic-bezier(0.4, 0, 0.2, 1); }

/* Realloc badge — slightly bigger / wraps cleanly when text grows. */
.math-ds-seq-realloc-badge { flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
    .math-ds-seq-cell.seq-just-copied { animation: none; }
    .math-ds-seq-cell.seq-just-copied::after { animation: none; opacity: 0; }
    .math-ds-seq-capbar .capbar-fill { transition: none; }
}

/* ──────────────────────────────────────────────────────────
 * Stage 10e: 2-phase step-by-step for insert_at / erase_at.
 *   .seq-targeting       — red pulsing ring (about to be erased)
 *   .seq-insertion-pre   — purple dashed slot (gap will open here)
 *   .math-ds-seq-step-banner — small pill above the array describing the
 *                              current pedagogical step
 * ────────────────────────────────────────────────────────── */

.math-ds-seq-step-banner {
    display: inline-block;
    align-self: flex-start;
    margin: 0 0 10px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    color: var(--math-primary);
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 999px;
    line-height: 1.35;
    animation: seq-step-banner-in 240ms ease-out;
}
@keyframes seq-step-banner-in {
    0%   { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ERASE target — red ring pulse + ✕ overlay */
.math-ds-seq-cell.seq-targeting,
.math-ds-seq-lnode.seq-targeting {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.32), 0 6px 20px rgba(239, 68, 68, 0.32);
    animation: seq-target-pulse 0.8s ease-in-out infinite alternate;
    z-index: 2;
}
.math-ds-seq-cell.seq-targeting .seq-val,
.math-ds-seq-cell.seq-targeting .seq-addr,
.math-ds-seq-cell.seq-targeting .seq-idx,
.math-ds-seq-lnode.seq-targeting .lnode-val,
.math-ds-seq-lnode.seq-targeting .lnode-addr,
.math-ds-seq-lnode.seq-targeting .lnode-idx { color: #fff; }
.math-ds-seq-cell.seq-targeting::before,
.math-ds-seq-lnode.seq-targeting::before {
    content: "✕ erase";
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9.5px;
    font-weight: 700;
    color: #b91c1c;
    background: #fff;
    border: 1px solid #ef4444;
    padding: 1px 6px;
    border-radius: 6px;
    white-space: nowrap;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 3;
}
@keyframes seq-target-pulse {
    0%   { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.32), 0 6px 20px rgba(239, 68, 68, 0.32); }
    100% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.16), 0 6px 24px rgba(239, 68, 68, 0.4); }
}

/* INSERT pre-marker — purple dashed slot indicating gap opens here */
.math-ds-seq-cell.seq-insertion-pre,
.math-ds-seq-lnode.seq-insertion-pre {
    background: rgba(102, 126, 234, 0.08) !important;
    color: var(--math-primary) !important;
    border: 2px dashed var(--math-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
    animation: seq-insert-pulse 0.9s ease-in-out infinite alternate;
}
.math-ds-seq-cell.seq-insertion-pre .seq-val,
.math-ds-seq-cell.seq-insertion-pre .seq-addr,
.math-ds-seq-cell.seq-insertion-pre .seq-idx,
.math-ds-seq-lnode.seq-insertion-pre .lnode-val,
.math-ds-seq-lnode.seq-insertion-pre .lnode-addr,
.math-ds-seq-lnode.seq-insertion-pre .lnode-idx { color: var(--math-primary) !important; }
.math-ds-seq-cell.seq-insertion-pre::before,
.math-ds-seq-lnode.seq-insertion-pre::before {
    content: "↓ insert here";
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9.5px;
    font-weight: 700;
    color: var(--math-primary);
    background: #fff;
    border: 1px solid var(--math-primary);
    padding: 1px 6px;
    border-radius: 6px;
    white-space: nowrap;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 3;
}
@keyframes seq-insert-pulse {
    0%   { box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2); }
    100% { box-shadow: 0 0 0 8px rgba(102, 126, 234, 0.08); }
}

@media (prefers-reduced-motion: reduce) {
    .math-ds-seq-cell.seq-targeting,
    .math-ds-seq-lnode.seq-targeting,
    .math-ds-seq-cell.seq-insertion-pre,
    .math-ds-seq-lnode.seq-insertion-pre { animation: none; }
    .math-ds-seq-step-banner { animation: none; }
}

