:root {
    --bg-base: #0A0F1A;
    --bg-panel: #121A2F;
    --bg-elevated: #1A2542;
    --border: #2A3B66;

    --c-primary: #00B4D8;
    --c-secondary: #90E0EF;
    --c-accent: #FF006E;

    --text-main: #E2E8F0;
    --text-muted: #94A3B8;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius: 6px;

    /* Layer Colors */
    --l2-color: #d97706;
    /* Ethernet orange */
    --l3-color: #059669;
    /* IP green */
    --l4-color: #2563eb;
    /* TCP/UDP blue */
    --l7-color: #db2777;
    /* App pink */
    --payload-color: #64748b;
}

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

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.85rem;
}

.mt-auto {
    margin-top: auto;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--c-primary);
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.nav-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Buttons & Inputs */
.btn {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: 0.2s;
    border: none;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: var(--c-primary);
    color: #000;
    font-weight: 600;
}

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

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

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--c-primary);
}

.select-input,
.text-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    outline: none;
}

.select-input:focus,
.text-input:focus {
    border-color: var(--c-primary);
}

/* Layout Grid */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.panel-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* Left - OSI Panel */
.osi-panel {
    width: 220px;
    flex-shrink: 0;
}

.osi-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 1rem;
}

.osi-layer {
    padding: 0.5rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: 0.2s;
}

.osi-layer.active {
    background: rgba(0, 180, 216, 0.1);
    border-color: var(--c-primary);
    color: var(--text-main);
}

.osi-layer[data-layer="1"],
.osi-layer[data-layer="2"] {
    border-left: 4px solid var(--l2-color);
}

.osi-layer[data-layer="3"] {
    border-left: 4px solid var(--l3-color);
}

.osi-layer[data-layer="4"] {
    border-left: 4px solid var(--l4-color);
}

.osi-layer[data-layer="5"],
.osi-layer[data-layer="6"],
.osi-layer[data-layer="7"] {
    border-left: 4px solid var(--l7-color);
}

.metrics-box {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border);
}

.metric-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.metric-row span {
    color: var(--text-muted);
}

.metric-row strong {
    color: var(--c-primary);
    font-family: var(--font-mono);
}

/* Center - Builder Panel */
.builder-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
}

.visualizer-canvas {
    flex: 1;
    overflow: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
}

.empty-state {
    color: var(--text-muted);
    font-style: italic;
}

.builder-controls {
    padding: 1rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.add-layer-controls {
    display: flex;
    gap: 0.5rem;
}

/* Packet SVG Styles */
.pkt-group {
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.pkt-group:hover .pkt-rect {
    filter: brightness(1.2);
    stroke: #FFF;
    stroke-width: 2;
}

.pkt-group.selected .pkt-rect {
    stroke: var(--c-accent);
    stroke-width: 2;
    filter: brightness(1.2);
}

.pkt-rect {
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pkt-text-bg {
    fill: rgba(0, 0, 0, 0.6);
}

.pkt-text {
    font-family: var(--font-mono);
    font-size: 14px;
    fill: #FFF;
    pointer-events: none;
    font-weight: bold;
}

.pkt-subtext {
    font-family: var(--font-ui);
    font-size: 10px;
    fill: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

/* Right - Inspector & Hex */
.right-sidebar {
    width: 380px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
}

/* Inspector */
.inspector-panel {
    flex: 1;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
}

.inspector-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-label {
    width: 90px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-align: right;
}

.field-input {
    flex: 1;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
}

.field-input input {
    width: 100%;
}

.field-input.unit::after {
    content: attr(data-unit);
    margin-left: -40px;
    color: var(--text-muted);
    font-size: 0.75rem;
    pointer-events: none;
}

.btn-calc {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: none;
}

/* Hex Dump */
.hexdump-panel {
    height: 280px;
    display: flex;
    flex-direction: column;
    background: #000;
}

.hexdump-container {
    flex: 1;
    display: flex;
    overflow-y: auto;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.hexdump-container::-webkit-scrollbar {
    width: 8px;
}

.hexdump-container::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.hexdump-gutter {
    color: #555;
    padding-right: 1rem;
    text-align: right;
    user-select: none;
}

.hexdump-hex {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    letter-spacing: 1px;
}

.hexdump-ascii {
    color: #888;
    padding-left: 1rem;
    word-break: break-all;
    width: 140px;
    flex-shrink: 0;
    white-space: pre-wrap;
}

/* Hex Bytes Colors */
.hx {
    display: inline-block;
    width: 24px;
    text-align: center;
    margin: 0 2px;
    border-radius: 2px;
    transition: 0.2s;
}

.hx:hover {
    background: #333;
    color: #FFF;
    cursor: crosshair;
}

.hx.hl {
    background: rgba(255, 255, 255, 0.2);
    color: #FFF;
    font-weight: bold;
}

.hx.L2 {
    color: var(--l2-color);
}

.hx.L3 {
    color: var(--l3-color);
}

.hx.L4 {
    color: var(--l4-color);
}

.hx.L7 {
    color: var(--l7-color);
}

.hx.Payload {
    color: var(--payload-color);
}

.asc {
    display: inline-block;
    width: 8px;
    text-align: center;
}

.asc.hl {
    background: rgba(255, 255, 255, 0.2);
    color: #FFF;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.modal-content.large {
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-close:hover {
    color: #FFF;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
    padding: 1rem;
}

.compare-col {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #000;
    overflow: hidden;
}

.compare-col h3 {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    margin: 0;
}

.compare-hex {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: #BBB;
    white-space: pre-wrap;
    word-break: break-all;
}

.compare-hex .diff-add {
    color: #10b981;
    font-weight: bold;
}

.compare-hex .diff-sub {
    color: #ef4444;
    text-decoration: line-through;
}