:root {
  --bg: #fff8e7;
  --ink: #2f2a24;
  --me: #8ed081;
  --bot: #ffffff;
  --accent: #ff9f5a;
  --line: #ecdcc0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}
.hidden { display: none !important; }
#app { height: 100%; display: flex; flex-direction: column; }

/* 口令页 */
.gate { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 360px; text-align: center;
  background: #fff; border-radius: 24px; padding: 28px 22px 22px;
  box-shadow: 0 10px 30px rgba(180, 140, 80, .18);
}
.logo { font-size: 56px; line-height: 1; }
.gate-card h1 { font-size: 22px; margin: 12px 0 4px; }
.tip { color: #8a7d6a; font-size: 14px; margin: 0 0 16px; }
#code {
  width: 100%; padding: 14px; font-size: 20px; text-align: center; letter-spacing: 4px;
  border: 2px solid var(--line); border-radius: 14px; background: #fffdf7; outline: none;
}
#code:focus { border-color: var(--accent); }
#gateBtn {
  width: 100%; margin-top: 14px; padding: 14px; font-size: 17px; font-weight: 600;
  color: #fff; background: var(--accent); border: 0; border-radius: 14px;
}
#gateBtn:active { transform: scale(.98); }
.err { color: #d1495b; font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* 聊天 */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #ffd166; box-shadow: 0 2px 8px rgba(0,0,0,.06); z-index: 2;
}
.avatar { font-size: 26px; }
.who { display: flex; flex-direction: column; line-height: 1.15; flex: 1; }
.who b { font-size: 16px; }
.who span { font-size: 12px; color: #6b5f4c; }
#resetBtn {
  border: 0; background: rgba(255,255,255,.6); width: 36px; height: 36px;
  border-radius: 50%; font-size: 18px; color: #6b5f4c;
}
.log {
  flex: 1; overflow-y: auto; padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.row { display: flex; gap: 8px; align-items: flex-end; }
.row.me { flex-direction: row-reverse; }
.bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 18px;
  background: var(--bot); box-shadow: 0 1px 3px rgba(0,0,0,.06);
  white-space: pre-wrap; word-break: break-word; font-size: 16px;
  animation: pop .16s ease-out;
}
.row.me .bubble { background: var(--me); border-bottom-right-radius: 6px; }
.row.bot .bubble { border-bottom-left-radius: 6px; }
.face { font-size: 22px; }
@keyframes pop { from { transform: translateY(4px); opacity: .2; } to { transform: none; opacity: 1; } }
.typing { display: inline-flex; gap: 4px; padding: 12px 16px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: #c9b79a;
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .3 } 30% { opacity: 1 } }
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #fffdf7; border-top: 1px solid var(--line);
}
#input {
  flex: 1; resize: none; max-height: 120px; padding: 11px 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 20px; background: #fff; outline: none;
}
#input:focus { border-color: var(--accent); }
textarea { resize: none !important; }
#input { overflow-y: auto; scrollbar-width: none; }
#input::-webkit-scrollbar { display: none; }
@supports (-webkit-touch-callout: none) { #input { font-size: 16px; } }
#sendBtn {
  padding: 11px 18px; border: 0; border-radius: 20px; font-size: 16px; font-weight: 600;
  color: #fff; background: var(--accent);
}
#sendBtn:disabled { opacity: .5; }
.sys { text-align: center; color: #9c8f7b; font-size: 12px; }
