:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --icon: 76px;
  --dock-icon: 56px;
  --label: #f5f7ff;
  --glass: rgba(255, 255, 255, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.app,
.dock-app,
.app img,
.dock-app img,
.icon-wrap,
.drag-ghost,
.drag-ghost img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--label);
  background: #0f1224;
  overflow-x: hidden;
  touch-action: manipulation;
}

body {
  position: relative;
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.is-dragging-icon {
  overflow: hidden;
  touch-action: none;
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 800px at 15% 10%, #5b6cff 0%, transparent 55%),
    radial-gradient(900px 700px at 90% 20%, #ff6b9d 0%, transparent 50%),
    radial-gradient(1000px 800px at 50% 100%, #2dd4bf 0%, transparent 55%),
    linear-gradient(165deg, #1a1f3a 0%, #12162b 45%, #0c1020 100%);
  filter: saturate(1.15);
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.status {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-t)) calc(22px + var(--safe-r)) 8px calc(22px + var(--safe-l));
  font-weight: 600;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.brand {
  font-size: 1.15rem;
}

.brand-en {
  margin-left: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.65;
}

#clock {
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.9;
}


/* Search — status icon + Spotlight-style floating sheet */
.search-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(245, 247, 255, 0.55);
  padding: 4px;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.search-btn:hover,
.search-btn:focus-visible {
  color: rgba(245, 247, 255, 0.95);
  outline: none;
}

.search-btn.is-active {
  color: rgba(245, 247, 255, 0.95);
}

.search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 22;
  background: rgba(8, 10, 22, 0.42);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
}

.search-sheet {
  position: fixed;
  z-index: 23;
  left: 50%;
  top: calc(18px + var(--safe-t));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  pointer-events: none;
}

.search-backdrop[hidden],
.search-sheet[hidden] {
  display: none !important;
}

.search-card {
  pointer-events: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(28px) saturate(1.45);
  -webkit-backdrop-filter: blur(28px) saturate(1.45);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  color: rgba(245, 247, 255, 0.8);
}

.search-ico {
  flex: 0 0 auto;
  opacity: 0.75;
}

#app-search {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #f5f7ff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}

#app-search::placeholder {
  color: rgba(245, 247, 255, 0.45);
}

#app-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-dismiss {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: rgba(245, 247, 255, 0.85);
  padding: 8px 4px;
  cursor: pointer;
  flex: 0 0 auto;
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.search-dismiss:hover,
.search-dismiss:focus-visible {
  color: #fff;
  outline: none;
}

.search-results {
  max-height: min(55vh, 420px);
  overflow: auto;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(1.35);
  -webkit-backdrop-filter: blur(24px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  padding: 6px;
}

.search-results[hidden],
.search-empty[hidden] {
  display: none !important;
}

.search-result {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.search-result:hover,
.search-result:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.search-result .icon-wrap {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.search-result-text {
  min-width: 0;
  flex: 1 1 auto;
}

.search-result-name {
  font-size: 0.98rem;
  font-weight: 600;
  color: #f5f7ff;
}

.search-result-desc {
  margin-top: 2px;
  font-size: 0.78rem;
  color: rgba(245, 247, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  color: rgba(245, 247, 255, 0.7);
  padding: 18px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

body.search-open {
  overflow: hidden;
}


.springboard {
  position: relative;
  z-index: 2;
  padding: 12px calc(18px + var(--safe-r)) 130px calc(18px + var(--safe-l));
  max-width: 980px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px 16px;
  justify-items: center;
}

@media (min-width: 720px) {
  :root { --icon: 88px; --dock-icon: 62px; }
  .grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 28px 20px;
  }
}

@media (min-width: 1024px) {
  :root { --icon: 96px; --dock-icon: 68px; }
  .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 32px 24px;
  }
}

@media (max-width: 380px) {
  :root { --icon: 68px; --dock-icon: 50px; }
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.app {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  width: 100%;
  max-width: 110px;
  padding: 6px 4px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.15s ease;
  touch-action: none;
  -webkit-touch-callout: none;
}

.app:active:not(.is-dragging):not(.is-lifted) {
  transform: scale(0.92);
}

.app:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 4px;
  border-radius: 16px;
}

.icon-wrap {
  width: var(--icon);
  height: var(--icon);
  border-radius: 22%;
  overflow: hidden;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  background: var(--app-color, #4a90e2);
  position: relative;
}

.icon-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.icon-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
}

.label {
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.hint {
  text-align: center;
  margin-top: 28px;
  font-size: 0.9rem;
  opacity: 0.7;
}

.hint[hidden] {
  display: none;
}

/* Dock — frosted bar always visible; pins are favorites, grid still shows all apps (iOS-like). */
.dock {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  width: min(480px, calc(100% - 32px));
  min-height: 76px;
  pointer-events: auto;
}

.dock-glass {
  width: 100%;
  min-height: 76px;
  border-radius: 28px;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.dock.is-drag-over .dock-glass {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow:
    0 8px 36px rgba(0, 0, 0, 0.3),
    0 0 0 2px rgba(255, 255, 255, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: scale(1.03);
}

.dock-apps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: nowrap;
  min-height: var(--dock-icon);
  width: 100%;
}

.dock-app {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  touch-action: none;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}

.dock-app .icon-wrap {
  width: var(--dock-icon);
  height: var(--dock-icon);
}

.dock-app .label {
  display: none;
}

/* Edit / jiggle mode */
body.is-editing .app:not(.is-lifted):not(.is-dragging) .icon-wrap,
body.is-editing .dock-app:not(.is-lifted):not(.is-dragging) .icon-wrap {
  animation: jiggle 0.28s ease-in-out infinite alternate;
}

body.is-editing .app:nth-child(odd) .icon-wrap,
body.is-editing .dock-app:nth-child(odd) .icon-wrap {
  animation-delay: -0.08s;
}

body.is-editing .app:nth-child(3n) .icon-wrap,
body.is-editing .dock-app:nth-child(3n) .icon-wrap {
  animation-delay: -0.16s;
}

@keyframes jiggle {
  from { transform: rotate(-2.2deg); }
  to { transform: rotate(2.2deg); }
}

.app.is-lifted .icon-wrap,
.dock-app.is-lifted .icon-wrap {
  transform: scale(1.12);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: none !important;
}

.app.is-dragging,
.dock-app.is-dragging {
  opacity: 0.35;
}

.app.is-dragging .icon-wrap,
.dock-app.is-dragging .icon-wrap {
  animation: none !important;
  transform: none;
}

.drag-ghost {
  position: fixed;
  z-index: 100;
  width: var(--icon);
  height: var(--icon);
  border-radius: 22%;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%) scale(1.15);
  will-change: left, top;
}

.drag-ghost img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.drag-ghost[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .app,
  .dock-app,
  .dock-glass { transition: none; }
  body.is-editing .app .icon-wrap,
  body.is-editing .dock-app .icon-wrap {
    animation: none;
  }
}


/* About — quiet status-bar entry + frosted sheet */
.status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.about-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(245, 247, 255, 0.55);
  padding: 4px 2px;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.about-btn:hover,
.about-btn:focus-visible {
  color: rgba(245, 247, 255, 0.9);
  outline: none;
}

.about-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 10, 22, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.about-backdrop[hidden],
.about-sheet[hidden] {
  display: none !important;
}

.about-sheet {
  position: fixed;
  z-index: 21;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 36px));
  max-height: min(70vh, 520px);
  pointer-events: none;
}

.about-card {
  pointer-events: auto;
  border-radius: 22px;
  background: rgba(28, 32, 56, 0.72);
  backdrop-filter: blur(28px) saturate(1.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  padding: 18px 18px 16px;
  color: #f5f7ff;
  overflow: auto;
  max-height: inherit;
}

.about-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.about-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.about-close {
  appearance: none;
  border: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(245, 247, 255, 0.85);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.about-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.about-lead {
  margin: 0 0 14px;
  font-size: 0.82rem;
  line-height: 1.45;
  opacity: 0.62;
}

.about-meta {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(245, 247, 255, 0.45);
  letter-spacing: 0.02em;
}


.about-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.about-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.about-app-name {
  font-size: 0.92rem;
  font-weight: 600;
}

.about-app-meta {
  font-size: 0.75rem;
  opacity: 0.55;
}

.about-app-link {
  font-size: 0.78rem;
  color: rgba(180, 205, 255, 0.85);
  text-decoration: none;
  word-break: break-all;
}

.about-app-link:hover {
  text-decoration: underline;
  color: #dbe7ff;
}

.about-foot {
  margin: 12px 0 0;
  font-size: 0.78rem;
  opacity: 0.5;
  text-align: center;
}
