/* ==========================================================================
   NullTrace UI — polished dark theme
   Keeps IDs/classes used by app.js and index.html
   ========================================================================== */

/* 1) Local Inter fonts */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/Inter-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
}

/* 2) Theme tokens (Dark) */
:root {
  --bg: #0b0e14;
  --bg-2: #0d1117;
  --panel: #0f1420;
  --panel-2: #0d141c;
  --surface: #101623;
  --border: #1a2230;

  --txt: #eaf5ff;
  --muted: #9aa5b1;

  --accent: #39ff14;     /* neon green */
  --accent-dim: #2dd10f;
  --accent-2: #80d4ff;   /* cyan */

  --ok: #24d365;
  --warn: #facc15;
  --danger: #ff4d4f;

  --shadow: 0 12px 32px rgba(0,0,0,.35), 0 0 1px rgba(255,255,255,.04) inset;
  --ring: 0 0 0 2px color-mix(in oklab, var(--accent) 50%, transparent);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --gap: 16px;
  --gap-sm: 10px;

  --bottom-bar-height: 3.25rem;

  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
  font-size: 14px;
  color-scheme: dark;
}

/* Optional light palette (kept subtle) */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f9fc;
    --bg-2: #eef3f8;
    --panel: #ffffff;
    --panel-2: #f9fbfe;
    --surface: #ffffff;
    --border: #e4e9f1;

    --txt: #0a1020;
    --muted: #5c6b7a;

    --shadow: 0 6px 20px rgba(12,16,22,.08), 0 0 0 1px rgba(8,12,18,.04) inset;
  }
}

/* 3) Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
html, body {
  margin: 0;
  background:
    radial-gradient(1200px 800px at 20% -10%, color-mix(in oklab, var(--accent) 20%, transparent) 8%, transparent 60%),
    radial-gradient(1000px 700px at 90% 0%, color-mix(in oklab, var(--accent-2) 28%, transparent) 8%, transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--txt);
}

::selection {
  background: color-mix(in oklab, var(--accent) 25%, transparent);
  color: var(--txt);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; inline-size: auto; max-inline-size: 100%; }

h1,h2,h3,h4 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.55rem; letter-spacing: .2px; }
h2 { font-size: 1.25rem; color: var(--accent); }
h3 { font-size: 1.05rem; }
h4 { font-size: .96rem; }

code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  background: color-mix(in oklab, var(--panel-2) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 .35rem;
  font-size: .92em;
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; }

.visually-hidden {
  position: absolute !important;
  clip: rect(1px,1px,1px,1px);
  clip-path: inset(50%);
  block-size: 1px; inline-size: 1px;
  overflow: hidden; white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* 4) Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 28px);
}

/* 5) Topbar */
.topbar {
  display: flex;
  gap: var(--gap);
  align-items: center;
  justify-content: space-between;
  background: color-mix(in oklab, var(--panel) 86%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  backdrop-filter: saturate(140%) blur(8px);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 10px; }
.brand-copy { display: grid; gap: 2px; }
.app-title { letter-spacing: .2px; }
.app-sub { margin: 0; font-size: .85rem; color: var(--muted); }

.status-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #0f1520, #0c121a);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .2px;
}
@media (prefers-color-scheme: light) {
  .badge { background: #f6f9ff; color: #445469; }
}
.badge-live::before{
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(36,211,101,.75);
  display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(36,211,101,.75); }
  70% { box-shadow: 0 0 0 10px rgba(36,211,101,0); }
  100% { box-shadow: 0 0 0 0 rgba(36,211,101,0); }
}
@media (prefers-reduced-motion: reduce) {
  .badge-live::before { animation: none; }
}

/* 6) Hero */
.hero { margin-bottom: 18px; }
.hero-card {
  display: grid;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0) 60%),
    color-mix(in oklab, var(--panel) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 4vw, 24px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.actions { display: flex; gap: 8px; }

.room-input,
.compose-input,
input[type="text"],
input[type="search"] {
  width: 100%;
  background: linear-gradient(180deg, #0e141c, #0b1118);
  color: var(--txt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .8rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
@media (prefers-color-scheme: light) {
  .room-input,
  .compose-input,
  input[type="text"],
  input[type="search"] {
    background: #ffffff;
  }
}
.room-input:focus,
.compose-input:focus,
input:focus {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border));
  box-shadow: var(--ring);
}

.hero-points {
  margin: 2px 0 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 4px;
  color: var(--muted);
}

/* 7) Buttons */
button, .btn {
  --btn-bg: var(--accent);
  --btn-fg: #0b140a;
  --btn-bdr: color-mix(in oklab, var(--accent) 40%, var(--border));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--btn-bdr);
  background: linear-gradient(180deg, color-mix(in oklab, var(--btn-bg) 80%, #fff 0%), var(--btn-bg));
  color: var(--btn-fg);
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease, filter .15s ease, opacity .2s;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled,
button:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary { --btn-bg: var(--accent); --btn-fg: #071004; }
.btn.ghost   {
  --btn-bg: #121a20;
  --btn-fg: var(--txt);
  --btn-bdr: var(--border);
  background: linear-gradient(180deg, #121a20, #0e161c);
}
@media (prefers-color-scheme: light) {
  .btn.ghost { --btn-bg: #f0f4fa; --btn-fg: #0a1020; background: linear-gradient(180deg, #f7faff, #eef4fb); }
}
.btn.danger  { --btn-bg: var(--danger); --btn-fg: #1a0607; }

/* 8) Pending approvals */
.pending { margin: 6px 0 10px; }
.pending-list {
  list-style: none;
  padding: 0; margin: 0;
  display: grid; gap: 6px;
}
.pending-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(180deg, #0e1420, #0c1118);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.pending-list button {
  height: 30px; padding: 0 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, #15c371, #13b468);
  border: 1px solid color-mix(in oklab, var(--ok) 40%, var(--border));
  color: #04130d;
}

/* 9) Main grid (chat + roster) */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--gap);
  align-items: start;
  margin-bottom: 12px;
}

/* Chat */
.chat-shell {
  background: color-mix(in oklab, var(--panel-2) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 420px;
  max-height: 62vh;
  overflow: hidden;
  display: grid;
}
.chat {
  list-style: none; margin: 0; padding: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}
.chat li {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.03);
  border-left: 4px solid transparent;
  word-break: break-word;
}
.chat li.in   { color: var(--accent); background: linear-gradient(180deg, rgba(57,255,20,.05), rgba(57,255,20,0)); }
.chat li.out  { color: var(--accent-2); text-align: right; background: linear-gradient(180deg, rgba(128,212,255,.05), rgba(128,212,255,0)); }
.chat li.error{ color: var(--danger); }
.chat li.sys  { color: var(--muted); font-style: italic; text-align: center; }
.chat li button.burn{
  margin-left: .6rem;
  background: #1d2732;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px;
  height: 24px;
  font-size: .8em;
  cursor: pointer;
}
.chat li button.burn:hover { color: var(--txt); border-color: color-mix(in oklab, var(--muted) 40%, var(--border)); }

/* Custom scrollbar */
.chat::-webkit-scrollbar,
.user-list::-webkit-scrollbar { width: 10px; height: 10px; }
.chat::-webkit-scrollbar-thumb,
.user-list::-webkit-scrollbar-thumb {
  background: #1b2430; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
.chat::-webkit-scrollbar-thumb:hover,
.user-list::-webkit-scrollbar-thumb:hover { background: #243140; }

/* Roster */
.roster {
  background: color-mix(in oklab, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 420px;
  max-height: 62vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}
.roster-head { display: grid; gap: 2px; margin-bottom: 8px; }
.user-list { overflow: auto; padding-right: 4px; }
.user-entry {
  display: grid;
  grid-template-columns: 16px auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-radius: 8px;
}
.user-entry:hover { background: rgba(255,255,255,.03); }
.user-entry .user-icon {
  width: 12px; height: 12px; border-radius: 50%; background: currentColor;
}

/* 10) Bottom bar */
.bottom-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--gap);
  align-items: center;
  background: linear-gradient(180deg, rgba(16,22,30,.6), rgba(12,16,22,.9));
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  height: var(--bottom-bar-height);
  box-shadow: var(--shadow);
  margin-top: 10px;
}

.compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.compose-input { height: 38px; }
.controls { display: flex; gap: 10px; align-items: center; }
.controls .btn.danger,
.controls #disconnectBtn {
  background: linear-gradient(180deg, #ff4d4f, #e64547);
  border-color: color-mix(in oklab, var(--danger) 45%, var(--border));
  color: #1a0708;
}

/* 11) Feature sections */
.features {
  background: color-mix(in oklab, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin: 18px 0 8px;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
}
.feature {
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: transform .08s ease, box-shadow .15s ease, border-color .2s ease;
}
.feature:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklab, var(--accent-2) 30%, var(--border));
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* How it works list */
.how-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 10px;
}
.how-list li {
  position: relative;
  padding-left: 38px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #0f1522, #0c1219);
  display: flex;
  align-items: center;
  padding-block: 8px;
  padding-inline: 38px 12px;
}
.how-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--accent-2), color-mix(in oklab, var(--accent-2) 75%, #0a0f16));
  color: #081018;
  display: grid; place-items: center;
  font-weight: 700; font-size: .85rem;
  border: 1px solid color-mix(in oklab, var(--accent-2) 35%, var(--border));
}

/* 12) Dialogs */
.dlg,
dialog {
  background: color-mix(in oklab, var(--panel) 95%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  padding: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.03) inset;
  max-width: 520px;
}
dialog::backdrop {
  background: rgba(4,6,10,.55);
  backdrop-filter: blur(2px);
}
dialog textarea,
.dlg textarea {
  width: 100%; min-height: 92px; resize: vertical;
  background: linear-gradient(180deg, #0f141c, #0b1118);
  color: var(--txt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .7rem;
}
.dlg .dlg-buttons,
dialog .dlg-buttons {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px;
}
.confirm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

/* 13) Focus states */
input, textarea, button, .btn { outline: none; }
input:focus-visible,
textarea:focus-visible,
button:focus-visible,
.btn:focus-visible { box-shadow: var(--ring); }

/* 14) Accessibility */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 15) Responsive */
@media (max-width: 1024px) {
  .grid { grid-template-columns: 1fr 260px; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .grid { grid-template-columns: 1fr; }
  .roster { order: -1; min-height: auto; max-height: none; }
  .chat-shell { max-height: 55vh; }
  .confirm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .hero-card { padding: 12px; }
  .quick-actions { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .feature-grid { grid-template-columns: 1fr; }
  .bottom-bar { grid-template-columns: 1fr; height: auto; }
  .compose { grid-template-columns: 1fr; }
}

/* 16) Legacy / stability */
.header-center { display: none; }            /* replaced by .topbar */
.welcome, .roadmap { display: none; }        /* replaced by .hero/.features */

#messages { padding: 6px; }
#userList { padding-right: 4px; }
#status.badge { min-width: 60px; justify-content: center; }
