:root {
    --bg: #0F172A;
    --bg-card: rgba(15, 23, 42, 0.8);
    --bg-input: rgba(10, 18, 35, 0.9);
    --text: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --primary: #10B981;
    --primary-glow: rgba(16, 185, 129, 0.15);
    --accent: #3B82F6;
    --accent-glow: rgba(59, 130, 246, 0.12);
    --red: #EF4444;
    --border: rgba(16, 185, 129, 0.1);
    --border-focus: rgba(16, 185, 129, 0.4);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --font: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    -webkit-font-smoothing: antialiased;
}

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

.app {
    max-width: 720px;
    margin: 0 auto;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.78rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-badge.active .status-dot {
    background: var(--primary);
    animation: pulse 1.5s infinite;
}

.status-badge.error .status-dot {
    background: var(--red);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), #059669);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-lg {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-xs);
    color: var(--red);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

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

/* Main */
.main {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.section-title-sm {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Connect Card */
.card-hero-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.card-hero-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* Port Input */
.port-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.port-input-group {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.port-input-group:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.port-prefix {
    font-family: var(--mono);
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.port-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--primary);
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.3rem 0.5rem;
    outline: none;
    width: 100px;
}

.port-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

/* Options */
.options-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.option-toggle input {
    display: none;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    transition: var(--transition);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 1px;
    left: 1px;
    transition: var(--transition);
}

.option-toggle input:checked~.toggle-switch {
    background: var(--primary-glow);
    border-color: var(--primary);
}

.option-toggle input:checked~.toggle-switch::after {
    background: var(--primary);
    left: 17px;
}

.password-field {
    flex: 1;
    min-width: 160px;
}

.text-input,
.select-input {
    width: 100%;
    padding: 0.45rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    outline: none;
}

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

.timeout-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.select-input {
    width: auto;
    min-width: 140px;
}

/* Session Card */
.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.share-url-box {
    margin-bottom: 1.25rem;
}

.share-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.4rem;
    display: block;
}

.url-row {
    display: flex;
    gap: 0.5rem;
}

.url-display {
    flex: 1;
    padding: 0.65rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--primary);
    word-break: break-all;
    display: flex;
    align-items: center;
}

/* QR */
.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.25rem;
}

.qr-canvas {
    width: 160px;
    height: 160px;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 8px;
}

.qr-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    text-align: center;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}

.stat-value {
    font-family: var(--mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* Log */
.log-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.log-entry {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(16, 185, 129, 0.04);
}

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

.log-entry .log-msg {
    color: var(--text-secondary);
}

.log-entry.log-connect .log-msg {
    color: var(--primary);
}

.log-entry.log-disconnect .log-msg {
    color: var(--red);
}

/* Session Meta */
.session-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.meta-item {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
}

.history-port {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--primary);
}

.history-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.history-duration {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.empty-state {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .main {
        padding: 0.75rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-hero-title {
        font-size: 1.15rem;
    }
}