*{box-sizing:border-box}

:root{
  --bg:#0b0c10;
  --panel:#111319;
  --panel2:#171920;
  --border:#292c35;
  --text:#f2f3f5;
  --muted:#969ba8;
  --dim:#686d79;
  --hover:#1c1f27;
  --accent:#f5f6f8;
  --danger:#ff6b6b;
  --success:#7de2a6
}

html,body{
  margin:0;
  width:100%;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif
}

body{
  overflow:hidden
}

button,input,textarea{
  font:inherit
}

button{
  color:inherit;
  border:0;
  cursor:pointer
}

button:disabled{
  cursor:not-allowed;
  opacity:.5
}

.hidden{
  display:none!important
}

.app{
  display:flex;
  height:100vh;
  width:100%
}

.sidebar{
  width:286px;
  min-width:286px;
  height:100vh;
  background:#0f1015;
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  padding:13px;
  z-index:20
}

.sidebar-top{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:14px
}

.brand{
  background:transparent;
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:700;
  font-size:15px;
  padding:9px 8px;
  border-radius:10px;
  flex:1;
  text-align:left
}

.brand:hover{
  background:var(--hover)
}

.brand-icon,.auth-logo{
  display:grid;
  place-items:center;
  background:#f4f5f7;
  color:#101116;
  font-weight:800
}

.brand-icon{
  width:30px;
  height:30px;
  border-radius:9px;
  font-size:17px
}

.icon-btn{
  background:transparent;
  width:36px;
  height:36px;
  border-radius:9px;
  display:grid;
  place-items:center;
  color:#b9bdc7;
  font-size:18px
}

.icon-btn:hover{
  background:var(--hover);
  color:#fff
}

.close-sidebar{
  display:none
}

.new-chat{
  height:43px;
  border:1px solid var(--border);
  border-radius:11px;
  background:#17191f;
  display:flex;
  align-items:center;
  gap:9px;
  padding:0 13px;
  color:#e9eaee;
  font-size:14px;
  transition:.15s
}

.new-chat:hover{
  background:#22252d;
  border-color:#383c47
}

.search-wrap{
  height:38px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#14161c;
  display:flex;
  align-items:center;
  gap:8px;
  padding:0 10px;
  margin-top:10px;
  color:var(--dim)
}

.search-wrap input{
  width:100%;
  border:0;
  outline:0;
  background:transparent;
  color:var(--text);
  font-size:12px
}

.search-wrap input::placeholder{
  color:#6f7480
}

.history-title{
  color:#777c88;
  text-transform:uppercase;
  letter-spacing:.08em;
  font-size:10px;
  font-weight:700;
  margin:21px 8px 9px
}

.history{
  flex:1;
  overflow-y:auto;
  padding-right:2px
}

.history-empty{
  color:#666b76;
  font-size:12px;
  line-height:1.5;
  padding:8px
}

.history-item{
  width:100%;
  background:transparent;
  color:#bfc2ca;
  text-align:left;
  border-radius:9px;
  padding:10px;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  margin-bottom:3px
}

.history-item:hover,
.history-item.active{
  background:var(--hover);
  color:#fff
}

.sidebar-bottom{
  padding-top:9px
}

.sidebar-action{
  width:100%;
  background:transparent;
  color:#999eaa;
  text-align:left;
  padding:9px 10px;
  border-radius:8px;
  font-size:12px
}

.sidebar-action:hover{
  background:var(--hover);
  color:#fff
}

.project-card{
  display:flex;
  align-items:center;
  gap:10px;
  border-top:1px solid var(--border);
  margin-top:7px;
  padding:13px 5px 3px;
  cursor:pointer
}

.project-avatar{
  width:34px;
  height:34px;
  border-radius:50%;
  background:#2a2d35;
  display:grid;
  place-items:center;
  font-weight:700;
  font-size:12px
}

.project-card>div:nth-child(2){
  display:flex;
  flex-direction:column;
  min-width:0;
  flex:1
}

.project-card strong{
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis
}

.project-card small{
  color:#777c88;
  font-size:9px;
  margin-top:2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis
}

.account-chevron{
  color:#777c88
}

.main{
  flex:1;
  min-width:0;
  height:100vh;
  display:flex;
  flex-direction:column;
  background:var(--bg)
}

.topbar{
  height:60px;
  min-height:60px;
  display:flex;
  align-items:center;
  padding:0 17px;
  border-bottom:1px solid rgba(255,255,255,.045)
}

.menu-btn{
  display:none
}

.model-btn{
  background:transparent;
  font-size:14px;
  font-weight:650;
  padding:8px 9px;
  border-radius:8px
}

.model-btn:hover{
  background:var(--hover)
}

.model-btn span{
  color:#777c88;
  margin-left:5px
}

.top-right{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px
}

.status-pill{
  color:#8d929e;
  font-size:10px;
  display:flex;
  align-items:center;
  gap:6px
}

.status-pill i{
  width:6px;
  height:6px;
  background:var(--success);
  border-radius:50%;
  box-shadow:0 0 8px rgba(125,226,166,.5)
}

.top-account{
  border:1px solid var(--border);
  font-size:11px;
  width:30px;
  height:30px;
  border-radius:50%;
  background:#171920
}

.chat-area{
  flex:1;
  overflow-y:auto;
  scroll-behavior:smooth
}

.messages{
  width:min(860px,calc(100% - 32px));
  margin:0 auto;
  padding:38px 0 170px
}

.welcome{
  min-height:calc(100vh - 275px);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center
}

.welcome-icon{
  width:62px;
  height:62px;
  border-radius:18px;
  display:grid;
  place-items:center;
  background:#f5f6f8;
  color:#111319;
  font-size:29px;
  box-shadow:0 0 50px rgba(255,255,255,.08)
}

.welcome h1{
  margin:20px 0 7px;
  font-size:clamp(27px,4vw,36px);
  letter-spacing:-.035em
}

.welcome p{
  margin:0;
  color:var(--muted);
  font-size:14px
}

.suggestions{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:9px;
  margin-top:27px;
  width:min(600px,100%)
}

.suggestion{
  text-align:left;
  background:#14161b;
  border:1px solid var(--border);
  border-radius:12px;
  padding:14px;
  color:#bfc3cc;
  font-size:12px;
  transition:.15s
}

.suggestion:hover{
  background:#1c1f27;
  color:#fff;
  transform:translateY(-1px)
}

.message{
  display:flex;
  gap:13px;
  margin:0 0 28px;
  animation:fadeIn .18s ease-out
}

.avatar{
  width:31px;
  height:31px;
  min-width:31px;
  border-radius:9px;
  display:grid;
  place-items:center;
  font-size:12px;
  font-weight:700
}

.message.user .avatar{
  background:#2c3038
}

.message.assistant .avatar{
  background:#f5f6f8;
  color:#111319
}

.message-body{
  min-width:0;
  flex:1;
  line-height:1.7;
  font-size:14px;
  color:#e2e4e9;
  overflow-wrap:anywhere
}

.message.user .message-body{
  background:#252830;
  border-radius:5px 14px 14px 14px;
  padding:10px 13px;
  max-width:85%
}

.message-actions{
  display:flex;
  gap:3px;
  margin-top:8px
}

.message-actions button{
  background:transparent;
  color:#747a87;
  border-radius:6px;
  padding:4px 7px;
  font-size:10px
}

.message-actions button:hover{
  background:#1c1f26;
  color:#ddd
}

.code-wrap{
  margin:12px 0;
  background:#08090c;
  border:1px solid #292d35;
  border-radius:11px;
  overflow:hidden
}

.code-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:8px 10px;
  border-bottom:1px solid #242730;
  color:#858b97;
  font-size:10px
}

.code-copy{
  background:transparent;
  color:#8d939f;
  font-size:10px
}

.code-copy:hover{
  color:#fff
}

pre{
  margin:0;
  padding:14px;
  overflow-x:auto;
  font:12px/1.65 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  color:#ddd
}

.inline-code{
  background:#22252d;
  border-radius:5px;
  padding:2px 5px;
  font:12px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace
}

.typing{
  display:inline-flex;
  gap:4px;
  align-items:center;
  padding:8px 0
}

.typing i{
  width:5px;
  height:5px;
  background:#999;
  border-radius:50%;
  animation:bounce 1.1s infinite
}

.typing i:nth-child(2){
  animation-delay:.15s
}

.typing i:nth-child(3){
  animation-delay:.3s
}

.composer-wrap{
  position:relative;
  width:min(860px,calc(100% - 32px));
  margin:-115px auto 0;
  padding:48px 0 14px;
  z-index:5;
  background:linear-gradient(to bottom,transparent,var(--bg) 30%)
}

.composer{
  display:flex;
  align-items:flex-end;
  gap:8px;
  border:1px solid #343842;
  background:#17191f;
  border-radius:17px;
  padding:8px 8px 8px 15px;
  box-shadow:0 10px 40px rgba(0,0,0,.3)
}

.composer:focus-within{
  border-color:#4b505c
}

textarea{
  flex:1;
  resize:none;
  outline:0;
  border:0;
  background:transparent;
  color:#eee;
  min-height:24px;
  max-height:180px;
  padding:5px 0;
  line-height:1.45;
  font-size:14px
}

textarea::placeholder{
  color:#777c88
}

.send-btn{
  width:36px;
  height:36px;
  border-radius:10px;
  background:#eee;
  color:#111;
  display:grid;
  place-items:center;
  font-size:20px;
  font-weight:700;
  transition:.15s
}

.send-btn:hover{
  background:#fff;
  transform:translateY(-1px)
}

.composer-meta{
  display:flex;
  justify-content:space-between;
  color:#626773;
  font-size:9px;
  padding:7px 5px 0
}

.composer-note{
  text-align:center;
  color:#555b67;
  font-size:9px;
  padding-top:5px
}

.toast-container{
  position:fixed;
  right:18px;
  bottom:18px;
  z-index:100;
  display:flex;
  flex-direction:column;
  gap:8px
}

.toast{
  background:#1b1e25;
  border:1px solid #353943;
  color:#e9ebef;
  padding:10px 13px;
  border-radius:10px;
  font-size:11px;
  box-shadow:0 12px 35px rgba(0,0,0,.35);
  animation:fadeIn .2s
}

.toast.error{
  border-color:#61383b
}

.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.68);
  backdrop-filter:blur(8px);
  z-index:70;
  display:grid;
  place-items:center;
  padding:20px
}

.modal{
  position:relative;
  width:min(520px,100%);
  max-height:85vh;
  overflow:auto;
  background:#12141a;
  border:1px solid #30343e;
  border-radius:18px;
  padding:25px;
  box-shadow:0 25px 80px rgba(0,0,0,.55)
}

.modal-close{
  position:absolute;
  right:15px;
  top:13px;
  background:transparent;
  color:#858b97;
  font-size:22px
}

.modal h2{
  margin:0 0 7px;
  font-size:20px
}

.modal p{
  color:var(--muted);
  font-size:12px;
  line-height:1.6
}

.setting-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 0;
  border-top:1px solid #242730;
  font-size:12px
}

.setting-row small{
  display:block;
  color:#777c88;
  margin-top:4px
}

.toggle{
  width:42px;
  height:23px;
  border-radius:20px;
  background:#333741;
  position:relative
}

.toggle.on{
  background:#e9eaee
}

.toggle:after{
  content:"";
  position:absolute;
  width:17px;
  height:17px;
  top:3px;
  left:3px;
  border-radius:50%;
  background:#888
}

.toggle.on:after{
  left:22px;
  background:#15171c
}

.modal-actions{
  display:flex;
  gap:8px;
  margin-top:18px
}

.danger-btn,
.secondary-btn{
  padding:10px 13px;
  border-radius:9px;
  font-size:11px
}

.danger-btn{
  background:#3a2022;
  color:#ffb5b5
}

.secondary-btn{
  background:#242730
}


/* =========================
   AUTH SCREEN
   ========================= */

.auth-screen{
  position:fixed;
  inset:0;
  display:grid;
  place-items:center;
  background:radial-gradient(circle at 50% 10%,#171b25 0,#0b0c10 48%);
  padding:20px;
  z-index:90;

  /* MOBILE FIX */
  overflow-y:auto;
  box-sizing:border-box;
  -webkit-overflow-scrolling:touch
}

.auth-card{
  width:min(430px,100%);
  background:rgba(18,20,26,.94);
  border:1px solid #30343e;
  border-radius:22px;
  padding:30px;
  box-shadow:0 25px 90px rgba(0,0,0,.5);
  text-align:center;
  height:auto;
  max-height:none
}

.auth-logo{
  width:54px;
  height:54px;
  border-radius:16px;
  font-size:26px;
  margin:0 auto 18px
}

.eyebrow{
  font-size:9px;
  letter-spacing:.18em;
  color:#7d8390;
  font-weight:700
}

.auth-card h1{
  font-size:25px;
  margin:9px 0 6px;
  letter-spacing:-.03em
}

.auth-card>p{
  color:#8f95a1;
  font-size:12px;
  margin:0 0 21px
}

.oauth-grid{
  display:grid;
  gap:9px
}

.oauth-btn{
  height:42px;
  border:1px solid #30343e;
  background:#171a20;
  border-radius:10px;
  font-size:12px;
  font-weight:600;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:9px
}

.oauth-btn:hover{
  background:#20232b
}

.oauth-mark{
  width:20px;
  height:20px;
  border-radius:5px;
  display:grid;
  place-items:center;
  font-weight:800
}

.google{
  background:#fff;
  color:#4285f4
}

.discord{
  background:#5865f2;
  color:#fff
}

.divider{
  display:flex;
  align-items:center;
  gap:10px;
  color:#666c78;
  font-size:10px;
  margin:18px 0
}

.divider:before,
.divider:after{
  content:"";
  height:1px;
  background:#292d35;
  flex:1
}

.auth-form{
  display:grid;
  gap:11px;
  text-align:left
}

.auth-form label{
  font-size:10px;
  color:#8f95a1
}

.auth-form input{
  display:block;
  width:100%;
  margin-top:6px;
  height:42px;
  border:1px solid #30343e;
  border-radius:10px;
  background:#101218;
  color:#eee;
  outline:0;
  padding:0 12px;
  font-size:12px
}

.auth-form input:focus{
  border-color:#555b68
}

.turnstile-box{
  min-height:65px;
  display:flex;
  justify-content:center;
  align-items:center;
  overflow:hidden;
  width:100%;
  max-width:100%
}

.primary-btn{
  height:42px;
  border-radius:10px;
  background:#f1f2f4;
  color:#111318;
  font-size:12px;
  font-weight:700
}

.primary-btn:hover{
  background:#fff
}

.text-btn{
  background:transparent;
  color:#aeb3bd;
  font-size:10px;
  margin-top:16px
}

.text-btn:hover{
  color:#fff
}

.auth-footnote{
  font-size:9px!important;
  color:#626873!important;
  margin-top:18px!important;
  line-height:1.5
}

@keyframes fadeIn{
  from{
    opacity:0;
    transform:translateY(4px)
  }

  to{
    opacity:1;
    transform:translateY(0)
  }
}

@keyframes bounce{
  0%,60%,100%{
    transform:translateY(0);
    opacity:.45
  }

  30%{
    transform:translateY(-4px);
    opacity:1
  }
}

.overlay{
  display:none
}


/* =========================
   TABLET / MOBILE
   ========================= */

@media(max-width:760px){

  .sidebar{
    position:fixed;
    left:0;
    top:0;
    transform:translateX(-105%);
    transition:transform .2s ease;
    box-shadow:15px 0 40px rgba(0,0,0,.35)
  }

  .sidebar.open{
    transform:translateX(0)
  }

  .close-sidebar,
  .menu-btn{
    display:grid
  }

  .overlay{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.55);
    z-index:15
  }

  .overlay.show{
    display:block
  }

  .messages{
    width:min(100% - 22px,860px);
    padding-top:25px
  }

  .composer-wrap{
    width:calc(100% - 18px);
    margin-top:-115px
  }

  .suggestions{
    grid-template-columns:1fr;
    width:100%
  }

  .message.user .message-body{
    max-width:90%
  }

  .status-pill{
    display:none
  }
}


/* =========================
   SMALL PHONES
   ========================= */

@media(max-width:420px){

  .topbar{
    padding:0 9px
  }

  .model-btn{
    margin-left:2px
  }

  .welcome h1{
    font-size:27px
  }

  /* FIX LOGIN PAGE ON PHONES */
  .auth-screen{
    min-height:100dvh;
    height:auto;

    /*
      Don't vertically center a card taller
      than the phone screen.
    */
    align-items:flex-start;
    justify-content:center;

    padding:28px 14px 50px;

    overflow-y:auto;
    overflow-x:hidden;

    box-sizing:border-box;
    -webkit-overflow-scrolling:touch
  }

  .auth-card{
    width:100%;
    max-width:430px;

    height:auto;
    max-height:none;

    margin:0 auto;

    padding:24px 18px;
  }

  .turnstile-box{
    width:100%;
    max-width:100%;
    overflow:hidden
  }
}


/* =========================
   VERY SMALL PHONES
   ========================= */

@media(max-width:360px){

  .auth-screen{
    padding:22px 10px 45px
  }

  .auth-card{
    padding:22px 14px
  }

  .auth-card h1{
    font-size:23px
  }

  .auth-card>p{
    font-size:11px
  }

  .oauth-btn{
    height:42px
  }
}
/* =========================
   MOBILE CHAT FIX
   ========================= */

@media (max-width:760px){

    html,
    body{
        width:100%;
        height:100%;
        overflow:hidden;
    }

    .app{
        width:100%;
        height:100dvh;
        min-height:0;
    }

    .main{
        width:100%;
        height:100dvh;
        min-height:0;
        display:flex;
        flex-direction:column;
    }

    .chat-area{
        flex:1 1 auto;
        min-height:0;
        height:auto;
        overflow-y:auto;
        overflow-x:hidden;
        -webkit-overflow-scrolling:touch;
    }

    .messages{
        min-height:0;
    }

    .composer-wrap{
        flex-shrink:0;
    }
}


/* Extra-small phones */
@media (max-width:420px){

    .app{
        height:100dvh;
    }

    .main{
        height:100dvh;
    }

    .chat-area{
        min-height:0;
        overflow-y:auto;
    }

    .composer-wrap{
        width:calc(100% - 18px);
    }
}
/* SVG LOGOS */
.auth-logo {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #181b22;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
}

.auth-logo img {
    width: 52px;
    height: 52px;
    display: block;
    object-fit: contain;
}
.oauth-mark {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.oauth-mark img {
    width: 20px;
    height: 20px;
    display: block;
    object-fit: contain;
}
.brand-mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
}
.brand-logo img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    display: block;
}
.welcome-icon {
  width: 78px;
  height: 78px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
  overflow: hidden;
}

.welcome-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* Cosmos logo - sidebar */
.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #171a21;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* Cosmos logo - welcome screen */
.welcome-icon {
  width: 78px;
  height: 78px;
  border-radius: 22px;
  background: #171a21;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
  overflow: hidden;
}

.welcome-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* Cosmos logo inside AI message avatar */
.message.assistant .avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #171a21;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.message.assistant .avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.message.assistant .avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #171a21;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.message.assistant .avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}