:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262b36;
  --text: #e7eaf0;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --accent-soft: #1d2a44;
  --hl: #ffd479;
  --hl-soft: #3a3320;
  --pref: #7ee0a0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .3px; }
.tag { color: var(--muted); font-size: 13px; }

#chat {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 140px;
}

.welcome { color: var(--muted); margin: 40px 0; }
.welcome p { margin: 0 0 8px; }
.welcome .sub { font-size: 14px; }

.node {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 64px;
}

.trigger {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.trigger-user_text { color: var(--accent); font-weight: 600; font-size: 15px; }
.trigger .mark { color: var(--accent); }

.answer {
  font-size: 18px;
  line-height: 1.55;
}
.answer.pending, .answer.failed { color: var(--muted); font-size: 16px; }

button.hl {
  background: var(--hl-soft);
  color: var(--hl);
  border: none;
  border-bottom: 1px dashed var(--hl);
  padding: 0 2px;
  margin: 0;
  font: inherit;
  cursor: pointer;
  border-radius: 3px;
}
button.hl:hover { background: var(--hl); color: #201a05; }

.menu {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-item {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: baseline;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}
.menu-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.menu-item .num {
  color: var(--muted);
  font-size: 13px;
  min-width: 16px;
}
.pref { color: var(--pref); font-size: 13px; }

.proactive {
  margin-top: 14px;
  padding: 10px 12px;
  background: #1a1610;
  border-left: 3px solid var(--hl);
  border-radius: 4px;
  font-size: 14px;
  color: #e8dcc2;
}
.ps-label { color: var(--hl); font-weight: 600; }

.composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.composer input {
  flex: 1;
  max-width: 640px;
  margin: 0 auto 0 max(20px, calc((100% - 760px) / 2 + 20px));
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
}
.composer input:focus { outline: none; border-color: var(--accent); }
.composer button {
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-right: max(20px, calc((100% - 760px) / 2 + 20px));
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pregen-off {
  position: fixed;
  bottom: 64px;
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---- admin ---- */
.admin { max-width: 960px; margin: 0 auto; }
.admin-bar { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 16px; }
.admin h1 { font-size: 20px; margin: 0; }
.admin h1 .back, .admin h1 a { color: var(--accent); text-decoration: none; }
.who { color: var(--muted); font-size: 13px; }
.who a { color: var(--accent); }
.muted { color: var(--muted); font-size: 14px; }
.nowrap { white-space: nowrap; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table tbody tr { cursor: pointer; }
.admin-table tbody tr:hover { background: var(--panel); }

.ttree, .tchildren { list-style: none; margin: 0; padding-left: 0; }
.tchildren { padding-left: 18px; border-left: 1px solid var(--line); margin-left: 8px; }
.tnode { padding: 8px 0 8px 10px; }
.thead { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.b-menu { background: #1d2a44; color: #6ea8fe; }
.b-annotation { background: var(--hl-soft); color: var(--hl); }
.b-user_text { background: #23301f; color: #7ee0a0; }
.ttrigger { font-weight: 600; }
.tstatus { font-size: 11px; color: var(--muted); }
.s-pending { color: var(--hl); }
.s-failed { color: #ff8080; }
.cur { font-size: 11px; color: #0b1220; background: var(--accent); padding: 1px 6px; border-radius: 4px; }
.is-current > .thead { outline: 1px dashed var(--accent); outline-offset: 4px; }
.tanswer { font-size: 15px; margin: 4px 0; }
.tmenu, .tann { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin: 4px 0; }
.tps { font-size: 12px; color: #e8dcc2; background: #1a1610; border-left: 2px solid var(--hl); padding: 4px 8px; margin: 4px 0; border-radius: 3px; }

/* ---- submit feedback ---- */
.composer-status {
  position: fixed;
  bottom: 72px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.composer button:disabled { opacity: .55; cursor: default; }
.composer button:disabled::after { content: "…"; }
