body {
    margin: 0;
    padding: 0;
    background: #f8fafc;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #475569;
}

.viewport {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    background-color: #f1f5f9;
    cursor: grab;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
    touch-action: none;
}

.viewport:active {
    cursor: grabbing;
}

#pan-zoom-container {
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    position: absolute;
    top: 0;
    left: 0;
}

object {
    width: 1920px;
    height: 1080px;
    pointer-events: none;
    display: block;
}

.control-panel {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(0);

    width: auto;
    min-width: 600px;
    max-width: 90%;

    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);

    padding: 20px 25px;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.5);

    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 200;

    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.control-panel.minimized {
    transform: translateX(-50%) translateY(100%);
}

.toggle-handle {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);

    width: 80px;
    height: 36px;

    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: none;
    border-radius: 16px 16px 0 0;

    cursor: pointer;
    color: #64748b;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    z-index: 201;
}

.toggle-handle:hover {
    background: #fff;
    color: #0ea5e9;
    top: -40px;
}

.control-panel.minimized .toggle-handle {
    background: #0ea5e9;
    color: white;
    box-shadow: 0 -5px 20px rgba(14, 165, 233, 0.4);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

.status-badge {
    background: #f1f5f9;
    color: #64748b;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-badge span {
    color: #0ea5e9;
}

.example-code {
    font-family: 'Fira Code', 'Courier New', monospace;
    color: #64748b;
    font-size: 0.9rem;
    background: #f8fafc;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.panel-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

select {
    background: #f8fafc;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    flex-grow: 1;
    transition: border-color 0.2s;
}

select:hover {
    border-color: #94a3b8;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

.btn-nav {
    background: #e0f2fe;
    color: #0369a1;
}

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

.btn-reset {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-reset:hover {
    background: #fecaca;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.btn:active {
    transform: scale(0.96);
}

.zoom-controls {
    position: absolute;
    bottom: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.zoom-btn {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: white;
    border: 1px solid #e2e8f0;
    color: #475569;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: #f8fafc;
    color: #0ea5e9;
    transform: scale(1.05);
}

.zoom-btn:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .control-panel {
        min-width: unset;
        width: 90%;
        bottom: 25px;
        padding: 15px;
    }

    .control-panel.minimized {
        transform: translateX(-50%) translateY(100%);
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .example-code {
        width: 100%;
        box-sizing: border-box;
    }

    .panel-actions {
        flex-wrap: wrap;
    }

    select {
        width: 100%;
    }

    .btn {
        flex-grow: 1;
    }

    .zoom-controls {
        bottom: auto;
        top: 20px;
        right: 20px;
    }

    .signal-1 {
        stroke: #0ea5e9 !important;
        stroke-width: 4px !important;
        stroke-dasharray: 10, 5;
        stroke-linecap: round;
        animation: flow 0.5s linear infinite;
        opacity: 1 !important;
    }

    .signal-0 {
        stroke: #94a3b8 !important;
        stroke-width: 3px !important;
        stroke-dasharray: 5, 5;
        opacity: 0.5 !important;
        animation: none !important;
    }

    .bit-1 {
        fill: #0ea5e9 !important;
    }

    .bit-0 {
        fill: #94a3b8 !important;
    }
}