:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #2b2b2b;
  --muted: #8a857c;
  --accent: #5b8c7b;
  --accent-ink: #ffffff;
  --me: #5b8c7b;
  --them: #ffffff;
  --them-border: #e7e3da;
  --danger: #b5524a;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }
.zh { color: var(--muted); font-weight: 400; }

/* ---- Setup ---- */
#setup { align-items: center; justify-content: center; padding: 20px; }
.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.logo { margin: 0; font-size: 34px; letter-spacing: -0.5px; }
.tagline { margin: 6px 0 24px; color: var(--ink); line-height: 1.5; font-size: 15px; }
.account { font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; margin: 0 0 18px; }
.account strong { color: var(--ink); }
.guest-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 0 0 16px; }
.guest-note a { display: inline-block; margin-top: 6px; color: var(--accent); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; margin-bottom: 6px; color: var(--ink); }
.field input[type="text"], .field select, .drawer select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--them-border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
}
#impressionFree { margin-top: 8px; }

.switches { display: flex; gap: 10px; margin: 6px 0 16px; }
.switch {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--them-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.switch small { display: block; color: var(--muted); font-size: 11px; }
.switch.small { flex: none; border: none; padding: 4px 0; }

button {
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: none;
  padding: 12px 16px;
}
.primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.primary:hover { filter: brightness(1.05); }
.ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.danger { background: var(--danger); color: #fff; }
.hint { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ---- Chat ---- */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--them-border);
}
.header-actions { display: flex; gap: 6px; }
.badge {
  font-size: 11px;
  color: var(--muted);
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid var(--them-border);
  border-radius: 999px;
}
.peer-bar {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--muted);
  background: #efece5;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { max-width: 78%; display: flex; flex-direction: column; gap: 3px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.me .bubble { background: var(--me); color: #fff; border-bottom-right-radius: 5px; }
.msg.them .bubble { background: var(--them); border: 1px solid var(--them-border); border-bottom-left-radius: 5px; }
.msg .nick { font-size: 11px; color: var(--muted); padding: 0 6px; }
.msg .meta { font-size: 11px; color: var(--muted); padding: 0 6px; display: flex; gap: 10px; }
.msg .meta button { background: none; border: none; color: var(--muted); padding: 0; font-size: 11px; text-decoration: underline; cursor: pointer; }
.original {
  font-size: 13px;
  color: var(--muted);
  border-left: 2px solid var(--them-border);
  padding: 2px 8px;
  margin: 2px 6px 0;
}
.coach {
  font-size: 12px;
  color: var(--accent);
  background: #eef3f1;
  border-radius: 8px;
  padding: 5px 9px;
  margin: 2px 6px 0;
  max-width: 100%;
}
.pending { opacity: 0.55; font-style: italic; }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border-top: 1px solid var(--them-border);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--them-border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  max-height: 140px;
}
.send { width: auto; padding: 0 20px; }

/* ---- Drawer ---- */
.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: flex-end;
}
.drawer-inner {
  width: 320px;
  max-width: 86vw;
  background: var(--surface);
  height: 100%;
  padding: 22px;
  overflow-y: auto;
}
.drawer h3 { margin-top: 0; }
.drawer-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.drawer-actions button { width: 100%; }
.disclosure { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 18px; }

@media (max-width: 480px) {
  .card { padding: 26px 20px; }
}
