:root {
  --bg: #f2f3f5;
  --panel: #ffffff;
  --line: #e3e5e8;
  --text: #1f2329;
  --muted: #8a9099;
  --brand: #3a7afe;
  --brand-soft: #e8f0ff;
  --bubble-in: #ffffff;
  --bubble-out: #3a7afe;
  --danger: #e5484d;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  padding: 9px 16px;
}
button:active { opacity: .85; }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--brand); padding: 6px 10px; }
button.danger { background: var(--danger); }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* --- message bubbles, shared by both pages ------------------------------- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.msg { display: flex; max-width: 78%; }
.msg .bubble {
  padding: 9px 13px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.msg .time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
}

.msg.them { align-self: flex-start; }
.msg.them .bubble { background: var(--bubble-in); border-top-left-radius: 3px; }

.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--bubble-out); color: #fff; border-top-right-radius: 3px; }
.msg.me .time { color: rgba(255, 255, 255, .75); }

.msg.system {
  align-self: center;
  max-width: 90%;
}
.msg.system .bubble {
  background: rgba(0, 0, 0, .05);
  color: var(--muted);
  font-size: 13px;
  box-shadow: none;
}

.day-sep {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 10px;
}

.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding-left: 4px; }

/* --- composer ------------------------------------------------------------ */

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  background: var(--bg);
}
.composer textarea:focus { border-color: var(--brand); }
