:root {
  --bg: #0e1116; --panel: #161b22; --line: #26303c; --fg: #e6edf3;
  --mut: #8b949e; --acc: #3b82f6; --ok: #2ea043; --bad: #f85149;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
a { color: var(--acc); }
.hidden { display: none !important; }
.muted { color: var(--mut); font-size: 13px; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.spacer { flex: 1; }
.stat { font-size: 13px; color: var(--mut); }
.stat b { color: var(--fg); }
.link-btn {
  color: var(--fg); text-decoration: none; font-size: 13px;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px;
}
.link-btn:hover { background: #0d1117; }

.layout { flex: 1; display: grid; grid-template-columns: 260px 1fr 320px; min-height: 0; }

.sidebar, .rail {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 12px; overflow-y: auto; min-height: 0;
}
.rail { border-right: none; border-left: 1px solid var(--line); }

.panel-block { margin-bottom: 16px; }
.lbl { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); margin: 8px 0 4px; }
.row { margin-bottom: 8px; }
.row.between { display: flex; align-items: center; justify-content: space-between; }

input, select, textarea, button {
  font: inherit; color: var(--fg); background: #0d1117;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
button { cursor: pointer; }
button.mini {
  background: var(--acc); border-color: var(--acc); font-weight: 600; font-size: 13px;
  padding: 6px 10px; width: auto;
}
button.link { background: none; border: none; color: var(--mut); width: auto; padding: 0 6px; font-size: 12px; }
button.link:hover { color: var(--bad); }
#send { width: auto; padding: 0 22px; background: var(--acc); border-color: var(--acc); font-weight: 600; }
#send:disabled { opacity: .5; }

.list { display: flex; flex-direction: column; gap: 4px; }
.conv-item, .expert-item {
  padding: 7px 9px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.conv-item:hover, .expert-item:hover { background: #0d1117; }
.conv-item.active, .expert-item.active { background: #12233b; border-color: var(--acc); }
.conv-title { font-size: 14px; }
.expert-name { font-size: 14px; font-weight: 600; }

.tabs { display: flex; gap: 6px; margin-top: 8px; }
.tab {
  flex: 1; background: #0d1117; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; padding: 6px;
}
.tab.active { background: var(--acc); border-color: var(--acc); font-weight: 600; }

.main { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 22px; max-width: 900px; width: 100%; margin: 0 auto; }
.empty { color: var(--mut); text-align: center; margin-top: 30vh; }
.msg { margin-bottom: 18px; }
.msg-role { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); margin-bottom: 4px; }
.msg-body {
  white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
}
.msg.user .msg-body { background: #12233b; }

.composer {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line);
  background: var(--panel); align-items: stretch;
}
.composer textarea { height: 48px; min-height: 48px; }

.mini-form { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.mem-item { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--line); }

.footer { padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--mut); text-align: center; }
.footer a { color: var(--mut); }

#toasts { position: fixed; right: 16px; bottom: 60px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { padding: 9px 14px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--bad); }

/* legal / docs pages */
.doc-page { max-width: 760px; margin: 0 auto; padding: 32px 20px; }
.doc-page h1 { margin-top: 0; }
.doc-page h2 { margin-top: 28px; }
.doc-page pre { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }

/* admin console */
.admin { max-width: 900px; margin: 0 auto; padding: 24px 20px; }
.admin section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th, .admin td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.admin .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar, .rail { display: none; }
}
