:root {
  --bg: #000000;
  --text: #ffffff;
  --muted: #8e8e8e;
  --pill-dark: #141416;
  --panel: rgba(20, 20, 24, 0.72);
  --panel-solid: #101014;
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.4);
  --accent: #c8c8c8;
  --font-sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: "BubbledotICG-FinePos", "Geist Pixel Circle", monospace;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: #000;
  color: var(--text);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bg { position: absolute; inset: 0; background: #000; overflow: hidden; z-index: 0; }
.bg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; filter: brightness(0.5) saturate(0.8); }

.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---------- sidebar ---------- */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
}

.logo-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
}
.logo-btn:hover { transform: scale(1.05); }
.logo-btn img { width: 30px; height: 30px; object-fit: contain; }

.logo-text {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: -0.02em;
}

.sidebar-chats {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-chats::-webkit-scrollbar { width: 4px; }
.sidebar-chats::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  transition: background 0.18s ease, color 0.18s ease;
  border: 1px solid transparent;
}
.chat-item i { font-size: 11px; opacity: 0.7; }
.chat-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item:hover { background: rgba(255,255,255,0.06); color: #e5e5e5; }
.chat-item.active { background: rgba(255,255,255,0.1); color: #fff; border-color: var(--border); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.active-users {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.active-users .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.gh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.25s cubic-bezier(0.22,1,0.36,1), box-shadow 0.25s ease;
  box-shadow: var(--shadow);
}
.gh-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 20px rgba(255,255,255,0.25); }
.gh-btn:active { transform: translateY(0) scale(0.98); }
.gh-btn i { font-size: 15px; }

/* ---------- main ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  min-height: 56px;
}

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px; height: 40px;
  background: var(--pill-dark);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
}
.burger span { width: 18px; height: 1.5px; background: #fff; border-radius: 2px; transition: 0.25s ease; }

.model-select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.model-logo-sm {
  width: 26px; height: 26px;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255,255,255,0.9);
  padding: 2px;
}

.model-select {
  background: var(--pill-dark);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 32px 8px 14px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  max-width: 380px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c8c8c8' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.model-select:hover { border-color: var(--border-soft); }
.model-select:focus { border-color: var(--border-soft); }

.think-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--pill-dark);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
}
.think-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.think-select {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  padding: 2px;
}

.topbar-right { margin-left: auto; }
.privacy-note { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.privacy-note i { color: #34d399; }

/* ---------- chat ---------- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.empty {
  margin: auto;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}
.display-head {
  font-family: var(--font-display);
  font-size: clamp(28px, 6.2vw, 72px);
  letter-spacing: -0.04em;
  line-height: 1.12;
  white-space: nowrap;
  text-shadow: 0 4px 40px rgba(255,255,255,0.15);
}
.sub { margin-top: 14px; color: var(--muted); font-size: 14px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 22px 30px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.msg { display: flex; gap: 12px; animation: msgIn 0.3s cubic-bezier(0.22,1,0.36,1) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg-avatar {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.msg-avatar img { width: 22px; height: 22px; object-fit: contain; }
.msg-avatar.user { background: var(--pill-dark); color: #fff; font-size: 12px; font-weight: 600; }

.msg-body { min-width: 0; flex: 1; }
.msg-role { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }

.bubble {
  font-size: 14.5px;
  line-height: 1.62;
  color: #eaeaea;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* reasoning block */
.reasoning {
  border-left: 2px solid rgba(255,255,255,0.2);
  padding: 2px 0 6px 12px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  white-space: pre-wrap;
}

/* thinking dots */
.think-anim { display: inline-flex; gap: 4px; padding: 4px 0; }
.think-anim span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: think 1.2s ease-in-out infinite; }
.think-anim span:nth-child(2) { animation-delay: 0.15s; }
.think-anim span:nth-child(3) { animation-delay: 0.3s; }
@keyframes think { 0%,100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-4px); opacity: 1; } }

/* code blocks */
.bubble pre {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}
.bubble code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.92em; background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 5px; }
.bubble pre code { background: none; padding: 0; }
.bubble .copy-btn { float: right; font-size: 11px; color: var(--muted); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; cursor: pointer; margin: 6px 6px 0 0; }

/* ---------- composer ---------- */
.composer-wrap {
  padding: 12px 18px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 12px 12px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease;
}
.composer:focus-within { border-color: var(--border-soft); }

.composer textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 40vh;
  min-height: 24px;
  padding: 4px 0;
}
.composer textarea::placeholder { color: var(--muted); }

.send-btn {
  width: 38px; height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #111;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.25s cubic-bezier(0.22,1,0.36,1), box-shadow 0.25s ease;
  box-shadow: 0 0 22px rgba(255,255,255,0.15);
}
.send-btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.05); box-shadow: 0 0 30px rgba(255,255,255,0.35); }
.send-btn:active:not(:disabled) { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn i { font-size: 14px; }

.privacy-warn { text-align: center; font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 99;
  box-shadow: var(--shadow);
  animation: msgIn 0.25s ease both;
}

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .burger { display: flex; }
  .app { flex-direction: column; }
  .model-select { max-width: 200px; }
  .privacy-note { display: none; }
  .display-head { font-size: clamp(28px, 9vw, 48px); }
}