:root {
  --primary: #10B981;
  --primary-dim: rgba(16,185,129,0.12);
  --secondary: #34D399;
  --accent: #F59E0B;
  --accent-dim: rgba(245,158,11,0.12);
  --bg: #0A0F0D;
  --bg-input: rgba(6,10,8,0.9);
  --border: rgba(16,185,129,0.1);
  --border-hover: rgba(16,185,129,0.2);
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 250ms ease;
  --glass: rgba(10,15,13,0.65);
  --glass-border: rgba(16,185,129,0.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.6;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(16,185,129,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(245,158,11,0.02) 0%, transparent 50%);
}
.app { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; min-height: 100vh; }

.header { padding: 16px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.header h1 { font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.status-badge { font-size: 0.68rem; padding: 3px 10px; border-radius: 12px; font-weight: 600; }
.status-badge.disconnected { background: rgba(239,68,68,0.1); color: #EF4444; }
.status-badge.connected { background: var(--primary-dim); color: var(--primary); }
.header-right { display: flex; gap: 6px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius-sm); border: none; font-family: var(--font); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn-primary { background: var(--primary); color: #0A0F0D; }
.btn-primary:hover { background: #059669; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--primary-dim); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.main { flex: 1; display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 16px 0; align-items: start; }

.panel { background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; animation: fadeIn 0.3s ease; }
.panel-header { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 0.88rem; font-weight: 600; }
.panel-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; }

.input, .select { width: 100%; padding: 6px 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: var(--font); font-size: 0.78rem; outline: none; transition: all var(--transition); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.field-label { display: flex; flex-direction: column; gap: 3px; font-size: 0.72rem; color: var(--text-dim); }
.section-title { font-size: 0.72rem; font-weight: 600; color: var(--text-dim); }
.divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* Toggles */
.toggle-row { display: flex; align-items: center; }
.toggle { font-size: 0.78rem; color: var(--text-dim); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle input { accent-color: var(--primary); }

/* Stats */
.stats { display: flex; flex-direction: column; gap: 4px; }
.stat-row { display: flex; justify-content: space-between; font-size: 0.72rem; }
.stat-label { color: var(--text-muted); }
.stat-value { font-family: var(--mono); color: var(--primary); font-weight: 600; }

/* Terminal */
.terminal-panel { display: flex; flex-direction: column; min-height: 500px; }
.terminal-body { flex: 1; display: flex; flex-direction: column; }
.terminal-output {
  flex: 1; background: #050A08; padding: 12px; font-family: var(--mono); font-size: 0.78rem;
  line-height: 1.6; overflow-y: auto; min-height: 400px; color: var(--secondary);
  border-bottom: 1px solid var(--border);
}
.terminal-output .ts { color: var(--text-muted); margin-right: 8px; }
.terminal-output .rx { color: var(--secondary); }
.terminal-output .tx { color: var(--accent); }
.terminal-output .sys { color: var(--text-muted); font-style: italic; }
.terminal-output .hex-byte { color: #60A5FA; margin-right: 4px; }

.send-row { display: flex; gap: 6px; padding: 10px 12px; }
.send-input { flex: 1; font-family: var(--mono); font-size: 0.82rem; }

/* Unsupported */
.unsupported-banner { padding: 16px; background: rgba(239,68,68,0.08); border-top: 1px solid rgba(239,68,68,0.2); text-align: center; font-size: 0.82rem; }
.unsupported-banner a { color: var(--primary); }

.footer { padding: 16px 0; text-align: center; font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: auto; }

.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
@media (max-width: 700px) { .main { grid-template-columns: 1fr; } .terminal-output { min-height: 250px; } }
