* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh;
    color: #e0e0e0;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== HEADER ==================== */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}
header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: linear-gradient(90deg, #f7971e, #ffd200);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
header p {
    font-size: 1.1em;
    opacity: 0.8;
}

/* ==================== NAVIGATION ==================== */
.main-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center;
}
.nav-btn {
    padding: 12px 20px;
    background: rgba(255,255,255,0.08);
    color: #ccc;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}
.nav-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}
.nav-btn.active {
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #1a1a2e;
    border-color: #f7971e;
    box-shadow: 0 4px 15px rgba(247,151,30,0.3);
}

/* ==================== SECTIONS ==================== */
.content-section {
    display: none;
}
.content-section.active {
    display: block;
    animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.content-section h2 {
    color: #f7971e;
    font-size: 1.8em;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(247,151,30,0.2);
    padding-bottom: 10px;
}

/* ==================== CONCEPT GRID / CARDS ==================== */
.concept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}
.concept-grid.two-col {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}
.concept-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 24px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.concept-card:hover {
    transform: translateY(-2px);
    border-color: rgba(247,151,30,0.3);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}
.concept-card h3 {
    color: #f7971e;
    margin-bottom: 12px;
    font-size: 1.2em;
}
.concept-card h4 {
    color: #ffd200;
    margin-bottom: 8px;
}
.concept-card p {
    color: #bbb;
    margin-bottom: 10px;
}
.concept-card ul {
    list-style: none;
    padding: 0;
    margin-top: 10px;
}
.concept-card ul li {
    padding: 4px 0 4px 20px;
    position: relative;
    color: #bbb;
}
.concept-card ul li::before {
    content: "•";
    color: #f7971e;
    font-weight: bold;
    position: absolute;
    left: 4px;
}
.concept-card code {
    background: rgba(247,151,30,0.15);
    color: #ffd200;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
}
.concept-card strong {
    color: #e0e0e0;
}

/* Card variants */
.card-warning {
    border-left: 4px solid #ff9800;
}
.card-danger {
    border-left: 4px solid #f44336;
}
.card-warning h3, .card-danger h3 {
    color: #ff9800;
}

/* ==================== DIAGRAM CONTAINER ==================== */
.diagram-container {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow-x: auto;
}
.diagram-container h3 {
    color: #ffd200;
    margin-bottom: 20px;
    font-size: 1.3em;
}
.diagram-caption {
    text-align: center;
    color: #888;
    margin-top: 15px;
    font-size: 0.9em;
    font-style: italic;
}

/* ==================== MINI DIAGRAMS (Overview) ==================== */
.mini-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 16px;
}
.chunk-seg {
    padding: 8px 14px;
    background: rgba(247,151,30,0.15);
    border: 1px solid rgba(247,151,30,0.3);
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
}
.chunk-seg.active-chunk {
    background: rgba(76,175,80,0.2);
    border-color: rgba(76,175,80,0.5);
    color: #4caf50;
    animation: pulse 1.5s ease infinite;
}
.chunk-arrow {
    color: #f7971e;
    font-weight: bold;
}

.abr-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.abr-level {
    padding: 6px 20px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    opacity: 0.4;
    transition: all 0.3s ease;
}
.abr-level.active {
    opacity: 1;
    background: rgba(76,175,80,0.2);
    border: 1px solid rgba(76,175,80,0.5);
    color: #4caf50;
}
.abr-level.high { background: rgba(33,150,243,0.15); color: #64b5f6; }
.abr-level.mid { background: rgba(76,175,80,0.15); color: #81c784; }
.abr-level.low { background: rgba(255,152,0,0.15); color: #ffb74d; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.3); }
    50% { box-shadow: 0 0 12px 3px rgba(76,175,80,0.3); }
}

/* ==================== PIPELINE FLOW ==================== */
.pipeline-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 20px;
}
.pipe-step {
    text-align: center;
    padding: 14px 18px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    min-width: 90px;
    transition: transform 0.3s, border-color 0.3s;
}
.pipe-step:hover {
    transform: translateY(-3px);
    border-color: rgba(247,151,30,0.4);
}
.pipe-icon {
    font-size: 1.8em;
    margin-bottom: 6px;
}
.pipe-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #ccc;
}
.pipe-label small {
    display: block;
    color: #888;
    font-weight: 400;
    margin-top: 2px;
}
.pipe-arrow {
    color: #f7971e;
    font-size: 1.5em;
    font-weight: bold;
}

/* ==================== MANIFEST EXPLORER ==================== */
.manifest-explorer {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}
.manifest-panel {
    flex: 1;
    min-width: 300px;
}
.manifest-arrow-col {
    display: flex;
    align-items: center;
    padding-top: 40px;
}
.manifest-arrow-text {
    color: #f7971e;
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
}
.manifest-file {
    background: #1e1e2e;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.file-tab {
    padding: 8px 16px;
    background: rgba(255,255,255,0.05);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    color: #888;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.file-tab.active {
    color: #f7971e;
    background: rgba(247,151,30,0.1);
}
.file-content {
    padding: 14px;
}
.file-content pre {
    margin: 0;
}
.file-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8em;
    color: #aaa;
    line-height: 1.7;
}
.hl-quality {
    color: #64b5f6;
    font-weight: 600;
}
.hl-segment {
    color: #81c784;
    font-weight: 600;
}

/* ==================== SEGMENT FETCH VIZ ==================== */
.segment-fetch-viz {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    flex-wrap: wrap;
}
.player-box, .server-box {
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px;
    min-width: 200px;
    text-align: center;
    transition: all 0.4s ease;
}
.player-box.highlighted, .server-box.highlighted {
    border-color: #f7971e;
    box-shadow: 0 0 20px rgba(247,151,30,0.2);
}
.player-label, .server-label {
    font-weight: 600;
    font-size: 1em;
    margin-bottom: 12px;
}
.player-buffer {
    background: #1a1a2e;
    border-radius: 6px;
    height: 20px;
    margin: 10px 0;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.buffer-fill {
    height: 100%;
    background: linear-gradient(90deg, #f7971e, #4caf50);
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 0%;
}
.buffer-label {
    font-size: 0.85em;
    color: #888;
}
.current-quality {
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(76,175,80,0.15);
    border-radius: 12px;
    font-size: 0.85em;
    color: #81c784;
    display: inline-block;
    transition: all 0.3s ease;
}
.fetch-arrow-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 80px;
}
.fetch-request, .fetch-response {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.78em;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.fetch-request.show {
    background: rgba(33,150,243,0.2);
    color: #64b5f6;
    opacity: 1;
    animation: msgSlide 0.4s ease;
}
.fetch-response.show {
    background: rgba(76,175,80,0.2);
    color: #81c784;
    opacity: 1;
    animation: msgSlide 0.4s ease;
}
.segment-store {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}
.stored-seg {
    padding: 6px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    font-size: 0.78em;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}
.stored-seg.delivered {
    background: rgba(76,175,80,0.2);
    border-color: rgba(76,175,80,0.4);
    color: #81c784;
}
.stored-seg.fetching {
    background: rgba(33,150,243,0.2);
    border-color: rgba(33,150,243,0.4);
    color: #64b5f6;
    animation: pulse 0.8s ease infinite;
}

@keyframes msgSlide {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ==================== ABR LADDER ==================== */
.abr-ladder-viz {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ladder-rung {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s ease;
    opacity: 0.5;
}
.ladder-rung.active-rung {
    opacity: 1;
    transform: scale(1.03);
}
.r1080 { background: rgba(33,150,243,0.15); color: #64b5f6; border-left: 3px solid #2196f3; }
.r720  { background: rgba(76,175,80,0.15); color: #81c784; border-left: 3px solid #4caf50; }
.r480  { background: rgba(255,193,7,0.15); color: #ffd54f; border-left: 3px solid #ffc107; }
.r360  { background: rgba(255,152,0,0.15); color: #ffb74d; border-left: 3px solid #ff9800; }
.r240  { background: rgba(244,67,54,0.15); color: #ef9a9a; border-left: 3px solid #f44336; }

/* ==================== ABR SIMULATION ==================== */
.abr-sim-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .abr-sim-grid { grid-template-columns: 1fr; }
}
.abr-player-panel {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}
.abr-video-area {
    background: #1a1a2e;
    border-radius: 10px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.abr-video-inner {
    text-align: center;
    transition: filter 0.5s ease;
}
.abr-res-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.7);
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    color: #81c784;
    transition: all 0.5s ease;
}
.abr-res-badge.low-quality { color: #ffb74d; }
.abr-res-badge.mid-quality { color: #81c784; }
.abr-res-badge.high-quality { color: #64b5f6; }
.abr-video-content {
    font-size: 1.5em;
    color: #ccc;
}
.abr-buffer-bar {
    background: #1a1a2e;
    border-radius: 4px;
    height: 8px;
    margin: 10px 0;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.abr-buffer-fill {
    height: 100%;
    background: linear-gradient(90deg, #f44336, #ff9800, #4caf50);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 50%;
}
.abr-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.85em;
    color: #aaa;
}
.abr-stats strong {
    color: #f7971e;
}
.abr-graph-panel {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.abr-graph-panel canvas {
    max-width: 100%;
}
.graph-legend {
    display: flex;
    gap: 16px;
    font-size: 0.8em;
    color: #888;
    margin-top: 8px;
}

/* ==================== CONTROLS ==================== */
.controls {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.btn-primary {
    padding: 10px 24px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #1a1a2e;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.3s, transform 0.2s;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(247,151,30,0.3);
}
.btn-secondary {
    padding: 10px 24px;
    background: rgba(255,255,255,0.08);
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.3s;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.12);
}
.step-indicator {
    margin-left: auto;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(33,150,243,0.15);
    color: #64b5f6;
}
.bw-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #bbb;
    font-size: 0.9em;
    margin-left: auto;
}
.bw-label input[type="range"] {
    accent-color: #f7971e;
}

/* ==================== CDN FLOW ==================== */
.cdn-flow {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    flex-wrap: wrap;
}
.cdn-actor {
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    min-width: 130px;
    transition: all 0.4s ease;
}
.cdn-actor.highlighted {
    border-color: #f7971e;
    box-shadow: 0 0 20px rgba(247,151,30,0.2);
}
.cdn-icon {
    font-size: 2em;
    margin-bottom: 6px;
}
.cdn-label {
    font-weight: 600;
    font-size: 0.9em;
    color: #ccc;
}
.cdn-label small {
    display: block;
    color: #888;
    font-weight: 400;
}
.cdn-cache-indicator {
    margin-top: 8px;
    padding: 4px 10px;
    background: rgba(76,175,80,0.15);
    border-radius: 10px;
    font-size: 0.78em;
    color: #81c784;
    transition: all 0.3s ease;
}
.cdn-cache-indicator.filling {
    background: rgba(33,150,243,0.2);
    color: #64b5f6;
    animation: pulse 0.8s ease infinite;
}
.cdn-arrow-area {
    display: flex;
    align-items: center;
    padding-top: 30px;
}
.cdn-route {
    color: #f7971e;
    font-size: 1.2em;
    transition: color 0.3s;
}
.cdn-route.active-route {
    color: #4caf50;
}
.cdn-users {
    display: flex;
    justify-content: space-around;
    padding: 10px 20px;
}
.cdn-user-group {
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 0.85em;
    color: #888;
}
.user-icon {
    font-size: 1.2em;
    transition: transform 0.3s;
}
.user-icon.receiving {
    transform: scale(1.3);
    color: #81c784;
}

/* ==================== LATENCY STACK ==================== */
.latency-stack {
    margin-top: 10px;
}
.latency-bar {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    height: 36px;
    font-size: 0.78em;
    font-weight: 600;
}
.latency-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a2e;
    padding: 0 4px;
    white-space: nowrap;
    min-width: 60px;
}
.latency-seg.encode  { background: #f7971e; }
.latency-seg.package { background: #ffd200; }
.latency-seg.upload  { background: #4caf50; }
.latency-seg.cdn     { background: #2196f3; }
.latency-seg.buffer  { background: #9c27b0; }

/* ==================== DRM FLOW ==================== */
.drm-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px;
}
.drm-step {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    min-width: 120px;
}
.drm-icon {
    font-size: 1.8em;
    margin-bottom: 6px;
}
.drm-arrow {
    color: #f7971e;
    font-size: 1.5em;
    font-weight: bold;
}

/* ==================== STATUS LOG ==================== */
.status-log {
    background: #1a1a2e;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 20px;
    border: 1px solid rgba(255,255,255,0.08);
}
.log-header {
    background: rgba(255,255,255,0.05);
    color: #ffd200;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 0.9em;
}
.log-content {
    padding: 12px 16px;
    max-height: 180px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8em;
    color: #c5c8c6;
    line-height: 1.8;
}
.log-content .log-entry { padding: 2px 0; }
.log-content .log-time { color: #555; margin-right: 8px; }
.log-content .log-success { color: #4caf50; }
.log-content .log-warn { color: #ff9800; }
.log-content .log-error { color: #f44336; }
.log-content .log-info { color: #64b5f6; }
.log-content .log-abr { color: #ce93d8; }

/* ==================== COMPARISON TABLE ==================== */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}
.comparison-table thead th {
    background: rgba(247,151,30,0.2);
    color: #f7971e;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
}
.comparison-table thead th:first-child { border-radius: 8px 0 0 0; }
.comparison-table thead th:last-child { border-radius: 0 8px 0 0; }
.comparison-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #bbb;
}
.comparison-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.comparison-table tbody tr:hover { background: rgba(247,151,30,0.05); }
.comparison-table code {
    background: rgba(247,151,30,0.15);
    color: #ffd200;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    header h1 { font-size: 1.8em; }
    .pipeline-flow { flex-direction: column; }
    .pipe-arrow { transform: rotate(90deg); }
    .segment-fetch-viz { flex-direction: column; }
    .fetch-arrow-area { flex-direction: row; }
    .cdn-flow { flex-direction: column; align-items: center; }
    .cdn-arrow-area { padding-top: 0; transform: rotate(90deg); }
    .manifest-explorer { flex-direction: column; }
    .manifest-arrow-col { padding-top: 0; transform: rotate(90deg); }
    .concept-grid.two-col { grid-template-columns: 1fr; }
    .abr-sim-grid { grid-template-columns: 1fr; }
    .drm-flow { flex-direction: column; }
    .drm-arrow { transform: rotate(90deg); }
    .controls { flex-direction: column; align-items: stretch; }
    .bw-label { margin-left: 0; }
}
