:root {
  --blue: #1677ff;
  --blue-deep: #0a4bb3;
  --bg: #0f172a;
  --panel: #1b2540;
  --panel-2: #232f52;
  --text: #e8eefc;
  --muted: #93a4c8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --bubble-user: #1677ff;
  --bubble-bot: #232f52;
  --radius: 18px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue));
  color: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .35);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .18);
  border-radius: 12px;
  font-size: 24px; font-weight: 800;
}
.title { font-size: 18px; font-weight: 700; line-height: 1.1; }
.sub { font-size: 12px; opacity: .9; }
.sub.online { color: #d7ffd9; }
.sub.offline { color: #ffe0e0; }
.sub.connecting { color: #fff3d6; }

.emotion {
  margin-left: auto;
  font-size: 14px;
  background: rgba(255, 255, 255, .16);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.subject {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}
.subject option { color: #111; }

/* ---------------- 聊天区 ---------------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.msg { max-width: 78%; padding: 12px 16px; border-radius: var(--radius); line-height: 1.6; font-size: 17px; word-break: break-word; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--bubble-user); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); color: var(--text); border-bottom-left-radius: 6px; }
.msg.bot.thinking { opacity: .55; font-style: italic; }
.msg .meta { display: block; font-size: 11px; opacity: .6; margin-top: 6px; }
.phase-pill {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: rgba(22, 119, 255, .18); color: #9cc4ff; margin-left: 6px;
}

/* ---------------- 输入区 ---------------- */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.iconbtn {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  border-radius: 14px;
  border: none;
  background: var(--panel-2);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  transition: transform .08s, background .2s;
}
.iconbtn:active { transform: scale(.92); }
.iconbtn.active { background: var(--blue); }
#msg {
  flex: 1;
  height: 52px;
  border: none;
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 17px;
  padding: 0 16px;
  outline: none;
}
#msg::placeholder { color: var(--muted); }
.sendbtn {
  flex: 0 0 auto;
  height: 52px;
  padding: 0 22px;
  border: none;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s, opacity .2s;
}
.sendbtn:active { transform: scale(.95); }
.sendbtn:disabled { opacity: .5; }

/* 小屏竖屏提示 */
.rotate-hint {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg); color: #fff;
  place-items: center; text-align: center; padding: 30px;
  font-size: 18px;
}
@media (orientation: portrait) and (max-width: 820px) {
  .rotate-hint { display: grid; }
}
