/* lsemu debug console (§13.6) — dark-first token palette. Self-contained, no
   external fonts or CDNs (must work offline). Flat surfaces, 0.5px borders,
   sentence case, equal-width type for logs/wire/footprint. */

:root {
  --bg:        #16161a;
  --bg-2:      #121215;
  --surface:   #1e1e23;
  --surface-2: #26262c;
  --surface-3: #2e2e35;
  --text:      #ecebe6;
  --text-2:    #b3b2ab;
  --text-3:    #807f78;
  --border:    rgba(236, 235, 230, 0.12);
  --border-2:  rgba(236, 235, 230, 0.22);
  --accent:    #6fb3f0;
  --accent-bg: #14375f;
  --ok:        #57c79f;
  --ok-bg:     #0c4536;
  --warn:      #e6a23a;
  --warn-bg:   #4d2f08;
  --danger:    #ef8a8a;
  --danger-bg: #5a1f1f;
  --idle:      #6c6b65;
  --radius:    8px;
  --radius-lg: 11px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); }

/* ───────────────────────── login ───────────────────────── */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #20202a 0%, var(--bg-2) 60%);
  z-index: 100;
}
.login-card {
  width: 340px; max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 24px 22px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  display: flex; flex-direction: column; gap: 12px;
}
.login-brand { display: flex; align-items: baseline; gap: 8px; }
.login-logo { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.login-sub { color: var(--text-3); font-size: 13px; }
.login-hint { margin: 0 0 2px; color: var(--text-2); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-3); }
.field input {
  font-family: inherit; font-size: 14px;
  background: var(--bg-2);
  color: var(--text);
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  padding: 9px 11px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  font-family: inherit; font-size: 14px; font-weight: 500;
  margin-top: 4px;
  background: var(--accent); color: #06243f;
  border: 0; border-radius: var(--radius);
  padding: 9px 14px; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 16px; }
.login-target { color: var(--text-3); font-size: 11.5px; font-family: var(--mono); word-break: break-all; }

/* ───────────────────────── top bar ───────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  border-bottom: 0.5px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; }

.conn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
  padding: 3px 10px; border: 0.5px solid var(--border); border-radius: 999px;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.conn.live .dot { background: var(--ok); }
.conn.live { color: var(--ok); border-color: var(--ok); }
.conn.down .dot { background: var(--danger); }
.conn.down { color: var(--danger); border-color: var(--danger); }

.btn-ghost {
  font-family: inherit; font-size: 12.5px; color: var(--text-2);
  background: transparent; border: 0.5px solid var(--border-2);
  border-radius: var(--radius); padding: 5px 11px; cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost:active { transform: scale(0.98); }

/* ───────────────────────── layout ───────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  height: calc(100vh - 47px);
  overflow: hidden;
}
@media (max-width: 820px) { .layout { grid-template-columns: 220px minmax(0,1fr); } }

/* ── sidebar (device list) ── */
.sidebar {
  border-right: 0.5px solid var(--border);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.side-head { display: flex; align-items: baseline; gap: 8px; padding: 14px 16px 8px; }
.side-head h2 { font-size: 13.5px; font-weight: 600; margin: 0; }
.side-head .count { color: var(--text-3); font-size: 12px; }
.filters { display: flex; gap: 5px; flex-wrap: wrap; padding: 0 14px 10px; }
.chip {
  font-family: inherit; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.chip:hover { border-color: var(--border-2); }
.chip.on { background: var(--accent-bg); color: var(--accent); border-color: transparent; }

.dev-list { overflow-y: auto; padding: 4px 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.dev {
  text-align: left; width: 100%;
  font-family: inherit;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 9px 11px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.dev:hover { border-color: var(--border-2); background: var(--surface-2); }
.dev.on { border-color: var(--accent); background: var(--accent-bg); }
.dev-top { display: flex; align-items: center; gap: 8px; }
.dev-name { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; letter-spacing: -0.01em; }
.dev-meta { display: flex; gap: 5px; flex-wrap: wrap; }

/* ── right panel ── */
.panel { overflow: hidden; display: flex; flex-direction: column; }
.panel-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.panel-empty-inner { text-align: center; color: var(--text-3); }
.ghost-icon { font-size: 42px; opacity: 0.4; margin-bottom: 10px; }
.panel-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.dev-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--border);
}
.dev-head .id { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.dev-head .did { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.type-tag { font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius); padding: 2px 9px; }
.tier-tag {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 2px 7px;
}

.state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
}
.state.mini { font-size: 11px; padding: 1px 8px; }
.state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); }
.state.s-active { background: var(--ok-bg); color: var(--ok); }
.state.s-active .dot { background: var(--ok); }
.state.s-offline { background: var(--surface-2); color: var(--text-3); }
.state.s-connecting, .state.s-backoff { background: var(--warn-bg); color: var(--warn); }
.state.s-connecting .dot, .state.s-backoff .dot { background: var(--warn); }
.state.s-failed { background: var(--danger-bg); color: var(--danger); }
.state.s-failed .dot { background: var(--danger); }

.online-btn {
  font-family: inherit; font-size: 12.5px; border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer;
  border: 0.5px solid var(--border-2); background: var(--surface); color: var(--text);
}
.online-btn:hover { background: var(--surface-2); }
.online-btn.to-offline { color: var(--danger); border-color: var(--danger); }
.online-btn.to-offline:hover { background: var(--danger-bg); }
.online-btn.to-online { color: var(--ok); border-color: var(--ok); }
.online-btn.to-online:hover { background: var(--ok-bg); }

/* ── tabs ── */
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 0.5px solid var(--border); background: var(--surface); }
.tab {
  font-family: inherit; font-size: 13px; color: var(--text-3);
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 11px 14px; cursor: pointer;
}
.tab:hover { color: var(--text-2); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

.tabpane { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tabpane.on { display: flex; }
#pane-control { overflow-y: auto; padding: 18px 20px; }

.divider { height: 0.5px; background: var(--border); margin: 16px 0; border: 0; }
.lbl { font-size: 12px; color: var(--text-3); margin: 0 0 8px; }
.notice {
  font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px; margin: 4px 0;
}
.notice.muted { color: var(--text-3); margin-top: 14px; }

/* triggers */
.triggers { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.tbtn {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 0.5px solid var(--border-2);
  border-radius: var(--radius); padding: 6px 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tbtn:hover:not(:disabled) { background: var(--accent-bg); border-color: transparent; color: var(--accent); }
.tbtn:active:not(:disabled) { transform: scale(0.98); }
.tbtn:disabled { opacity: 0.4; cursor: not-allowed; }
.tbtn .ic { font-size: 13px; line-height: 1; }
.conf {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px; border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.conf label { font-size: 12px; color: var(--text-3); }
.conf input[type=range] { width: 92px; accent-color: var(--accent); }
.conf .val { font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 30px; color: var(--text-2); }

/* enabled toggles */
.toggles { display: flex; flex-direction: column; gap: 6px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.toggle .cl { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); min-width: 64px; }
.toggle .nm { font-size: 13px; color: var(--text-3); flex: 1; }
.sw { position: relative; width: 38px; height: 22px; flex: 0 0 auto; }
.sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sw .track { position: absolute; inset: 0; background: var(--surface-3); border: 0.5px solid var(--border-2); border-radius: 999px; transition: background 0.12s; }
.sw .knob { position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--text-3); transition: transform 0.12s, background 0.12s; }
.sw input:checked + .track { background: var(--ok-bg); border-color: var(--ok); }
.sw input:checked + .track .knob { transform: translateX(16px); background: var(--ok); }
.sw input:disabled { cursor: not-allowed; }
.sw input:disabled + .track { opacity: 0.45; }

/* advertised cluster grid */
.cl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.cl-chip { display: flex; align-items: baseline; gap: 8px; background: var(--surface-2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 5px 10px; }
.cl-chip .cl-id { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.cl-chip .cl-nm { font-size: 12px; color: var(--text-3); }

/* ── streams (log + wire) ── */
.banner {
  font-size: 12px; color: var(--warn);
  background: var(--warn-bg); border-bottom: 0.5px solid var(--border);
  padding: 8px 16px; line-height: 1.45;
}
.banner code { font-family: var(--mono); font-size: 11px; background: rgba(0,0,0,0.25); padding: 1px 4px; border-radius: 4px; }
.stream-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-bottom: 0.5px solid var(--border); background: var(--surface);
}
.stream-toolbar .tail { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.stream-toolbar .tail input {
  width: 64px; font-family: var(--mono); font-size: 12px;
  background: var(--bg-2); color: var(--text); border: 0.5px solid var(--border-2); border-radius: 6px; padding: 3px 6px;
}
.chk { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.chk input { accent-color: var(--accent); }
.stream-state { font-size: 11.5px; color: var(--text-3); padding: 2px 9px; border: 0.5px solid var(--border); border-radius: 999px; }
.stream-state.live { color: var(--ok); border-color: var(--ok); }
.stream-state.down { color: var(--danger); border-color: var(--danger); }

.stream-body {
  flex: 1; overflow-y: auto; padding: 8px 0;
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--bg-2);
}
.raw-line { padding: 1px 16px; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.raw-line.err { color: var(--danger); }
.raw-line.warn { color: var(--warn); }

.wire-line { display: flex; align-items: baseline; gap: 8px; padding: 3px 16px; flex-wrap: wrap; border-bottom: 0.5px solid rgba(236,235,230,0.04); }
.wt-type { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); flex: 0 0 auto; }
.wt-conn .wt-type, .wire-line.wt-conn .wt-type { background: var(--accent-bg); color: var(--accent); }
.wire-line.wt-signin .wt-type { background: var(--ok-bg); color: var(--ok); }
.wire-line.wt-reconnect .wt-type { background: var(--warn-bg); color: var(--warn); }
.wire-line.wt-event .wt-type { background: #3a2a55; color: #c4a6f0; }
.wire-line.wt-cmd .wt-type { background: #2a3a55; color: #a6c4f0; }
.wt-tag { font-size: 11px; color: var(--text-3); }
.wt-text { font-size: 12px; color: var(--text-2); flex: 1; min-width: 120px; }
.wt-ids { display: flex; gap: 6px; flex-wrap: wrap; }
.id-pill { display: inline-flex; flex-direction: column; gap: 0; background: var(--surface-2); border: 0.5px solid var(--border); border-radius: 6px; padding: 2px 8px; }
.id-raw { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.id-meta { font-size: 10.5px; color: var(--text-3); }

.log-empty { color: var(--text-3); font-family: var(--sans); font-size: 13px; padding: 18px 16px; }

/* ── footprint ── */
#pane-footprint { overflow-y: auto; }
.fp-tier { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.fp-sections { padding: 16px 20px; }
.fp-group { font-size: 12px; color: var(--text-3); font-weight: 500; margin: 18px 0 10px; text-transform: none; }
.fp-group:first-child { margin-top: 0; }
.fp-row { margin-bottom: 14px; }
.fp-row-head { display: flex; align-items: baseline; gap: 8px; }
.fp-name { font-family: var(--mono); font-size: 12.5px; color: var(--text); min-width: 90px; }
.fp-nums { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.fp-badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 8px; border-radius: 999px; }
.fp-badge.ok { background: var(--ok-bg); color: var(--ok); }
.fp-badge.bad { background: var(--danger-bg); color: var(--danger); }
.fp-bar { height: 8px; background: var(--surface-3); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.fp-fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.2s; }
.fp-fill.warn { background: var(--warn); }
.fp-fill.over { background: var(--danger); }
.fp-pct { font-size: 11px; color: var(--text-3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.fp-row.over .fp-name { color: var(--danger); }
.fp-raw { padding: 14px 20px; font-size: 12px; color: var(--text-2); white-space: pre-wrap; overflow-x: auto; }

/* ── misc ── */
.empty { border: 0.5px dashed var(--border-2); border-radius: var(--radius-lg); padding: 26px 18px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty.small { padding: 16px 12px; font-size: 12.5px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); color: var(--text);
  border: 0.5px solid var(--border-2);
  font-size: 13px; padding: 8px 16px; border-radius: var(--radius);
  opacity: 0; pointer-events: none; transition: opacity 0.18s; z-index: 50;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
