*{ 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;

  --content-max:760px;
  --content-side:14px;
}

html,body{
  height:100%;
  margin:0;
  background:var(--bg);
  color:#eaeaea;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",sans-serif;
}

body{
  overflow-x:hidden;
}

#app{
  height:100%;
  display:flex;
  flex-direction:column;
}

#topbar{
  position:sticky;
  top:0;
  z-index:5;
  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-shell{
  width:100%;
  max-width:var(--content-max);
  margin:0 auto;
  padding:10px var(--content-side);
}

.topbar-scroll{
  width:100%;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
}

.topbar-scroll::-webkit-scrollbar{
  display:none;
}

.topbar-inner{
  width:max-content;
  min-width:100%;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:nowrap;
}

.pill{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid #2a2a2a;
  background:#101010;
  flex:0 0 auto;
}

.model-pill{
  min-width:260px;
}

.model-label{
  font-size:13px;
  color:#cfcfcf;
  white-space:nowrap;
  flex:0 0 auto;
}

select{
  background:#0f0f0f;
  color:#fff;
  border:1px solid #333;
  border-radius:10px;
  padding:6px 10px;
  outline:none;
  min-width:180px;
  flex:0 0 auto;
}

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;
  font-family:"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji","Segoe UI Symbol",sans-serif;
  flex:0 0 38px;
}

.iconbtn:hover{
  background:#161616;
}

.emoji{
  line-height:1;
  display:inline-block;
}

#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:var(--content-max);
  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:var(--content-max);
  margin:0 var(--content-side);
  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);
  max-height:min(90vh,860px);
  overflow-y:auto;
  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);
}

.field-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  margin:10px 0 4px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.field.wide{
  grid-column:1 / -1;
}

.field span{
  font-size:12px;
  color:#bdbdbd;
}

.field input{
  width:100%;
  border:1px solid #2f2f2f;
  border-radius:12px;
  background:#0f0f0f;
  color:#fff;
  outline:none;
  padding:9px 10px;
  font-size:13px;
}

.field input:focus{
  border-color:#4a4a4a;
}

.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);
  max-height:90vh;
  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);
  display:flex;
  flex-direction:column;
}

#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;
  overflow-y:auto;
}

#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){
  :root{
    --composer-gap:12px;
    --content-side:10px;
  }

  .topbar-shell{
    padding:8px var(--content-side);
  }

  .topbar-inner{
    gap:8px;
  }

  .iconbtn{
    width:36px;
    height:36px;
    flex:0 0 36px;
    font-size:17px;
  }

  .pill{
    padding:7px 10px;
  }

  .model-pill{
    min-width:220px;
  }

  .model-label{
    font-size:12px;
  }

  select{
    min-width:130px;
    font-size:15px;
  }

  .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{
    border-radius:20px;
  }

  .field-grid{
    grid-template-columns:1fr;
  }

  .field.wide{
    grid-column:auto;
  }

  button#sendBtn{
    padding:9px 12px;
    border-radius:16px;
  }
}

::-webkit-scrollbar{
  width:6px;
  height:6px;
}

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