/* 全站共用：工具入口条 + 结果评分/鼓掌动效（无内联样式，符合站点 CSP style-src 'self'） */

/* ---------- 站内工具入口条：每个页面都有，访客可在任意工具间切换 ---------- */
.toolnav {
  flex-basis: 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 2px;
  padding: 4px 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 135, 150, 0.45) transparent;
}
.toolnav::-webkit-scrollbar { height: 5px; }
.toolnav::-webkit-scrollbar-thumb { background: rgba(120, 135, 150, 0.4); border-radius: 99px; }
.toolnav::-webkit-scrollbar-track { background: transparent; }

.toolnav-item {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px 4px 5px;
  border-radius: 999px;
  border: 1px solid rgba(130, 145, 160, 0.3);
  background: rgba(255, 255, 255, 0.78);
  color: #26405c;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.toolnav-item:hover {
  text-decoration: none;
  background: #fff;
  border-color: #9db8d8;
  box-shadow: 0 4px 14px rgba(24, 62, 110, 0.16);
  transform: translateY(-1px);
}
.toolnav-item:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.toolnav-icon { display: block; width: 18px; height: 18px; border-radius: 5px; }

/* ---------- 结果评分（星级 + 等级标签） ---------- */
.rw-score {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: #1f2f3d;
  animation: rwPop 0.32s ease-out;
}
.rw-stars { letter-spacing: 1.5px; font-size: 15px; line-height: 1; color: #f59e0b; }
.rw-star-off { color: rgba(120, 130, 140, 0.32); }
.rw-tier {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.rw-score[data-tier="s"] .rw-tier { background: rgba(245, 158, 11, 0.2); color: #92400e; }
.rw-score[data-tier="a"] .rw-tier { background: rgba(16, 185, 129, 0.18); color: #047857; }
.rw-score[data-tier="b"] .rw-tier { background: rgba(59, 130, 246, 0.16); color: #1d4ed8; }
.rw-score[data-tier="c"] .rw-tier { background: rgba(148, 163, 184, 0.22); color: #475569; }
.rw-score[data-tier="d"] .rw-tier { background: rgba(239, 68, 68, 0.16); color: #b91c1c; }

@keyframes rwPop {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------- 鼓掌 / 彩点：一次性动效，不拦截点击 ---------- */
.rw-cheer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}
.rw-cheer > span {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 19px;
  line-height: 1;
  opacity: 0;
  animation: rwClap 1.15s ease-out forwards;
}
.rw-cheer > span:nth-child(2) { right: 40px; font-size: 16px; animation-delay: 0.09s; }
.rw-cheer > span:nth-child(3) { right: 62px; font-size: 14px; animation-delay: 0.16s; }
.rw-cheer > i {
  position: absolute;
  bottom: 14px;
  right: 24px;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: #fbbf24;
  opacity: 0;
  animation: rwDot 1.1s ease-out forwards;
}
.rw-cheer > i:nth-of-type(1) { background: #f472b6; animation-delay: 0.04s; }
.rw-cheer > i:nth-of-type(2) { background: #34d399; animation-delay: 0.1s; }
.rw-cheer > i:nth-of-type(3) { background: #60a5fa; animation-delay: 0.02s; }
.rw-cheer > i:nth-of-type(4) { background: #fbbf24; animation-delay: 0.14s; }
.rw-cheer > i:nth-of-type(5) { background: #a78bfa; animation-delay: 0.08s; }

@keyframes rwClap {
  0% { opacity: 0; transform: translate(6px, 8px) scale(0.6) rotate(-14deg); }
  22% { opacity: 1; transform: translate(-2px, -6px) scale(1.18) rotate(9deg); }
  55% { opacity: 1; transform: translate(-6px, -16px) scale(1) rotate(-5deg); }
  100% { opacity: 0; transform: translate(-10px, -34px) scale(0.9) rotate(7deg); }
}
@keyframes rwDot {
  0% { opacity: 1; transform: translate(0, 0) scale(0.7); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-46px, -30px) scale(1); }
}

.rw-host { position: relative; }

@media (prefers-reduced-motion: reduce) {
  .rw-cheer { display: none; }
  .rw-score { animation: none; }
  .toolnav-item:hover { transform: none; }
}

@media (max-width: 640px) {
  .toolnav-item { font-size: 12px; padding: 4px 9px 4px 4px; }
  .toolnav-icon { width: 16px; height: 16px; }
  .rw-score { margin-left: 0; }
}

/* ---------- 结果刻度条：直观看出数值落在量尺的哪一段 ---------- */
.rw-gauge {
  flex-basis: 100%;
  width: 100%;
  margin-top: 12px;
}
.rw-bar {
  display: block;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e6edf8;
  -webkit-appearance: none;
  appearance: none;
}
.rw-bar::-webkit-progress-bar { background: #e6edf8; border-radius: 999px; }
.rw-bar::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #93c5fd, #4f46e5);
  transition: width 0.35s ease;
}
.rw-bar::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, #93c5fd, #4f46e5);
}

/* 百分制：60/70/80/90 分段底色（与刻度线性对应） */
.rw-gauge[data-kind="percent"] .rw-bar::-webkit-progress-bar {
  background: linear-gradient(
    90deg,
    #fee2e2 0 60%,
    #fef3c7 60% 70%,
    #dbeafe 70% 80%,
    #dcfce7 80% 90%,
    #bbf7d0 90% 100%
  );
}
.rw-gauge[data-kind="percent"] .rw-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #f59e0b, #10b981);
}
.rw-gauge[data-kind="percent"] .rw-bar::-moz-progress-bar {
  background: linear-gradient(90deg, #f59e0b, #10b981);
}

/* 睡眠：7–9 小时理想区间着色（7/12≈58.3%，9/12=75%） */
.rw-gauge[data-kind="sleep"] .rw-bar::-webkit-progress-bar {
  background: linear-gradient(90deg, #e6edf8 0 58.3%, #dcfce7 58.3% 75%, #e6edf8 75% 100%);
}
.rw-gauge[data-kind="sleep"] .rw-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #a5b4fc, #6d28d9);
}
.rw-gauge[data-kind="sleep"] .rw-bar::-moz-progress-bar {
  background: linear-gradient(90deg, #a5b4fc, #6d28d9);
}

.rw-gauge[data-kind="water"] .rw-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #7dd3fc, #0284c7);
}
.rw-gauge[data-kind="water"] .rw-bar::-moz-progress-bar {
  background: linear-gradient(90deg, #7dd3fc, #0284c7);
}

.rw-axis {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.2;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.rw-axis span:nth-child(2) { text-align: center; }
.rw-axis span:last-child { text-align: right; }

@media (prefers-reduced-motion: reduce) {
  .rw-bar::-webkit-progress-value { transition: none; }
}

/* ---------- 工具卡片顶部的簇色条：纯装饰，给每个表单一点色彩身份 ---------- */
.tool,
.panel { position: relative; }
.tool::before,
.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c1, #6366f1), var(--c2, #2563eb));
  opacity: 0.85;
  pointer-events: none;
}

/* 日程表的星期表头用簇色区分 */
body[data-site-cluster="schedule"] th {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(21, 128, 61, 0.08));
  color: #14532d;
}

/* ============================================================
   页眉工具条布局修正
   - 桌面：整行平铺显示全部工具，不再横向滚动、不出现滚动条
   - 窄屏：保留滑动，但隐藏滚动条并加两侧渐隐
   ============================================================ */
.toolnav {
  flex-wrap: wrap;
  overflow: visible;
  row-gap: 6px;
}
.toolnav-item {
  gap: 5px;
  padding: 4px 10px 4px 5px;
  font-size: 12.5px;
}
.toolnav-icon { width: 16px; height: 16px; }

@media (max-width: 640px) {
  .toolnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  }
  .toolnav::-webkit-scrollbar { display: none; height: 0; }
  .toolnav-item { font-size: 12px; padding: 4px 9px 4px 4px; }
  .toolnav-icon { width: 15px; height: 15px; }
}

/* ---------- 语言切换：中文版 / English ---------- */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border: 1px solid rgba(130, 145, 160, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #26405c;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.lang-switch:hover {
  background: #fff;
  border-color: #9db8d8;
  text-decoration: none;
}
.lang-switch:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.toolnav .lang-switch { order: -1; margin-right: 4px; }

.lang-hint {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #1f2b3a;
  color: #f8fafc;
  box-shadow: 0 10px 30px rgba(15, 30, 50, 0.28);
  font-size: 14px;
}
.lang-hint a { color: #fff; text-decoration: underline; white-space: nowrap; }
.lang-hint button {
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
@media (max-width: 640px) {
  .lang-hint { left: 12px; right: 12px; transform: none; max-width: none; flex-wrap: wrap; }
}
