@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&family=Baloo+2:wght@500;700&display=swap');

:root {
  --bg: #14171c;
  --surface: #1b1f26;
  --border: #2a2f38;
  --text: #e7e4dd;
  --text-muted: #8b93a1;
  --straight: #5b8dbf;
  --straight-dim: #3f6183;
  --eli5: #e8a33d;
  --eli5-dim: #a9752c;
  --code: #5bbf8d;
  --code-dim: #3f8a63;
  --accent-color: var(--straight);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 12px;
}
.bar h1 { font-size: 18px; font-weight: 600; margin: 0; }

.switcher { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border); padding: 3px; border-radius: 20px; flex-wrap: wrap; }
.tab {
  appearance: none; border: none; background: transparent; color: var(--text-muted);
  font-family: inherit; font-size: 13.5px; font-weight: 500; padding: 7px 14px; cursor: pointer;
  border-radius: 16px;
  transition: box-shadow 0.2s ease;
}
.tab-straight.is-active { background: var(--straight-dim); color: #fff; box-shadow: 0 0 10px color-mix(in srgb, var(--straight) 50%, transparent); }
.tab-eli5 { font-family: 'Baloo 2', 'IBM Plex Sans', sans-serif; }
.tab-eli5.is-active { background: var(--eli5-dim); color: #fff; box-shadow: 0 0 10px color-mix(in srgb, var(--eli5) 50%, transparent); }
.tab-code { font-family: 'IBM Plex Mono', monospace; }
.tab-code.is-active { background: var(--code-dim); color: #fff; box-shadow: 0 0 10px color-mix(in srgb, var(--code) 50%, transparent); }

/* ---------- thread ---------- */

.thread {
  flex: 1; overflow-y: auto; padding: 28px 24px 12px; max-width: 720px; width: 100%;
  margin: 0 auto; display: flex; flex-direction: column; gap: 18px;
}
.empty-state { margin: auto; text-align: center; color: var(--text-muted); max-width: 380px; }
.empty-headline { color: var(--text); font-size: 17px; font-weight: 500; margin: 0 0 6px; }
.empty-sub { font-size: 13.5px; margin: 0; }

.msg { max-width: 82%; line-height: 1.55; font-size: 15px; }
.msg-user { align-self: flex-end; background: var(--surface); border: 1px solid var(--border); padding: 10px 15px; border-radius: 16px 16px 4px 16px; }
.msg-bot { align-self: flex-start; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent-color); max-width: 92%; }
.msg-bot .msg-label { display: block; font-size: 11px; color: var(--accent-color); margin-bottom: 4px; font-weight: 600; }
.msg-bot.persona-eli5 { font-family: 'Baloo 2', 'IBM Plex Sans', sans-serif; font-size: 15.5px; }
.msg-bot.persona-straight { font-family: 'IBM Plex Mono', monospace; font-size: 14px; }
.msg-bot.persona-code { font-family: 'IBM Plex Sans', sans-serif; font-size: 14.5px; }
.thinking-row { display: flex; align-items: center; padding: 4px 0; }
.thinking-logo { width: 34px; height: 34px; border-radius: 9px; animation: logo-pulse 1.1s ease-in-out infinite; }
@keyframes logo-pulse { 0%, 100% { opacity: 0.55; transform: scale(0.92); filter: drop-shadow(0 0 0px var(--accent-color)); } 50% { opacity: 1; transform: scale(1.05); filter: drop-shadow(0 0 8px var(--accent-color)); } }
.msg img.msg-image { max-width: 220px; border-radius: 10px; display: block; margin-top: 6px; cursor: zoom-in; }

.msg-bot h1, .msg-bot h2, .msg-bot h3 { margin: 10px 0 6px; font-weight: 600; color: var(--text); }
.msg-bot h1 { font-size: 16.5px; } .msg-bot h2 { font-size: 15.5px; } .msg-bot h3 { font-size: 14.5px; }
.msg-bot p { margin: 6px 0; }
.msg-bot ul, .msg-bot ol { margin: 6px 0; padding-left: 20px; }
.msg-bot li { margin: 3px 0; }
.msg-bot code { background: var(--surface); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-family: 'IBM Plex Mono', monospace; font-size: 0.92em; }
.msg-bot .katex-display { margin: 10px 0; overflow-x: auto; overflow-y: hidden; }
.msg-bot .katex { color: var(--text); font-size: 1.05em; }
.msg-bot strong { color: var(--text); }

.code-block-wrap { position: relative; margin: 8px 0; }
.code-block-wrap pre { border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 13px; margin: 0; }
.code-block-wrap pre code { background: none; border: none; padding: 0; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted); font-size: 11px; padding: 4px 9px; border-radius: 6px;
  cursor: pointer; font-family: 'IBM Plex Sans', sans-serif;
}
.copy-btn:hover { color: var(--text); }

/* ---------- image preview ---------- */

.image-preview { max-width: 720px; width: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 10px; }
.image-preview[hidden] { display: none; }
.image-preview img { height: 56px; width: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; }
.image-preview button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1;
}

/* ---------- composer ---------- */

.composer { display: flex; gap: 8px; padding: 16px 24px 22px; max-width: 720px; width: 100%; margin: 0 auto; align-items: center; }

.icon-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease;
}
.icon-btn:hover { border-color: var(--accent-color, var(--straight)); color: var(--accent-color, var(--straight)); }
.icon-btn.listening { border-color: #e05c5c; color: #e05c5c; box-shadow: 0 0 10px rgba(224,92,92,0.5); }

#messageInput {
  flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 14.5px; padding: 11px 16px; outline: none;
  border-radius: 24px; min-width: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#messageInput:focus {
  border-color: var(--accent-color, var(--straight));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color, var(--straight)) 25%, transparent);
}

#sendBtn {
  flex-shrink: 0;
  background: var(--accent-color, var(--straight)); border: none; color: #14171c; font-family: inherit;
  font-weight: 600; font-size: 14px; padding: 0 20px; cursor: pointer;
  border-radius: 24px;
  transition: box-shadow 0.2s ease, transform 0.1s ease;
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent-color, var(--straight)) 45%, transparent);
}
#sendBtn:hover:not(:disabled) { box-shadow: 0 0 20px color-mix(in srgb, var(--accent-color, var(--straight)) 65%, transparent); }
#sendBtn:active:not(:disabled) { transform: scale(0.96); }
#sendBtn:disabled { opacity: 0.5; cursor: default; }

/* ---------- lightbox ---------- */

#lightbox {
  position: fixed; inset: 0; background: rgba(10,12,15,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
#lightboxClose {
  position: absolute; top: 18px; right: 20px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 18px;
  cursor: pointer;
}

@media (max-width: 480px) {
  .bar { padding: 14px 16px; }
  .thread { padding: 20px 16px 12px; }
  .composer { padding: 14px 16px 18px; }
  .image-preview { padding: 0 16px; }
  .msg { max-width: 92%; }
}
.bar h1 { font-size: 18px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; } .header-logo { height: 30px; width: auto; display: block; }
