:root {
  --qaq-text: #262626;
  --qaq-muted: #8e8e93;
  --qaq-icon-size: clamp(56px, 16vw, 68px);
  --qaq-page-padding: clamp(14px, 4vw, 22px);
  --qaq-grid-gap-x: clamp(10px, 3.5vw, 18px);
  --qaq-grid-gap-y: clamp(18px, 4vw, 26px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  overflow: hidden;
  background: #e9e9e9;
  color: var(--qaq-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

button {
  border: 0;
  font: inherit;
}

.qaq-desktop {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 320px;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  background: #fafafa;
}

.qaq-wallpaper {
  position: absolute;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 7%, rgba(0, 0, 0, 0.035), transparent 28%),
    radial-gradient(circle at 88% 89%, rgba(0, 0, 0, 0.045), transparent 34%),
    linear-gradient(150deg, #ffffff 0%, #f8f8f8 46%, #eeeeee 100%);
}

.qaq-wallpaper::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.55;
  background:
    linear-gradient(118deg, transparent 0 44%, rgba(0, 0, 0, 0.018) 45% 47%, transparent 48% 100%),
    linear-gradient(43deg, transparent 0 58%, rgba(0, 0, 0, 0.02) 59% 60%, transparent 61% 100%);
}

.qaq-statusbar {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  justify-content: space-between;
  min-height: calc(env(safe-area-inset-top, 0px) + 36px);
  padding: env(safe-area-inset-top, 0px) 18px 9px;
  color: #111;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.qaq-statusbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.qaq-statusbar-right i {
  font-size: 12px;
}

.qaq-battery {
  position: relative;
  width: 25px;
  height: 12px;
  padding: 2px;
  border: 1.5px solid #111;
  border-radius: 3px;
}

.qaq-battery::after {
  position: absolute;
  top: 3px;
  right: -4px;
  width: 2px;
  height: 4px;
  border-radius: 0 2px 2px 0;
  content: "";
  background: #111;
}

.qaq-battery-level {
  width: 76%;
  height: 100%;
  border-radius: 1px;
  background: #111;
}

.qaq-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.qaq-search {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  width: calc(100% - 32px);
  height: 39px;
  margin: 3px 16px 14px;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.055);
  color: #777;
  font-size: 14px;
  text-align: left;
}

.qaq-search:active {
  background: rgba(0, 0, 0, 0.09);
}

.qaq-search i {
  color: #555;
  font-size: 14px;
}

.qaq-pages {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.qaq-pages::-webkit-scrollbar {
  display: none;
}

.qaq-page {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  padding: 2px var(--qaq-page-padding) 12px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.qaq-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: var(--qaq-grid-gap-y) var(--qaq-grid-gap-x);
  width: 100%;
  min-height: 100%;
}

.qaq-tile {
  position: relative;
  display: flex;
  flex: 0 0 calc((100% - (var(--qaq-grid-gap-x) * 3)) / 4);
  flex-direction: column;
  align-items: center;
  min-width: 0;
  gap: 7px;
  cursor: pointer;
  touch-action: pan-x;
  transition: transform 150ms ease, opacity 150ms ease;
}

.qaq-tile:active:not(.qaq-drag-source) {
  transform: scale(0.93);
}

.qaq-editing .qaq-tile {
  touch-action: none;
}

.qaq-icon {
  display: flex;
  flex: 0 0 var(--qaq-icon-size);
  align-items: center;
  justify-content: center;
  width: var(--qaq-icon-size);
  height: var(--qaq-icon-size);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 17px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(222, 222, 222, 0.92));
  box-shadow:
    0 4px 11px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.qaq-icon i {
  color: #202020;
  font-size: clamp(23px, 6.7vw, 29px);
}

.qaq-tile-label {
  width: 100%;
  overflow: hidden;
  color: #242424;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 文件夹封面：强制外框和内部四个图标均为正方形 */
.qaq-folder-icon {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px;
  width: var(--qaq-icon-size);
  height: var(--qaq-icon-size);
  aspect-ratio: 1 / 1;
  padding: 8px;
  overflow: hidden;
  background: #d3d3d3;
}

.qaq-folder-icon > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
}

.qaq-folder-icon > span i {
  display: block;
  width: auto;
  height: auto;
  font-size: 13px;
  line-height: 1;
}

.qaq-folder-icon span i {
  font-size: 13px;
}

.qaq-delete {
  position: absolute;
  top: -6px;
  right: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #777;
  color: #fff;
  font-size: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

.qaq-editing .qaq-delete {
  display: flex;
}

.qaq-wiggle {
  animation: qaq-wiggle 360ms ease-in-out infinite alternate;
}

.qaq-drag-source {
  opacity: 0.18;
}

.qaq-drag-proxy {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.11);
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, 0.26));
}

.qaq-drag-proxy .qaq-delete {
  display: none;
}

.qaq-dots {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 27px;
  padding-bottom: 8px;
}

.qaq-dot {
  width: 5px;
  height: 5px;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.28);
  transition: width 180ms ease, background 180ms ease;
}

.qaq-dot.qaq-active {
  width: 18px;
  background: rgba(0, 0, 0, 0.84);
}

.qaq-dock-wrap {
  flex: 0 0 auto;
  height: calc(env(safe-area-inset-bottom, 0px) + 94px);
  padding: 0 12px env(safe-area-inset-bottom, 0px);
}

.qaq-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 86px;
  padding: 8px 12px 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 0;
  border-radius: 25px 25px 0 0;
  background: rgba(238, 238, 238, 0.78);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.07);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.qaq-dock .qaq-tile {
  flex: 0 0 auto;
  width: 64px;
}

.qaq-dock .qaq-icon {
  flex-basis: 60px;
  width: 60px;
  height: 60px;
  border-radius: 16px;
}

.qaq-dock .qaq-tile-label {
  display: none;
}

.qaq-folder-modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  opacity: 0;
  background: rgba(255, 255, 255, 0.53);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.qaq-folder-modal.qaq-open {
  visibility: visible;
  opacity: 1;
}

.qaq-folder-window {
  width: min(100%, 365px);
  padding: 18px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 24px;
  background: rgba(248, 248, 248, 0.94);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.2);
  transform: scale(0.94);
  transition: transform 210ms cubic-bezier(0.2, 0.85, 0.3, 1.15);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
}

.qaq-folder-modal.qaq-open .qaq-folder-window {
  transform: scale(1);
}

.qaq-folder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.qaq-folder-title {
  color: #222;
  font-size: 17px;
  font-weight: 700;
}

.qaq-folder-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: #e4e4e4;
  color: #333;
}

.qaq-folder-grid {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 20px 12px;
  min-height: 145px;
}

.qaq-folder-grid .qaq-tile {
  flex: 0 0 calc((100% - 36px) / 4);
}

.qaq-folder-grid .qaq-icon {
  flex: 0 0 var(--qaq-icon-size);
  width: var(--qaq-icon-size);
  height: var(--qaq-icon-size);
}

.qaq-editbar {
  position: fixed;
  right: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 105px);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 13px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #555;
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.11);
  transform: translate(50%, 20px);
  visibility: hidden;
  opacity: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.qaq-editbar.qaq-show {
  transform: translate(50%, 0);
  visibility: visible;
  opacity: 1;
}

.qaq-editbar button {
  padding: 0;
  background: transparent;
  color: #111;
  font-size: 13px;
  font-weight: 700;
}

@keyframes qaq-wiggle {
  from {
    transform: rotate(-1.1deg);
  }

  to {
    transform: rotate(1.1deg);
  }
}

@media (min-width: 600px) {
  body {
    display: grid;
    place-items: center;
    padding: 18px;
    background: #e8e8e8;
  }

  .qaq-desktop {
    width: min(430px, 100%);
    height: min(900px, calc(100dvh - 36px));
    border: 8px solid #121212;
    border-radius: 38px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  }
}

@media (max-width: 360px) {
  :root {
    --qaq-icon-size: 56px;
    --qaq-grid-gap-x: 9px;
    --qaq-grid-gap-y: 17px;
  }

  .qaq-dock {
    padding-right: 8px;
    padding-left: 8px;
  }

  .qaq-dock .qaq-tile {
    width: 58px;
  }

  .qaq-dock .qaq-icon {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }
}

/* 固定网格空位 */
.qaq-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(88px, auto);
  align-content: start;
  gap: var(--qaq-grid-gap-y) var(--qaq-grid-gap-x);
  width: 100%;
  min-height: 100%;
}

/* 每一个固定空位 */
.qaq-slot {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  min-height: 88px;
  border-radius: 18px;
  transition:
    background 160ms ease,
    outline 160ms ease,
    transform 160ms ease;
}

/* 可放置位置 */
.qaq-slot.qaq-drop-target {
  background: rgba(0, 0, 0, 0.075);
  outline: 2px dashed rgba(0, 0, 0, 0.25);
  outline-offset: -4px;
}

/* 网格中的 App 不再自己参与 flex 宽度计算 */
.qaq-grid > .qaq-slot > .qaq-tile {
  width: 100%;
  flex: 0 0 100%;
}

/* 文件夹里的 App */
.qaq-folder-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(88px, auto);
  align-content: start;
  gap: 20px 12px;
  min-height: 176px;
}

/* 文件夹里的图标固定为正方形 */
.qaq-folder-grid .qaq-slot {
  min-height: 88px;
}

.qaq-folder-grid .qaq-tile {
  width: 100%;
  flex: 0 0 100%;
}

.qaq-folder-grid .qaq-icon,
.qaq-folder-grid .qaq-folder-icon {
  flex: 0 0 var(--qaq-icon-size);
  width: var(--qaq-icon-size);
  height: var(--qaq-icon-size);
  min-width: var(--qaq-icon-size);
  min-height: var(--qaq-icon-size);
  aspect-ratio: 1 / 1;
}

/* 文件夹封面里的四个小图标 */
.qaq-folder-icon {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.qaq-folder-icon > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
}

.qaq-folder-icon > span i {
  display: block;
  width: auto;
  height: auto;
  font-size: 13px;
  line-height: 1;
}

/* 更新弹窗 */
.qaq-update-modal {
  position: fixed;
  z-index: 3000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
}

.qaq-update-modal.qaq-open {
  visibility: visible;
  opacity: 1;
}

.qaq-update-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.qaq-update-card {
  position: relative;
  width: min(100%, 360px);
  padding: 26px 22px 22px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  color: #222;
  transform: translateY(12px) scale(0.96);
  transition: transform 220ms cubic-bezier(0.2, 0.85, 0.3, 1.1);
}

.qaq-update-modal.qaq-open .qaq-update-card {
  transform: translateY(0) scale(1);
}

.qaq-update-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  margin: 0 auto 14px;
  border-radius: 17px;
  background: #222;
  color: #fff;
  font-size: 21px;
}

.qaq-update-title {
  margin-bottom: 7px;
  color: #171717;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

.qaq-update-version {
  margin-bottom: 17px;
  color: #8c8c8c;
  font-size: 12px;
  text-align: center;
}

.qaq-update-content {
  max-height: 210px;
  overflow-y: auto;
  padding: 14px;
  border-radius: 13px;
  background: #f2f2f2;
  color: #555;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
}

.qaq-update-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 19px;
}

.qaq-update-button {
  min-height: 42px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.qaq-update-later {
  background: #eeeeee;
  color: #333;
}

.qaq-update-ignore {
  background: #e2e2e2;
  color: #444;
}

.qaq-update-confirm {
  grid-column: 1 / -1;
  background: #222;
  color: #fff;
}

.qaq-update-button:active {
  transform: scale(0.97);
}