:root {
  --bg: #0e1116;
  --bg2: #161b22;
  --bg3: #1f2630;
  --line: #2b3341;
  --text: #e6e8eb;
  --muted: #8b96a5;
  --accent: #2f81f7;
  --green: #3fb950;
  --red: #f85149;
  --amber: #e3b341;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.boot { padding: 40px; color: var(--muted); text-align: center; }

/* Layout */
header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--line);
}
header.top .logo { font-weight: 700; font-size: 17px; }
header.top .logo span { color: var(--accent); }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-size: 14px;
}
nav.tabs a.active { background: var(--bg3); color: var(--text); }
nav.tabs a .pill {
  background: var(--red); color: #fff; border-radius: 9px; font-size: 11px;
  padding: 1px 6px; margin-left: 5px; font-weight: 600;
}
main { max-width: 980px; margin: 0 auto; padding: 14px; padding-bottom: 60px; }

/* Cards & lists */
.card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 16px; margin-bottom: 10px; }
.card h3 { font-size: 14px; margin: 12px 0 6px; color: var(--muted); }
.list-item {
  display: block; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; color: var(--text); cursor: pointer;
}
.list-item:hover { border-color: var(--accent); }
.list-item .row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.list-item .who { font-weight: 600; }
.list-item .msg { color: var(--text); word-break: break-word; }
.list-item .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Badges */
.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.page { color: var(--accent); border-color: rgba(47,129,247,.4); }
.badge.escalated { color: var(--amber); border-color: rgba(227,179,65,.45); }
.badge.replied { color: var(--green); border-color: rgba(63,185,80,.4); }
.badge.queued { color: var(--accent); border-color: rgba(47,129,247,.4); }
.badge.banned, .badge.hidden, .badge.deleted { color: var(--red); border-color: rgba(248,81,73,.4); }
.badge.new, .badge.processing { color: var(--muted); }
.badge.img { color: #b083f0; border-color: rgba(176,131,240,.4); }
.badge.conf-hi { color: var(--green); border-color: rgba(63,185,80,.4); }
.badge.conf-lo { color: var(--amber); border-color: rgba(227,179,65,.4); }

/* Chips row */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 12px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 18px; color: var(--muted); font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Forms */
label.f { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > * { flex: 1; }
.inline > .fix { flex: 0 0 auto; }

/* Buttons */
button {
  font: inherit; border: none; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  background: var(--bg3); color: var(--text); font-weight: 500;
}
button:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); color: #fff; }
button.good { background: var(--green); color: #06120a; }
button.danger { background: var(--red); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Detail view */
.kv { color: var(--muted); font-size: 13px; margin-bottom: 3px; }
.kv b { color: var(--text); font-weight: 600; }
.quote {
  border-left: 3px solid var(--line); padding: 8px 12px; margin: 8px 0;
  background: var(--bg); border-radius: 0 8px 8px 0; color: var(--muted); font-size: 14px;
}
.quote.hot { border-left-color: var(--accent); color: var(--text); font-size: 15px; }
.aibox { border: 1px dashed rgba(47,129,247,.5); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.aibox .t { color: var(--accent); font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
img.attach { max-width: 100%; max-height: 340px; border-radius: 8px; margin: 8px 0; border: 1px solid var(--line); }

/* Misc */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--green); }
.warn { color: var(--amber); }
.err { color: var(--red); }
.spacer { height: 8px; }
.center { text-align: center; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.t th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; z-index: 99; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.err { border-color: var(--red); }

/* Login */
.login-wrap { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login-wrap .logo { font-size: 26px; font-weight: 700; text-align: center; margin-bottom: 18px; }
.login-wrap .logo span { color: var(--accent); }

/* Chat */
.chatlog { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.bub { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.bub.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bub.bot { align-self: flex-start; background: var(--bg3); border-bottom-left-radius: 4px; }
.bub .vmeta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.bub.user .vmeta { color: rgba(255,255,255,.75); }

@media (max-width: 640px) {
  main { padding: 10px; }
  header.top { padding: 8px 10px; }
  .inline { flex-direction: column; align-items: stretch; }
  .inline > * { width: 100%; }
}
