*{ box-sizing:border-box; }
:root{
  --bg:#0b0b0b;
  --border:#222;
  --muted:#9a9a9a;

  --bubble-ai:#141414;
  --bubble-user:#1f1f1f;

  --input-bg:#2d2d2d;
  --input-border:#444;

  --btn-bg:#3b3b3b;
  --btn-bg-hover:#4a4a4a;

  --composer-gap:18px;
  --spacer-extra:28px;
}
html,body{
  height:100%;
  margin:0;
  background:var(--bg);
  color:#eaeaea;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto;
}
#app{ height:100%; display:flex; flex-direction:column; }

#topbar{
  position:sticky;
  top:0;
  z-index:5;
  display:flex;
  justify-content:center;
  padding:10px 0;
  background:linear-gradient(to bottom, rgba(11,11,11,.92), rgba(11,11,11,.65));
  backdrop-filter: blur(8px);
  border-bottom:1px solid #151515;
}
.topbar-inner{
  width:100%;
  max-width:760px;
  padding:0 14px;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}
.pill{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid #2a2a2a;
  background:#101010;
}
.pill label{ font-size:13px; color:#cfcfcf; }

select{
  background:#0f0f0f;
  color:#fff;
  border:1px solid #333;
  border-radius:10px;
  padding:6px 10px;
  outline:none;
}
select option{ background:#0f0f0f; color:#fff; }

.iconbtn{
  width:38px;height:38px;
  border-radius:999px;
  border:1px solid #2a2a2a;
  background:#101010;
  color:#fff;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
  transition:.15s;
}
.iconbtn:hover{ background:#161616; }

#history{
  flex:1;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  display:flex;
  justify-content:center;
  padding:18px 0 18px 0;
}
.chat{
  width:100%;
  max-width:760px;
  padding:0 16px;
}
.row{
  display:flex;
  gap:10px;
  margin:12px 0;
  align-items:flex-start;
}
.row.ai{ justify-content:flex-start; }
.row.user{ justify-content:flex-end; }

.avatar{
  width:34px;height:34px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 34px;
  font-weight:700;
  font-size:13px;
  user-select:none;
  border:1px solid var(--border);
}
.avatar.bot{ background:radial-gradient(circle at 30% 30%, #3a3a3a, #161616); }
.avatar.human{ background:radial-gradient(circle at 30% 30%, #404040, #1b1b1b); }

.content{
  display:flex;
  flex-direction:column;
  gap:6px;
  max-width:min(640px,78vw);
}
.meta{
  font-size:12px;
  color:var(--muted);
  padding:0 4px;
}
.bubble{
  padding:12px 14px;
  border-radius:16px;
  line-height:1.6;
  white-space:pre-wrap;
  word-break:break-word;
  border:1px solid var(--border);
}
.bubble.ai{ background:var(--bubble-ai); }
.bubble.user{ background:var(--bubble-user); }

.row.user .content{ align-items:flex-end; }
.row.user .meta{ text-align:right; }

.stats{
  font-size:12px;
  color:#7f7f7f;
  padding:0 4px;
  line-height:1.3;
}

#bottom-spacer{ width:100%; height:180px; }

.input-floating{
  position:fixed;
  bottom:var(--composer-gap);
  left:0;
  width:100%;
  display:flex;
  justify-content:center;
  pointer-events:none;
}
.input-inner{
  pointer-events:auto;
  width:100%;
  max-width:760px;
  margin:0 14px;
  background:var(--input-bg);
  border:1px solid var(--input-border);
  border-radius:26px;
  padding:10px 12px;
  display:flex;
  align-items:flex-end;
  gap:10px;
  box-shadow:0 10px 30px rgba(0,0,0,.45);
}
textarea#msg{
  flex:1;
  resize:none;
  border:none;
  outline:none;
  background:transparent;
  color:#fff;
  font-size:15px;
  max-height:200px;
  padding:6px 6px 6px 10px;
}
button#sendBtn{
  border:none;
  color:#fff;
  background:var(--btn-bg);
  padding:9px 14px;
  border-radius:18px;
  cursor:pointer;
  transition:.15s;
  flex:0 0 auto;
}
button#sendBtn:hover{ background:var(--btn-bg-hover); }

/* Settings */
#settingsMask{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:10;
  padding:16px;
}
#settings{
  width:min(760px,92vw);
  border:1px solid #2a2a2a;
  background:#0f0f0f;
  border-radius:18px;
  box-shadow:0 30px 80px rgba(0,0,0,.6);
  padding:14px;
}
#settingsHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
#settingsHeader h3{ margin:0; font-size:16px; color:#eaeaea; }
#settingsHeader .hint{ font-size:12px; color:#9f9f9f; }

.card{
  border:1px solid #242424;
  background:#101010;
  border-radius:14px;
  padding:12px;
  margin:10px 0;
}
.card h4{ margin:0 0 8px 0; font-size:14px; color:#eaeaea; }
.card p{ margin:0 0 10px 0; font-size:12px; color:#9c9c9c; line-height:1.5; }

.rowline{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 0;
  border-top:1px solid #1c1c1c;
}
.rowline:first-of-type{ border-top:none; }

.toggle{ display:flex; align-items:center; gap:10px; user-select:none; }
.toggle input{ transform: scale(1.1); }

.btns{ display:flex; gap:10px; flex-wrap:wrap; }

.smallbtn{
  border:1px solid #2a2a2a;
  background:#141414;
  color:#fff;
  border-radius:12px;
  padding:8px 12px;
  cursor:pointer;
}
.smallbtn:hover{ background:#1b1b1b; }
.smallbtn.danger{ border-color:#3a1f1f; background:#1a0f0f; }
.smallbtn.danger:hover{ background:#241010; }

#customPrompt{
  width:100%;
  min-height:160px;
  resize:vertical;
  border-radius:12px;
  background:#0f0f0f;
  border:1px solid #2f2f2f;
  color:#fff;
  padding:10px;
  outline:none;
  font-size:13px;
  line-height:1.5;
}

/* Donate modal */
#donateMask{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.65);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:30;
  padding:16px;
}
#donateCard{
  width:min(520px, 92vw);
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(16,16,16,0.92);
  box-shadow:0 30px 90px rgba(0,0,0,0.65);
  overflow:hidden;
}
#donateHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 14px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
#donateHead .t{ font-weight:700; }
#donateClose{
  width:34px;height:34px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(30,30,30,0.55);
  color:#fff;
  cursor:pointer;
}
#donateBody{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
#donateImg{
  width:100%;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.08);
  display:block;
}
#donateNote{
  font-size:12px;
  color:#bdbdbd;
  line-height:1.5;
}

@media (max-width:768px){
  .chat{ padding:0 12px; }
  .avatar{ width:30px;height:30px;flex-basis:30px;font-size:12px; }
  .content{ max-width:86vw; }
  textarea#msg{ font-size:16px; }
  .input-inner{ margin:0 10px;border-radius:20px; }
  button#sendBtn{ padding:9px 12px;border-radius:16px; }
  :root{ --composer-gap:12px; }
  .topbar-inner{ padding:0 10px; }
}

::-webkit-scrollbar{ width:6px; }
::-webkit-scrollbar-thumb{ background:#2a2a2a;border-radius:4px; }
