/* ===== 角色扮演 · 暖色系设计 ===== */
:root {
  --coral: #E25A3D;
  --peach: #F2845C;
  --light-peach: #FFD9C2;
  --light-peach2: #FFE4D6;
  --ink: #4A3128;
  --cream: #FFF7F2;
  --muted: #A08A80;
  --line: #F0E3DA;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--cream);
}
.hidden { display: none !important; }

/* 手机壳容器：移动端铺满，PC 端居中卡片 */
.app-phone {
  width: min(420px, 100%);
  height: min(780px, calc(100vh - 48px));
  min-height: 520px;
  margin: 0 auto;
  background: var(--cream);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

/* ===== 顶部栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}
.topbar-title { flex: 1; font-size: 17px; font-weight: 500; text-align: center; }
.btn-back, .btn-icon, .btn-save {
  border: none; background: none; cursor: pointer;
  font-size: 15px; color: var(--coral); padding: 4px 6px;
}
.btn-save { font-weight: 500; }

/* ===== 认证 ===== */
#view-auth { align-items: center; justify-content: center; padding: 32px 24px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.logo-dot {
  width: 52px; height: 52px; border-radius: 16px;
  background: var(--coral); margin: 0 auto 14px;
  position: relative;
}
.logo-dot::after {
  content: ""; position: absolute; left: 18px; top: 16px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
}
.auth-head h1 { font-size: 22px; font-weight: 500; margin: 0 0 8px; }
.auth-head .sub { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.6; }
.auth-tabs { display: flex; background: var(--light-peach2); border-radius: 12px; padding: 4px; margin-bottom: 18px; width: 100%; max-width: 300px; }
.auth-tab {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 9px 0; border-radius: 9px; font-size: 14px; color: var(--muted);
}
.auth-tab.active { background: #fff; color: var(--coral); font-weight: 500; }
.auth-panel { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ===== 表单 ===== */
.input, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; font-family: inherit; color: var(--ink);
  background: #fff; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--peach); }
.textarea { resize: none; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; }

.btn {
  border: none; border-radius: 12px; cursor: pointer;
  padding: 12px; font-size: 15px; font-weight: 500;
}
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:active { background: #c94f33; }
.btn-ghost { background: #fff; color: var(--coral); border: 1px solid var(--light-peach); white-space: nowrap; padding: 12px 14px; }

.field-label { font-size: 13px; color: var(--muted); margin: 14px 0 6px; display: block; }
.chip-row { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 16px; border-radius: 20px; font-size: 13px; cursor: pointer;
}
.chip.selected { background: var(--light-peach2); border-color: var(--coral); color: var(--coral); }

/* ===== 角色列表 ===== */
.list-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.role-card {
  background: #fff; border-radius: 16px; padding: 16px;
  margin-bottom: 12px; cursor: pointer; border: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.role-card:active { background: #FFF9F5; }
.role-avatar {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: var(--light-peach2); color: var(--coral);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.role-info { flex: 1; min-width: 0; }
.role-name { font-size: 16px; font-weight: 500; }
.role-desc { font-size: 12px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-edit-btn { border: none; background: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px; }
.empty-tip { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }
.fab {
  position: absolute; right: 22px; bottom: 22px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--coral); color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 14px rgba(226, 90, 61, 0.35);
}
.fab:active { background: #c94f33; }

/* ===== 角色编辑 ===== */
.edit-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.preset-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; }
.preset-chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.preset-chip:active { background: var(--light-peach2); }

/* ===== 聊天 ===== */
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
.chat-hint { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 16px; line-height: 1.7; }
.msg { max-width: 76%; margin-bottom: 12px; display: flex; }
.msg .bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.msg.them { align-self: flex-start; }
.msg.them .bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 6px; }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--coral); color: #fff; border-top-right-radius: 6px; }
.typing { align-self: flex-start; }
.typing .bubble { background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 14px; }

.chat-input-bar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--line); background: #fff; flex-shrink: 0;
}
.chat-input {
  flex: 1; border: 1px solid var(--line); border-radius: 20px;
  padding: 10px 14px; font-size: 15px; font-family: inherit; color: var(--ink);
  outline: none; resize: none; max-height: 100px; background: var(--cream);
}
.chat-input:focus { border-color: var(--peach); }
.btn-send {
  border: none; background: var(--coral); color: #fff;
  border-radius: 20px; padding: 10px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn-send:active { background: #c94f33; }
.btn-send:disabled { background: var(--muted); }

/* ===== toast ===== */
.toast {
  position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(74, 49, 40, 0.9); color: #fff;
  padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 100;
  max-width: 80%; text-align: center;
}

/* ===== 移动端 & PC 自适应 ===== */
@media (max-width: 480px) {
  .app-phone { height: 100vh; min-height: 0; }
}
@media (min-width: 900px) {
  body {
    background: linear-gradient(135deg, #FFE4D6 0%, #FFF7F2 40%, #FFD9C2 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px 0;
  }
  .app-phone { border-radius: 20px; box-shadow: 0 12px 40px rgba(74, 49, 40, 0.12); }
}
