/* 白色桌面和通用面板；照片、头像和聊天内容保留原色。 */
html body { background:#f4f5f7; color:#252a32; }
html body .phone-frame { background:#fff; }
html body #home-screen { background:#fff !important; background-image:none !important; }
html body #home-screen .widget-bg { background:#f8f9fb !important; border:1px solid #edf0f4 !important; box-shadow:none !important; backdrop-filter:none; }
html body #home-screen .app-icon span { color:#363b44 !important; text-shadow:none !important; font-weight:500; }
html body .icon-img-wrapper { background:#f6f7f9 !important; border:none !important; box-shadow:none !important; backdrop-filter:none !important; }
html body .icon-img-wrapper::after { display:none !important; }
html body .icon-img-wrapper img { width:100%;height:100%;object-fit:cover; }
html body #dock { background:#f7f8fa !important; border:1px solid #edf0f3 !important; box-shadow:0 6px 22px #1f293708 !important; backdrop-filter:none !important; }
html body #home-screen [style*="text-shadow"] { text-shadow:none !important; }
html body #home-screen [style*="inset 0"] { box-shadow:none !important; }
html body .selector-sheet { background:#f8f9fb !important; border:1px solid #eef0f3; }
html body .selector-option { background:#fff !important; color:#303640; }
html body #settings, html body #world-book, html body #market, html body #offline-settings-page, html body #offline-active-page { background-color:#fff !important; background-image:none !important; }
html body [data-target="beautify"], html body #beautify { display:none !important; }
html body #home-screen .home-page { color:#303640; }
html body #icon-wechat, html body #icon-settings, html body #icon-forum, html body #icon-world-book, html body #icon-market, html body #icon-story, html body #icon-script { background:transparent !important; }

/* 移除指定装饰组件，同时退出网格布局，不占用空位。 */
html body #home-screen .desktop-removed-widget { display:none !important; }

/* 天空桌面：图标与用户提供的壁纸。 */
html body #home-screen { background-image:url("assets/sky/wallpaper.jpg") !important; background-size:cover !important; background-position:center !important; }
html body #home-screen .widget-bg { background:#ffffffb8 !important; border-color:#ffffffa0 !important; }
html body #dock { background:#ffffff80 !important; backdrop-filter:blur(18px) !important; }
html body .desktop-app-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:26px 16px; padding:20px; align-content:start; }
html body .desktop-app-grid>.widget-4x2 { grid-column:1 / -1; grid-row:auto; min-height:110px; }
html body .desktop-app-grid>.app-icon { min-width:0; align-self:start; }
html body .desktop-app-grid .icon-img-wrapper,html body #dock .icon-img-wrapper { width:96px;height:96px;background:transparent !important;border-radius:17px; }
html body #icon-world-book>*,html body #icon-market>*,html body #icon-story>*,html body #icon-script>*,html body #icon-forum>*,html body #icon-settings>*,html body #icon-wechat>* { display:none; }
html body #icon-world-book::before { content:"";position:absolute;inset:0;background:url("assets/sky/worldbook.png") center/cover; }
html body #icon-market::before { content:"";position:absolute;inset:0;background:url("assets/sky/market.png") center/cover; }
html body #icon-story::before { content:"";position:absolute;inset:0;background:url("assets/sky/story.png") center/cover; }
html body #icon-script::before { content:"";position:absolute;inset:0;background:url("assets/sky/worldbook.png") center/cover; }
html body #icon-forum::before { content:"";position:absolute;inset:0;background:url("assets/sky/weibo.png") center/cover; }
html body #icon-settings::before { content:"";position:absolute;inset:0;background:url("assets/sky/settings.png") center/cover; }
html body #icon-wechat::before { content:"";position:absolute;inset:0;background:url("assets/sky/wechat.png") center/cover; }

html body.desktop-editing [data-layout-key] { touch-action:none; animation:desktop-wiggle .25s infinite alternate; cursor:grab; }
html body.desktop-editing .layout-dragging { opacity:.35; animation:none; }
@keyframes desktop-wiggle { from {transform:rotate(-1.5deg)} to {transform:rotate(1.5deg)} }
.desktop-layout-tools { position:absolute;top:12px;right:16px;z-index:30;display:flex;gap:8px; }
.desktop-layout-tools button { background:#ffffffe6;color:#394c60;border:1px solid #ffffffb0;border-radius:16px;padding:7px 13px;font-size:12px;cursor:pointer; }
@media(prefers-reduced-motion:reduce) { html body.desktop-editing [data-layout-key] { animation:none; } }

.story-create-sheet { bottom:0;width:100%;max-height:90%;overflow-y:auto;padding:20px;box-sizing:border-box;border-radius:24px 24px 0 0; }
.story-create-sheet label { display:block;font-size:13px;color:#555;margin:15px 0 7px; }
.story-create-sheet input,.story-create-sheet textarea,.story-create-sheet select { width:100%;box-sizing:border-box;border:1px solid #e1e6ed;border-radius:10px;padding:11px;background:#fff;color:#333;font:inherit;resize:vertical; }
.story-create-sheet button { cursor:pointer; }
.story-create-modes { display:flex;gap:10px;margin:12px 0; }
.story-create-modes button { flex:1;border:1px solid #dde4ef;padding:12px;border-radius:10px;background:#fff;color:#555; }
.story-create-modes button[aria-pressed="true"] { background:#eaf2ff;color:#426eaa;border-color:#b7d1f4; }
.story-create-sheet [hidden] { display:none!important; }
.story-create-sheet button:disabled { opacity:.6;cursor:wait; }
@media(max-width:380px) { html body .desktop-app-grid {gap:24px 8px;padding:16px 10px;} }

/* 左侧四格应用，底栏保留剧情；长按后显示完成按钮。 */
html body .desktop-app-grid .desktop-left-apps { grid-column:1 / -1; display:grid;grid-template-columns:repeat(2,96px);gap:26px 18px;justify-content:start; }
html body .desktop-layout-tools { display:none; }
html body.desktop-editing .desktop-layout-tools { display:flex; }

/* 每个应用使用相同高度和顶部对齐，避免缺少名称导致图标居中偏移。 */
html body .desktop-left-apps > .app-icon { display:flex;flex-direction:column;align-items:center;justify-content:flex-start;height:128px;gap:0; }
html body .desktop-left-apps > .app-icon .icon-img-wrapper { flex-shrink:0;margin:0 auto; }
html body .desktop-left-apps > .app-icon > span { display:block;margin-top:8px;line-height:20px;min-height:20px; }
html body .desktop-left-apps > .app-icon > span { margin-top:0; }
html body #dock .app-icon > span { display:block;margin-top:0;line-height:16px;min-height:16px;font-size:12px;color:#363b44;text-shadow:none;font-weight:500; }
html body #dock { height:112px; }

/* 应用右侧的可更换照片相框。 */
html body .desktop-app-grid .desktop-left-apps { grid-column:1 / -1;grid-row:2; }
html body .desktop-photo-frame { grid-column:1 / -1;grid-row:2;justify-self:end;align-self:center;width:calc(100% - 214px);max-width:250px;aspect-ratio:1;border:0;padding:0;background:transparent;position:relative;cursor:pointer;transform:none; }
.desktop-frame-art { position:absolute;inset:0;width:100%;height:100%;object-fit:contain;pointer-events:none;z-index:2; }
.desktop-frame-photo { position:absolute;left:22%;top:18.5%;width:58%;height:58%;object-fit:cover;transform:rotate(6deg); }
.desktop-frame-placeholder { position:absolute;left:22%;top:18.5%;width:58%;height:58%;background:#ffffff70;color:#6c8ca5;display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:24px;transform:rotate(6deg); }
.desktop-frame-placeholder small { font-size:11px; }
.desktop-photo-frame [hidden] { display:none; }

/* 剧本与游戏使用整页工作区，避免底部抽屉遮挡内容。 */
html body .selector-overlay:has(.story-create-sheet) { background:#fff!important; backdrop-filter:none!important; }
html body .story-create-sheet { inset:0!important; width:100%!important; height:100%!important; max-height:none!important; min-height:100%!important; border-radius:0!important; border:0!important; padding:24px 22px calc(24px + env(safe-area-inset-bottom, 0px))!important; overflow-y:auto!important; box-shadow:none!important; }
html body .story-create-sheet > .flex-between { position:sticky; top:0; z-index:2; padding:4px 0 16px; background:#fff; }
html body .story-create-sheet [data-content] { max-width:760px; margin:0 auto; padding-bottom:28px; }
html body .story-create-sheet [data-content] button { border:1px solid #d9dee7; border-radius:9px; background:#fff; padding:8px 12px; margin:4px 3px 4px 0; color:#273142; }
html body .story-create-sheet [data-content] button:hover { background:#f3f6fa; }

/* 剧本入口按 Luna 式主流程聚焦；维护项默认折叠。 */
html body .story-create-sheet .story-current { margin:4px 0 18px; color:#596273; font-size:15px; }
html body .story-create-sheet .story-primary-actions { display:flex; gap:10px; margin:8px 0 22px; }
html body .story-create-sheet .story-primary-actions button { flex:1; min-height:46px; font-size:16px; font-weight:600; border-radius:12px; }
html body .story-create-sheet [data-games] button { width:100%; display:block; margin:8px 0; min-height:44px; text-align:left; font-size:15px; }
html body .story-create-sheet [data-templates] > div { padding:12px 0!important; border-bottom:1px solid #edf0f4; }
html body .story-create-sheet .story-more { margin-top:24px; border-top:1px solid #e4e8ee; padding-top:15px; }
html body .story-create-sheet .story-more summary { cursor:pointer; color:#657083; font-size:14px; padding:6px 0 12px; }
html body .story-create-sheet .story-more-actions { display:flex; flex-wrap:wrap; gap:6px; }
html body .story-create-sheet .story-more-actions button { font-size:13px; color:#596273; }
html body .story-import-progress { display:flex; flex-direction:column; gap:7px; margin-top:12px; padding:10px 12px; border:1px solid #edf0f4; border-radius:10px; background:#f8fafc; color:#687386; font-size:12px; }
html body .story-import-progress[hidden] { display:none!important; }
html body .story-import-progress-track { height:5px; overflow:hidden; border-radius:5px; background:#e6eaf0; }
html body .story-import-progress-track > div { width:0; height:100%; border-radius:5px; background:#3e3237; transition:width .3s ease; }

/* 移动端统一安全区与导航层：模拟状态栏隐藏后仍给系统顶部留出可点击空间。 */
@media (max-width: 480px) {
  :root { --mobile-top-safe: max(env(safe-area-inset-top), 44px); --mobile-bottom-safe: max(env(safe-area-inset-bottom), 8px); }
  html body .phone-frame { overflow:hidden; }
  html body .pages-container { min-height:0; }
  html body .page:not(#home-screen) { padding-top:var(--mobile-top-safe)!important; }
  html body .page:not(#home-screen) > .nav-bar:first-child,
  html body .page:not(#home-screen) > .forum-top-nav:first-child { top:0!important; min-height:56px!important; height:56px!important; padding-top:0!important; z-index:120!important; background:#fff!important; border-bottom:1px solid #edf0f3!important; box-shadow:0 1px 8px rgba(25,35,50,.04)!important; }
  html body .page:not(#home-screen) > .nav-bar:first-child .nav-left,
  html body .page:not(#home-screen) > .nav-bar:first-child .nav-right { min-height:42px!important; display:flex!important; align-items:center!important; }
  html body .page:not(#home-screen) > .forum-top-nav:first-child { height:84px!important; min-height:84px!important; padding-top:28px!important; box-shadow:none!important; }
  html body #settings { padding-top:var(--mobile-top-safe)!important; background:#f4f5f7!important; }
  html body #settings > .nav-bar:first-child { background:#f4f5f7!important; }
  html body #settings > div:nth-child(2) { height:calc(100% - 56px)!important; padding:18px 14px calc(24px + var(--mobile-bottom-safe))!important; }
  html body #settings h1 { font-size:26px!important; margin:0 0 14px!important; }
  html body #settings [style*="linear-gradient"] { border-radius:14px!important; box-shadow:0 2px 10px rgba(30,40,55,.05)!important; }
  html body #offline-settings-page,html body #offline-search-page { padding-top:var(--mobile-top-safe)!important; background:#f4f5f7!important; }
  html body #offline-settings-page > .nav-bar:first-child,html body #offline-search-page > .nav-bar:first-child { background:#fff!important; }
  html body #offline-settings-scroll-area { padding:20px 16px calc(24px + var(--mobile-bottom-safe))!important; }
  html body #offline-settings-page .form-group { margin-bottom:16px!important; }
  html body #offline-settings-page [style*="linear-gradient"] { background:#fff!important; border:1px solid #e8ebef!important; border-radius:14px!important; box-shadow:0 2px 10px rgba(30,40,55,.04)!important; }
  html body #offline-settings-page .flex-center button { height:48px!important; border-radius:12px!important; background:#ff8200!important; letter-spacing:0!important; }
  html body #offline-active-page { padding-top:var(--mobile-top-safe)!important; }
  html body #offline-active-page > .flex-between:first-child { min-height:56px!important; padding:0 16px 0!important; background:#fff; border-bottom:1px solid #edf0f3; }
  html body #story-project-overlay,html body #story-create-overlay { padding-top:var(--mobile-top-safe)!important; }
  html body #story-project-overlay .selector-sheet { max-height:calc(100% - var(--mobile-top-safe))!important; padding:20px 16px calc(20px + var(--mobile-bottom-safe))!important; border-radius:18px 18px 0 0!important; background:#fff!important; }
  html body #story-create-overlay .story-create-sheet { padding:0 16px calc(24px + var(--mobile-bottom-safe))!important; }
  html body #story-create-overlay .story-create-sheet > .flex-between { min-height:56px!important; margin:0 -16px 10px!important; padding:0 16px!important; border-bottom:1px solid #edf0f3; }
  html body #story-create-overlay .story-create-modes { position:sticky; top:56px; z-index:2; padding:8px 0; background:#fff; }
  html body #story-create-overlay .story-create-sheet label { margin:12px 0 6px!important; color:#566172!important; }
  html body #story-create-overlay .story-create-sheet input,
  html body #story-create-overlay .story-create-sheet textarea,
  html body #story-create-overlay .story-create-sheet select { border-radius:10px!important; border-color:#dfe4eb!important; background:#f8fafc!important; }
  html body #story-create-overlay .story-create-sheet .btn-primary { position:sticky; bottom:var(--mobile-bottom-safe); z-index:3; width:100%; min-height:48px; border-radius:12px!important; background:#ff8200!important; color:#fff!important; box-shadow:0 5px 16px rgba(255,130,0,.2)!important; }
  html body #story-create-overlay .story-create-sheet .sheet-cancel { width:100%; margin-top:8px!important; }
}

@media (max-width: 480px) {
  html body #forum.weibo-ui { padding-top:0!important; }
  html body .selector-overlay:has(.story-create-sheet) { padding-top:var(--mobile-top-safe)!important; }
  html body .selector-overlay:has(.story-create-sheet) .story-create-sheet { padding-top:0!important; }
  html body .selector-overlay:has(.story-create-sheet) .story-create-sheet > .flex-between { min-height:56px!important; margin:0 -16px 10px!important; padding:0 16px!important; border-bottom:1px solid #edf0f3; }
}
