/* Global Styles - Minimalist Cute Black & White */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
/* ===== iOS 安全区域全局支持 ===== */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* 支持旧版iOS */
@supports (padding: max(0px)) {
    :root {
        --safe-area-top: max(env(safe-area-inset-top, 0px), 0px);
        --safe-area-bottom: max(env(safe-area-inset-bottom, 0px), 0px);
    }
}

body {
    font-family: "Gaegu", cursive, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #e0e0e0;
    margin: 0;
    padding: 0;
    height: auto;
    height: 100dvh; /* 动态视口高度自动排除地址栏 */
    width: 100vw;
    overflow: hidden;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    /* iOS 安全区域 */
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}


/* Phone Container - Mobile Simulator */
.phone-container {
    width: 100%;
    height: 100%;
    max-width: 414px; /* iPhone Max width */
    height: 100dvh;
    height: -webkit-fill-available; /* iOS Safari 回退 */
    max-height: 100dvh;
    background-color: #fff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 12px solid #000;
    border-radius: 50px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}


@media (max-width: 450px) {
    .phone-container {
        max-width: 100%;
        max-height: 100dvh;
        max-height: -webkit-fill-available;
        border: none;
        border-radius: 0;
        /* 移动端不需要body的安全区padding，自己处理 */
    }

    body {
        padding: 0; /* 移动端取消body的安全区padding */
    }
}


/* Status Bar */
.status-bar {
    height: 44px;
    height: calc(44px + var(--safe-area-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    padding-top: var(--safe-area-top);
    font-size: 16px;
    font-weight: 700;
    color: #000;
    z-index: 1000;
    position: absolute;
    top: 0;
    width: 100%;
    background: transparent;
    pointer-events: none;
}


.status-icons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.status-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.battery-capsule {
    border: 2px solid #000;
    border-radius: 20px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    min-width: 45px;
}

/* Home Screen */
.home-screen {
    flex: 1;
    padding: 60px 25px 0;
    padding-top: calc(60px + var(--safe-area-top));
    padding-bottom: calc(130px + var(--safe-area-bottom)); /* 为dock留空间 */
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    background: transparent;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
}


.row-container {
    display: flex;
    gap: 15px; /* Gap between widget and app group */
    width: 100%;
    flex: 0 0 auto; /* Do not stretch vertically */
    aspect-ratio: 2.1 / 1; /* Maintain aspect ratio for the row */
}

.widget-wrapper.large-widget {
    flex: 1;
    height: 100%;
    position: relative;
    aspect-ratio: 1 / 1; /* Make widget square */
}

.app-group {
    flex: 1;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px; /* Small gap between apps */
    aspect-ratio: 1 / 1; /* Make app group square */
}

/* Todo Widget - Photo Frame Style */
.todo-widget {
    width: 100%;
    height: 100%;
    background: #fff;
    border: 3px solid #000;
    border-radius: 20px; /* Capsule-like */
    padding: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 4px 0px #000;
    transform: rotate(-1deg);
    transition: transform 0.2s;
    overflow: hidden;
    position: relative;
}

.todo-widget:active {
    transform: scale(0.98) rotate(-2deg);
}

.todo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    z-index: 2;
}

.todo-header h3 {
    font-size: 16px;
    font-weight: bold;
    background: #fff;
    padding: 1px 4px;
    border-radius: 4px;
    border: 1.5px solid #000;
}

.todo-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.todo-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    z-index: 2;
}

.todo-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    background: rgba(255,255,255,0.8);
    padding: 5px;
    border-radius: 5px;
}

.todo-list li.completed {
    text-decoration: line-through;
    color: #999;
}

.todo-list li .check {
    width: 14px;
    height: 14px;
    border: 1.5px solid #333;
    border-radius: 3px;
    display: inline-block;
}

.todo-list li.completed .check {
    background: #333;
}

/* Squeeze Widget - Round Capsule */
.squeeze-widget {
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 100px; /* Full Capsule shape */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
    border: 3px solid #000;
    box-shadow: 4px 4px 0px #000;
    overflow: hidden;
    position: relative;
}

.squeeze-widget:active {
    transform: scale(0.95);
}

.squeeze-content {
    text-align: center;
    z-index: 2;
}

.squeeze-content img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10; /* Ensure image stays on top */
}

#squeezeText {
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

/* App Icons */
.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    transition: transform 0.1s;
    justify-content: center;
}

.app-icon:active {
    transform: scale(0.9);
}

.app-icon-inner {
    width: 58px; /* Slightly larger icons */
    height: 58px;
    background: #fff;
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #000;
    box-shadow: 2px 2px 0px #000;
    overflow: hidden;
    transition: all 0.2s;
}

.app-icon:active .app-icon-inner {
    transform: scale(0.95);
    box-shadow: 1px 1px 0px #000;
    transform: translate(1px, 1px);
}

.app-icon-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    padding: 0; /* Remove padding for full image */
}

.app-icon span {
    font-size: 10px;
    color: #000;
    font-weight: 700;
    margin-top: 2px;
}

/* Dock Bar */
.dock-bar {
    position: absolute;
    bottom: 35px;
    bottom: calc(35px + var(--safe-area-bottom)); /* 适配iOS底部安全区 */
    left: 25px;
    right: 25px;
    height: 80px;
    background: #fff;
    border-radius: 40px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 20px;
    border: 3px solid #000;
    box-shadow: 5px 5px 0px #000;
    z-index: 100;
}

/* 移动端dock优化 */
@media (max-width: 450px) {
    .dock-bar {
        bottom: calc(15px + var(--safe-area-bottom));
        left: 15px;
        right: 15px;
        height: 70px;
    }
}


/* Modals & Sub Pages */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #fff;
    width: 90%;
    max-height: 90%;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 2px solid #333;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 50px;
}

.sub-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 300;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

.sub-header {
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    border-bottom: 1px solid #eee;
    background: #fff;
}

.sub-title {
    font-size: 16px;
    font-weight: bold;
}

.sub-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    padding-bottom: 100px; /* Prevent bottom content from being hidden */
}

.back-btn, .menu-btn, .close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #333;
    padding: 5px;
}

.header-action-btn {
    background: none;
    border: none;
    color: #333;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: #666;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1.5px solid #333;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

.action-btn {
    width: 100%;
    padding: 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.action-btn.secondary {
    background: #fff;
    color: #333;
    border: 1.5px solid #333;
}

/* Animations */
@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes slideDown {
    from { transform: translateY(-100%) translateX(-50%); }
    to { transform: translateY(0) translateX(-50%); }
}

.page-enter {
    animation: slideIn 0.3s ease forwards;
}

.page-exit {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
    from { transform: translateX(0); }
    to { transform: translateX(100%); }
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
    border: 1.5px solid #333;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border: 1.5px solid #333;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #333;
}

input:checked + .slider:before {
    transform: translateX(16px);
    background-color: #fff;
}

/* Setting Item */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.setting-section {
    margin-bottom: 20px;
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    border: 1.5px solid #333;
}

.style-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.style-option {
    padding: 5px 15px;
    border: 2px solid #000;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.style-option.active {
    background: #000;
    color: #fff;
}

.setting-section h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Action Sheet */
.action-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.action-sheet-content {
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    animation: slideUp 0.3s ease;
    border-top: 2px solid #333;
}

.action-sheet-item {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    cursor: pointer;
}

.action-sheet-item:last-child {
    border-bottom: none;
    color: #ff4d4f;
    font-weight: bold;
    margin-top: 10px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* In-App Notification - Enhanced for Native Feel */
.in-app-notification {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #333;
    padding: 12px 15px;
    border-radius: 16px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    animation: notifSlideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.05);
    transform-origin: top center;
}

@keyframes notifSlideDown {
    from { transform: translateY(-100%) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Toast Message */
.toast-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 10001;
    animation: fadeInOut 2s ease forwards;
    pointer-events: none;
    text-align: center;
    max-width: 80%;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -40%); }
    10% { opacity: 1; transform: translate(-50%, -50%); }
    90% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* Custom Dialog */
.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10002;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.custom-dialog {
    background: #fff;
    width: 85%;
    max-width: 320px;
    border-radius: 20px;
    padding: 25px;
    border: 2px solid #333;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.custom-dialog h3 {
    text-align: center;
    font-size: 20px;
    margin: 0;
    font-weight: bold;
}

.custom-dialog p {
    text-align: center;
    font-size: 15px;
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.custom-dialog input, .custom-dialog textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid #333;
    border-radius: 12px;
    outline: none;
    font-size: 16px;
    background: #f9f9f9;
    transition: all 0.2s;
}

.custom-dialog input:focus, .custom-dialog textarea:focus {
    background: #fff;
    border-color: #000;
}

.custom-dialog-buttons {
    display: flex;
    gap: 12px;
}

.custom-dialog-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
    transition: transform 0.1s;
}

.custom-dialog-btn:active {
    transform: scale(0.95);
}

.custom-dialog-btn.cancel {
    background: #f0f0f0;
    color: #333;
}

.custom-dialog-btn.confirm {
    background: #333;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
/* 高级设置折叠框 */
.advanced-settings {
    margin-top: 15px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
}

.advanced-settings summary {
    padding: 12px 15px;
    background: #f5f5f5;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.advanced-settings summary:hover {
    background: #eee;
}

.advanced-settings summary::-webkit-details-marker {
    display: none;
}

.advanced-settings summary::after {
    content: '▶';
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 12px;
}

.advanced-settings[open] summary::after {
    transform: rotate(90deg);
}

.advanced-content {
    padding: 15px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.advanced-content label {
    font-size: 13px;
    color: #555;
    margin-top: 5px;
}

.advanced-content input[type="range"] {
    width: 100%;
    margin: 5px 0;
}

.advanced-content select,
.advanced-content input[type="number"] {
    padding: 8px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}
/* ===== 全局APP容器适配（学习同人墙的方式）===== */
.app-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    z-index: 200;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

/* APP内部头部适配 */
.app-container .sub-header,
.app-container .qq-header,
.app-container .tw-header,
.app-container .ig-header,
.app-container .ff-header {
    padding-top: var(--safe-area-top);
    min-height: calc(50px + var(--safe-area-top));
    flex-shrink: 0;
}

/* APP内部底部导航适配 */
.app-container .bottom-nav,
.app-container .qq-nav,
.app-container .tw-nav,
.app-container .ig-nav,
.app-container .ff-nav {
    padding-bottom: var(--safe-area-bottom);
    min-height: calc(60px + var(--safe-area-bottom));
    flex-shrink: 0;
}

/* APP内部内容区适配 */
.app-container .sub-content,
.app-container .qq-content,
.app-container .tw-content,
.app-container .ig-content,
.app-container .ff-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; /* 防止滚动穿透 */
}

/* 桌面端恢复原有样式 */
@media (min-width: 451px) {
    .app-container {
        position: absolute; /* 桌面端使用absolute */
    }

    .app-container .sub-header,
    .app-container .qq-header,
    .app-container .tw-header,
    .app-container .ig-header,
    .app-container .ff-header {
        padding-top: 0;
        min-height: 50px;
    }

    .app-container .bottom-nav,
    .app-container .qq-nav,
    .app-container .tw-nav,
    .app-container .ig-nav,
    .app-container .ff-nav {
        padding-bottom: 0;
        min-height: 60px;
    }
}

/* ===== 滚动优化 ===== */
* {
    -webkit-overflow-scrolling: touch;
}

/* 防止iOS橡皮筋效果导致的布局问题 */
html, body {
    overscroll-behavior: none;
}
