/* NovaBot web client.
 *
 * The Grok-style roster and chat, served by the same daemon that the iPhone
 * app talks to. One client, one contract, two ways in.
 */

:root {
  --ink: #0b0b0c;
  --muted: #6b6b70;
  --line: #e8e8ea;
  --accent: #111113;
  --bg: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

#app { display: flex; height: 100%; }

/* ---- roster ---- */

#roster {
  width: 340px;
  min-width: 260px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  gap: 8px;
}

.roster-head h1 { font-size: 17px; font-weight: 600; margin: 0; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: #f6f6f7; }

.roster-list { overflow-y: auto; flex: 1; padding: 0 8px 24px; }

.roster-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
}
.roster-item:hover { background: #f6f6f7; }
.roster-item.active { background: #efeff1; }

.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 15px;
}
.avatar.square { border-radius: 12px; }

.roster-meta { min-width: 0; flex: 1; }
.roster-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  margin-left: 6px;
}

/* ---- chat ---- */

#chat { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-head .title { font-weight: 600; font-size: 16px; }
.chat-head .model { font-size: 12px; color: var(--muted); }
.chat-head .spacer { flex: 1; }

.messages { flex: 1; overflow-y: auto; padding: 20px 18px 8px; }

.msg { margin: 0 0 18px; max-width: 720px; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bubble {
  border-radius: 16px;
  padding: 10px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user .bubble { background: #f1f1f3; }
.msg.bot .bubble { background: #f7f7f8; border: 1px solid var(--line); }
.msg.error .bubble {
  background: #fff5f5;
  border: 1px solid #f0c4c4;
  color: #8a1f1f;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.msg .block-text { display: block; }
.msg .block-text + .block-text { margin-top: 8px; }

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 18px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px 16px;
  font: inherit;
  max-height: 160px;
  min-height: 40px;
}
.composer textarea:focus { outline: 2px solid #d9d9dd; }
.send {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.send:disabled { opacity: 0.35; }

.hint { font-size: 12px; color: var(--muted); padding: 0 18px 8px; }
.empty { color: var(--muted); font-size: 14px; padding: 40px 18px; text-align: center; }

/* ---- sheets ---- */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.28);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 20;
}
.sheet {
  background: #fff;
  border-radius: 16px;
  width: min(420px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px;
}
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
}

.option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
}
.option:hover { background: #f6f6f7; }
.option .t { font-weight: 500; font-size: 15px; }
.option .d { font-size: 12px; color: var(--muted); }
.option .mark { margin-left: auto; font-weight: 700; }

.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn {
  border-radius: 999px;
  padding: 9px 18px;
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ---- phone ---- */

@media (max-width: 720px) {
  #roster { width: 100%; min-width: 0; }
  #app.show-chat #roster { display: none; }
  #app:not(.show-chat) #chat { display: none; }
  .back { display: grid !important; }
}
.back { display: none; }
