/* =================================================================
   0. 根字体大小与单位设置 (Root Font Size & Unit Setup)
   ================================================================= */
html {
  /* 移动端优先：基于 375px 设计稿宽度，1rem 在此基准下等于 10px。
     公式: 10px * (当前屏幕宽度 / 375px) = calc(10 / 375 * 100vw) = 2.66667vw */
  font-size: 2.66667vw;
}

@media (min-width: 768px) {
  /* 在平板及以上设备，使用一个固定的、较大的基础字体大小，避免元素无限放大 */
  html {
    font-size: 16px;
  }
}

/* =================================================================
   1. 全局变量与基础样式 (Global Variables & Base Styles)
   ================================================================= */

/* --- 主题四：日落余晖 (Sunset Glow) --- */
:root {
  /* 颜色主题 */
  --color-bg-primary: #2c1a1d; /* 深红色背景 */
  --color-bg-secondary: #4a2a2a; /* 次级背景 */
  --color-bg-tertiary: #6e3a3a; /* 三级背景 */
  --color-bg-darker: #1e1214; /* 更深的背景 */
  --color-bg-chat: #8b4513; /* 聊天背景 */
  --color-bg-modal: #a0522d; /* 弹窗背景 */
  --color-bg-light: #ffffff;
  --color-bg-input: #fff8f0; /* 输入框背景 */
  --color-bg-input-error: #fff5f5;

  /* 文本颜色 */
  --color-text-primary: #fffaf0; /* 主要文本颜色 */
  --color-text-secondary: #ffcc80; /* 次要文本颜色 */
  --color-text-placeholder: #b29e9e; /* 占位符颜色 */
  --color-text-dark: #5d4037; /* 深色文本 */

  /* 强调色 */
  --color-accent-pink: #ff6f61; /* 珊瑚粉 */
  --color-accent-purple: #c86b85; /* 柔和的莓红色 */
  --color-accent-yellow: #ffa500; /* 橙色 */
  --color-accent-gold: #ff8c00; /* 暗橙色 */
  --color-accent-highlight: #ff4500; /* 橙红色高光 */
  --color-accent-bright-yellow: #ffdb58; /* 明亮的黄色 */

  /* 渐变 */
  --gradient-primary: linear-gradient(
    90deg,
    var(--color-accent-purple),
    var(--color-accent-pink) 50%,
    var(--color-accent-yellow)
  );
  --gradient-title: linear-gradient(
    150deg,
    #ffb6c1,
    #ffe4b5 50%,
    var(--color-accent-yellow)
  );
  --gradient-modal-header: linear-gradient(
    90deg,
    #ff6f61,
    #c86b85 53%,
    #8b4513
  );

  /* 边框和错误状态 */
  --color-border-primary: #ff7f50;
  --color-border-input: #f5deb3;
  --color-border-input-focus: #d2691e;
  --color-border-input-error: #e53e3e;

  /* 尺寸与圆角 (保持不变) */
  --border-radius-s: 2.133vw;
  --border-radius-m: 3.2vw;
  --border-radius-l: 5.867vw;
  --border-radius-xl: 8vw;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Microsoft YaHei", sans-serif;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.main-content {
  padding: 1.6rem; /* 16px -> 1.6rem */
  flex-grow: 1;
}

.scrollbar-hidden::-webkit-scrollbar {
  display: none;
}
.scrollbar-hidden {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* =================================================================
   2. 通用组件样式 (Common Components)
   ================================================================= */
.header {
  padding: 1.6rem 2rem; /* 16px 20px */
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  height: 6rem; /* 60px */
}

.header .header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 4rem; /* 40px */
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease;
  padding: 0;
}
.header .header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}
.header .header-btn img {
  width: 90%;
  height: 90%;
}

.header .title {
  font-weight: 700;
  text-align: center;
  font-size: clamp(20px, 2.4rem, 24px); /* 保留 clamp，但使用 rem 作为基准 */
  background: var(--gradient-title);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1rem, 12px);
  margin: 0;
  white-space: nowrap;
}
.header .title img {
  width: clamp(28px, 3.6rem, 36px);
}

.header .left-placeholder,
.header .right-placeholder {
  width: 4rem; /* 40px */
}

.modal-wrapper {
  padding: 0 !important;
  max-width: 90%;
  border-radius: 1.2rem !important; /* 12px */
  background-color: var(--color-bg-modal) !important;
}
.modal-title-wrapper {
  height: 5.3rem; /* 53px */
  background: var(--gradient-modal-header);
  border-radius: 1.2rem 1.2rem 0 0;
}
.modal-title {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem; /* 24px */
  font-weight: 600;
  background: var(--gradient-title);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.modal-body .action {
  width: 90%;
  height: 5.8rem; /* 58px */
  background: var(--gradient-primary);
  border-radius: 2.9rem; /* 29px */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem; /* 21px */
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 auto 2.6rem; /* 26px */
  cursor: pointer;
}

/* =================================================================
   4. 通用加载动画 (Universal Loading Spinner)
   ================================================================= */
.loading-container {
  position: relative;
}
.custom-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(43, 16, 85, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  border-radius: inherit;
}
.custom-loading-spinner {
  width: 5rem; /* 50px */
  height: 5rem;
  border: 4px solid rgba(255, 255, 255, 0.3); /* px is fine for border */
  border-top-color: var(--color-accent-highlight);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* =================================================================
   5. 自定义 Toast 通知 (Custom Toast Notification)
   ================================================================= */
.custom-toast-container {
  position: fixed;
  top: 2rem; /* 20px */
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem; /* 10px */
}
.custom-toast {
  display: flex;
  align-items: center;
  padding: 1.2rem 2rem; /* 12px 20px */
  border-radius: 1.2rem;
  color: var(--color-text-primary);
  font-size: clamp(14px, 1.6rem, 16px);
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(-2rem); /* 20px */
  transition: opacity 0.3s ease, transform 0.3s ease;
  min-width: 28rem; /* 280px */
  max-width: 90%;
}
.custom-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.custom-toast .icon {
  margin-right: 1.2rem; /* 12px */
  width: 2.2rem; /* 22px */
  height: 2.2rem;
}
.custom-toast.success {
  background: linear-gradient(135deg, #28a745, #218838);
}
.custom-toast.error {
  background: linear-gradient(135deg, #dc3545, #c82333);
}
.custom-toast.warning {
  background: linear-gradient(135deg, #ffc107, #e0a800);
  color: #212529;
}
.custom-toast.success .icon {
  content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
}
.custom-toast.error .icon {
  content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>');
}
.custom-toast.warning .icon {
  content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23212529"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/></svg>');
}

/* --- 通用提醒区域样式 --- */
.reminder-section {
  margin-top: 2.4rem;
}
.reminder-block {
  margin-bottom: 2.4rem;
}
.reminder-block .reminder-title {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  color: var(--color-accent-bright-yellow);
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.reminder-block .reminder-title .left,
.reminder-block .reminder-title .right {
  flex-grow: 1;
  height: 1px;
  background: linear-gradient(
    to right,
    rgba(221, 179, 255, 0),
    var(--color-text-secondary)
  );
}
.reminder-block .reminder-title .left {
  background: linear-gradient(
    to left,
    rgba(221, 179, 255, 0),
    var(--color-text-secondary)
  );
}
.reminder-block .content {
  font-size: 1.4rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}
.reminder-block .content p {
  margin-bottom: 0.5rem;
}
