/* =====================================================================
 * 「当前世界」独立 App · 主界面样式（新拟物派 Neumorphism）
 * ---------------------------------------------------------------------
 * 入口：②号子屏幕「快捷功能」磁贴 → window.LoveMiCurrentWorld.open()
 * 设计：浅色同色系背景 + 双重柔和阴影（左上亮、右下暗），圆角，按压内凹。
 *       参照 tools/新拟物派.md 的 Design Tokens 与 Component Recipes。
 * 兼容：纯 CSS，无框架；box-shadow 双阴影、flex、env(safe-area-inset-*)
 *       在 iOS Safari / 各安卓 WebView（华为/小米/OPPO/vivo/魅族/三星）
 *       及 via / 谷歌 / Edge / 搜狗 / 雨见 / 夸克等浏览器均通用。
 * 命名：统一 cw- 前缀，独立文件，不与其它模块共用。
 * ===================================================================== */

.cw-root {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    z-index: 100150;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease-in-out, visibility .3s ease-in-out;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #4a5568;
    -webkit-tap-highlight-color: transparent;
}
.cw-root.is-open { pointer-events: auto; opacity: 1; visibility: visible; }
.cw-root * { box-sizing: border-box; }

.cw-screen {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #e0e5ec;
    overflow: hidden;
    transform: translateY(12px) scale(.992);
    opacity: 0;
    transition: transform .3s ease-in-out, opacity .3s ease-in-out;
}
.cw-root.is-open .cw-screen { transform: translateY(0) scale(1); opacity: 1; }

/* -------------------- 顶栏：左返回 / 居中标题 / 右上「新建」 -------------------- */
.cw-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: #e0e5ec;
    box-shadow: 0 4px 8px #c4cad3, 0 -2px 4px #ffffff;
    position: relative;
    z-index: 2;
}
.cw-title-wrap { flex: 1; min-width: 0; text-align: center; }
.cw-title-wrap h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .02em;
    color: #3a4253;
}
.cw-title-wrap p {
    margin: 2px 0 0;
    font-size: 11px;
    line-height: 1.3;
    color: #98a0ad;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 圆形图标按钮（返回）：新拟物外凸 → 按下内凹 */
.cw-icon-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #e0e5ec;
    color: #5a6373;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 5px 5px 10px #b8bec7, -5px -5px 10px #ffffff;
    transition: box-shadow .3s ease-in-out, color .2s ease-in-out;
    -webkit-appearance: none;
    appearance: none;
}
.cw-icon-btn:hover { box-shadow: 3px 3px 6px #b8bec7, -3px -3px 6px #ffffff; }
.cw-icon-btn:active { box-shadow: inset 4px 4px 8px #b8bec7, inset -4px -4px 8px #ffffff; }

/* 「新建」按钮：强调色实心 + 新拟物外凸 */
.cw-new-btn {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    background: #6d5dfc;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 5px 5px 10px #b8bec7, -5px -5px 10px #ffffff;
    transition: box-shadow .3s ease-in-out, filter .2s ease-in-out;
    -webkit-appearance: none;
    appearance: none;
}
.cw-new-btn .cw-new-btn__plus { font-size: 18px; line-height: 1; font-weight: 800; }
.cw-new-btn:hover { box-shadow: 3px 3px 6px #b8bec7, -3px -3px 6px #ffffff; }
.cw-new-btn:active { box-shadow: inset 4px 4px 8px #5847d6, inset -4px -4px 8px #8273ff; filter: brightness(.98); }

/* -------------------- 内容区 -------------------- */
.cw-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 18px 16px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

.cw-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

/* 地图卡片：新拟物外凸卡片 */
.cw-map-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 16px 14px;
    border-radius: 20px;
    background: #e0e5ec;
    box-shadow: 8px 8px 16px #b8bec7, -8px -8px 16px #ffffff;
    cursor: pointer;
    transition: box-shadow .3s ease-in-out;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}
.cw-map-card:hover { box-shadow: 6px 6px 12px #b8bec7, -6px -6px 12px #ffffff; }
.cw-map-card:active { box-shadow: inset 6px 6px 12px #b8bec7, inset -6px -6px 12px #ffffff; }
.cw-map-card:focus-visible { box-shadow: 0 0 0 3px rgba(109, 93, 252, .4), 8px 8px 16px #b8bec7, -8px -8px 16px #ffffff; }

.cw-map-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.cw-map-card__name {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 700;
    color: #3a4253;
    word-break: break-word;
    line-height: 1.3;
}
/* 卡片右上「⋯」菜单按钮（新拟物小圆钮） */
.cw-map-card__menu {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: #e0e5ec;
    color: #8a93a3;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 3px 3px 6px #b8bec7, -3px -3px 6px #ffffff;
    transition: box-shadow .2s ease-in-out;
    -webkit-appearance: none;
    appearance: none;
}
.cw-map-card__menu:active { box-shadow: inset 3px 3px 6px #b8bec7, inset -3px -3px 6px #ffffff; }

.cw-map-card__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cw-pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 10px;
    border-radius: 999px;
    background: #e0e5ec;
    color: #6a7384;
    font-size: 11px;
    font-weight: 700;
    box-shadow: inset 3px 3px 6px #b8bec7, inset -3px -3px 6px #ffffff;
}
.cw-map-card__friends {
    font-size: 12px;
    line-height: 1.5;
    color: #8a93a3;
    word-break: break-word;
}
.cw-map-card__friends b { color: #6d5dfc; font-weight: 700; }
.cw-map-card__go {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 700;
    color: #6d5dfc;
    letter-spacing: .02em;
}

/* 空状态 */
.cw-empty {
    margin: 8px auto 0;
    max-width: 320px;
    text-align: center;
    padding: 28px 22px;
    border-radius: 22px;
    background: #e0e5ec;
    box-shadow: inset 8px 8px 16px #b8bec7, inset -8px -8px 16px #ffffff;
}
.cw-empty__icon { font-size: 40px; line-height: 1; }
.cw-empty h3 { margin: 14px 0 6px; font-size: 16px; font-weight: 700; color: #3a4253; }
.cw-empty p { margin: 0 0 16px; font-size: 13px; line-height: 1.6; color: #98a0ad; }
.cw-empty .cw-new-btn { box-shadow: 5px 5px 10px #b8bec7, -5px -5px 10px #ffffff; }

/* -------------------- 弹层（新建/重命名/删除/菜单） -------------------- */
.cw-modal {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(120, 130, 148, .34);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}
.cw-modal__panel {
    width: 100%;
    max-width: 320px;
    border-radius: 22px;
    background: #e0e5ec;
    box-shadow: 10px 10px 22px #b1b7c0, -10px -10px 22px #ffffff;
    padding: 22px 20px 18px;
}
.cw-modal__panel h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: #3a4253; }
.cw-modal__panel p { margin: 0 0 14px; font-size: 12.5px; line-height: 1.6; color: #98a0ad; }

.cw-input {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    background: #e0e5ec;
    color: #3a4253;
    font-size: 15px;
    box-shadow: inset 5px 5px 10px #b8bec7, inset -5px -5px 10px #ffffff;
    transition: box-shadow .3s ease-in-out;
    -webkit-appearance: none;
    appearance: none;
}
.cw-input:focus { outline: none; box-shadow: inset 2px 2px 5px #b8bec7, inset -2px -2px 5px #ffffff; }

.cw-modal__actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}
.cw-btn {
    flex: 1;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    background: #e0e5ec;
    color: #5a6373;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 5px 5px 10px #b8bec7, -5px -5px 10px #ffffff;
    transition: box-shadow .3s ease-in-out, filter .2s ease-in-out;
    -webkit-appearance: none;
    appearance: none;
}
.cw-btn:active { box-shadow: inset 4px 4px 8px #b8bec7, inset -4px -4px 8px #ffffff; }
.cw-btn--accent { background: #6d5dfc; color: #fff; }
.cw-btn--accent:active { box-shadow: inset 4px 4px 8px #5847d6, inset -4px -4px 8px #8273ff; filter: brightness(.98); }
.cw-btn--danger { background: #ef6f6f; color: #fff; }
.cw-btn--danger:active { box-shadow: inset 4px 4px 8px #d45a5a, inset -4px -4px 8px #ff8585; filter: brightness(.98); }

/* 卡片操作菜单（重命名 / 删除） */
.cw-menu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.cw-menu-item {
    width: 100%;
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    background: #e0e5ec;
    color: #4a5568;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    padding: 0 18px;
    box-shadow: 5px 5px 10px #b8bec7, -5px -5px 10px #ffffff;
    transition: box-shadow .3s ease-in-out;
    -webkit-appearance: none;
    appearance: none;
}
.cw-menu-item:active { box-shadow: inset 4px 4px 8px #b8bec7, inset -4px -4px 8px #ffffff; }
.cw-menu-item--danger { color: #d6534f; }

@media (prefers-reduced-motion: reduce) {
    .cw-root, .cw-screen, .cw-icon-btn, .cw-new-btn, .cw-map-card, .cw-btn, .cw-menu-item, .cw-input {
        transition: none !important;
    }
}
