/* ====== chat.html 原 CSS ====== */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #0d1117;
  color: #c9d1d9;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}
.app {
  display: grid;
  grid-template-columns: 42% 58%;
  height: 100vh;
  /* 移动端动态视口高度，避免地址栏/底部栏导致输入框被压出屏幕 */
  height: 100dvh;
}
.left {
  border-right: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.right {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.left-top, .right-top {
  padding: 10px;
  border-bottom: 1px solid #30363d;
  background: #0d1117;
  position: sticky;
  top: 0;
  z-index: 2;
}
.left-top-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.plus-btn {
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.nav-btn {
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: none; /* 仅移动端显示 */
  margin-right: 8px;
  flex-shrink: 0;
}
.tree-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px;
}
.session-node {
  margin: 6px 0;
  border: 1px solid #21262d;
  border-radius: 10px;
  background: #0d1117;
}
.session-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 10px;
  list-style: none;
  gap: 8px;
}
.session-title {
  font-size: 13px;
  font-weight: 650;
  color: #c9d1d9;
  line-height: 1.3;
  word-break: break-all;
  flex: 1;
}
.muted { color: #8b949e; font-size: 12px; }
.q-list {
  margin: 0;
  padding: 0 10px 10px 22px;
  list-style: none;
}
.q-item {
  cursor: pointer;
  margin: 7px 0;
  color: #58a6ff;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}
.q-item:hover { text-decoration: underline; }

.right-top .line {
  margin: 2px 0;
  font-size: 13px;
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.logout-btn {
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.benefit-btn {
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  margin-left: 8px;
  flex-shrink: 0;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: #0d1117;
}
.msg-row { display: flex; margin: 12px 0; width: 100%; }
.msg-row.me { justify-content: flex-end; }
.msg-row.bot { justify-content: flex-start; }
.msg {
  max-width: 90%;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
  position: relative;
}
.msg.me { background: #1f6feb1c; }
.msg.bot { background: #161b22; }
.msg-head {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 12px;
  color: #8b949e;
}
.anchor-link {
  position: absolute;
  right: 40px;
  top: 8px;
  font-size: 12px;
  color: #58a6ff;
  text-decoration: none;
}
/* 分享按钮（emoji） */
.share-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  z-index: 10;
}
.chat-bottom {
  border-top: 1px solid #30363d;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: stretch;
  background: #0d1117;
  /* 兼容 iPhone 底部安全区，避免按钮贴到底看不全 */
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center; /* 提交按钮在输入框高度内垂直居中 */
}
.mode-select, .send-btn, .query-input {
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #0d1117;
  color: #c9d1d9;
  padding: 8px;
  font-size: 13px;
}
.query-input {
  flex: 1;
  min-height: 78px;
  resize: vertical;
  line-height: 1.5;
  font-family: inherit;
}
.send-btn {
  cursor: pointer;
  background: #238636;
  border-color: #238636;
  padding: 8px 14px;
}
.send-btn:disabled { cursor: not-allowed; opacity: 0.5; }

/* 代码复制按钮 */
.copy-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}
.markdown-body pre:hover .copy-btn { opacity: 1; }
.copy-btn.copied { background: #238636; border-color: #238636; color: #ffffff; }
.markdown-body pre { position: relative; padding-top: 28px; }
.markdown-body { background: transparent !important; color: #c9d1d9 !important; max-width: 100% !important; }

/* 登录弹层 / 通用弹层 */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(1, 4, 9, 0.65);
  z-index: 50;
  padding: 20px;
}
.modal.show { display: flex; }
.card {
  width: min(420px, 92vw);
  border: 1px solid #30363d;
  background: #0d1117;
  border-radius: 12px;
  padding: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.row { display: flex; gap: 8px; }
.field {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #c9d1d9;
  margin: 8px 0;
  font-size: 13px;
}
.btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #161b22;
  color: #c9d1d9;
  cursor: pointer;
  font-size: 13px;
}
.btn.primary { background: #238636; border-color: #238636; }
.btn.small { width: auto; padding: 8px 12px; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #c9d1d9;
  cursor: pointer;
  font-size: 13px;
}
.tab.active { background: #161b22; }

.benefit-box { margin-top: 12px; }
.benefit-title { font-weight: 650; margin: 6px 0; }
.benefit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.benefit-table th, .benefit-table td {
  border: 1px solid #30363d;
  padding: 8px 6px;
  text-align: center;
}
.benefit-table th { background: #161b22; font-weight: 650; }

@media (max-width: 980px) {
  .app { grid-template-columns: 100%; }
  /* 移动端：左侧变成抽屉 */
  .nav-btn { display: inline-flex; align-items: center; justify-content: center; }
  .left {
    display: flex;
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    width: min(86vw, 380px);
    z-index: 80;
    background: #0d1117;
    box-shadow: 0 0 0 1px #30363d, 0 20px 60px rgba(0,0,0,.35);
    transition: left 0.18s ease;
  }
  .left.show { left: 0; }

  /* 移动端输入框更紧凑，避免“太靠下看不全” */
  .query-input {
    min-height: 56px;
    resize: none;
  }
}

/* 抽屉遮罩 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.55);
  z-index: 70;
  display: none;
}
.drawer-mask.show { display: block; }

/* ====== share.html 额外 CSS（覆盖/补充） ====== */
.wrap {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 980px;
  margin: 0 auto;
}
.topbar {
  padding: 10px 12px;
  border-bottom: 1px solid #30363d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  background: #0d1117;
  z-index: 2;
}
.wrap .msg { max-width: 92%; }
