/* 应用骨架：流动背景、顶栏、视图区、底部 Tab */

/* —— 真·流动背景 —— */
#bg-fluid {
  position: fixed; inset: -14%; z-index: -2;
  background:
    radial-gradient(60% 50% at 16% 10%, rgba(168, 230, 207, 0.55), transparent 60%),
    radial-gradient(52% 44% at 88% 18%, rgba(94, 202, 165, 0.42), transparent 60%),
    radial-gradient(64% 54% at 50% 100%, rgba(52, 211, 153, 0.26), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  animation: bgSpin 70s linear infinite;
  will-change: transform;
}
/* 漂移光晕（由 main.js 注入 .orb 元素；纯柔径向渐变，不依赖 blur，省电） */
#bg-fluid .orb {
  position: absolute; border-radius: 50%; opacity: 0.85;
  mix-blend-mode: screen; will-change: transform;
}
#bg-fluid .orb.o1 {
  width: 62vmax; height: 62vmax; left: -12vmax; top: -14vmax;
  background: radial-gradient(circle, rgba(120, 232, 192, 0.6), transparent 66%);
  animation: orbDrift1 22s ease-in-out infinite alternate;
}
#bg-fluid .orb.o2 {
  width: 52vmax; height: 52vmax; right: -14vmax; top: 6vmax;
  background: radial-gradient(circle, rgba(78, 212, 172, 0.5), transparent 66%);
  animation: orbDrift2 29s ease-in-out infinite alternate;
}
#bg-fluid .orb.o3 {
  width: 48vmax; height: 48vmax; left: 18vmax; bottom: -18vmax;
  background: radial-gradient(circle, rgba(190, 242, 214, 0.55), transparent 66%);
  animation: orbDrift3 35s ease-in-out infinite alternate;
}

/* —— 颗粒质感叠层（消除色带、增加触感） —— */
#grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

#app {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 90px);
  max-width: 520px;
  margin: 0 auto;
}

#app-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 4px 6px 18px;
}
#app-header .title {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 500; letter-spacing: 0.4px;
}
#app-header .subtitle { font-size: 13px; color: var(--muted); }

#view { flex: 1; }

/* —— 底部 Tab（含滑动药丸指示器） —— */
#tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 14px);
  width: min(460px, calc(100% - 32px));
  display: flex; justify-content: space-around;
  padding: 7px 6px;
  background: var(--surface-strong);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-radius: 26px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.45);
  z-index: 20;
}

.tab {
  position: relative; z-index: 1;
  flex: 1; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 0;
  transition: color 0.3s var(--ease-out), transform 0.3s var(--ease-spring);
}
.tab::before {
  content: ""; width: 22px; height: 22px; border-radius: 8px;
  background: currentColor; opacity: 0.28;
  mask-size: contain; mask-repeat: no-repeat; mask-position: center;
  -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center;
}
.tab.active { color: var(--green-700); transform: translateY(-1px); }
.tab.active::before { opacity: 0.95; background: linear-gradient(135deg, var(--green-600), var(--green-400)); }

/* 滑动药丸指示器 */
.tab-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 6px;
  width: calc((100% - 12px) / 3);
  border-radius: 18px; z-index: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(225, 245, 236, 0.7));
  box-shadow: 0 6px 16px rgba(47, 169, 138, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 0.42s var(--ease-spring);
}

/* 精致线性图标（mask 路径，纯 CSS 零依赖） */
.tab[data-id="today"]::before { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 3c3.5 4.2 6 7.4 6 10.5A6 6 0 0 1 6 13.5C6 10.4 8.5 7.2 12 3Z' stroke='black' stroke-width='1.8' fill='none' stroke-linejoin='round'/><path d='M9.5 14.5h5' stroke='black' stroke-width='1.8' stroke-linecap='round'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 3c3.5 4.2 6 7.4 6 10.5A6 6 0 0 1 6 13.5C6 10.4 8.5 7.2 12 3Z' stroke='black' stroke-width='1.8' fill='none' stroke-linejoin='round'/><path d='M9.5 14.5h5' stroke='black' stroke-width='1.8' stroke-linecap='round'/></svg>"); }
.tab[data-id="charts"]::before { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 16c3-7 5 4 8-3s4 6 7-2' stroke='black' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 16c3-7 5 4 8-3s4 6 7-2' stroke='black' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
.tab[data-id="settings"]::before { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 8h10M18 8h2M4 16h2M10 16h10' stroke='black' stroke-width='1.8' stroke-linecap='round'/><circle cx='16' cy='8' r='2.2' stroke='black' stroke-width='1.8' fill='none'/><circle cx='8' cy='16' r='2.2' stroke='black' stroke-width='1.8' fill='none'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 8h10M18 8h2M4 16h2M10 16h10' stroke='black' stroke-width='1.8' stroke-linecap='round'/><circle cx='16' cy='8' r='2.2' stroke='black' stroke-width='1.8' fill='none'/><circle cx='8' cy='16' r='2.2' stroke='black' stroke-width='1.8' fill='none'/></svg>"); }

/* 视图切换过渡 */
#view.entering { animation: viewIn 0.32s var(--ease-out); }
#view.leaving { opacity: 0; transition: opacity 0.12s ease; }

/* 背景流动关键帧 */
@keyframes bgSpin { to { transform: rotate(360deg); } }
@keyframes orbDrift1 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(9vmax, 7vmax) scale(1.18); }
  100% { transform: translate(-5vmax, 11vmax) scale(1.05); }
}
@keyframes orbDrift2 {
  0%   { transform: translate(0, 0) scale(1.05); }
  50%  { transform: translate(-8vmax, 9vmax) scale(0.92); }
  100% { transform: translate(6vmax, -6vmax) scale(1.12); }
}
@keyframes orbDrift3 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(7vmax, -8vmax) scale(1.15); }
  100% { transform: translate(-9vmax, -4vmax) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  #bg-fluid { animation: none; }
  #bg-fluid .orb { animation: none !important; }
  #view.entering { animation: none; }
  .tab-indicator { transition: none; }
}
