:root {
  --bg: #070a0e;
  --shell: #10161f;
  --bar: #141c27;
  --line: #1d2939;
  --me: #2f6bff;
  --me-2: #2456d6;
  --ai: #1b2532;
  --text: #e8eef7;
  --muted: #7c8b9e;
  --ok: #35d07f;
  --warn: #f2b134;
  --err: #ff6b6b;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #2575e3;
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 手机壳：桌面居中，手机上铺满 */
.shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  max-height: 880px;
  background: var(--shell);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--line);
}

@media (max-width: 520px) {
  .shell {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, var(--bar), rgba(20, 28, 39, 0.86));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

img.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.who {
  flex: 1;
  min-width: 0;
}

.nick {
  font-weight: 600;
  letter-spacing: 0.3px;
}

.state {
  font-size: 12px;
  color: var(--muted);
}

.state.on {
  color: var(--ok);
}
.state.off {
  color: var(--warn);
}

.ghost {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  padding: 4px 8px;
  cursor: pointer;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}

.row.me {
  flex-direction: row-reverse;
}

.bubble {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 16px;
  background: var(--ai);
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  animation: pop 0.16s ease-out;
}

.row.me .bubble {
  background: linear-gradient(180deg, var(--me), var(--me-2));
  color: #fff;
}

.row.pending .bubble {
  opacity: 0.72;
}

.row.noanim .bubble {
  animation: none;
}

.row.failed .bubble {
  box-shadow: 0 0 0 1px var(--err) inset;
}

.bubble.sticker {
  padding: 0;
  background: transparent;
  box-shadow: none;
  max-width: 60%;
}

.bubble.sticker img {
  display: block;
  width: 100%;
  max-width: 200px;
  border-radius: 10px;
}

.meta {
  font-size: 11px;
  color: var(--muted);
  margin: 0 4px 2px;
}

@keyframes pop {
  from {
    transform: translateY(6px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.typing {
  display: flex;
  gap: 5px;
  padding: 4px 20px 10px;
}

.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a5a6e;
  animation: b 1.1s infinite ease-in-out;
}
.typing .dot:nth-child(2) {
  animation-delay: 0.15s;
}
.typing .dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes b {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bar);
}

textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0d131b;
  color: var(--text);
  font: inherit;
  outline: none;
}

textarea:focus {
  border-color: #2c4a7a;
}

.send {
  width: 58px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--me), var(--me-2));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.send:active {
  transform: translateY(1px);
}

.gate {
  position: fixed;
  inset: 0;
  background: #2575e3;
  display: grid;
  place-items: center;
  z-index: 10;
}

.gate.hidden,
.hidden {
  display: none !important;
}

.gate-card {
  width: min(320px, 86vw);
  padding: 22px 22px 26px;
  border-radius: 22px;
  background: #c3eaff;
  box-shadow: 0 18px 50px rgba(6, 40, 90, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  text-align: center;
}

.gate-avatar {
  width: 132px;
  height: 132px;
  display: block;
  margin: 0 auto 6px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 12px rgba(20, 70, 140, 0.25));
}

.gate-title {
  margin: 4px 0 18px;
  min-height: 30px;
  font-size: 20px;
  font-weight: 700;
  color: #0b2f66;
  letter-spacing: 1px;
}

.gate-title::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: #0b2f66;
  animation: caret 0.9s steps(1) infinite;
}

.gate-title.done::after {
  display: none;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

.gate-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 16px;
}

.gate-card input {
  width: 100%;
  margin-bottom: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(11, 47, 102, 0.18);
  background: #ffffff;
  color: #0b2f66;
  font: inherit;
  outline: none;
  text-align: center;
  letter-spacing: 3px;
}

.gate-card input::placeholder {
  color: rgba(11, 47, 102, 0.42);
  letter-spacing: 1px;
}

.gate-card input:focus {
  border-color: #2f6bff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.18);
}

/* 用 text + 打码，绕开华为安全键盘（它会锁死成纯英文） */
.gate-card input.masked {
  -webkit-text-security: disc;
}

.gate-card button {
  margin-top: 12px;
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--me), var(--me-2));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.gate-err {
  min-height: 18px;
  margin-top: 8px;
  color: #b3261e;
  font-size: 12px;
}
