* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
  background: #0f0f0f;
  color: #e4e4e4;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.header {
  background: #1a1a1a;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}
.header .tokens {
  margin-left: auto;
  font-size: 12px;
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.header .new-chat {
  background: #2a2a2a;
  color: #e4e4e4;
  border: 1px solid #3a3a3a;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.header .new-chat:hover {
  background: #3a3a3a;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.message.user {
  align-self: flex-end;
  background: #007aff;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.message.bot {
  align-self: flex-start;
  background: #2a2a2a;
  color: #e4e4e4;
  border-bottom-left-radius: 4px;
}
.message.error {
  align-self: center;
  background: #3a1a1a;
  color: #ff6b6b;
  font-size: 12px;
}
/* Rich (markdown/html) bot messages: block layout, no pre-wrap. */
.message.bot.rich {
  white-space: normal;
}
.message.bot.rich a {
  color: #6cb2ff;
  text-decoration: underline;
  word-break: break-all;
}
.message.bot.rich code {
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.message.bot.rich pre {
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.message.bot.rich pre code {
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
}
.message.bot.rich ul,
.message.bot.rich ol {
  margin: 6px 0;
  padding-left: 22px;
}
.message.bot.rich li {
  margin: 2px 0;
}
.message.bot.rich blockquote {
  border-left: 3px solid #555;
  padding-left: 10px;
  margin: 6px 0;
  color: #b8b8b8;
}
.message.bot.rich h1, .message.bot.rich h2, .message.bot.rich h3,
.message.bot.rich h4, .message.bot.rich h5, .message.bot.rich h6 {
  font-size: 1.05em;
  margin: 8px 0 4px;
  color: #ffffff;
}
.message.bot.rich hr {
  border: none;
  border-top: 1px solid #3a3a3a;
  margin: 8px 0;
}
.message.bot.rich .action-line {
  border-left: 3px solid #007aff;
  background: #223349;
  border-radius: 0 8px 8px 0;
  padding: 6px 10px;
  margin: 6px 0;
  font-weight: 600;
}
/* Inline action inside that notice ("Click here"): a real anchor rendered as a
   compact button, so the one click that enables web search and re-sends the
   message reads as clickable rather than as prose. */
.message.bot.rich .action-line a {
  background: #007aff;
  color: #ffffff;
  border-radius: 10px;
  padding: 1px 8px;
  text-decoration: none;
  white-space: nowrap;
  word-break: normal;
}
.message.bot.rich .action-line a:hover {
  background: #0066d6;
}
/* Per-answer save button: floats on the bubble corner, visible on hover. */
.message.bot {
  position: relative;
}
.msg-save {
  position: absolute;
  top: -10px;
  right: -10px;
  background: #1a1a1a;
  color: #9a9a9a;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.message.bot:hover .msg-save {
  opacity: 1;
}
.msg-save:hover {
  color: #e4e4e4;
  background: #2a2a2a;
}
/* "Thinking…" bubble shown while the model is responding. */
.message.thinking {
  align-self: flex-start;
  background: #2a2a2a;
  color: #9a9a9a;
  border-bottom-left-radius: 4px;
}
.thinking-dots::after {
  content: '';
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: thinking-dots 1.2s steps(4, end) infinite;
}
@keyframes thinking-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}
.input-area {
  background: #1a1a1a;
  padding: 12px 20px 16px;
  border-top: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Visible web-search checkbox: a real, standard checkbox above the input row so
   it reads clearly as an option rather than as one of the header buttons. */
.web-search-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  font-size: 13px;
  color: #b8b8b8;
  cursor: pointer;
  user-select: none;
}
.web-search-toggle input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #007aff;
  cursor: pointer;
}
.web-search-toggle:hover {
  color: #e4e4e4;
}
.web-search-toggle input:checked + span {
  color: #6cb2ff;
}
/* Keyboard focus ring on the checkbox only (no outline on mouse click). */
.web-search-toggle input:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: 2px;
}
.input-row {
  display: flex;
  gap: 12px;
}
.input-row input {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 24px;
  padding: 12px 20px;
  color: #e4e4e4;
  font-size: 14px;
  outline: none;
}
.input-row input:focus {
  border-color: #007aff;
}
.input-row input::placeholder {
  color: #666;
}
.input-row button {
  background: #007aff;
  color: #ffffff;
  border: none;
  border-radius: 24px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.input-row button:hover {
  background: #0066d6;
}
.input-row button:disabled {
  background: #3a3a3a;
  cursor: not-allowed;
}

.back {
  display: block;
  padding: 8px 20px;
  font-size: 13px;
  color: #9a9a9a;
  text-decoration: none;
}
.back:hover {
  color: #ffffff;
  background: #161616;
}
