:root {
    --bg-gradient-start: #eef2f7;
    --bg-gradient-end: #d9e2ec;
    --card-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
    --brand-primary: #1e3a8a;
    --brand-accent: #2563eb;
    --brand-secondary: #0f172a;
    --neutral-100: #ffffff;
    --neutral-200: #f3f4f6;
    --neutral-400: #6b7280;
    --neutral-600: #374151;
    --success: #0ea5e9;
    --warning: #f97316;
    --border-radius-lg: 24px;
    --border-radius-md: 18px;
    --border-radius-sm: 12px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--neutral-600);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    background: var(--neutral-100);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

header {
    background: linear-gradient(120deg, var(--brand-primary), var(--brand-secondary));
    color: var(--neutral-100);
    padding: 48px;
    text-align: center;
}

header h1 {
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    margin-top: 12px;
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    opacity: 0.92;
}

.header-highlights {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.highlight-pill {
    background: rgba(255, 255, 255, 0.12);
    color: var(--neutral-100);
    border-radius: 999px;
    padding: 10px 20px;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    padding: 0 48px;
}

.overview-card {
    background: var(--neutral-100);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.overview-card h2 {
    font-size: 1.35rem;
    color: var(--brand-primary);
}

.overview-card h3 {
    font-size: 1.05rem;
    color: var(--neutral-600);
    margin-bottom: 8px;
}

.overview-card p {
    color: var(--neutral-400);
    line-height: 1.7;
}

.overview-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--neutral-400);
    line-height: 1.6;
}

.overview-card li::before {
    content: "•";
    color: var(--brand-accent);
    margin-right: 10px;
    font-weight: 700;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.overview-grid ul {
    margin-top: 4px;
}

.overview-grid li::before {
    color: var(--warning);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: 24px 48px;
    flex-wrap: wrap;
    background: rgba(37, 99, 235, 0.05);
    border-top: 1px solid rgba(37, 99, 235, 0.08);
    border-bottom: 1px solid rgba(37, 99, 235, 0.08);
}

.btn {
    padding: 12px 28px;
    border-radius: 999px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--neutral-100);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: linear-gradient(120deg, #2563eb, #1d4ed8);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
    background: linear-gradient(120deg, #0369a1, #0ea5e9);
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.25);
}

.btn-reset {
    background: linear-gradient(120deg, #15803d, #22c55e);
    box-shadow: 0 10px 20px rgba(34, 197, 94, 0.25);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: var(--neutral-100);
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.speed-control label {
    font-weight: 600;
    color: var(--neutral-600);
}

#speedSlider {
    width: 160px;
}

#speedLabel {
    font-weight: 600;
    min-width: 44px;
    color: var(--brand-accent);
    text-align: right;
}

.main-layout {
    display: flex;
    gap: 32px;
    padding: 0 48px 48px;
}

.diagram-panel {
    flex: 1 1 0;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.05), rgba(14, 116, 144, 0.05));
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
    padding: 32px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.step-indicator {
    align-self: center;
    background: var(--neutral-100);
    padding: 12px 24px;
    border-radius: 999px;
    font-weight: 600;
    color: var(--brand-primary);
    border: 1px solid rgba(37, 99, 235, 0.15);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.architecture {
    position: relative;
    padding: 48px 40px;
    min-height: 540px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.component {
    background: var(--neutral-100);
    border-radius: var(--border-radius-sm);
    padding: 24px;
    margin: 10px auto;
    width: clamp(260px, 70%, 420px);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    opacity: 0.3;
    transform: translateY(10px);
    transition: all 0.4s ease;
}

.component.active {
    opacity: 1;
    transform: translateY(0);
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 20px 40px rgba(37, 99, 235, 0.18);
}

.component.pulse {
    animation: pulse 1.4s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.component-header {
    text-align: center;
    margin-bottom: 12px;
}

.component-header h2 {
    font-size: 1.35rem;
    color: var(--brand-secondary);
    letter-spacing: -0.01em;
}

.component-content {
    text-align: center;
    color: var(--neutral-400);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.component-content p {
    line-height: 1.6;
}

.example {
    background: rgba(37, 99, 235, 0.08);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--brand-primary);
}

.features {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.feature {
    background: rgba(37, 99, 235, 0.08);
    color: var(--brand-accent);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.connections {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke: var(--success);
    stroke-width: 3;
    stroke-dasharray: 8 10;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: dash 18s linear infinite;
}

.connection-line.active {
    opacity: 1;
}

@keyframes dash {
    to {
        stroke-dashoffset: -300;
    }
}

.message {
    position: absolute;
    background: var(--neutral-100);
    padding: 12px 18px;
    border-radius: 999px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--neutral-600);
    opacity: 0;
    transform: translateY(0);
    transition: opacity 0.4s ease;
    z-index: 2;
    white-space: nowrap;
}

.message.show {
    opacity: 1;
}

.message.move-down {
    animation: moveDown 1.1s ease-in-out;
}

@keyframes moveDown {
    0% { transform: translateY(0); }
    50% { transform: translateY(14px); }
    100% { transform: translateY(0); }
}

#message1 {
    left: 50%;
    top: 17%;
    transform: translateX(-50%);
}

#message2 {
    left: 50%;
    top: 39%;
    transform: translateX(-50%);
}

#message3 {
    left: 50%;
    top: 62%;
    transform: translateX(-50%);
}

#message4 {
    left: 50%;
    top: 90%;
    transform: translateX(-50%);
}

.explanation-panel {
    background: var(--neutral-100);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: var(--border-radius-sm);
    padding: 24px 28px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

.explanation-panel h3 {
    font-size: 1.2rem;
    color: var(--brand-secondary);
    margin-bottom: 10px;
}

.explanation-panel p {
    line-height: 1.7;
    color: var(--neutral-400);
    font-size: 1.05rem;
}

.sidebar {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-card {
    background: var(--neutral-100);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 24px 22px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-card h3 {
    font-size: 1.15rem;
    color: var(--brand-secondary);
}

.sidebar-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--neutral-400);
    line-height: 1.6;
}

.sidebar-card li::before {
    content: "•";
    color: var(--brand-accent);
    margin-right: 8px;
    font-weight: 700;
}

.step-reference ol {
    counter-reset: step-counter;
    display: flex;
    flex-direction: column;
    gap: 10px;
    list-style: none;
    color: var(--neutral-400);
}

.step-reference li {
    position: relative;
    padding: 12px 14px 12px 46px;
    border-radius: 14px;
    border: 1px solid transparent;
    min-height: 48px;
    line-height: 1.45;
    transition: all 0.3s ease;
}

.step-reference li::before {
    counter-increment: step-counter;
    content: counter(step-counter);
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    background: rgba(37, 99, 235, 0.1);
    color: var(--brand-primary);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.step-reference li.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.25);
    color: var(--brand-secondary);
    font-weight: 600;
}

.step-reference li.active::before {
    background: var(--brand-accent);
    color: var(--neutral-100);
}

footer {
    text-align: center;
    padding: 24px 16px 32px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--neutral-400);
}

footer a {
    color: var(--brand-primary);
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 1080px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        flex: 1 1 auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    header {
        padding: 36px 24px;
    }

    .overview {
        padding: 0 24px;
    }

    .controls {
        flex-direction: column;
        gap: 14px;
        padding: 24px;
    }

    .speed-control {
        width: 100%;
        justify-content: center;
    }

    .main-layout {
        padding: 0 24px 36px;
    }

    .architecture {
        padding: 40px 16px;
    }

    .component {
        width: 100%;
    }

    .step-reference li {
        padding-left: 42px;
    }
}

@media (max-width: 520px) {
    header h1 {
        font-size: 1.8rem;
    }

    .highlight-pill {
        font-size: 0.8rem;
    }

    #speedSlider {
        width: 120px;
    }
}
