/* ==========================================================================
   牧院圈 MuYuanQuan — 基础层
   ========================================================================== */

:root {
  --mq-primary: #5b7cfa;
  --mq-primary-2: #8b5cf6;
  --mq-accent: #ff6b9d;
  --mq-cyan: #22d3ee;
  --mq-amber: #fbbf24;
  --mq-green: #34d399;
  --mq-rose: #fb7185;

  --mq-grad-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --mq-grad-warm: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --mq-grad-cool: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --mq-grad-sun: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --mq-grad-mint: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --mq-grad-violet: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);

  --mq-bg: #f5f6fa;
  --mq-surface: #ffffff;
  --mq-surface-2: #fafbfe;
  --mq-text: #1a1d29;
  --mq-text-2: #5a6072;
  --mq-text-3: #969cb0;
  --mq-line: rgba(0, 0, 0, 0.07);

  --mq-glass: rgba(255, 255, 255, 0.72);
  --mq-glass-line: rgba(255, 255, 255, 0.55);

  --mq-sh-1: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --mq-sh-2: 0 4px 16px rgba(16, 24, 40, .08);
  --mq-sh-3: 0 12px 32px rgba(16, 24, 40, .12);
  --mq-sh-glow: 0 8px 28px rgba(91, 124, 250, .32);

  --mq-radius: 18px;
  --mq-radius-sm: 12px;
  --mq-radius-lg: 24px;
  --mq-tabbar-h: 62px;
  --mq-header-h: 56px;
  --mq-safe-b: env(safe-area-inset-bottom, 0px);
  --mq-safe-t: env(safe-area-inset-top, 0px);

  --mq-ease: cubic-bezier(.4, 0, .2, 1);
  --mq-spring: cubic-bezier(.34, 1.56, .64, 1);
}

html[data-theme="dark"] {
  --mq-bg: #0b0d14;
  --mq-surface: #151824;
  --mq-surface-2: #1c2030;
  --mq-text: #eef1f8;
  --mq-text-2: #a8b0c4;
  --mq-text-3: #6b7488;
  --mq-line: rgba(255, 255, 255, 0.08);
  --mq-glass: rgba(21, 24, 36, 0.72);
  --mq-glass-line: rgba(255, 255, 255, 0.1);
  --mq-sh-1: 0 1px 3px rgba(0, 0, 0, .4);
  --mq-sh-2: 0 4px 16px rgba(0, 0, 0, .45);
  --mq-sh-3: 0 12px 32px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--mq-bg);
  color: var(--mq-text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

img { max-width: 100%; display: block; border: 0; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--mq-line); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Aurora 背景 ---------- */
.mq-aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.mq-aurora i {
  position: absolute; display: block; border-radius: 50%;
  filter: blur(72px); opacity: .5;
  animation: mqFloat 22s var(--mq-ease) infinite;
  will-change: transform;
}
.mq-aurora i:nth-child(1) { width: 320px; height: 320px; top: -90px; left: -80px; background: radial-gradient(circle, #667eea, transparent 68%); }
.mq-aurora i:nth-child(2) { width: 300px; height: 300px; top: 12%; right: -100px; background: radial-gradient(circle, #f093fb, transparent 68%); animation-delay: -6s; }
.mq-aurora i:nth-child(3) { width: 340px; height: 340px; bottom: 6%; left: -110px; background: radial-gradient(circle, #4facfe, transparent 68%); animation-delay: -12s; }
.mq-aurora i:nth-child(4) { width: 260px; height: 260px; bottom: -80px; right: -60px; background: radial-gradient(circle, #43e97b, transparent 68%); animation-delay: -18s; }
@keyframes mqFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(42px, -34px) scale(1.12); }
  66%      { transform: translate(-32px, 30px) scale(.92); }
}
html[data-theme="dark"] .mq-aurora i { opacity: .34; }

/* ---------- 布局 ---------- */
.mq-app {
  position: relative; z-index: 1;
  max-width: 640px; margin: 0 auto; min-height: 100vh;
  padding-bottom: calc(var(--mq-tabbar-h) + var(--mq-safe-b) + 12px);
}
.mq-page { display: none; animation: mqPageIn .34s var(--mq-ease); }
.mq-page.is-active { display: block; }
@keyframes mqPageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.mq-wrap { padding: 0 16px; }

/* ---------- 顶部栏 ---------- */
.mq-header {
  position: sticky; top: 0; z-index: 50;
  padding-top: var(--mq-safe-t);
  background: var(--mq-glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--mq-line);
}
.mq-header-inner { height: var(--mq-header-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.mq-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.mq-brand-logo {
  width: 34px; height: 34px; border-radius: 11px; object-fit: cover;
  box-shadow: var(--mq-sh-glow); background: var(--mq-grad-main);
}
.mq-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.mq-brand-name {
  font-size: 16.5px; font-weight: 800; letter-spacing: .3px;
  background: var(--mq-grad-main);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mq-brand-sub { font-size: 10px; color: var(--mq-text-3); letter-spacing: .5px; }
.mq-header-spacer { flex: 1; }

.mq-icon-btn {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center; color: var(--mq-text-2);
  transition: background .2s, transform .2s, color .2s;
}
.mq-icon-btn:active { transform: scale(.9); background: var(--mq-line); }
.mq-icon-btn svg { width: 20px; height: 20px; }

/* ---------- 底部导航 ---------- */
.mq-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  height: calc(var(--mq-tabbar-h) + var(--mq-safe-b));
  padding-bottom: var(--mq-safe-b);
  background: var(--mq-glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--mq-line);
  display: flex; align-items: center;
  /* 使用视口单位避免 max-width 在 <640px 时导致的横向溢出 */
  width: 100%;
  max-width: min(640px, 100vw);
  margin: 0 auto;
}
.mq-tab {
  flex: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--mq-text-3); font-size: 10.5px; font-weight: 600;
  transition: color .24s; position: relative;
}
.mq-tab svg { width: 21px; height: 21px; transition: transform .3s var(--mq-spring); }
.mq-tab.on { color: var(--mq-primary); }
.mq-tab.on svg { transform: translateY(-2px) scale(1.09); }
.mq-tab.on::before {
  content: ''; position: absolute; top: 6px; width: 26px; height: 3px;
  border-radius: 2px; background: var(--mq-grad-main);
}

/* ---------- 按钮 ---------- */
.mq-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 22px; border-radius: 14px;
  font-size: 15px; font-weight: 700;
  transition: transform .2s var(--mq-spring), box-shadow .24s, opacity .2s;
}
.mq-btn:active { transform: scale(.96); }
.mq-btn svg { width: 18px; height: 18px; }
.mq-btn-primary { background: var(--mq-grad-main); color: #fff; box-shadow: var(--mq-sh-glow); }
.mq-btn-ghost { background: var(--mq-surface); color: var(--mq-text-2); border: 1px solid var(--mq-line); }
.mq-btn-block { width: 100%; }
.mq-btn-sm { height: 38px; padding: 0 16px; font-size: 13.5px; border-radius: 11px; }
.mq-btn[disabled] { opacity: .55; pointer-events: none; }

.mq-fab {
  position: fixed;
  right: max(18px, calc(50vw - 320px + 18px));
  bottom: calc(var(--mq-tabbar-h) + var(--mq-safe-b) + 16px);
  width: 54px; height: 54px; border-radius: 19px;
  background: var(--mq-grad-main); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(91,124,250,.45);
  z-index: 60;
  transition: transform .26s var(--mq-spring);
}
.mq-fab:active { transform: scale(.88) rotate(90deg); }
.mq-fab svg { width: 24px; height: 24px; }

/* ---------- 表单 ---------- */
.mq-field { margin-bottom: 15px; }
.mq-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--mq-text-2); }
.mq-label i { color: var(--mq-accent); font-style: normal; }
.mq-input, .mq-textarea, .mq-select {
  width: 100%; padding: 13px 15px; border-radius: 13px;
  border: 1.5px solid var(--mq-line); background: var(--mq-surface);
  font-size: 15px; outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  -webkit-appearance: none; appearance: none;
}
.mq-input:focus, .mq-textarea:focus, .mq-select:focus {
  border-color: var(--mq-primary); box-shadow: 0 0 0 4px rgba(91,124,250,.11);
}
.mq-input::placeholder, .mq-textarea::placeholder { color: var(--mq-text-3); }
.mq-textarea { min-height: 120px; resize: vertical; line-height: 1.66; }
.mq-hint { font-size: 11.5px; color: var(--mq-text-3); margin-top: 6px; }

.mq-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mq-chip {
  padding: 9px 15px; border-radius: 12px;
  background: var(--mq-surface); border: 1.5px solid var(--mq-line);
  font-size: 13.5px; font-weight: 600; color: var(--mq-text-2);
  transition: all .22s var(--mq-ease);
}
.mq-chip.on { background: var(--mq-grad-main); border-color: transparent; color: #fff; box-shadow: var(--mq-sh-glow); }
.mq-chip:active { transform: scale(.94); }

.mq-switch-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; background: var(--mq-surface);
  border-radius: 13px; border: 1.5px solid var(--mq-line);
}
.mq-switch-row-txt { flex: 1; }
.mq-switch-row-txt b { display: block; font-size: 14px; font-weight: 700; }
.mq-switch-row-txt span { font-size: 11.5px; color: var(--mq-text-3); }
.mq-switch {
  width: 48px; height: 28px; border-radius: 16px;
  background: var(--mq-line); position: relative;
  transition: background .28s var(--mq-ease); flex-shrink: 0;
}
.mq-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: var(--mq-sh-1); transition: transform .28s var(--mq-spring);
}
.mq-switch.on { background: var(--mq-grad-main); }
.mq-switch.on::after { transform: translateX(20px); }

/* ---------- 工具类 ---------- */
.mq-hide { display: none !important; }
.mq-mt { margin-top: 14px; }
.mq-center { text-align: center; }
.mq-row { display: flex; align-items: center; gap: 10px; }
.mq-fill { flex: 1; }
.mq-nowrap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mq-alert {
  margin: 12px 16px 0; padding: 12px 14px;
  border-radius: var(--mq-radius-sm); font-size: 13px;
  display: flex; align-items: center; gap: 9px; font-weight: 600;
}
.mq-alert svg { width: 17px; height: 17px; flex-shrink: 0; }
.mq-alert-warn { background: rgba(251,191,36,.14); color: #b45309; }
.mq-alert-info { background: rgba(91,124,250,.11); color: #4453c4; }
html[data-theme="dark"] .mq-alert-warn { color: #fbbf24; }
html[data-theme="dark"] .mq-alert-info { color: #93a5ff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}