* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.container { width: 100%; max-width: 420px; }

.card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.title { font-size: 24px; font-weight: 700; color: #1a1a2e; margin-bottom: 4px; }
.subtitle { font-size: 14px; color: #666; margin-bottom: 24px; }

/* Form fields */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: #444; }
.field input:not([type="checkbox"]):not([type="file"]),
.field select,
.field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid #e2e4ee; border-radius: 10px;
  font-size: 14px; color: #222; background: #fff; outline: none; font-family: inherit;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,.12);
}
.field input.readonly, .field input:disabled {
  background: #fff; color: #9aa0b4; border-color: #e6e8f0; cursor: default;
}

/* 注册字段展开动画 */
.field {
  max-height: 80px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .3s ease, opacity .3s ease, margin .3s ease;
}
.field.hidden {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  gap: 0;
  border: 0;
}

/* Checkbox */
.field-row { display: flex; align-items: center; max-height: none; }
.check-row { justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: #555; cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: #667eea; }

/* 密码显隐 */
.field input[type="tel"] {
  padding: 12px 14px; border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 14px; transition: border-color .2s, box-shadow .2s; outline: none;
}
.pwd-wrap { position: relative; display: flex; }
.pwd-wrap input { width: 100%; padding-right: 42px; }
.pwd-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1;
  padding: 6px 8px; color: #999;
}
.pwd-toggle:hover { color: #667eea; }

/* 历史账号 */
.history-box { margin-bottom: 18px; }
.history-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #999; margin-bottom: 8px; }
.link.tiny { font-size: 12px; }
.history-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid #e3e6f5; background: #f6f7fb; color: #555; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: #667eea; color: #667eea; }
.form-tip { font-size: 12px; color: #8a6d3b; background: #fcf8e3; border: 1px solid #faebcc; border-radius: 8px; padding: 8px 10px; }
.form-tip.hidden { display: none; }

/* Buttons */
.btn {
  padding: 12px 24px; border: none; border-radius: 8px; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: all .2s;
}
.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5a6fd6; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; transform: none; }
.btn-full { width: 100%; }
.btn-outline {
  background: transparent; border: 1.5px solid #ddd; color: #555; margin-top: 20px;
}
.btn-outline:hover { border-color: #667eea; color: #667eea; }

/* Messages */
.form-msg { font-size: 13px; min-height: 18px; text-align: center; }
.form-msg.error { color: #e74c3c; }
.form-msg.success { color: #27ae60; }

/* Profile view */
.avatar {
  width: 64px; height: 64px; border-radius: 50%; background: #667eea center/cover no-repeat;
  color: #fff; font-size: 28px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; margin: 0 auto 16px;
}
#profile-view { text-align: center; position: relative; overflow: hidden; }
#profile-view > *:not(.bg-layer) { position: relative; z-index: 1; }
.bg-layer { position: absolute; inset: 0; z-index: 0; display: none; }
#profile-view.has-bg .bg-layer { display: block; }
.bg-layer img, .bg-layer video { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-layer::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.72); }
.profile-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.profile-actions .btn { margin-top: 0; flex: 1; padding-left: 0; padding-right: 0; }
a.btn { text-decoration: none; display: inline-block; text-align: center; }
.text-muted { color: #888; font-size: 18px; }

/* Turnstile */
.turnstile-box { display: flex; justify-content: center; min-height: 65px; max-height: none; }

/* Utility */
.hidden { display: none !important; }
.field.hidden { display: flex !important; } /* 注册字段用过渡动画而非直接隐藏 */

/* ===== 设置页 ===== */
#settings-card { max-width: 560px; margin: 0 auto; }
.container:has(#settings-card) { max-width: 560px; }

.section { padding: 20px 0; border-top: 1px solid #eef0f6; }
.section:first-of-type { border-top: none; padding-top: 4px; }
.section-head { margin-bottom: 16px; }
.section-head .section-title {
  font-size: 13px; font-weight: 700; color: #667eea; letter-spacing: .04em; text-transform: uppercase;
}

.field select, .field textarea {
  padding: 12px 14px; border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.field select:focus, .field textarea:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.12); }

.field-row-2 { display: flex; gap: 14px; }
.field-row-2 .field { flex: 1; }

.divider { border: none; border-top: 1px solid #eee; margin: 28px 0; }
.section-title { font-size: 16px; font-weight: 600; color: #1a1a2e; margin-bottom: 4px; }

.settings-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }
.link { background: none; border: none; color: #667eea; font-size: 14px; cursor: pointer; text-decoration: none; padding: 0; font-family: inherit; }
.link:hover { text-decoration: underline; }
.link.danger { color: #e74c3c; }

/* 头像上传 */
.avatar-upload { display: flex; gap: 14px; align-items: center; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%; flex: 0 0 auto;
  background: #eef0fa center/cover no-repeat; border: 1.5px solid #ddd;
  display: flex; align-items: center; justify-content: center; color: #999; font-size: 13px;
}
.avatar-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.btn-sm { padding: 8px 14px; font-size: 13px; align-self: flex-start; }

/* 背景上传 */
.bg-upload { display: flex; flex-direction: column; gap: 10px; }
.bg-preview {
  width: 100%; aspect-ratio: 16 / 6; border-radius: 10px; overflow: hidden;
  background: #eef0fa; border: 1.5px solid #ddd;
  display: flex; align-items: center; justify-content: center; color: #999; font-size: 13px;
}
.bg-preview img, .bg-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-actions { display: flex; flex-direction: column; gap: 8px; }
.bg-row { display: flex; gap: 8px; }
.bg-row input[type="url"] { flex: 1; padding: 10px 12px; border: 1.5px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; }
.bg-row input[type="url"]:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.12); }
.bg-kind { padding: 10px 12px; border: 1.5px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; background: #fff; cursor: pointer; }
.upload-hint { font-size: 12px; color: #999; }

/* ===== chat 子域卡片（复用主页的头像 / 背景层渲染） ===== */
#chat-card { text-align: center; position: relative; overflow: hidden; }
#chat-card > *:not(.bg-layer) { position: relative; z-index: 1; }
#chat-card.has-bg .bg-layer { display: block; }

/* Responsive */
@media (max-width: 480px) {
  .card { padding: 28px 20px; }
  .title { font-size: 20px; }
}
