:root {
  --bg: #0d0f12;
  --panel: #16191e;
  --line: #262b33;
  --fg: #e7ebf0;
  --dim: #8b95a3;
  --accent: #4f8cff;
  --mine: #2b4a7d;
  --theirs: #1d2128;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- 首页 ---------- */

#join {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: .02em;
}

.hint {
  color: var(--dim);
  font-size: 14px;
  margin: 0 0 24px;
}

.tiny {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.7;
  margin: 24px 0 0;
}

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dim);
  font-size: 12px;
  margin: 18px 0;
}

.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

input[type="text"], textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}

input[type="text"]:focus, textarea:focus { border-color: var(--accent); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  padding: 12px 16px;
  transition: filter .15s, opacity .15s;
}

button:active { filter: brightness(.88); }

button.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

#go { width: 100%; margin-top: 10px; }

/* ---------- 聊天 ---------- */

#chat header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
  color: var(--dim);
  flex: 0 0 auto;
}

.spacer { flex: 1; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7482;
  transition: background .2s;
  flex: 0 0 auto;
}

.dot.on { background: #35c46a; }

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--dim);
  padding: 6px 10px;
  font-size: 13px;
}

button.ghost:hover { color: var(--fg); }

#log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  background: var(--theirs);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 15px;
  animation: pop .16s ease-out;
}

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

.msg.mine {
  align-self: flex-end;
  background: var(--mine);
  border-bottom-right-radius: 4px;
}

.msg.theirs { border-bottom-left-radius: 4px; }

.msg .t {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, .4);
  margin-top: 3px;
  text-align: right;
}

.sys {
  align-self: center;
  color: var(--dim);
  font-size: 12px;
  padding: 4px 10px;
}

#chat footer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

#text {
  resize: none;
  overflow: hidden;          /* 自动增高，不要滚动条 */
  max-height: 120px;
  line-height: 1.45;
  padding: 10px 13px;
  border-radius: 20px;
  scrollbar-width: none;
}

#text::-webkit-scrollbar { display: none; }

#log { scrollbar-width: thin; }

button.round {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
