/* ========== Local Fonts ========== */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../assets/fonts/nunito-latin.woff2') format('woff2');
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #e8ecf2;
  color: #264653;
  font-family: "Nunito", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ========== 小程序外壳（桌面/平板居中“手机”，手机全宽） ========== */
.mp-viewport {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
}
@media (max-width: 480px) {
  .mp-viewport {
    padding: 0;
    align-items: stretch;
  }
  /* 与桌面端一致：外壳高度锁在视口内，主内容在 .main-content 内滚动，底栏始终贴在壳底 */
  .mp-shell {
    min-height: 100dvh;
    height: 100dvh;
    max-height: 100dvh;
  }
}

.mp-shell {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: calc(100vh - 24px);
  min-height: calc(100dvh - 24px);
  background: #FFF9E6;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* fixed 子元素相对本容器定位（小程序视窗内） */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}
@media (min-width: 481px) {
  .mp-shell {
    border-radius: 28px;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.6) inset,
      0 24px 80px rgba(38, 70, 83, 0.12),
      0 8px 24px rgba(0, 0, 0, 0.06);
    min-height: min(calc(100dvh - 24px), 900px);
    max-height: calc(100dvh - 24px);
  }
}

/* 顶栏（参考小程序导航栏） */
.mp-header {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 209, 102, 0.35);
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  z-index: 60;
}
.mp-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.mp-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mp-header-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(145deg, #FFD166, #F4A261);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(244, 162, 97, 0.35);
}
.mp-header-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #264653;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mp-header-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: #6b7280;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.mp-header-name {
  text-decoration: none;
  cursor: pointer;
  color: #6b7280;
}
a.mp-header-name:hover {
  color: #F4A261;
}
.mp-header-logout {
  font-size: 0.7rem;
  font-weight: 800;
  color: #F4A261;
  background: rgba(255, 209, 102, 0.2);
  border: none;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mp-header-logout:hover {
  background: #FFD166;
  color: #fff;
}

a { text-decoration: none; color: inherit; }
button { border: none; cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

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

/* ========== App Layout ========== */
.app-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

/* ========== Sidebar（小程序模式隐藏，统一用底栏） ========== */
.sidebar {
  display: none !important;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}
.sidebar-logo-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 2px solid #FFD166;
}
.sidebar-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #F4A261;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  transition: all 0.3s ease;
  color: #6b7280;
  font-weight: 700;
  font-size: 1rem;
}
.nav-item:hover {
  background: #FFF9E6;
  color: #F4A261;
  transform: scale(1.05);
}
.nav-item.active {
  background: #FFD166;
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,209,102,0.3);
  font-weight: 900;
}
.nav-item.active:hover {
  transform: scale(1.05);
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  justify-content: center;
  padding-top: 24px;
}
.sidebar-duck {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

/* ========== Duck Run Animation ========== */
@keyframes duck-run {
  0%, 100% { transform: translateX(0) scaleX(1); }
  49% { transform: translateX(80px) scaleX(1); }
  50% { transform: translateX(80px) scaleX(-1); }
  99% { transform: translateX(0) scaleX(-1); }
}
.duck-run {
  animation: duck-run 3s ease-in-out infinite;
}

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
.main-content::-webkit-scrollbar { display: none; }
.main-content { -ms-overflow-style: none; scrollbar-width: none; }

/* ========== Bottom Nav（小程序底栏，始终显示） ========== */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  box-shadow: 0 -4px 20px rgba(38, 70, 83, 0.08);
  border-radius: 20px 20px 0 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  flex-shrink: 0;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 700;
  transition: color 0.2s;
}
.bottom-nav-item.active { color: #F4A261; }
.bottom-nav-item .bottom-nav-icon {
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s;
  background: transparent;
}
.bottom-nav-item.active .bottom-nav-icon {
  background: #FFD166;
  color: #fff;
}

/* ========== Page Transition ========== */
.page-enter {
  opacity: 0;
}
.page-active {
  opacity: 1;
  transition: opacity 0.35s ease;
}

/* ========== Backdrop (shared drawer/modal) ========== */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38,70,83,0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.backdrop.open,
.backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ========== Drawer Panel (shared) ========== */
.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  z-index: 110;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  flex-direction: column;
  border-radius: 24px 0 0 24px;
  overflow: hidden;
}
.drawer-panel.open {
  transform: translateX(0);
}

/* ========== Common Button Styles ========== */
.btn-primary {
  background: linear-gradient(135deg, #FFD166, #F4A261);
  color: #fff;
  font-weight: 900;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(244,162,97,0.3);
}
.btn-primary:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 32px rgba(244,162,97,0.4);
}
.btn-primary:active { transform: scale(0.96); }

.btn-secondary {
  background: #FFF9E6;
  color: #F4A261;
  font-weight: 900;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: #FFD166;
  color: #fff;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -80px);
  z-index: 300;
  background: #F4A261;
  color: #fff;
  padding: 16px 32px;
  border-radius: 9999px;
  font-weight: 900;
  font-size: 1.125rem;
  box-shadow: 0 12px 40px rgba(244,162,97,0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.5s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  transform: translate(-50%, 32px);
  opacity: 1;
}

/* ========== Pill / Tag ========== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

/* ========== Card ========== */
.card {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.3s;
}
.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* ========== Range Slider ========== */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 9999px;
  background: #FFF9E6;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #F4A261;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(244,162,97,0.4);
}

/* ========== Utility ========== */
.text-duck-orange { color: #F4A261; }
.text-duck-dark { color: #264653; }
.bg-warm { background: #FFF9E6; }
.bg-white-60 { background: rgba(255,255,255,0.6); }

/* Float bounce animation */
@keyframes float-bounce {
  0%, 100% { transform: translateY(10px); }
  50% { transform: translateY(-10px); }
}
.float-bounce {
  animation: float-bounce 3s ease-in-out infinite;
}

/* Pulse animation */
@keyframes pulse-soft {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.2; }
}

/* Shake for bell */
@keyframes bell-shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(15deg); }
  75% { transform: rotate(-15deg); }
}

/* Wiggle for level up */
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(8deg); }
  75% { transform: rotate(-8deg); }
}

/* ========== Sidebar User Info ========== */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(255,249,230,0.7);
  border-radius: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(255,209,102,0.3);
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  background: #FFD166;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.sidebar-user-detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-user-name {
  font-size: 0.9375rem;
  font-weight: 900;
  color: #264653;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-logout-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: color 0.2s;
}
.sidebar-logout-btn:hover { color: #F4A261; }

/* ========== Sidebar Bottom (duck track + user widget) ========== */
.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-duck-track {
  position: relative;
  height: 60px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.sidebar-duck-small {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex-shrink: 0;
  --duck-travel: 120px;
  animation: duck-widget-run 3s ease-in-out infinite;
}
@keyframes duck-widget-run {
  0%,  100% { transform: translateX(0)                      scaleX(1);  }
  49%        { transform: translateX(var(--duck-travel))     scaleX(1);  }
  50%        { transform: translateX(var(--duck-travel))     scaleX(-1); }
  99%        { transform: translateX(0)                      scaleX(-1); }
}
