:root {
    --bg-main: #0F172A;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);

    --primary: #EC4899;
    /* Pink */
    --primary-hover: #db2777;
    --accent: #14B8A6;
    /* Teal */
    --accent-hover: #0d9488;

    --text-primary: #f8fafc;
    --text-sec: #94a3b8;

    /* Frame Type Colors */
    --c-stream: #3b82f6;
    /* Blue */
    --c-ack: #10b981;
    /* Green */
    --c-crypto: #f59e0b;
    /* Yellow */
    --c-padding: #64748b;
    /* Gray */
    --c-conn: #a855f7;
    /* Purple */

    --radius: 12px;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
}

.font-mono {
    font-family: var(--font-mono);
}

.hidden {
    display: none !important;
}

.text-error {
    color: #ef4444;
}

.text-success {
    color: #10b981;
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: var(--font-ui);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--accent);
    color: white;
}

.btn-secondary:hover {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-sec);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    border-radius: 0;
    z-index: 10;
}

.brand {
    padding: 24px;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.brand-sub {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.brand-icn {
    display: inline-block;
    background: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.input-section {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border-color);
}

.input-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-sec);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

textarea {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    resize: none;
    margin-bottom: 12px;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.nav-menu {
    padding: 24px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-sec);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: rgba(236, 72, 153, 0.1);
    color: var(--primary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    display: inline-block;
}

.dot.stream {
    background: var(--c-stream);
}

.dot.ack {
    background: var(--c-ack);
}

.dot.crypto {
    background: var(--c-crypto);
}

.dot.padding {
    background: var(--c-padding);
}

.action-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
}

.action-footer .btn {
    width: 100%;
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-header {
    height: 70px;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
}

.conn-stats {
    display: flex;
    gap: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-val {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.rtt-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(20, 184, 166, 0.15);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.dashboard-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    height: calc(100vh - 70px);
}

.view-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

.panel-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-sec);
    font-size: 0.95rem;
}

.legend {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sec);
}

.lgd-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Timeline */
.timeline-container {
    height: 120px;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px;
    position: relative;
}

.packet-timeline {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 100%;
    min-width: max-content;
}

.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sec);
    font-style: italic;
}

.pkt-node {
    height: 60px;
    min-width: 20px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pkt-node:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid white;
}

.pkt-node.active {
    border: 2px solid white;
    transform: translateY(-4px);
}

.frame-chunk {
    width: 100%;
}

.bg-stream {
    background: var(--c-stream);
}

.bg-ack {
    background: var(--c-ack);
}

.bg-crypto {
    background: var(--c-crypto);
}

.bg-padding {
    background: var(--c-padding);
}

.bg-conn {
    background: var(--c-conn);
}

/* Details Split */
.details-split {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

.hex-view,
.frame-details {
    flex: 1;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sec-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-sec);
    text-transform: uppercase;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.hex-view pre {
    flex: 1;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #a78bfa;
    line-height: 1.5;
}

.parsed-data {
    flex: 1;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Structured JSON-like view */
.kv-row {
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

.kv-key {
    color: var(--accent);
    margin-right: 8px;
}

.kv-val {
    color: var(--text-primary);
}

/* Multiplex diagram */
.multiplex-diagram,
.migration-diagram {
    flex: 1;
    border-radius: var(--radius);
    padding: 32px;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.comp-card {
    padding: 32px;
    border-radius: var(--radius);
}

.h3-card {
    border: 1px solid var(--primary);
    box-shadow: 0 0 30px rgba(236, 72, 153, 0.1) inset;
}

.comp-card h3 {
    font-size: 1.2rem;
    margin-bottom: 24px;
    color: white;
}

.feat-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feat-list li {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text-primary);
    color: var(--bg-main);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Diagram canvas specific styles injected by JS */
.canvas-stream {
    position: absolute;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-weight: bold;
    color: white;
    font-size: 0.8rem;
    transition: left 2s linear;
}