:root {
  --bg: #ffffff;
  --bg-sub: #f5f6f8;
  --bg-side: #fafbfc;
  --text: #1f2328;
  --text-sub: #656d76;
  --text-mute: #8b949e;
  --border: #e4e6eb;
  --brand: #4d6bfe;
  --brand-soft: #eef2ff;
  --danger: #cf222e;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sub);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo {
  width: 56px; height: 56px; margin: 0 auto 12px;
  display: block; object-fit: contain;
}
.auth-brand h1 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.auth-brand p { font-size: 13px; color: var(--text-sub); }
.auth-model { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

.auth-tabs {
  display: flex; gap: 4px; background: var(--bg-sub);
  padding: 4px; border-radius: 8px; margin-bottom: 20px;
}
.tab {
  flex: 1; padding: 7px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; font-size: 13px;
  color: var(--text-sub); font-family: inherit;
}
.tab.active { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.05); }

#authForm input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none; background: #fff;
}
#authForm input:focus { border-color: var(--brand); }
.auth-error { color: var(--danger); font-size: 13px; min-height: 20px; }
.btn-primary {
  width: 100%; padding: 10px; background: var(--brand); color: #fff;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn-primary:hover { background: #3d5ae0; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-mute); margin-top: 14px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 260px; flex-shrink: 0; background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 12px;
}
.sidebar-head { padding: 4px 6px 14px; }
.brand-mini { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.brand-dot {
  width: 22px; height: 22px; display: inline-block;
  object-fit: contain; flex: none;
}

.new-task {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; background: var(--brand); color: #fff;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit; margin-bottom: 14px;
}
.new-task:hover { background: #3d5ae0; }
.plus { font-size: 16px; line-height: 1; }

.quota-box {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px;
}
.quota-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-sub); }
.quota-row strong { color: var(--brand); font-size: 15px; }
.quota-bar { height: 4px; background: var(--border); border-radius: 2px; margin: 7px 0 5px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--brand); border-radius: 2px; transition: width .3s; }
.quota-note { font-size: 11px; color: var(--text-mute); }

.session-list { flex: 1; overflow-y: auto; margin: 0 -4px; }
.session-item {
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-sub); margin-bottom: 2px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  white-space: nowrap;
}
.session-item:hover { background: var(--bg-sub); }
.session-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.session-name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.session-del {
  opacity: 0; border: none; background: transparent; cursor: pointer;
  color: var(--text-mute); font-size: 15px; padding: 0 2px; flex-shrink: 0;
}
.session-item:hover .session-del { opacity: 1; }
.session-del:hover { color: var(--danger); }

.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.user-mail { font-size: 12px; color: var(--text-mute); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; }
.btn-ghost {
  width: 100%; padding: 7px; background: transparent;
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 12px; color: var(--text-sub); font-family: inherit;
}
.btn-ghost:hover { background: var(--bg-sub); }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px; flex-shrink: 0; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.skill-badge {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: var(--brand-soft); color: var(--brand); font-weight: 500;
}
.turns-note { font-size: 12px; color: var(--text-mute); }
.btn-export {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text-sub);
  font-size: 12px; font-family: inherit; cursor: pointer;
}
.btn-export:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.chat-area { flex: 1; overflow-y: auto; padding: 24px; }

.empty-state { max-width: 680px; margin: 7vh auto 0; text-align: center; }
.empty-logo {
  width: 52px; height: 52px; display: block;
  object-fit: contain; margin: 0 auto 16px;
}
.empty-state h2 { font-size: 19px; font-weight: 600; margin-bottom: 10px; }
.empty-state p { color: var(--text-sub); font-size: 13px; margin-bottom: 24px; }

.suggest-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.suggest-card {
  text-align: left; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff; cursor: pointer;
  font-size: 13px; color: var(--text-sub); font-family: inherit;
}
.suggest-card:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.messages { max-width: 760px; margin: 0 auto; }
.msg { margin-bottom: 22px; display: flex; gap: 12px; }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
}
.msg-user .msg-avatar { background: #57606a; }
.msg-ai .msg-avatar { background: var(--brand); }
.msg-avatar-logo { object-fit: contain; background: var(--brand); border-radius: 6px; padding: 4px; filter: brightness(0) invert(1); }
.msg-body { flex: 1; min-width: 0; }
.msg-label { font-size: 12px; color: var(--text-mute); margin-bottom: 4px; }
.msg-content { word-wrap: break-word; overflow-wrap: break-word; }
.msg-content p { margin-bottom: 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content ul, .msg-content ol { margin: 0 0 10px 20px; }
.msg-content li { margin-bottom: 4px; }
.msg-content code {
  background: var(--bg-sub); padding: 2px 5px; border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
}
.msg-content pre {
  background: #f6f8fa; padding: 12px; border-radius: 8px;
  overflow-x: auto; margin-bottom: 10px;
}
.msg-content pre code { background: none; padding: 0; }
.msg-content blockquote {
  border-left: 3px solid var(--border); padding-left: 12px;
  color: var(--text-sub); margin-bottom: 10px;
}
.msg-content h1, .msg-content h2, .msg-content h3 {
  font-size: 15px; font-weight: 600; margin: 14px 0 8px;
}
.msg-content table { border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
.msg-content th, .msg-content td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.msg-content th { background: var(--bg-sub); font-weight: 600; }
.cursor {
  display: inline-block; width: 6px; height: 14px; background: var(--brand);
  vertical-align: text-bottom; animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.skill-tag {
  display: inline-block; font-size: 11px; color: var(--brand);
  background: var(--brand-soft); padding: 2px 8px; border-radius: 20px; margin-bottom: 8px;
}

/* ---------- 输入 ---------- */
.composer { flex-shrink: 0; padding: 0 24px 20px; }
.composer-box {
  max-width: 760px; margin: 0 auto; border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; display: flex;
  align-items: flex-end; gap: 10px; background: #fff;
}
.composer-box:focus-within { border-color: var(--brand); }
.btn-attach {
  width: 32px; height: 32px; flex: none; display: flex; align-items: center;
  justify-content: center; background: transparent; border: none;
  color: var(--text-sub); cursor: pointer; border-radius: 8px;
}
.btn-attach:hover { background: var(--bg-sub); color: var(--brand); }
.btn-attach:disabled { opacity: .4; cursor: not-allowed; }

.attachments {
  max-width: 760px; margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px;
}
.att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 4px; background: var(--bg-sub);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; max-width: 200px;
}
.att-thumb { width: 24px; height: 24px; border-radius: 4px; object-fit: cover; flex: none; }
.att-icon {
  width: 24px; height: 24px; flex: none; display: inline-flex; align-items: center;
  justify-content: center; background: var(--brand); color: #fff;
  border-radius: 4px; font-size: 10px; font-weight: 600;
}
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.att-size { color: var(--text-mute); font-size: 11px; }
.att-remove {
  width: 16px; height: 16px; flex: none; display: inline-flex; align-items: center;
  justify-content: center; background: transparent; border: none;
  color: var(--text-mute); cursor: pointer; border-radius: 50%;
}
.att-remove:hover { background: var(--border); color: var(--text); }
.upload-tip {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  padding: 8px 14px; background: #FCEBEB; color: #791F1F;
  border: 1px solid #A32D2D; border-radius: 8px; font-size: 13px;
  z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
#input {
  flex: 1; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 14px; line-height: 1.6;
  max-height: 180px; padding: 4px 0; background: transparent; color: var(--text);
}
.send-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: var(--brand); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.send-btn:disabled { background: var(--border); color: var(--text-mute); cursor: not-allowed; }
.composer-foot {
  max-width: 760px; margin: 8px auto 0; font-size: 11px;
  color: var(--text-mute); text-align: center;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .suggest-grid { grid-template-columns: 1fr; }
  .chat-area { padding: 16px; }
}
