*{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%}
body{
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:#f7f7f8;
  color:#111827;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

a{text-decoration:none;color:inherit}
button,input,textarea,select{font:inherit}

.app{
  display:flex;
  height:100vh;
  overflow:hidden;
  background:#fff;
}

/* Sidebar */
.sidebar{
  width:300px;
  background:#f9f9f9;
  border-right:1px solid #ececec;
  display:flex;
  flex-direction:column;
  padding:14px 12px;
}

.brand{
  padding:6px 8px 14px;
}

.brand-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.logo{
  width:30px;
  height:30px;
  object-fit:contain;
  border-radius:8px;
  background:#fff;
}

.brand-title{
  font-size:17px;
  font-weight:700;
  color:#111827;
  letter-spacing:-0.01em;
}

.new-btn{
  width:100%;
  border:none;
  outline:none;
  background:#ffffff;
  color:#111827;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:12px 14px;
  cursor:pointer;
  font-size:14px;
  font-weight:600;
  transition:.18s ease;
  box-shadow:0 1px 2px rgba(0,0,0,.03);
}

.new-btn:hover{
  background:#f3f4f6;
  border-color:#d1d5db;
}

.new-btn:active{
  transform:scale(.995);
}

.conv-list{
  flex:1;
  overflow:auto;
  padding-top:12px;
}

.conv-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:10px 10px 10px 12px;
  border-radius:14px;
  margin-bottom:8px;
  cursor:pointer;
  transition:.18s ease;
}

.conv-item:hover{
  background:#f3f4f6;
}

.conv-item.active{
  background:#eceff3;
}

.conv-main{
  flex:1;
  min-width:0;
}

.conv-title{
  font-size:14px;
  font-weight:600;
  color:#111827;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.conv-scope{
  font-size:12px;
  color:#9ca3af;
  margin-top:4px;
}

.conv-actions{
  display:flex;
  gap:6px;
  opacity:0;
  transition:.18s ease;
}

.conv-item:hover .conv-actions,
.conv-item.active .conv-actions{
  opacity:1;
}

.conv-act{
  width:28px;
  height:28px;
  border:none;
  outline:none;
  background:#ffffff;
  border-radius:10px;
  cursor:pointer;
  color:#4b5563;
  font-size:13px;
  box-shadow:0 1px 3px rgba(0,0,0,.06);
  transition:.18s ease;
}

.conv-act:hover{
  background:#f9fafb;
  color:#111827;
}

.empty-conv{
  color:#9ca3af;
  font-size:13px;
  padding:8px 4px;
}

.sidebar-footer{
  border-top:1px solid #ececec;
  padding:14px 8px 6px;
}

.login-btn,
.logout-link{
  display:inline-block;
  color:#10a37f;
  font-size:14px;
  font-weight:600;
}

.account-entry{
  width:100%;
  border:none;
  background:#ffffff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:12px 14px;
  text-align:left;
  cursor:pointer;
  font-weight:600;
}

.account-entry:hover{
  background:#f9fafb;
}

.account-name{
  color:#111827;
}

/* Main */
.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
  position:relative;
  background:#ffffff;
}

.topbar{
  height:72px;
  border-bottom:1px solid #f0f0f0;
  display:flex;
  align-items:center;
  padding:0 22px;
  background:#fff;
  position:relative;
  z-index:2;
}

.topbar-left{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
}

/* model select */
.model-switch{
  display:flex;
  align-items:center;
}

.model-select-wrap{
  position:relative;
  display:inline-flex;
  align-items:center;
}

.model-select{
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
  border:none;
  outline:none;
  background:#f3f4f6;
  color:#111827;
  padding:10px 40px 10px 16px;
  border-radius:999px;
  font-size:14px;
  font-weight:600;
  line-height:1;
  cursor:pointer;
  transition:.18s ease;
  box-shadow:inset 0 0 0 1px #e5e7eb;
  min-width:140px;
}

.model-select:hover{
  background:#eceff3;
}

.model-select:focus{
  box-shadow:inset 0 0 0 1px #d1d5db, 0 0 0 4px rgba(16,163,127,.08);
}

.model-chevron{
  position:absolute;
  right:14px;
  pointer-events:none;
  color:#6b7280;
  font-size:14px;
  line-height:1;
}

/* scope switch */
.scope-switch{
  display:flex;
  align-items:center;
  gap:8px;
  background:#f3f4f6;
  padding:4px;
  border-radius:999px;
}

.scope-pill{
  border:none;
  outline:none;
  background:transparent;
  color:#4b5563;
  border-radius:999px;
  padding:9px 18px;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:.18s ease;
}

.scope-pill:hover{
  color:#111827;
}

.scope-pill.active{
  background:#111827;
  color:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,.08);
}

/* messages */
.messages{
  flex:1;
  overflow:auto;
  padding:24px 0 140px;
  background:#fff;
}

.messages-inner{
  max-width:860px;
  margin:0 auto;
  padding:0 20px;
}

.messages.center-mode{
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  padding:0;
}

.messages.center-mode .messages-inner{
  width:100%;
  max-width:920px;
  padding:0 20px;
}

.welcome{
  text-align:center;
  margin-bottom:35%;
}

.welcome h1{
  margin:0;
  font-size:48px;
  line-height:1.08;
  font-weight:800;
  color:#111827;
  letter-spacing:-0.03em;
}

/* input */
.inputbar{
  width:100%;
  background:#fff;
  z-index:3;
}

.inputbar.floating{
  position:absolute;
  left:50%;
  bottom:40%;
  transform:translateX(-50%);
  max-width:860px;
  padding:0 20px;
}

.input-shell{
  width:100%;
  padding-left:20%;
  padding-right:20%;
  max-height: 180px;
  overflow-y: scroll;
}

.file-info{
  min-height:18px;
  margin-bottom:8px;
  font-size:13px;
  color:#10a37f;
  padding-left:6px;
}

.composer{
  display:flex;
  align-items:flex-end;
  gap:10px;
  border:1px solid #e5e7eb;
  border-radius:28px;
  padding:10px 12px;
  background:#fff;
  box-shadow:0 8px 30px rgba(0,0,0,.06);
}

.composer:focus-within{
  border-color:#d1d5db;
  box-shadow:0 10px 34px rgba(0,0,0,.08);
}

textarea{
  flex:1;
  min-height:28px;
  max-height:180px;
  border:none;
  outline:none;
  resize:none;
  font-size:15px;
  line-height:1.7;
  color:#111827;
  padding:7px 2px;
  background:transparent;
  font-family:inherit;
}

.icon-btn{
  width:40px;
  height:40px;
  flex:0 0 40px;
  border:none;
  outline:none;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size:16px;
  transition:.18s ease;
}

.icon-btn.soft{
  background:#f3f4f6;
  color:#374151;
}

.icon-btn.soft:hover{
  background:#e5e7eb;
}

.icon-btn.send{
  background:#111827;
  color:#fff;
}

.icon-btn.send:hover{
  background:#000;
}

.icon-btn.stop{
  background:#111827;
  color:#fff;
}

.icon-btn.stop:hover{
  background:#000;
}

.send-arrow{
  transform:translateX(1px);
}

.hidden{
  display:none !important;
}

/* messages */
.msg{
  margin:22px 0;
}

.msg-row{
  display:flex;
}

.user-row{
  justify-content:flex-end;
}

.ai-row{
  justify-content:flex-start;
}

.user-bubble{
  max-width:min(72%, 720px);
  background:#f3f4f6;
  color:#111827;
  border-radius:22px;
  padding:14px 18px;
  line-height:1.75;
  font-size:15px;
  word-break:break-word;
}

.ai-text{
  max-width:min(82%, 780px);
  color:#111827;
  line-height:1.8;
  font-size:15px;
  word-break:break-word;
}

/* file blocks */
.file-card{
  margin-top:12px;
  background:#fafafa;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:12px 14px;
  font-size:13px;
}

.file-link{
  color:#10a37f;
  font-weight:600;
}

.file-image{
  margin-top:10px;
  max-width:280px;
  border-radius:12px;
  display:block;
  border:1px solid #e5e7eb;
}

/* markdown */
.md p{margin:0 0 14px}
.md ul,.md ol{margin:0 0 14px 20px}
.md li{margin:4px 0}
.md h1,.md h2,.md h3,.md h4{
  margin:20px 0 12px;
  line-height:1.35;
  color:#111827;
}
.md h1{font-size:30px}
.md h2{font-size:24px}
.md h3{font-size:20px}
.md h4{font-size:17px}
.md blockquote{
  margin:14px 0;
  padding:10px 14px;
  border-left:4px solid #10a37f;
  background:#f9fafb;
  color:#374151;
  border-radius:6px;
}
.md pre{
  margin:14px 0;
  background:#0f172a;
  color:#e5e7eb;
  padding:14px;
  border-radius:14px;
  overflow:auto;
}
.md code{
  font-family:Consolas, Monaco, monospace;
  font-size:13px;
}
.md :not(pre)>code{
  background:#f3f4f6;
  color:#b91c1c;
  padding:2px 6px;
  border-radius:6px;
}
.md table{
  border-collapse:collapse;
  width:100%;
  margin:14px 0;
}
.md th,.md td{
  border:1px solid #e5e7eb;
  padding:10px 12px;
  text-align:left;
}
.md th{background:#f9fafb}
.md a{
  color:#10a37f;
  text-decoration:underline;
}

/* typing */
.typing{
  display:inline-flex;
  gap:6px;
  align-items:center;
  min-height:20px;
}

.typing span{
  width:7px;
  height:7px;
  border-radius:50%;
  background:#10a37f;
  opacity:.45;
  animation:blink 1s infinite ease-in-out;
}
.typing span:nth-child(2){animation-delay:.18s}
.typing span:nth-child(3){animation-delay:.36s}

@keyframes blink{
  0%,80%,100%{transform:scale(.7);opacity:.35}
  40%{transform:scale(1);opacity:1}
}

/* modal */
.modal-mask{
  position:fixed;
  inset:0;
  background:rgba(17,24,39,.32);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:99;
}

.account-modal{
  width:min(880px, 92vw);
  height:min(620px, 84vh);
  background:#fff;
  border-radius:24px;
  display:flex;
  overflow:hidden;
  box-shadow:0 20px 80px rgba(0,0,0,.18);
}

.account-side{
  width:220px;
  background:#f9fafb;
  border-right:1px solid #ececec;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.account-tab{
  border:none;
  background:#fff;
  border-radius:14px;
  padding:12px 14px;
  text-align:left;
  font-weight:600;
  cursor:pointer;
}

.account-tab.active{
  background:#111827;
  color:#fff;
}

.account-side-logout{
  margin-top:auto;
  color:#10a37f;
  font-weight:600;
  padding:8px 4px;
}

.account-content{
  flex:1;
  position:relative;
  padding:28px 28px 22px;
  overflow:auto;
}

.modal-close{
  position:absolute;
  top:18px;
  right:18px;
  width:36px;
  height:36px;
  border:none;
  border-radius:50%;
  background:#f3f4f6;
  cursor:pointer;
  font-size:20px;
}

.tab-panel{display:none}
.tab-panel.active{display:block}

.info-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
  margin-top:20px;
}

.info-item{
  background:#f9fafb;
  border:1px solid #ececec;
  border-radius:16px;
  padding:16px;
}

.info-item label{
  display:block;
  color:#6b7280;
  font-size:13px;
  margin-bottom:8px;
}

.token-value-wrap{
  display:flex;
  align-items:center;
  gap:6px;
}

.tip-wrap{
  position:relative;
  display:inline-flex;
  align-items:center;
}

.tip-icon{
  width:18px;
  height:18px;
  border-radius:50%;
  background:#111827;
  color:#fff;
  font-size:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:default;
}

.tip-pop{
  position:absolute;
  left:24px;
  top:50%;
  transform:translateY(-50%);
  white-space:nowrap;
  background:#111827;
  color:#fff;
  font-size:12px;
  padding:8px 10px;
  border-radius:10px;
  opacity:0;
  pointer-events:none;
  transition:.18s ease;
}

.tip-wrap:hover .tip-pop{
  opacity:1;
}

.primary-btn{
  border:none;
  background:#111827;
  color:#fff;
  border-radius:12px;
  padding:10px 14px;
  cursor:pointer;
}

.team-head{
  margin-top:18px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.team-name-line label{
  display:block;
  font-size:13px;
  color:#6b7280;
  margin-bottom:8px;
}

.team-add-member{
  display:flex;
  gap:10px;
}

.team-add-member input{
  flex:1;
  border:1px solid #d1d5db;
  border-radius:12px;
  padding:12px 14px;
  outline:none;
}

.team-member-list{
  margin-top:20px;
  display:grid;
  gap:10px;
}

.team-member-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  border:1px solid #ececec;
  border-radius:14px;
  padding:14px 16px;
  background:#fff;
}

.tm-name{
  font-weight:600;
}

.tm-role{
  color:#6b7280;
  font-size:13px;
}

::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:999px}
::-webkit-scrollbar-track{background:transparent}

@media (max-width: 900px){
  .sidebar{width:220px}
  .welcome h1{font-size:42px}
  .inputbar.floating{bottom:14%}
}

@media (max-width: 760px){
  .app{
    display:block;
    height:auto;
    min-height:100vh;
  }

  .sidebar{
    width:100%;
    border-right:none;
    border-bottom:1px solid #ececec;
  }

  .main{
    min-height:calc(100vh - 180px);
  }

  .topbar{
    padding:0 12px;
    height:auto;
    min-height:72px;
  }

  .topbar-left{
    width:100%;
    gap:10px;
  }

  .model-select{
    min-width:126px;
  }

  .scope-switch{
    transform:scale(.98);
    transform-origin:left center;
  }

  .messages{
    padding:18px 0 120px;
  }

  .messages-inner{
    padding:0 12px;
  }

  .welcome h1{
    font-size:34px;
  }

  .inputbar.floating{
    position:absolute;
    left:0;
    right:0;
    transform:none;
    bottom:10%;
    padding:0 12px;
    max-width:none;
  }

  .user-bubble,
  .ai-text{
    max-width:100%;
  }

  .account-modal{
    width:96vw;
    height:88vh;
    flex-direction:column;
  }

  .account-side{
    width:100%;
    border-right:none;
    border-bottom:1px solid #ececec;
    flex-direction:row;
    flex-wrap:wrap;
  }

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

  .team-add-member{
    flex-direction:column;
  }
}