/* 奇棋网 agent.css — 智能体主对话界面样式（首页） */

.agent-data-notice { margin: 0; padding: .55rem 1rem; font-size: .76rem; line-height: 1.5; background: #faf6ef; color: #665541; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.llm-modal input[name="code"] { display: block; width: 100%; padding: .6rem; margin: .5rem 0; font: inherit; border: 1px solid var(--border); border-radius: 6px; }

/* ---------- 对话容器 ---------- */
.agent-chat {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(90, 60, 20, .07);
  overflow: hidden;
  min-height: 520px;
  height: calc(100vh - 230px);
  max-height: 860px;
}

/* ---------- 头部 ---------- */
.agent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.2rem;
  background: linear-gradient(135deg, var(--primary), #d98a45);
  color: #fff;
}
.agent-id { display: flex; align-items: center; gap: .65rem; }
.agent-id small { display: block; opacity: .9; font-size: .75rem; }
.agent-avatar {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: #fff;
  color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.agent-badge {
  flex: none;
  font-size: .75rem;
  padding: .25rem .7rem;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  color: #fff;
}
.agent-badge.badge-online { background: rgba(255,255,255,.28); }
.agent-badge.badge-local { background: rgba(0,0,0,.28); }

/* ---------- 消息区 ---------- */
.agent-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(circle at 12px 12px, rgba(179,71,0,.045) 4px, transparent 5px);
  background-size: 48px 48px;
}
.agent-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  scroll-behavior: smooth;
}

.amsg {
  max-width: 86%;
  padding: .6rem .95rem;
  border-radius: 14px;
  font-size: .95rem;
  line-height: 1.65;
  word-break: break-word;
}
.amsg-ai {
  align-self: flex-start;
  background: var(--bg, #faf6ed);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.amsg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 4px;
}
.amsg-note { display: block; margin-top: .3rem; opacity: .65; font-size: .78rem; }

/* 打字中光标 */
.amsg-typing::after {
  content: "▋";
  color: var(--primary);
  animation: am-blink .9s step-end infinite;
  margin-left: 2px;
}
@keyframes am-blink { 50% { opacity: 0; } }

/* ---------- 快捷条 ---------- */
.agent-quickrow {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .6rem;
}
.agent-chip {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: .28rem .85rem;
  font-size: .82rem;
  cursor: pointer;
  transition: all .18s;
}
.agent-chip:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

.agent-linkrow { margin-top: .5rem; }

/* ---------- 快捷场景卡 ---------- */
.agent-scenes {
  display: flex;
  gap: .5rem;
  padding: .6rem 1.2rem;
  overflow-x: auto;
  border-top: 1px dashed var(--border);
  background: #fdfaf3;
  scrollbar-width: none;
}
.agent-scenes::-webkit-scrollbar { display: none; }
.agent-scene {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: .45rem .8rem;
  cursor: pointer;
  transition: all .18s;
  text-align: left;
}
.agent-scene:hover { border-color: var(--primary); box-shadow: 0 3px 10px rgba(179,71,0,.14); transform: translateY(-2px); }
.agent-scene .sc-ico { font-size: 1.15rem; }
.agent-scene .sc-t { font-weight: 700; font-size: .84rem; color: var(--text); }
.agent-scene small { font-size: .7rem; color: var(--text-light); }

/* ---------- 输入区 ---------- */
.agent-input-row {
  display: flex;
  gap: .5rem;
  padding: .75rem 1.2rem;
  border-top: 1.5px solid var(--border);
  background: #fff;
}
.agent-input-row input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: .55rem .9rem;
  font-size: .95rem;
  background: var(--bg, #faf6ed);
  outline: none;
  min-width: 0;
}
.agent-input-row input:focus { border-color: var(--primary); background: #fff; }
.agent-input-row button {
  flex: none;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  min-width: 46px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background .18s;
}
.agent-input-row button:disabled { opacity: .6; cursor: default; }
.agent-input-row #agent-send:hover:not(:disabled) { background: #94401c; }
.agent-icon-btn {
  background: transparent !important;
  border: 1.5px solid var(--border) !important;
  color: var(--text-light) !important;
  font-size: .95rem !important;
}
.agent-icon-btn#agent-photo:hover { border-color: var(--primary); color: var(--primary) !important; }

/* ---------- 照片气泡 ---------- */
.amsg-photo {
  display: block;
  max-width: 200px;
  max-height: 200px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.65);
  margin-top: .25rem;
  object-fit: cover;
}
.amsg-uploading { font-size: .85rem; opacity: .9; }

/* 打字指示条 */
.agent-typing {
  display: none;
  gap: 5px;
  padding: .3rem 1.3rem .6rem;
}
.agent-typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary);
  opacity: .4;
  animation: am-bounce 1s infinite;
}
.agent-typing i:nth-child(2) { animation-delay: .15s; }
.agent-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes am-bounce { 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- 内嵌对战槽 ---------- */
.embed-slot {
  align-self: stretch;
  width: 100%;
  margin: .2rem 0 .4rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.embed-slot-collapsed { margin: .3rem 0; }

.embed-game {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: .9rem 1rem;
  box-shadow: 0 3px 12px rgba(90,60,20,.08);
}
.embed-game.embed-won { border-color: #2f6f4f; box-shadow: 0 3px 14px rgba(47,111,79,.25); }

.embed-head {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.embed-head b { font-size: 1rem; }
.embed-status { font-size: .82rem; color: var(--text-light); }
.embed-goal { font-size: .86rem; margin: 0 0 .6rem; }

.embed-board-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.embed-board { flex: 1 1 300px; min-width: 260px; max-width: 480px; }
.embed-xq .embed-board { max-width: 340px; }   /* 象棋盘 9×10 更高，收窄更协调 */
.embed-ctrl { flex: 1 1 220px; min-width: 210px; display: flex; flex-direction: column; gap: .6rem; }
.embed-story { font-size: .85rem; color: var(--text-light); margin: 0; }
.embed-log-t { margin: .3rem 0 .2rem; font-size: .85rem; }
.embed-log { max-height: 150px; overflow-y: auto; font-size: .8rem; padding-left: 1.4rem; }
.embed-note { font-size: .84rem; color: var(--text-light); margin: .2rem 0; }

/* ---------- 指令渲染卡 ---------- */
.agent-games-card {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .6rem;
}
.agent-game-chip {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: .6rem .7rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all .18s;
}
.agent-game-chip:hover { border-color: var(--primary); transform: translateY(-2px); }
.agent-game-chip img { width: 100%; height: auto; border-radius: 8px; }
.agent-game-chip span { font-weight: 700; font-size: .88rem; }
.agent-game-chip small { font-size: .72rem; color: var(--text-light); }

.agent-progress-card { display: flex; flex-direction: column; gap: .7rem; padding: .4rem .2rem; }
.ap-row { display: flex; align-items: center; gap: .7rem; font-size: .88rem; }
.ap-row > span { flex: none; width: 92px; }
.ap-row b { flex: none; font-size: .82rem; color: var(--text-light); }
.ap-bar {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.ap-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #d98a45); border-radius: 999px; transition: width .6s; }
.ap-tip { font-size: .76rem; color: var(--text-light); margin: 0; }

/* ---------- 首页双视图 tab ---------- */
.home-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.2rem;
}
.home-tab {
  border: none;
  background: transparent;
  padding: .55rem 1.3rem;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .18s;
}
.home-tab:hover { color: var(--primary); }
.home-tab.on { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .agent-chat { height: calc(100vh - 190px); min-height: 480px; max-height: none; }
  .amsg { max-width: 94%; }
  .agent-head { padding: .6rem .9rem; }
  .agent-msgs { padding: .8rem .8rem; }
  .agent-scenes { padding: .5rem .8rem; }
  .agent-input-row { padding: .6rem .8rem; }
  .embed-board-row { flex-direction: column; }
  .embed-board { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-chip, .agent-scene, .agent-game-chip { transition: none; }
  .agent-typing i, .amsg-typing::after { animation: none; }
}

/* ---------- 头部右侧（徽标 + 设置按钮） ---------- */
.agent-head-right { display: flex; align-items: center; gap: .5rem; }
.agent-badge { cursor: pointer; transition: background .15s; }
.agent-badge:hover { background: rgba(255,255,255,.42); }
.agent-head-btn {
  flex: none;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.agent-head-btn:hover { background: rgba(255,255,255,.35); }

/* ---------- LLM 设置弹窗 ---------- */
.llm-modal-mask {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(43, 26, 8, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: llmFade .18s ease;
}
@keyframes llmFade { from { opacity: 0; } }
.llm-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(60, 35, 8, .28);
  animation: llmPop .18s ease;
}
@keyframes llmPop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.llm-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.2rem;
  background: linear-gradient(135deg, var(--primary), #d98a45);
  color: #fff;
  border-radius: 16px 16px 0 0;
}
.llm-x {
  border: none; background: transparent; color: #fff;
  font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.llm-x:hover { background: rgba(255,255,255,.25); }
.llm-modal-body { padding: 1rem 1.2rem 1.2rem; }
.llm-intro {
  font-size: .82rem; color: var(--text-light);
  line-height: 1.65; margin: 0 0 .8rem;
}
.llm-presets { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .8rem; }
.llm-preset {
  font-size: .78rem; padding: .3rem .8rem;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text);
  cursor: pointer; transition: all .15s;
}
.llm-preset:hover { border-color: var(--primary); color: var(--primary); }
.llm-preset.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.llm-field { display: block; margin-bottom: .7rem; }
.llm-field span {
  display: block; font-size: .76rem; color: var(--text-light); margin-bottom: .25rem;
}
.llm-field input {
  width: 100%; box-sizing: border-box;
  font-size: .85rem; padding: .5rem .7rem;
  border: 1.5px solid var(--border); border-radius: 9px;
  color: var(--text); background: #fff;
}
.llm-field input:focus { outline: none; border-color: var(--primary); }
.llm-check {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: var(--text);
  margin: .2rem 0 .6rem; cursor: pointer;
}
.llm-check input { accent-color: var(--primary); }
.llm-tip {
  font-size: .74rem; color: var(--text-light);
  background: rgba(217, 138, 69, .08);
  border-radius: 8px; padding: .5rem .7rem; margin: 0 0 .5rem;
  min-height: 0;
}
.llm-tip:empty { display: none; }
.llm-status {
  font-size: .8rem; line-height: 1.6; margin: 0 0 .7rem;
  word-break: break-all;
}
.llm-status.ok { color: #1b7a3d; }
.llm-status.bad { color: #b3261e; }
.llm-actions { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.llm-privacy {
  font-size: .7rem; color: var(--text-light);
  line-height: 1.6; margin: 0;
}
.llm-privacy code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px;
  font-size: .68rem;
}
