:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f4f5f7;
  background: #0f121a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #0f121a; }
body { min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }
.shell { min-height: 100vh; }

.login-card {
  width: min(440px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #e1063a;
  color: white;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 18px 48px rgba(225, 6, 58, 0.26);
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 19px; }

.eyebrow {
  margin: 22px 0 6px;
  color: #9aa2b3;
  font-size: 11px;
  letter-spacing: .16em;
  font-weight: 700;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(32px, 7vw, 48px); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 18px; letter-spacing: -.02em; }
.muted { color: #9aa2b3; }
.error { min-height: 22px; margin-top: 14px; color: #ff7895; }

.stack { display: grid; gap: 14px; margin-top: 26px; }
label span { display: block; margin-bottom: 7px; color: #b8bfcc; font-size: 13px; }
input, textarea, select {
  width: 100%;
  border: 1px solid #2a3140;
  background: #151a24;
  color: #f7f8fa;
  border-radius: 12px;
  outline: none;
}
input { padding: 13px 14px; }
input:focus, textarea:focus, select:focus { border-color: #59647a; box-shadow: 0 0 0 3px rgba(89,100,122,.16); }

.primary, .secondary, .ghost, .send {
  border: 0;
  border-radius: 12px;
  color: white;
}
.primary { padding: 13px 16px; background: #e1063a; font-weight: 700; }
.primary:disabled, .send:disabled { opacity: .5; cursor: default; }
.secondary { padding: 10px 12px; background: #202633; border: 1px solid #303849; }
.ghost { padding: 8px 10px; background: transparent; color: #aeb6c5; }

.app { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #222936;
  background: #0c0f16;
}
.sidebar-top { padding: 20px 18px 14px; display: grid; gap: 16px; }
.brand-row { display: flex; align-items: center; gap: 11px; }
.brand-row strong, .brand-row span { display: block; }
.brand-row span { color: #8f98a9; font-size: 12px; margin-top: 2px; }

.node-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 7px 9px;
  border-radius: 999px;
  background: #171c26;
  color: #aab2c0;
  font-size: 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #747d8d; }
.node-badge.online .dot { background: #5ed29a; box-shadow: 0 0 0 4px rgba(94,210,154,.09); }
.node-badge.degraded .dot { background: #f1b35f; }
.node-badge.offline .dot { background: #747d8d; }

.session-list { flex: 1; overflow: auto; padding: 6px 10px 16px; }
.session-item {
  width: 100%;
  display: block;
  text-align: left;
  padding: 10px 11px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #cbd1dc;
}
.session-item:hover { background: #151a23; }
.session-item.active { background: #191f2b; border-color: #2a3343; color: white; }
.session-item small { display: block; margin-top: 4px; color: #747e90; }
.sidebar-bottom { padding: 12px 16px; border-top: 1px solid #202633; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.sidebar-bottom .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.chat-panel { min-width: 0; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid #202735;
  background: rgba(15, 18, 26, .88);
  backdrop-filter: blur(12px);
}
.chat-header .eyebrow { margin: 0 0 4px; }
.context-control { min-width: 145px; }
.context-control span { margin-bottom: 5px; }
select { padding: 8px 10px; }

.messages {
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 28px 24px 140px;
  overflow-wrap: anywhere;
}
.empty-state { color: #7f8898; text-align: center; padding: 80px 20px; }
.message { margin: 0 0 22px; }
.message .role { margin-bottom: 7px; color: #818b9d; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.message .bubble { white-space: pre-wrap; line-height: 1.62; }
.message.user { margin-left: auto; max-width: 78%; }
.message.user .role { text-align: right; }
.message.user .bubble {
  width: fit-content;
  margin-left: auto;
  padding: 11px 14px;
  border-radius: 16px 16px 4px 16px;
  background: #202735;
  color: #f4f5f7;
}
.message.assistant { max-width: 92%; }
.message.assistant .bubble { color: #e8ebf0; }

.composer-wrap {
  position: fixed;
  left: 280px;
  right: 0;
  bottom: 0;
  padding: 14px 24px 12px;
  background: linear-gradient(180deg, rgba(15,18,26,0), #0f121a 26%, #0f121a 100%);
}
.composer { width: min(850px, 100%); margin: 0 auto; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
textarea { min-height: 52px; max-height: 180px; resize: none; padding: 14px 15px; line-height: 1.45; }
.send { width: 46px; height: 46px; background: #e1063a; font-size: 24px; font-weight: 700; }
.job-status { width: min(850px, 100%); min-height: 20px; margin: 0 auto 4px; color: #8e98aa; font-size: 12px; }
.fineprint { width: min(850px, 100%); margin: 7px auto 0; text-align: center; color: #626c7d; font-size: 10px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid #202735; }
  .sidebar-top { grid-template-columns: 1fr auto; align-items: center; padding: 12px 14px; }
  .brand-row { grid-column: 1; }
  .node-badge { grid-column: 2; grid-row: 1; }
  .secondary { grid-column: 1 / -1; }
  .session-list { display: none; }
  .sidebar-bottom { display: none; }
  .chat-header { padding: 12px 14px; }
  .context-control { min-width: 120px; }
  .messages { padding: 22px 14px 140px; }
  .message.user { max-width: 88%; }
  .composer-wrap { left: 0; padding: 12px 14px 10px; }
}
