:root {
  --bg: #111318;
  --bg2: #171a21;
  --fg: #e8eaef;
  --dim: #8b92a1;
  --me: #2f6bff;
  --you: #23262f;
  --line: #242832;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login {
  position: fixed; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg); padding: 24px; z-index: 20;
}
.login-card { width: 100%; max-width: 340px; }
.login h1 { font-size: 22px; margin: 0 0 6px; font-weight: 600; }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 18px; }
.login input {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg2);
  color: var(--fg); font-size: 16px; outline: none;
}
.login input:focus { border-color: var(--me); }
.login button {
  width: 100%; margin-top: 12px; padding: 14px;
  border: 0; border-radius: 12px; background: var(--me);
  color: #fff; font-size: 16px; font-weight: 600;
}
.err { color: #ff6b6b; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- 主界面 ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  flex: 0 0 auto; display: flex; align-items: center;
  justify-content: space-between; padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(17,19,24,.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3ecf6a; }
.dot.off { background: #8b92a1; }
.dot.bad { background: #ff6b6b; }
.icon-btn {
  background: none; border: 0; color: var(--dim);
  font-size: 22px; line-height: 1; padding: 4px 10px;
}

.msgs {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 8px;
}

.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 18px;
  font-size: 15px; line-height: 1.5; word-break: break-word;
  white-space: pre-wrap; animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(4px); opacity: 0 } to { transform: none; opacity: 1 } }

.bubble.me { align-self: flex-end; background: var(--me); color: #fff; border-bottom-right-radius: 6px; }
.bubble.you { align-self: flex-start; background: var(--you); border-bottom-left-radius: 6px; }
.bubble.sys { align-self: center; background: transparent; color: var(--dim); font-size: 12px; }

.time { align-self: center; color: var(--dim); font-size: 11px; margin: 6px 0; }

/* ---------- 输入中 ---------- */
.typing {
  display: flex; gap: 4px; padding: 0 20px 6px;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--dim);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s }
.typing span:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%,80%,100% { opacity: .25 } 40% { opacity: 1 } }

/* ---------- 输入框 ---------- */
.composer {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px;
  padding: 10px 14px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); font-size: 15px; line-height: 1.4;
  font-family: inherit; outline: none;
}
.composer textarea:focus { border-color: var(--me); }
.send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--me); color: #fff;
  font-size: 18px; font-weight: 700;
}
.send:disabled { opacity: .4 }

/* ---------- 设置面板 ---------- */
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; z-index: 20;
}
.sheet-inner {
  width: 100%; background: var(--bg2);
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 14px; font-size: 16px; }
.row {
  display: flex; justify-content: space-between;
  padding: 10px 0; font-size: 14px; border-bottom: 1px solid var(--line);
}
.row span { color: var(--dim); }
.sep { height: 12px; }
.ghost {
  width: 100%; margin-top: 10px; padding: 13px;
  border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--fg); font-size: 15px;
}
.ghost.danger { color: #ff6b6b; border-color: #4a2a2a; }
.tiny { color: var(--dim); font-size: 11px; margin: 12px 0 0; text-align: center; }
