﻿* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #e8e8e8;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: #1a1a1a;
  display: flex; align-items: center; justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(1000px, 96vw);
  height: min(760px, 94vh);
  background: #f5f5f5;
  border-radius: 8px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .06);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶部栏 ---------- */
.head {
  height: 58px; flex: 0 0 58px;
  background: #fff;
  border-bottom: 1px solid #ececec;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ava { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #dfeafb; }
.ava.big { width: 64px; height: 64px; margin-bottom: 10px; }
.names { display: flex; flex-direction: column; }
.name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #22c55e; display: inline-block;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .15);
}
.dot.off { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .15); }
.tools { display: flex; align-items: center; gap: 18px; }
.tools svg { width: 19px; height: 19px; fill: none; stroke: #3b3b3b; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .82; }

/* ---------- 消息区 ---------- */
.chat {
  flex: 1 1 auto; overflow-y: auto; padding: 18px 34px 22px;
  background: #f5f5f5;
  scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: #cfcfcf; border-radius: 8px; }

.time {
  text-align: center; margin: 14px 0 12px;
  font-size: 12px; color: #9a9a9a;
}
.time span { background: rgba(255, 255, 255, .72); padding: 2px 10px; border-radius: 10px; }

.row { display: flex; gap: 10px; margin: 10px 0; align-items: flex-start; }
.row.me { flex-direction: row-reverse; }
.row .ava { width: 38px; height: 38px; flex: 0 0 38px; }

.bubble {
  position: relative;
  max-width: 62%;
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 14.5px; line-height: 1.55;
  background: #fff;
  color: #1a1a1a;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .03);
}
.bubble::after {
  content: ""; position: absolute; top: 12px;
  width: 10px; height: 10px; background: inherit;
  transform: rotate(45deg); border-radius: 2px;
}
.row.bot .bubble::after { left: -4px; }
.row.me .bubble { background: #12b7f5; color: #fff; }
.row.me .bubble::after { right: -4px; }

.bubble.emoji {
  background: transparent; box-shadow: none; padding: 0 2px;
  font-size: 40px; line-height: 1.15;
}
.bubble.emoji::after { display: none; }

.ava.me {
  background: #d7e6fb; color: #3d6fb4;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}

/* 输入中 */
.dots { display: flex; gap: 5px; align-items: center; padding: 13px 14px; }
.dots span {
  width: 4px; height: 4px; border-radius: 50%; background: #9aa0a6;
  animation: blink 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- 输入区 ---------- */
.composer { flex: 0 0 auto; background: #fff; border-top: 1px solid #ececec; padding: 8px 16px 12px; }
.bar { display: flex; align-items: center; gap: 16px; color: #6b6b6b; font-size: 17px; padding: 2px 2px 6px; }
.bar svg { width: 19px; height: 19px; fill: none; stroke: #5f6368; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.bar .sep { width: 1px; height: 15px; background: #e3e3e3; }
.sendline { display: flex; align-items: flex-end; gap: 10px; }
#input {
  flex: 1 1 auto; resize: none; border: none; outline: none;
  font: inherit; font-size: 14.5px; line-height: 1.5;
  padding: 8px 6px; max-height: 120px; background: transparent; color: #1a1a1a;
}
#input::placeholder { color: #a8a8a8; }
.send {
  flex: 0 0 auto; height: 34px; padding: 0 20px;
  border: none; border-radius: 6px;
  background: #12b7f5; color: #fff; font: inherit; font-size: 14px;
  cursor: pointer;
}
.send:disabled { background: #a9dcf5; cursor: default; }

/* ---------- 口令门 ---------- */
.gate {
  position: fixed; inset: 0; background: rgba(20, 28, 40, .55);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.gate.hidden { display: none; }
.gate-card {
  width: 320px; background: #fff; border-radius: 12px; padding: 26px 24px;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}
.gate-card h1 { font-size: 18px; margin: 0 0 6px; }
.gate-card .hint { color: #8a8a8a; font-size: 13px; margin: 0 0 16px; }
.gate-card input {
  width: 100%; height: 38px; border: 1px solid #dcdcdc; border-radius: 7px;
  padding: 0 12px; font: inherit; font-size: 14px; outline: none;
}
.gate-card input:focus { border-color: #12b7f5; }
.gate-card button {
  margin-top: 14px; width: 100%; height: 38px; border: none; border-radius: 7px;
  background: #12b7f5; color: #fff; font: inherit; cursor: pointer;
}
.err { color: #e5484d; font-size: 12px; height: 16px; margin: 10px 0 0; }

@media (max-width: 640px) {
  body { display: block; background: #f5f5f5; }
  html, body { overflow: hidden; height: 100%; }
  .shell {
    position: fixed; inset: 0;
    width: 100vw; height: 100vh; height: 100dvh;
    border-radius: 0; box-shadow: none;
  }
  .chat { overscroll-behavior: contain; }
  .head { padding: 0 12px; height: 54px; flex-basis: 54px; }
  .tools { gap: 14px; }
  .tools svg:nth-child(2), .tools svg:nth-child(3) { display: none; }
  .chat { padding: 12px 12px 16px; }
  .row { gap: 8px; margin: 8px 0; }
  .row .ava { width: 34px; height: 34px; flex-basis: 34px; }
  .bubble { max-width: 76%; font-size: 15px; line-height: 1.5; }
  .bubble.emoji { font-size: 36px; }
  .composer { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
  .bar { gap: 14px; padding-bottom: 4px; }
  #input { font-size: 16px; }
  .send { height: 36px; padding: 0 18px; font-size: 15px; }
  .gate-card { width: calc(100vw - 44px); }
}



/* ---------- 表情面板 / 小屋入口 ---------- */
.bar .ico-btn { background: none; border: 0; padding: 0; display: flex; cursor: pointer; color: inherit; }
.home-link { display: flex; align-items: center; }
.home-link svg { width: 19px; height: 19px; fill: none; stroke: #3b3b3b; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .82; }
.composer { position: relative; }
.emoji-panel {
  position: absolute; left: 12px; bottom: calc(100% - 4px);
  width: 300px; padding: 8px;
  background: #fff; border: 1px solid #e6e6e6; border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
  display: none; z-index: 12;
}
.emoji-panel.show { display: block; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-grid button {
  font-size: 20px; line-height: 1; background: none; border: 0;
  padding: 5px 0; border-radius: 6px; cursor: pointer;
}
.emoji-grid button:hover { background: #f1f1f1; }

.gate-card .dl { display: inline-block; margin-top: 10px; color: #12b7f5; font-size: 13px; text-decoration: none; }
.gate-card .dl:hover { text-decoration: underline; }


.bubble.img { padding: 4px; background: #fff; }
.bubble.img img { display: block; max-width: 220px; max-height: 220px; border-radius: 6px; }
