:root {
    --primary: #22C55E;
    --secondary: #86EFAC;
    --accent: #A3E635;
    --bg: #0A1A0D;
    --surface: rgba(15, 30, 18, .7);
    --border: rgba(255, 255, 255, .08);
    --text: #E6F0E8;
    --text-muted: #6B8572;
    --error: #EF4444;
    --warning: #F59E0B;
    --radius: 12px;
    --font: 'Inter', system-ui, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

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

.glass {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border)
}

.hidden {
    display: none !important
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh
}

/* Connection Bar */
.connection-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    z-index: 10
}

.connection-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error);
    transition: all .3s;
    box-shadow: 0 0 8px rgba(239, 68, 68, .4)
}

.status-dot.connected {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(34, 197, 94, .4)
}

.status-dot.connecting {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, .4);
    animation: pulse 1s infinite
}

.status-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-muted)
}

.connection-center {
    flex: 1;
    display: flex;
    gap: 8px
}

.url-input {
    flex: 1;
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-family: var(--mono);
    font-size: .85rem;
    transition: all .2s
}

.url-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, .15)
}

.btn-connect,
.btn-disconnect {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all .2s
}

.btn-connect {
    background: var(--primary);
    color: #fff
}

.btn-connect:hover {
    background: #16a34a;
    transform: translateY(-1px)
}

.btn-disconnect {
    background: var(--error);
    color: #fff
}

.btn-disconnect:hover {
    background: #dc2626
}

.btn-connect i,
.btn-disconnect i {
    width: 16px;
    height: 16px
}

.connection-right {
    display: flex;
    gap: 8px
}

.icon-btn {
    background: rgba(0, 0, 0, .2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s
}

.icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary)
}

.icon-btn:disabled {
    opacity: .4;
    cursor: not-allowed
}

.icon-btn i {
    width: 18px;
    height: 18px
}

/* Main Layout */
.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden
}

.message-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.inspector-pane {
    width: 380px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    overflow: hidden
}

.pane-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center
}

.pane-header h2 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px
}

.pane-header h2 i {
    width: 18px;
    height: 18px;
    color: var(--primary)
}

.msg-count {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: var(--mono)
}

/* Messages */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px
}

.message-list::-webkit-scrollbar {
    width: 4px
}

.message-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-muted);
    text-align: center
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text)
}

.empty-state p {
    max-width: 300px;
    font-size: .9rem
}

.msg-item {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .2s;
    animation: slideIn .2s ease
}

.msg-item:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, .02)
}

.msg-item.active {
    border-color: var(--primary);
    background: rgba(34, 197, 94, .05)
}

.msg-item.sent {
    border-left: 3px solid var(--primary)
}

.msg-item.received {
    border-left: 3px solid var(--accent)
}

.msg-item.system {
    border-left: 3px solid var(--warning);
    opacity: .8
}

.msg-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px
}

.msg-dir {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px
}

.msg-dir.sent {
    color: var(--primary)
}

.msg-dir.received {
    color: var(--accent)
}

.msg-dir.system {
    color: var(--warning)
}

.msg-time {
    font-size: .7rem;
    color: var(--text-muted);
    font-family: var(--mono)
}

.msg-preview {
    font-family: var(--mono);
    font-size: .85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%
}

.msg-size {
    font-size: .65rem;
    color: var(--text-muted);
    margin-top: 4px
}

/* Inspector */
.inspector-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px
}

.inspector-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: .9rem;
    text-align: center
}

.inspector-section {
    margin-bottom: 20px
}

.inspector-section h3 {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px
}

.inspector-section h3 i {
    width: 14px;
    height: 14px
}

.inspector-kv {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem
}

.inspector-kv .key {
    color: var(--text-muted);
    font-weight: 500
}

.inspector-kv .val {
    font-family: var(--mono);
    color: var(--accent)
}

.inspector-code {
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    font-family: var(--mono);
    font-size: .8rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--secondary);
    max-height: 400px;
    overflow-y: auto;
    position: relative
}

.inspector-hex {
    font-family: var(--mono);
    font-size: .75rem;
    line-height: 1.8;
    color: var(--text-muted);
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    overflow-x: auto
}

.hex-offset {
    color: var(--primary);
    margin-right: 12px
}

.hex-byte {
    margin-right: 4px
}

.hex-ascii {
    color: var(--accent);
    margin-left: 12px
}

.copy-inspector {
    position: absolute;
    top: 8px;
    right: 8px
}

/* Send Bar */
.send-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border)
}

.msg-type-select {
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: .85rem;
    font-family: inherit;
    cursor: pointer
}

.send-input {
    flex: 1;
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-family: var(--mono);
    font-size: .85rem;
    resize: none;
    transition: all .2s;
    max-height: 80px
}

.send-input:focus {
    outline: none;
    border-color: var(--primary)
}

.btn-send {
    background: var(--primary);
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s
}

.btn-send:hover:not(:disabled) {
    background: #16a34a;
    transform: translateY(-1px)
}

.btn-send:disabled {
    opacity: .4;
    cursor: not-allowed
}

.btn-send i {
    width: 18px;
    height: 18px
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: .85rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .3);
    z-index: 200;
    opacity: 0;
    transition: all .3s cubic-bezier(.175, .885, .32, 1.275)
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px)
    }

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .5
    }
}

@media(max-width:768px) {
    .inspector-pane {
        display: none
    }

    .connection-bar {
        flex-wrap: wrap
    }

    .connection-center {
        order: 3;
        width: 100%
    }
}