:root {
  --bg: #faf7f2;
  --card-bg: #ffffff;
  --bot-edge: #ffb86c;
  --me-edge: #6fcf97;
  --me-bg: #fcfff8;
  --text: #222;
  --muted: #888;
  --error: #d93025;
  --primary: #ff8a65;
  --primary-text: #fff;
  --border: #e8e0d0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); }
body { display: flex; }
main#app { width: 100%; max-width: 720px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

.screen { display: none; padding: 20px 16px; flex: 1; flex-direction: column; gap: 12px; animation: fade .2s ease; }
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.card { background: var(--card-bg); border-radius: 14px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.04); display: flex; flex-direction: column; gap: 14px; }
.card.center { text-align: center; align-items: center; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.big-emoji { font-size: 48px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text); }
label.consent { flex-direction: row; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.5; }
.radio-group { display: flex; gap: 16px; }
.radio-group label { flex-direction: row; gap: 4px; }

input[type=text], input[type=number], select, textarea {
  font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: var(--text); width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input.error-shake { border-color: var(--error); animation: shake .25s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

button { font-size: 15px; padding: 12px 16px; border-radius: 10px; border: none; cursor: pointer; font-family: inherit; }
button.primary { background: var(--primary); color: var(--primary-text); }
button.primary:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: #f0ece4; color: var(--text); }
button:active { transform: scale(.98); }
.row { display: flex; gap: 10px; }
.row > button { flex: 1; }

.error { color: var(--error); font-size: 13px; margin: 0; min-height: 18px; }

/* 聊天流 */
.chat-stream { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.bubble { background: #fff; border-radius: 12px; padding: 12px 14px; border-left: 3px solid var(--bot-edge); font-size: 15px; line-height: 1.55; max-width: 88%; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.bubble .who { font-size: 11px; color: var(--muted); margin-bottom: 4px; letter-spacing: 1px; }
.bubble.me { border-left-color: var(--me-edge); background: var(--me-bg); margin-left: 12%; align-self: flex-end; max-width: 88%; }
.bubble.typing::after { content: "·"; animation: dots 1.2s infinite; }
@keyframes dots { 0% { content: " ·"; } 33% { content: " ··"; } 66% { content: " ···"; } 100% { content: " ·"; } }

.composer { background: #fff; border-top: 1px solid var(--border); padding: 10px 12px; position: sticky; bottom: 0; }
.composer textarea { resize: none; min-height: 38px; max-height: 100px; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
#char-counter { font-size: 11px; color: var(--muted); }
.composer button { padding: 8px 18px; }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
