* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: linear-gradient(180deg, #f6f0da 0%, #f3f4ea 35%, #eff4f5 100%);
  color: #2d2b3a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}
.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px;
}
.topbar, .grid-main, .card { position: relative; z-index: 1; }

.topbar {

  max-width: 1295px;
  margin-left: auto;
  margin-right: auto;
  border-bottom: 1px solid rgba(236,72,153,.2);
}

.brand { display: flex; align-items: center; gap: 10px; }
.banana {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #ffb48a, #f6d0ff);
  display: grid; place-items: center;
}
.brand h1 { margin: 0; color: #d65adf; }
.brand p { margin: 0; font-size: 12px; color: #5c6077; }
.top-actions { display: flex; gap: 10px; }

.btn { border: none; border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.btn.soft { background: #dceee8; color: #2f7968; }
.btn.icon {
  background: #e8ddff; color: #7959df;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
}
.btn.icon svg { width: 18px; height: 18px; fill: currentColor; }
.btn.green { background: #c9f0da; color: #2c8b5a; }
.btn.gray { background: #ececf0; color: #666; }
.btn.orange { background: linear-gradient(90deg, #ff8b2c, #ff5db1); color: #fff; }
.btn.purple { background: linear-gradient(90deg, #d044c0, #7a53f2); color: #fff; }
.btn.cyan { background: #14b8b0; color: #fff; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #efe6ff 0%, #e8dcff 45%, #e5d9ff 100%);
  border: 1px solid #dcccf6;
  border-radius: 0 0 14px 14px;
  padding: 0px 16px;
  margin-bottom: 5px;
}

.title {
  font-size: 18px;
  font-weight: 700;
  color: #c154d3;
  letter-spacing: 0.2px;
}

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

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 12px;
  min-height: calc(100vh - 108px);
}

.left-panel { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: #f2edf3;
  border: 1px solid #dfcfee;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(130, 88, 177, 0.06);
}

.card-title {
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  margin-bottom: 10px;
  color: #6154ff;
  letter-spacing: 0.3px;
}

.label {
  display: block;
  font-size: 14px;
  color: #56516a;
  margin-bottom: 6px;
  margin-top: 8px;
}

.input {
  width: 100%;
  background: #ffffff;
  color: #2d2b3a;
  border: 1px solid #d7c8ea;
  border-radius: 12px;
  padding: 9px 11px;
  outline: none;
  transition: all .15s ease;
}
.input:focus {
  border-color: #c767ef;
  box-shadow: 0 0 0 3px rgba(199, 103, 239, 0.14);
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(90deg, #6f85ff 0%, #6a6df8 100%);
  transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:hover { box-shadow: 0 6px 14px rgba(120, 96, 223, 0.2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(90deg, #ff8a1f 0%, #f250b2 100%);
}
.btn.gray {
  color: #3a3650;
  background: #ebe7f0;
  border: 1px solid #d9cfeb;
}
.btn.danger {
  background: linear-gradient(90deg, #ff6a70 0%, #e04357 100%);
}

.status {
  font-size: 13px;
  color: #615b7b;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.chat-panel {
  background: #eef1f2;
  border: 1px solid #ddd3eb;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(116, 87, 158, 0.06);
}

.chat-list {
  flex: 1;
  overflow: auto;
  padding: 14px;
}

.empty {
  color: #7a7792;
  font-size: 13px;
}

.msg {
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
}
.msg-role {
  width: 82px;
  flex-shrink: 0;
  color: #6e6a84;
  font-size: 12px;
  padding-top: 4px;
  font-weight: 600;
}
.msg-body { flex: 1; }

.msg-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  min-height: 22px;
}
.model-tag {
  font-size: 12px;
  color: #7d58d3;
  background: #f0e8ff;
  border: 1px solid #d9c9f5;
  border-radius: 999px;
  padding: 2px 8px;
}
.copy-btn {
  font-size: 12px;
  border: 1px solid #d8cbee;
  background: #f7f2ff;
  color: #5f5189;
  border-radius: 8px;
  padding: 2px 8px;
  cursor: pointer;
}
.copy-btn:hover { background: #efe7ff; }

.msg-content {
  background: #ffffff;
  border: 1px solid #ddd1ee;
  border-radius: 12px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}
.msg.user .msg-content {
  border-color: #c9d6ff;
  background: #f5f8ff;
}
.msg.assistant .msg-content {
  border-color: #e6d2f3;
  background: #fff9ff;
}
.msg.system .msg-content {
  border-color: #dcd9ef;
  background: #f5f5fb;
}

.composer {
  border-top: 1px solid #ddd3eb;
  padding: 12px;
  background: #f6f3f9;
}
.composer-input {
  min-height: 92px;
  resize: vertical;
}
.composer-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(57, 40, 79, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
}
.modal.hidden { display: none; }

.modal-content {
  width: min(560px, calc(100vw - 24px));
  background: #f6f1fb;
  border: 1px solid #deceef;
  border-radius: 14px;
  padding: 14px;
}
.modal-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #5e45b2;
}
.modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.test-result {
  margin-top: 8px;
  color: #635f7c;
  font-size: 13px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}
/* 关键：让主区域有稳定高度 */
.app {
  height: 100vh;
  overflow: hidden;
}
.layout {
  height: calc(100vh - 110px); /* 64 按你的 topbar 实际高度调整 */
  min-height: 0;
}
/* 关键：右侧聊天列改为上下结构 */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
/* 消息列表独立滚动，不再把输入框往下顶 */
.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 12px;
}
/* 输入区固定在底部 */
.composer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  background: #fff; /* 改成你页面背景色 */
  z-index: 10;
  padding-top: 8px;
  border-top: 1px solid #eee;
}
/* 顶部布局：在原有基础上支持中间导航区 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap; /* 小屏自动换行，避免挤压 */
}

/* 新增导航区 */
.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;                 /* 占据中间弹性空间 */
  min-width: 260px;
  justify-content: center; /* 菜单居中更大方 */
}

/* 导航链接：轻量胶囊风格，贴合你现有按钮体系 */
.top-nav a {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  color: #374151;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid #e5e7eb;
  transition: all .2s ease;
  white-space: nowrap;
}

.top-nav a:hover {
  color: #111827;
  background: #ffffff;
  border-color: #d1d5db;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.top-nav a:active {
  transform: translateY(1px);
}

/* 当前页高亮（可选：给当前a加 class="active"） */
.top-nav a.active {
  color: #166534;
  background: #ecfdf3;
  border-color: #86efac;
}

/* 保持右侧按钮不被压缩 */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 响应式：小屏让导航换到下一行并左对齐更好读 */
@media (max-width: 1100px) {
  .top-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .top-nav::-webkit-scrollbar {
    height: 6px;
  }

  .top-nav::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 999px;
  }
}