:root {
  --bg: #eef2ff;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --blue: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --purple: #7c3aed;
  --orange: #f97316;
  --status-bar-height: 48px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(124, 58, 237, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(37, 99, 235, 0.2), transparent 35%),
    var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }
#app {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.phone {
  width: 100%;
  max-width: 420px;
  height: min(840px, 100vh - 32px);
  border-radius: 38px;
  overflow: hidden;
  background: #000;
  border: 12px solid #000;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
  position: relative;
}
.wallpaper {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #60a5fa 0%, #4f46e5 45%, #9333ea 100%);
  background-size: cover;
  background-position: center;
}
.status-bar {
  position: relative;
  z-index: 3;
  height: var(--status-bar-height);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px 0;
  font-size: 13px;
  font-weight: 600;
}
.status-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-icon {
  display: block;
  flex: 0 0 auto;
}
.status-icon--signal,
.status-icon--wifi {
  width: 16px;
  height: 12px;
}
.status-icon--battery {
  width: 18px;
  height: 12px;
}
.screen, .home, .view { position: absolute; inset: 0; }
.screen { z-index: 2; }
.home { padding: calc(var(--status-bar-height) + 24px) 24px 24px; overflow-y: auto; }
.home {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.home__toolbar {
  display: flex;
  justify-content: flex-end;
  min-height: 40px;
}
.home__done-btn {
  flex: 0 0 auto;
  min-width: 72px;
}
.home__desktop {
  --desktop-row-height: 78px;
  --desktop-row-gap: 12px;
  --desktop-col-gap: 14px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: var(--desktop-row-height);
  row-gap: var(--desktop-row-gap);
  column-gap: var(--desktop-col-gap);
  min-height: calc(var(--desktop-row-height) * 7 + var(--desktop-row-gap) * 6);
  align-content: start;
}
.home__grid-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: var(--desktop-row-height);
  row-gap: var(--desktop-row-gap);
  column-gap: var(--desktop-col-gap);
  pointer-events: none;
  z-index: 0;
}
.home__grid-cell {
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.desktop-item {
  position: relative;
  z-index: 1;
  padding: 0;
  border: 0;
  background: none;
  user-select: none;
  -webkit-user-select: none;
}
.desktop-item:focus-visible {
  outline: 2px solid rgba(191, 219, 254, 0.95);
  outline-offset: 4px;
}
.desktop-item--app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: #fff;
}
.desktop-item--widget {
  display: block;
}
.desktop-item__app-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding-top: 2px;
}
.desktop-item__app-inner--custom {
  width: 100%;
  height: 100%;
  padding-top: 0;
  align-items: stretch;
  justify-content: stretch;
}
.desktop-item--widget .desktop-item__app-inner {
  height: 100%;
  padding-top: 0;
}
.desktop-item__label {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.home__desktop .profile-card {
  margin-top: 0;
  min-height: auto;
  height: 100%;
}
.home__profile-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.6;
}
.home--editing .desktop-item {
  cursor: grab;
  touch-action: none;
}
.home--editing .desktop-item--profile,
.home--editing .desktop-item--app .app-launch-btn {
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.2);
}
.desktop-item--dragging {
  cursor: grabbing !important;
  opacity: 0.94;
  transition: none !important;
}
.desktop-item--dragging .app-launch-btn,
.desktop-item--dragging.profile-card {
  box-shadow: 0 24px 40px rgba(15, 23, 42, 0.26);
}
.hidden { display: none !important; }
.profile-card, .card, .list-item {
  border: 1px solid var(--line);
  background: var(--panel);
}
.profile-card {
  width: 100%;
  margin-top: 8px;
  min-height: 168px;
  background: rgba(15, 23, 42, 0.48);
  border-color: rgba(255, 255, 255, 0.18);
  border-radius: 32px;
  color: #fff;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  backdrop-filter: blur(18px);
  position: relative;
  overflow: hidden;
}
.avatar {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
  border: 4px solid rgba(255, 255, 255, 0.18);
  position: relative;
  z-index: 1;
}
.profile-card .avatar {
  width: 72px;
  height: 72px;
  border-width: 3px;
}
.profile-name { margin: 12px 0 6px; font-size: 14px; font-weight: 800; }
.profile-signature { margin: 0; font-size: 22px; font-weight: 900; line-height: 1.12; opacity: 0.85; }
.app-grid { margin-top: 28px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 14px; }
.app-icon { text-align: center; color: #fff; }
.app-launch-btn {
  width: 58px;
  height: 58px;
  margin: 0 auto 8px;
  border-radius: 18px;
  color: #fff;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.app-launch-btn--image {
  padding: 0;
  background: transparent;
  overflow: hidden;
}
.app-launch-btn__image {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 18px;
  pointer-events: none;
  user-select: none;
}
.app-icon span { display: block; font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,0.35); }
.view {
  top: var(--status-bar-height);
  height: calc(100% - var(--status-bar-height));
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.view--app {
  top: 0;
  height: 100%;
}
.header {
  padding: 12px 16px 12px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
}
.view--app .header {
  padding-top: calc(var(--status-bar-height) + 12px);
  min-height: calc(60px + var(--status-bar-height));
  background: var(--panel);
}
.header h1 { margin: 0; font-size: 17px; }
.text-btn { background: none; color: var(--blue); font-weight: 600; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; background: #f3f4f6; }
.content { position: relative; flex: 1; overflow-y: auto; padding: 16px; }
.card { border-radius: 20px; padding: 16px; box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04); }
.stack, .list { display: flex; flex-direction: column; gap: 12px; }
.list-item { gap: 12px; align-items: center; padding: 12px; border-radius: 16px; display:flex; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { margin: 0 0 4px; font-weight: 700; }
.list-item-desc { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); text-align: center; gap: 10px; }
.form-row { display: flex; flex-direction: column; gap: 8px; }
.form-row label { font-size: 13px; color: var(--muted); font-weight: 700; }
.field, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f9fafb;
  padding: 12px 14px;
  outline: none;
}
.upload-field {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px dashed #bfdbfe;
  border-radius: 14px;
  background: #eff6ff;
  color: var(--blue);
  font-weight: 700;
  padding: 12px 14px;
  text-align: center;
}
.upload-input {
  display: none;
}
.upload-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.textarea { resize: vertical; min-height: 92px; }
.actions { display: flex; gap: 10px; }
.primary, .secondary, .danger {
  flex: 1;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
}
.primary { background: var(--blue); color: #fff; }
.secondary { background: #eef2ff; color: var(--blue); }
.danger { background: #fee2e2; color: #b91c1c; }
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
}
.phone--app-open .status-bar {
  color: var(--text);
}
@media (max-width: 520px) {
  #app { padding: 0; }
  .phone { height: 100vh; border-radius: 0; border: 0; max-width: none; }
}
