/* ── shared visualization styles ─────────────────────────── */

.viz {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.75rem 0;
    overflow-x: auto;
}
.viz-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b6b6b;
    margin: 0 0 1rem 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.viz-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.viz-btn {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}
.viz-btn:hover { border-color: #1e40af; color: #1e40af; }
.viz-btn.active {
    background: #1e40af;
    color: #fff;
    border-color: #1e40af;
}
.viz-label {
    font-size: 0.75rem;
    color: #6b6b6b;
    margin-top: 0.75rem;
}
.viz-note {
    font-size: 0.78rem;
    color: #6b6b6b;
    font-style: italic;
    margin-top: 0.6rem;
}

/* ── example 1: prefix KV cache ─────────────────────────── */

.kv-requests { display: flex; flex-direction: column; gap: 0.75rem; }
.kv-row { display: flex; align-items: center; gap: 0.5rem; }
.kv-row-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: #374151;
    min-width: 80px;
    flex-shrink: 0;
}
.kv-bar {
    display: flex;
    height: 36px;
    border-radius: 5px;
    overflow: hidden;
    flex: 1;
    max-width: 500px;
}
.kv-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 500;
    color: #fff;
    transition: all 0.4s ease;
    white-space: nowrap;
    padding: 0 0.5rem;
}
.kv-prefix { background: #1e40af; flex: 3; }
.kv-unique { background: #3b82f6; flex: 1; }
.kv-cached {
    background: repeating-linear-gradient(
        45deg, #94a3b8, #94a3b8 4px, #b0bec5 4px, #b0bec5 8px
    );
    color: #475569;
    flex: 3;
}
.kv-time {
    font-size: 0.78rem;
    font-weight: 500;
    min-width: 80px;
    text-align: right;
    color: #374151;
    transition: color 0.3s;
}
.kv-time.fast { color: #16a34a; font-weight: 600; }

/* ── example 2: speculative decoding ─────────────────────── */

.spec-tokens {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.spec-tok {
    width: 72px;
    height: 38px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1.5px solid transparent;
}
.spec-tok.empty {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
}
.spec-tok.draft {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}
.spec-tok.accepted {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}
.spec-tok.rejected {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
    text-decoration: line-through;
}
.spec-tok.corrected {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
}
.spec-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.spec-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: #6b6b6b;
}
.spec-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
.spec-step-info {
    font-size: 0.78rem;
    color: #374151;
    min-height: 1.4em;
    margin-top: 0.5rem;
}

/* ── example 3: continuous batching timeline ─────────────── */

.batch-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 600px) {
    .batch-compare { grid-template-columns: 1fr; }
}
.batch-col-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
}
.batch-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.batch-lane {
    display: flex;
    height: 24px;
    position: relative;
}
.batch-lane-label {
    font-size: 0.68rem;
    color: #6b6b6b;
    width: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 2px;
}
.batch-lane-bar {
    flex: 1;
    position: relative;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}
.batch-seg {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #fff;
    font-weight: 500;
}
.batch-seg.prefill { background: #1e40af; }
.batch-seg.decode { background: #60a5fa; }
.batch-seg.wait { background: #e5e7eb; }
.batch-time-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.62rem;
    color: #9ca3af;
    padding-left: 52px;
}
.batch-gpu {
    margin-top: 0.5rem;
    padding-left: 52px;
}
.batch-gpu-bar {
    height: 10px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}
.batch-gpu-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #1e40af, #60a5fa);
}
.batch-gpu-label {
    font-size: 0.65rem;
    color: #6b6b6b;
    margin-top: 2px;
}

/* ── example 4: prompt reduction ─────────────────────────── */

.prompt-demo { max-width: 480px; }
.prompt-slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.prompt-slider-label {
    font-size: 0.78rem;
    color: #374151;
    min-width: 60px;
}
.prompt-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    outline: none;
}
.prompt-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #1e40af;
    border-radius: 50%;
    cursor: pointer;
}
.prompt-slider-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e40af;
    min-width: 24px;
    text-align: center;
}
.prompt-meter {
    margin-bottom: 0.6rem;
}
.prompt-meter-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #6b6b6b;
    margin-bottom: 3px;
}
.prompt-meter-track {
    height: 18px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.prompt-meter-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease, background 0.3s ease;
}
.prompt-meter-fill.blue { background: #1e40af; }
.prompt-meter-fill.amber { background: #d97706; }
.prompt-meter-fill.green { background: #16a34a; }

/* ── example 5: paged KV cache ───────────────────────────── */

.paged-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 600px) {
    .paged-compare { grid-template-columns: 1fr; }
}
.paged-col-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}
.paged-mem {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
}
.paged-block {
    height: 28px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 500;
    transition: all 0.3s;
}
.paged-block.a { background: #1e40af; color: #fff; }
.paged-block.b { background: #7c3aed; color: #fff; }
.paged-block.c { background: #0891b2; color: #fff; }
.paged-block.free { background: #f3f4f6; border: 1px dashed #d1d5db; color: #9ca3af; }
.paged-block.frag {
    background: repeating-linear-gradient(
        45deg, #fecaca, #fecaca 3px, #fee2e2 3px, #fee2e2 6px
    );
    color: #dc2626;
    font-size: 0.6rem;
}
.paged-block.pool { background: #ecfdf5; border: 1px solid #86efac; color: #16a34a; }

/* ── example 6: flash attention ──────────────────────────── */

.attn-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 600px) {
    .attn-compare { grid-template-columns: 1fr; }
}
.attn-col-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.6rem;
}
.attn-flow {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
}
.attn-layer {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
}
.attn-box {
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
}
.attn-box.qkv { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.attn-box.smat { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; min-width: 120px; }
.attn-box.sram { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.attn-box.out { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.attn-arrow {
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: center;
}
.attn-mem-tag {
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    margin-top: 0.15rem;
}
.attn-mem-tag.hbm { background: #fef3c7; color: #92400e; }
.attn-mem-tag.sram-tag { background: #d1fae5; color: #065f46; }

/* ── example 7: quantization ─────────────────────────────── */

.quant-demo { max-width: 400px; }
.quant-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.quant-row-label {
    font-size: 0.72rem;
    color: #6b6b6b;
    min-width: 80px;
}
.quant-bar-track {
    flex: 1;
    height: 22px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.quant-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease, background 0.4s ease;
    display: flex;
    align-items: center;
    padding-left: 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}
.quant-quality {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
}
.quant-quality-dots {
    display: flex;
    gap: 3px;
}
.quant-quality-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    transition: background 0.3s;
}
.quant-quality-dot.on { background: #16a34a; }
.quant-quality-dot.warn { background: #d97706; }
.quant-quality-label {
    font-size: 0.72rem;
    color: #6b6b6b;
    transition: color 0.3s;
}
