/* ==========================================
   Reset & Global
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

@font-face {
    font-family: 'iOS Bold';
    src: url('font/仿ios粗体.ttf') format('truetype');
}

:root {
    --icon-size: 60px;
    --icon-radius: 13.5px;
    --grid-gap: 24px;
    --label-size: 11px;
}

/* ==========================================
   html/body: 纯背景容器
   ========================================== */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #E3E9D7;
    font-family: 'iOS Bold', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    overscroll-behavior: none;
}

body.custom-font-applied {
    font-family: 'CustomFont', 'iOS Bold', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
}

/* ==========================================
   .page: 普通文档流，overflow-y:auto 自然处理滚动
   不使用任何 vh/dvh/fixed/absolute/flex:1
   ========================================== */
.page {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top, 44px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    box-sizing: border-box;
    background-color: #E3E9D7;
}

/* ==========================================
   图标网格
   ========================================== */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--grid-gap);
    padding: 40px 20px;
}

/* ==========================================
   单个图标项
   ========================================== */
.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.app-item:active {
    transform: scale(0.85);
}

/* 编辑模式抖动 */
.app-item.wiggle {
    animation: wiggle 0.3s ease-in-out infinite alternate;
}

@keyframes wiggle {
    0%   { transform: rotate(-1.5deg); }
    100% { transform: rotate(1.5deg); }
}

/* ==========================================
   图标外壳
   ========================================== */
.app-icon {
    width: var(--icon-size);
    height: var(--icon-size);
    border-radius: var(--icon-radius);
    overflow: hidden;
    background: #2c2c2e;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-icon.placeholder {
    background: rgba(0, 0, 0, 0.08);
    border: 1px dashed rgba(0, 0, 0, 0.2);
}

.app-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 图标文字标签 */
.app-label {
    font-size: var(--label-size);
    color: #739353;
    text-align: center;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* ==========================================
   全局刷新缓存按钮
   ========================================== */
.refresh-btn {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    right: 16px;
    z-index: 1000;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.refresh-btn:active { transform: scale(0.92); }
.refresh-btn.spinning svg { animation: spin-once 0.65s linear; }
@keyframes spin-once {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
