: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;
}

/* ---- layout: collapsible sidebar + content ---- */
.brand { color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .3px; }
.brand-sm { color: var(--text); text-decoration: none; font-weight: 700; }
.material-symbols-outlined { font-size: 20px; line-height: 1; vertical-align: middle; }

.icon-btn {
  background: none; border: none; color: var(--text); cursor: pointer;
  display: inline-flex; padding: 4px; border-radius: 6px;
}
.icon-btn:hover { background: rgba(255, 255, 255, .06); }

.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 30;
  transform: translateX(-100%); transition: transform .18s ease;
}
body.nav-open .sidebar { transform: translateX(0); }

.content { margin-left: 0; min-height: 100vh; transition: margin-left .18s ease; }
body.nav-open .content { margin-left: 260px; }

.mtop {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
body.nav-open .mtop { display: none; }

.scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px; }
.side-newchat {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 12px; padding: 10px 12px;
  background: var(--accent-soft); color: var(--text); text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px; font-weight: 600;
}
.side-newchat:hover { border-color: var(--accent); }
.side-sessions { flex: 1 1 auto; overflow-y: auto; padding: 6px 8px; }
.side-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; }
.session-list { list-style: none; margin: 0; padding: 0; }
.session-item a {
  display: block; color: var(--text); text-decoration: none;
  padding: 8px 10px; border-radius: 6px; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item a:hover { background: rgba(255, 255, 255, .05); }
.session-item.active a { background: var(--accent-soft); color: var(--accent); }
.session-empty, .side-hint { color: var(--muted); font-size: 13px; padding: 8px 10px; }
.side-account {
  border-top: 1px solid var(--line); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.acct-email { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.acct-link:hover { text-decoration: underline; }
.gbtn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--panel); color: var(--text); text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-weight: 600; font-size: 13px;
}
.gbtn:hover { border-color: var(--accent); }
.gmark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; color: #4285f4; font-weight: 700; font-size: 12px;
}

@media (max-width: 820px) {
  .sidebar { width: 82vw; max-width: 300px; }
  body.nav-open .content { margin-left: 0; }
  body.nav-open .scrim { display: block; }
}

#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; }

.answer table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0 4px;
  font-size: 15px;
}
.answer th, .answer td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.answer thead th {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}
.answer tbody tr:nth-child(even) { background: rgba(255, 255, 255, .02); }

.answer pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0 4px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
}
.answer pre code { background: none; padding: 0; font-size: inherit; }
.answer code {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.illus {
  margin: 14px 0 4px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}
.illus svg { max-width: 100%; height: auto; }
.illus-pending {
  color: var(--muted); font-size: 14px; text-align: left;
  animation: illus-pulse 1.5s ease-in-out infinite;
}
@keyframes illus-pulse {
  0%, 100% { opacity: .45; border-color: var(--line); }
  50%      { opacity: 1;   border-color: var(--accent); }
}

.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);
  transition: left .18s ease;
}
body.nav-open .composer { left: 260px; }
@media (max-width: 820px) { body.nav-open .composer { left: 0; } }
.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: "…"; }
