/* ===== Base ===== */

:root{
  --bg:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;

  --blue:#3b82f6;
  --blue-weak:#bfdbfe;
  --blue-bg:#eff6ff;

  --pei:#e6f2ff;   --pei-b:#cfe6ff;  /* 浅蓝 */
  --lee:#ffe6ef;   --lee-b:#ffd0df;  /* 浅粉 */
  --ai:  #e8f7ee;  --ai-b:  #d1f0de;  /* 浅绿 (AI通用) */
}

*{box-sizing:border-box}
html,body{height:100%;margin:0;overflow-x: hidden;}
body{
  background:var(--bg);
  color:var(--text);
  font:14px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue","PingFang SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif
}

/* ===== App Grid (Desktop) ===== */
.app{
  display:grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "sidebar header"
    "sidebar main"
    "sidebar composer";
  height:100vh;
}

/* ===== Sidebar ===== */
.sidebar{
  grid-area:sidebar;
  border-right:1px solid var(--line);
  background:#fafafa;
  display:flex;
  flex-direction:column;
  min-width:240px;
}
.sidebar .slot-controls{ display:none; } /* 手机时用 */

.sidebar .top{ padding:10px 12px; border-bottom:1px solid var(--line); }
.search{
  width:100%; height:34px; border:1px solid #d1d5db; border-radius:8px; padding:0 10px; background:#fff;
  font:14px/1.5 inherit;
}
.side-actions{ display:flex; flex-direction:column; gap:8px; padding:10px 12px; border-bottom:1px solid var(--line); }
.btn{ height:36px; padding:0 12px; width:100%; border-radius:8px; font-size:14px; border:1px solid #d1d5db; background:#fff; color:#374151; cursor:pointer }
.btn.primary{ background:#111827; color:#fff; border-color:#111827 }
.btn.ghost{ background:#fff }
.btn:disabled{ opacity:.6; cursor:not-allowed }

.section{ padding:8px 12px 6px; color:#475569; font-weight:600 }

.side-scroll{
  /* Projects 高度随内容，Chats 占剩余 */
  display:flex; flex-direction:column; min-height:0; /* 关键：允许子元素收缩 */
  overflow:hidden;
}
.projects{ padding:6px 10px 12px; display:flex; flex-direction:column; gap:6px }
.chats{ padding:6px 10px 12px; display:flex; flex-direction:column; gap:6px; overflow:auto; min-height:0; }

/* chat item */
.chat-item{
  border:1px solid transparent;
  border-left:3px solid transparent;
  border-radius:8px;
  padding:10px 12px;
  background:#fff;
  cursor:pointer;
  transition:background .15s,border-color .15s;
}
.chat-item:hover{ background:#f8fafc; }
.chat-item.active{
  border-color: var(--blue-weak);
  border-left-color: var(--blue);
  background: var(--blue-bg);
}

/* ===== Header ===== */
.header{
  grid-area:header;
  border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px; gap:10px; background:#fff;
}
.h-left,.h-right{ display:flex; align-items:center; gap:12px }
.title{ font-weight:600 }

.controls-block{ display:flex; align-items:center; gap:12px }
.controls-block .lbl{ margin-right:6px; color:#475569; font-size:13px }
.model-select{
  width:140px; height:32px; font-size:14px; line-height:32px;
  padding:0 8px; border:1px solid #d1d5db; border-radius:8px; background:#fff
}
.cb{ display:flex; align-items:center; gap:6px; color:#374151 }

/* 汉堡按钮（仅手机可见） */
.hamburger{ display:none; width:36px; height:36px; border:1px solid #d1d5db; border-radius:8px; background:#fff; cursor:pointer; }
.hamburger:before{ content:"☰"; font-size:18px; }
.hamburger.is-open:before{ content:"✖"; }

/* ===== Messages ===== */
.main{
  grid-area:main; overflow:auto; background:#fff; padding:16px;
}
/* 新：铺满主区域，稳定贴左；两侧留内边距避免“贴边丑” */
.messages{
  max-width: none;
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;   /* 左右都留 16px */
}
.msg{ 
	display:flex; gap:10px; 
	flex-direction: column; 
	align-items: flex-start; 
}
  .msg .meta {
    min-width: auto;
    text-align: left;
    font-size: 12px;
    margin-bottom: 2px;
 	min-width:72px; color:#64748b;  
 	padding-top:6px;
 }
.bubble{
  max-width: min(720px, 98%);
  padding:10px 12px; border-radius:10px; border:1px solid var(--line);
  white-space:pre-wrap; word-break:break-word
}
.msg.pei .bubble{ background:var(--pei); border-color:var(--pei-b) }
.msg.lee .bubble{ background:var(--lee); border-color:var(--lee-b) }
.msg.gpt .bubble,
.msg.gemini .bubble {
  background: var(--ai);
  border-color: var(--ai-b);
}

/* 按钮放进气泡内 */
.bubble .ops {
  margin-top: 4px;
  display: flex;
  gap: 6px;
}
.bubble .ops .op {
  font-size: 12px;
  padding: 2px 6px;
}
.op{ border:1px solid #d1d5db; border-radius:6px; cursor:pointer; background:#fff; color:#374151 }
.op:hover{ background:#f8fafc }

/* ===== Composer ===== */
.composer{
  grid-area:composer; border-top:1px solid var(--line);
  background:#fff; 
  display:flex; 
  align-items:center; 
  gap:10px; 
  padding-top: :10px; 
  padding-right: 2px
  padding-left: 300px;
}
.input-wrap{
  position:relative; flex:1; display:flex; align-items:center;
  border:1px solid #d1d5db; border-radius:8px; background:#fff; padding-left:12px; height:44px
}
.input-wrap .prefix{
  display:none; color:#6b7280; user-select:none; pointer-events:none; margin-right:2px
}
#message{
  flex:1; border:0; outline:0; padding:10px 12px; font-size:14px; resize:none; background:transparent;
  font-family:inherit; /* placeholder 字体一致 */
}
#message::placeholder{ color:#9ca3af; opacity:1; font:inherit }

.btns{ display:flex; align-items:center; gap:8px }

/* Ask GPT：桌面=大按钮；手机=图标 */
.askgpt-btn{
  height:36px; padding:0 12px; border-radius:8px; font-size:14px;
  border:1px solid #d1d5db; background:#fff; color:#374151; cursor:pointer
}
.askgpt-btn.on{ background:var(--blue); color:#fff; border-color:var(--blue) }
.askgpt-icon{ display:none } /* 桌面隐藏图标 */
.attach-icon{ display:none }

/* ===== Mobile (≤768px) ===== */
@media (max-width:768px){
  .app{
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "composer";
  }
  .hamburger{ display:inline-block; }

  /* 侧栏抽屉 */
  .sidebar{
    position:fixed; left:0; top:0; bottom:0; width:70vw; max-width:420px;
    transform:translateX(-100%); transition:transform .2s ease; z-index:40;
    border-right:1px solid var(--line);
  }
  .sidebar.open{ transform:translateX(0); }
  .sidebar .slot-controls{ display:block; padding:10px 12px; border-bottom:1px solid var(--line); background:#fff }

  .scrim{ position:fixed; inset:0; background:rgba(0,0,0,.35); display:none; z-index:30 }
  .scrim.show{ display:block }

  body.no-scroll{ overflow:hidden }

  /* Header 中不显示 controls-block（控件搬到侧栏顶部） */
  .controls-block{ display:none }

  /* 按钮图标化 */
  .btn.ghost.attach-text{ display:none }
  .attach-icon,
  .askgpt-icon{
    display:inline-flex; align-items:center; justify-content:center;
    width:40px; height:40px; border:1px solid #d1d5db; border-radius:10px; background:#fff;
    font-size:18px; line-height:1; cursor:pointer; user-select:none; color:#374151
  }
  .askgpt-btn{ display:none } /* 手机隐藏大按钮 */
  .askgpt-icon.on{ color:#111827; background:#e5f3ff; border-color:var(--blue) }
}

/* ===== Utilities ===== */
.hidden{ display:none }

/* ———确保遮罩/侧栏有清晰层级——— */
.scrim   { z-index: 10010; }
.sidebar { z-index: 10020; }

/* ———侧栏打开时，让汉堡按钮固定在左上角，并盖在侧栏之上——— */
@media (max-width: 768px){
  :root{ --drawer-clearance: 48px; }

  .sidebar.open .slot-controls{
    margin-top: var(--drawer-clearance);
  }

  .header .hamburger{ z-index: 5; }

  .sidebar.open ~ .header .hamburger{
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10050;
    background: #fff;
    color: #111;
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    top: calc(env(safe-area-inset-top, 0px) + 12px);
  }

  .messages { padding: 0 4px; }
  .bubble   { max-width: 100%; }
  .msg { flex-direction: row; align-items: flex-start; }
  .msg .meta {
    min-width: auto;
    text-align: left;
    padding-top: 0;
    font-size: 12px;
    margin-bottom: 2px;
  }

}

/* 侧栏项默认外观 */
.sidebar .chat-item{
  border:1px solid #e5e7eb;
  border-radius:10px;
  padding:10px 12px;
  background:#fff;
}

/* 当前选中项 */
.sidebar .chat-item.active{
  border-color:#3b82f6;
  box-shadow:0 0 0 2px rgba(59,130,246,.15) inset;
  background:#eff6ff;
}

.header .title{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 360px);
}
:root {
  --vh: 1vh;
  --composer-h: 64px;
  --vvb: 0px;
  --android-extra: 12px;
}

/* 消息区：留出空间避免被输入区挡住 */
.messages {
  padding: 16px;
  padding-bottom: calc(var(--composer-h, 56px) + 24px);
  overflow-y: auto;
  scroll-padding-bottom: calc(var(--composer-h, 56px) + 24px);
}

/* ===== Composer ===== */
.composer {
  position: fixed; /* <-- 关键：使用固定定位 */
  bottom: 0;
  right: 0;
  left: 280px; /* <-- 关键：左边留出侧边栏的宽度 */
  z-index: 10; /* 确保它在最上层 */

  /* --- 以下是您原有的样式，保持不变 --- */
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  box-shadow: 0 -2px 10px rgba(0,0,0,.05); /* 可选：增加一点阴影效果 */
}

/* 当屏幕变窄（手机模式）时，让输入框铺满宽度 */
@media (max-width: 768px) {
  .composer {
    left: 0; /* <-- 关键：在手机上左边距归零 */
  }
}