/* 品味小宇宙 — 科普实验室统一样式壳（返回胶囊 + 触控防滚动 + 竖屏半屏抽屉） */
html,
body {
  overflow-x: clip;
}

canvas {
  touch-action: none;
}

.pw-back-pill {
  position: fixed;
  z-index: 10020;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.pw-back-pill:active,
.pw-audio-pill:active {
  transform: scale(0.96);
}

.pw-back-pill[data-pos="top-left"] {
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
}

.pw-back-pill[data-pos="top-right"] {
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
}

.pw-back-pill[data-pos="bottom-left"] {
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
}

.pw-back-pill[data-pos="bottom-right"] {
  bottom: max(14px, env(safe-area-inset-bottom));
  right: max(12px, env(safe-area-inset-right));
}

.pw-back-pill[data-theme="dark"] {
  background: rgba(13, 12, 11, 0.74);
  color: #f3eee3;
  border: 1px solid rgba(216, 186, 140, 0.3);
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.6);
}

.pw-back-pill[data-theme="light"] {
  background: rgba(243, 238, 227, 0.9);
  color: #181613;
  border: 1px solid rgba(24, 22, 19, 0.16);
  box-shadow: 0 8px 22px -10px rgba(24, 22, 19, 0.28);
}

@media (hover: hover) {
  .pw-back-pill[data-theme="dark"]:hover {
    background: rgba(27, 25, 23, 0.94);
    border-color: rgba(216, 186, 140, 0.7);
    transform: translateY(-1px);
  }

  .pw-back-pill[data-theme="light"]:hover {
    background: #fbf8f1;
    border-color: rgba(181, 72, 37, 0.6);
    transform: translateY(-1px);
  }
}

.pw-drawer-toggle,
.pw-drawer-tabs,
.pw-drawer-backdrop {
  display: none;
}

.pw-audio-pill {
  position: fixed;
  z-index: 10020;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.pw-audio-pill svg {
  flex: none;
  width: 14px;
  height: 14px;
}

.pw-audio-pill[data-theme="dark"] {
  background: rgba(13, 12, 11, 0.74);
  color: #f3eee3;
  border: 1px solid rgba(216, 186, 140, 0.3);
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.6);
}

.pw-audio-pill[data-theme="dark"][data-muted="true"] {
  color: rgba(243, 238, 227, 0.58);
}

.pw-audio-pill[data-theme="light"] {
  background: rgba(243, 238, 227, 0.9);
  color: #181613;
  border: 1px solid rgba(24, 22, 19, 0.16);
  box-shadow: 0 8px 22px -10px rgba(24, 22, 19, 0.28);
}

.pw-audio-pill[data-theme="light"][data-muted="true"] {
  color: rgba(24, 22, 19, 0.5);
}

@media (hover: hover) {
  .pw-audio-pill[data-theme="dark"]:hover {
    background: rgba(27, 25, 23, 0.94);
    border-color: rgba(216, 186, 140, 0.7);
    transform: translateY(-1px);
  }

  .pw-audio-pill[data-theme="light"]:hover {
    background: #fbf8f1;
    border-color: rgba(181, 72, 37, 0.6);
    transform: translateY(-1px);
  }
}

body.pw-shot-mode .pw-back-pill,
body.pw-shot-mode .pw-audio-pill,
body.pw-shot-mode .pw-fun-wrap,
body.pw-shot-mode .pw-drawer-toggle,
body.pw-shot-mode .pw-drawer-tabs {
  display: none !important;
}

@media (max-width: 768px) {
  .pw-back-pill,
  .pw-audio-pill {
    height: 32px;
    padding: 0 10px;
    font-size: 11.5px;
  }

  .pw-audio-pill svg {
    width: 13px;
    height: 13px;
  }

  body.pw-drawer-open .pw-fun-wrap {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(8px);
  }

  .pw-drawer-toggle {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 10025;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  }

  .pw-drawer-toggle svg {
    flex: none;
    width: 15px;
    height: 15px;
  }

  .pw-drawer-toggle:active {
    transform: scale(0.96);
  }

  .pw-drawer-toggle[data-theme="dark"] {
    background: rgba(13, 12, 11, 0.9);
    color: #f3eee3;
    border: 1px solid rgba(216, 186, 140, 0.36);
    box-shadow: 0 10px 26px -8px rgba(0, 0, 0, 0.7);
  }

  .pw-drawer-toggle[data-theme="light"] {
    background: rgba(24, 22, 19, 0.92);
    color: #f3eee3;
    border: 1px solid rgba(24, 22, 19, 0.2);
    box-shadow: 0 10px 26px -10px rgba(24, 22, 19, 0.4);
  }

  .pw-drawer-toggle[aria-expanded="true"] {
    background: #e5532d;
    border-color: #e5532d;
    color: #fff7ef;
  }

  .pw-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10010;
    background: rgba(8, 7, 6, 0.44);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  body.pw-drawer-open .pw-drawer-backdrop {
    display: block;
  }

  .pw-drawer-tabs {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 10025;
    display: none;
    align-items: center;
    gap: 5px;
    max-width: calc(100vw - 118px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .pw-drawer-tabs::-webkit-scrollbar {
    display: none;
  }

  body.pw-drawer-open .pw-drawer-tabs.has-tabs {
    display: flex;
  }

  .pw-drawer-tab {
    height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(243, 238, 227, 0.18);
    background: rgba(13, 12, 11, 0.88);
    color: #b9b1a2;
    font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  }

  .pw-drawer-tab:active {
    transform: scale(0.96);
  }

  .pw-drawer-tab[data-theme="light"] {
    background: rgba(243, 238, 227, 0.94);
    color: #4a443b;
    border-color: rgba(24, 22, 19, 0.16);
  }

  .pw-drawer-tab[aria-selected="true"] {
    background: #f3eee3;
    border-color: #f3eee3;
    color: #0d0c0b;
  }

  .pw-drawer-tab[data-theme="light"][aria-selected="true"] {
    background: #181613;
    border-color: #181613;
    color: #f3eee3;
  }

  .pw-drawer-panel {
    display: none !important;
  }

  body.pw-drawer-open .pw-drawer-panel.pw-drawer-active {
    display: block !important;
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: calc(64px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: calc(100vw - 20px) !important;
    height: auto !important;
    max-height: 50dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    z-index: 10022 !important;
    border-radius: 18px !important;
    box-shadow: 0 22px 48px -12px rgba(0, 0, 0, 0.6) !important;
    animation: pw-drawer-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@keyframes pw-drawer-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.pw-drawer-open .pw-drawer-panel.pw-drawer-active {
    animation: none !important;
  }
}
