/* ============================================================
   主题变量：Win11（默认） / Win10
   ============================================================ */
:root{
    --tb-height: 48px;
    --tb-bg: #f3f3f3;
    --tb-border: rgba(0,0,0,.06);
    --panel-bg: rgba(243, 243, 243, 0.94);
    --panel-fg: #1b1b1b;
    --panel-sub: #5a5a5a;
    --accent: #0078d4;
    --accent-soft: rgba(0, 120, 212, .10);
    --hover: rgba(0, 0, 0, .06);
    --radius: 8px;
    --radius-sm: 6px;
    --blur: 22px;
    --shadow: 0 12px 40px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .08);
    --tb-justify: center;
    --tb-btn-radius: 6px;
    --startmenu-w: 540px;
    --font: 'Segoe UI', 'Microsoft YaHei', -apple-system, sans-serif;
}

body[data-theme="win10"]{
    --tb-height: 40px;
    --tb-bg: #1f1f1f;
    --tb-border: rgba(255,255,255,.08);
    --panel-bg: rgba(28, 28, 28, 0.97);
    --panel-fg: #f2f2f2;
    --panel-sub: #a8a8a8;
    --accent: #00a2ed;
    --accent-soft: rgba(0, 162, 237, .18);
    --hover: rgba(255, 255, 255, .10);
    --radius: 0px;
    --radius-sm: 0px;
    --blur: 0px;
    --shadow: 0 0 0 1px rgba(0,0,0,.5), 0 10px 30px rgba(0, 0, 0, .4);
    --tb-justify: flex-start;
    --tb-btn-radius: 0px;
    --startmenu-w: 660px;
}

*{
    margin: 0px;
    padding: 0px;
    box-sizing: border-box;
}

body{
    background: url("src/bg2.jpg") no-repeat center center/cover;
    height: 100vh;
    overflow: hidden;
    font-family: var(--font);
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

/* 桌面与任务栏禁止长按选中（面板内文本仍可选中复制） */
.desktopIcons, .taskbar{
    -webkit-user-select: none;
    user-select: none;
}

button, input, textarea{
    font-family: inherit;
    outline: none;
}

/* ============================================================
   任务栏
   ============================================================ */
.taskbar{
    position: fixed;
    bottom: 0px;
    left: 0px;
    width: 100vw;
    height: var(--tb-height);
    display: flex;
    align-items: center;
    background-color: var(--tb-bg);
    border-top: 1px solid var(--tb-border);
    z-index: 110;
}

.tb-center{
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: var(--tb-justify);
    gap: 4px;
    padding: 0 6px;
}

.tb-btn{
    background: none;
    border: none;
    cursor: pointer;
    height: calc(var(--tb-height) - 8px);
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--tb-btn-radius);
    transition: background-color .15s ease;
}
.tb-btn:hover{ background-color: var(--hover); }
.tb-btn img{ width: 24px; height: 24px; }
.tb-btn.active{ background-color: var(--accent-soft); }

body[data-theme="win10"] .tb-btn img{ width: 20px; height: 20px; }

.tb-tray{
    position: absolute;
    right: 0px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 4px;
}

#righttaskbar{
    display: none;
}

/* 右下角实时时钟 */
.tb-clock{
    text-align: right;
    font-size: 11.5px;
    line-height: 1.3;
    color: var(--panel-fg, #1b1b1b);
    padding: 0 6px;
}
body[data-theme="win10"] .tb-clock{
    color: #f2f2f2;
}
.tb-time{
    font-weight: 600;
    letter-spacing: .5px;
}
.tb-date{
    opacity: .75;
    font-size: 10.5px;
}

/* ===== 系统托盘：网络/音量/电量/输入法/通知 ===== */
.tb-icons{
    display: flex;
    align-items: center;
    gap: 1px;
    margin-right: 4px;
}

.tb-ico{
    background: none;
    border: none;
    cursor: pointer;
    height: calc(var(--tb-height) - 10px);
    min-width: 30px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    color: var(--panel-fg, #1b1b1b);
    font-size: 13px;
    position: relative;
    transition: background-color .15s ease;
}
.tb-ico:hover{ background: var(--hover); }
body[data-theme="win10"] .tb-ico{ color: #f2f2f2; }

.ico-wifi{ font-size: 11px; }
.ico-wifi.offline{ opacity: .35; }

/* 电池图标 */
.bat-wrap{ cursor: default; }
.bat{
    display: inline-block;
    width: 20px;
    height: 11px;
    border: 1px solid currentColor;
    border-radius: 2px;
    position: relative;
    padding: 1px;
}
.bat::after{
    content: '';
    position: absolute;
    right: -3px;
    top: 2.5px;
    width: 2px;
    height: 4px;
    background: currentColor;
    border-radius: 0 1px 1px 0;
}
.bat-fill{
    display: block;
    height: 100%;
    background: currentColor;
    border-radius: 1px;
    transition: width .3s ease;
}
.bat-fill.low{ background: #e81123; }
.bat-fill.charging{ background: #0d8a16; }
.bat-txt{ font-size: 10.5px; opacity: .8; }

/* 输入法 */
.tb-ime{
    font-size: 11px;
    font-weight: 600;
    min-width: 26px;
    letter-spacing: .5px;
}

/* 通知角标 */
.notif-badge{
    position: absolute;
    top: 2px;
    right: 1px;
    background: #e81123;
    color: #fff;
    font-size: 9px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 8px;
    min-width: 14px;
    font-weight: 600;
}
.notif-badge.hide{ display: none; }

/* 音量弹窗 */
.tray-pop{
    position: fixed;
    right: 8px;
    bottom: calc(var(--tb-height) + 6px);
    z-index: 12000;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    display: none;
    flex-direction: column;
    gap: 10px;
    min-width: 190px;
    color: var(--panel-fg);
}
.tp-title{ font-size: 12.5px; font-weight: 600; }
.tray-pop input[type=range]{ width: 100%; cursor: pointer; }
.tp-val{ font-size: 11.5px; text-align: right; color: var(--panel-sub); }

/* 通知中心 */
.notif-panel{
    position: fixed;
    right: 8px;
    bottom: calc(var(--tb-height) + 6px);
    z-index: 12000;
    width: 340px;
    max-width: 92vw;
    max-height: 60vh;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    color: var(--panel-fg);
}
.np-head{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-size: 13.5px;
    font-weight: 600;
    border-bottom: 1px solid var(--tb-border);
}
.np-clear{
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    font-size: 11.5px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
}
.np-clear:hover{ background: var(--hover); }

.np-list{ overflow-y: auto; padding: 8px; }
.np-item{
    background: var(--hover);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 12.5px;
}
.np-item .npi-t{ font-weight: 600; margin-bottom: 3px; }
.np-item .npi-b{ color: var(--panel-sub); line-height: 1.45; }
.np-item .npi-tm{ font-size: 10.5px; color: var(--panel-sub); margin-top: 5px; }
.np-empty{
    padding: 34px;
    text-align: center;
    color: var(--panel-sub);
    font-size: 12.5px;
}

.tb-theme{
    background: var(--accent-soft);
    border: none;
    cursor: pointer;
    height: calc(var(--tb-height) - 14px);
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    border-radius: var(--radius-sm);
    color: var(--panel-fg);
    font-size: 12px;
    transition: background-color .15s ease;
}
.tb-theme:hover{ background-color: var(--hover); }
.tb-t-ico{ font-size: 13px; }
.tb-t-txt{ font-weight: 600; letter-spacing: .3px; }

/* ============================================================
   面板通用
   ============================================================ */
.panel{
    position: absolute;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--panel-fg);
    overflow: hidden;
}

/* 开始菜单 */
.startmenu{
    bottom: -700px;
    left: 50%;
    transform: translateX(-50%);
    width: var(--startmenu-w);
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    padding: 18px;
    text-align: left;
    transition: bottom .35s ease;
    z-index: 100;
}

.sm-search{
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--hover);
    border-radius: 18px;
    padding: 7px 14px;
    margin-bottom: 14px;
}
.sm-ico{ opacity: .6; font-size: 13px; }
.sm-search input{
    flex: 1;
    background: none;
    border: none;
    color: var(--panel-fg);
    font-size: 13px;
}
.sm-search input::placeholder{ color: var(--panel-sub); }

.sm-section-title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--panel-sub);
    margin: 4px 0 10px;
}
.sm-sort{
    background: none;
    border: none;
    cursor: pointer;
    color: var(--panel-sub);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.sm-sort:hover{ background: var(--hover); }

.sm-grid{
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    overflow-y: auto;
    flex: 1;
    min-height: 120px;
}
body[data-theme="win10"] .sm-grid{
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.sm-app{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    transition: background-color .12s ease;
    position: relative;
}
.sm-app:hover{ background-color: var(--hover); }
.sm-app img{
    width: 30px;
    height: 30px;
    object-fit: contain;
}
.sm-app span{
    font-size: 10.5px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
}
body[data-theme="win10"] .sm-app{
    background: var(--accent);
    color: #fff;
}
body[data-theme="win10"] .sm-app:hover{
    filter: brightness(1.15);
}

.sm-empty{
    display: none;
    text-align: center;
    color: var(--panel-sub);
    font-size: 12px;
    padding: 24px 0;
}

.sm-footer{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--tb-border);
}
.sm-user{
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}
.sm-avatar{
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}
.sm-power{
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    color: var(--panel-fg);
    padding: 5px 9px;
    border-radius: var(--radius-sm);
}
.sm-power:hover{ background: var(--hover); }

.power-menu{
    display: none;
    position: absolute;
    right: 14px;
    bottom: 58px;
    background: var(--panel-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 4px 0;
    min-width: 140px;
    z-index: 10;
}
.pm-item{
    padding: 8px 16px;
    font-size: 12.5px;
    cursor: pointer;
}
.pm-item:hover{ background: var(--hover); }

/* 搜索面板 */
.searchmenu{
    bottom: -700px;
    left: 50%;
    transform: translateX(-50%);
    width: 620px;
    max-height: 74vh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    transition: bottom .35s ease;
    z-index: 100;
}
.search-box{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: var(--hover);
    border-radius: var(--radius-sm);
}
.sb-ico{ opacity: .6; font-size: 14px; }
.search-box input{
    flex: 1;
    background: none;
    border: none;
    color: var(--panel-fg);
    font-size: 14px;
}
.search-box input::placeholder{ color: var(--panel-sub); }
.sb-clear{
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--panel-sub);
    padding: 0 4px;
}
.sb-clear:hover{ color: var(--panel-fg); }

.search-results{
    margin-top: 10px;
    overflow-y: auto;
    max-height: 60vh;
}
.sr-group{
    font-size: 11px;
    font-weight: 600;
    color: var(--panel-sub);
    padding: 10px 10px 5px;
}
.sr-item{
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.sr-item:hover, .sr-item.sel{ background: var(--hover); }
.sr-item.sel{ box-shadow: inset 0 0 0 1px var(--accent); }
.sr-item img{ width: 22px; height: 22px; object-fit: contain; }
.sr-txt{ flex: 1; min-width: 0; }
.sr-title{ font-size: 13px; }
.sr-url{
    font-size: 11px;
    color: var(--panel-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sr-empty{
    padding: 30px;
    text-align: center;
    color: var(--panel-sub);
    font-size: 13px;
}

/* 小组件 */
.widgetmenu{
    left: -620px;
    top: 12px;
    bottom: 12px;
    width: 420px;
    display: flex;
    flex-direction: column;
    padding: 16px;
    transition: left .4s ease;
    z-index: 100;
}
.wg-head{
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}
.wg-grid{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    overflow-y: auto;
}
.wg-card{
    background: var(--hover);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.wg-clock{ grid-column: span 2; align-items: center; justify-content: center; padding: 22px; }
.wg-time{ font-size: 40px; font-weight: 300; letter-spacing: 1px; }
.wg-date{ font-size: 12.5px; color: var(--panel-sub); }
.wg-ct{
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--panel-sub);
    font-weight: 600;
}
.wg-w-row{ display: flex; align-items: baseline; gap: 10px; }
.wg-w-temp{ font-size: 28px; font-weight: 300; }
.wg-w-desc{ font-size: 13px; }
.wg-w-loc{ font-size: 11px; color: var(--panel-sub); }
.wg-s-row{
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
}
.wg-s-row span{ color: var(--panel-sub); }
.wg-s-row b{ font-weight: 600; }
.wg-note-input{
    background: rgba(255,255,255,.06);
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--panel-fg);
    font-size: 12px;
    padding: 7px;
    resize: none;
    height: 78px;
    width: 100%;
}
.wg-note-input:focus{ border-color: var(--accent); }

/* 文件资源管理器 */
.filemenu{
    left: 60px;
    top: -800px;
    width: 860px;
    max-width: 92vw;
    height: 560px;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    transition: top .3s ease;
    z-index: 100;
}
.exp-titlebar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 6px 8px 14px;
    font-size: 12.5px;
    border-bottom: 1px solid var(--tb-border);
}
.exp-winbtns{ display: flex; }
.exp-wb{
    background: none;
    border: none;
    cursor: pointer;
    color: var(--panel-fg);
    width: 40px;
    height: 28px;
    font-size: 13px;
}
.exp-wb:hover{ background: var(--hover); }
.exp-close:hover{ background: #e81123; color: #fff; }

.exp-toolbar{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--tb-border);
}
.exp-nav{
    background: none;
    border: none;
    cursor: pointer;
    color: var(--panel-fg);
    font-size: 15px;
    width: 30px;
    height: 28px;
    border-radius: var(--radius-sm);
}
.exp-nav:hover{ background: var(--hover); }
.exp-address{
    flex: 1;
    background: var(--hover);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 12px;
    color: var(--panel-sub);
}
.exp-filter{
    background: var(--hover);
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    width: 170px;
    font-size: 12px;
    color: var(--panel-fg);
}
.exp-filter::placeholder{ color: var(--panel-sub); }

.exp-body{
    flex: 1;
    display: flex;
    overflow: hidden;
}
.exp-sidebar{
    width: 210px;
    border-right: 1px solid var(--tb-border);
    overflow-y: auto;
    padding: 8px 6px;
    font-size: 12.5px;
}
.exp-node{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.exp-node:hover{ background: var(--hover); }
.exp-node.active{ background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.exp-node .en-cnt{ margin-left: auto; font-size: 11px; color: var(--panel-sub); }

.exp-content{
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
}
.exp-file{
    width: 104px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
}
.exp-file:hover{ background: var(--hover); }
.exp-file img{ width: 34px; height: 34px; object-fit: contain; }
.exp-file span{
    font-size: 11px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
}
.exp-status{
    padding: 5px 14px;
    font-size: 11.5px;
    color: var(--panel-sub);
    border-top: 1px solid var(--tb-border);
}

/* 商店（保留原静态图） */
.microsoftstore{
    position: absolute;
    left: 0px;
    top: -800px;
    text-align: center;
    width: 100%;
    transition: top .3s ease;
    z-index: 5;
}
#store{
    width: 800px;
    max-width: 92vw;
    border-radius: 4px;
}

/* ============================================================
   桌面图标（纵向流式，排满一列自动换列）
   ============================================================ */
.desktopIcons{
    position: fixed;
    top: 0px;
    left: 0px;
    height: calc(100vh - 52px);
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 10px 8px;
    z-index: 1;
}

.icon{
    width: 72px;
    margin: 4px 6px;
    text-align: center;
    flex-shrink: 0;
    font-size: 11px;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.icon a{
    text-decoration: none;
    color: inherit;
    display: block;
}

.icon img{
    width: 40px;
    margin: 2px;
}

.icon span{
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
    line-height: 1.25;
}

/* ============================================================
   右键菜单
   ============================================================ */
.ctx-menu{
    position: fixed;
    z-index: 9999;
    min-width: 220px;
    background: var(--panel-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 4px 0;
    display: none;
    font-size: 13px;
}

.ctx-item{
    padding: 8px 28px 8px 14px;
    cursor: default;
    position: relative;
    user-select: none;
    color: var(--panel-fg);
    transition: background-color .12s ease;
}
.ctx-item:hover{ background-color: var(--hover); }

.ctx-icon{
    margin-right: 10px;
    width: 18px;
    text-align: center;
    display: inline-block;
    opacity: .75;
}
.ctx-arrow{ float: right; font-size: 9px; margin-top: 4px; opacity: .5; }
.ctx-sep{ height: 1px; margin: 5px 10px; background: var(--tb-border); }

/* ============================================================
   壁纸选择面板
   ============================================================ */
.wp-panel{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    width: 520px;
    max-width: 92vw;
    max-height: 70vh;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.wp-header{
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.wp-close{
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
    border-radius: 4px;
}
.wp-close:hover{ background: rgba(0,0,0,.06); color: #000; }

.wp-grid{
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    overflow-y: auto;
    max-height: calc(70vh - 52px);
}

.wp-item{
    aspect-ratio: 16/10;
    border-radius: 8px;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    border: 3px solid transparent;
    transition: all .18s ease;
    position: relative;
    overflow: hidden;
}
.wp-item:hover{ border-color: rgba(0,120,212,.5); transform: scale(1.03); }
.wp-item.active{ border-color: #0078d4; box-shadow: 0 0 0 2px rgba(0,120,212,.25); }
.wp-item .wp-label{
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 4px 6px;
    font-size: 11px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
    background: linear-gradient(transparent, rgba(0,0,0,.45));
}

/* ============================================================
   响应式适配：动态视口 / 平板 / 手机 / 小屏 / 触控 / 安全区
   注意：面板的 bottom / left / top 由 JS 内联控制，此处只改
   宽度、间距、字号等显示属性，避免与 JS 定位冲突。
   ============================================================ */

/* 1) 动态视口高度：修复移动端浏览器地址栏导致的 100vh 溢出 */
@supports (height: 100dvh){
    body{ height: 100dvh; }
    .desktopIcons{ height: calc(100dvh - 56px); }
    .startmenu, .searchmenu{ max-height: 74dvh; }
    .filemenu{ max-height: 80dvh; }
}

/* 2) 平板 ≤1024px：面板宽度收敛，图标略缩 */
@media (max-width: 1024px){
    .startmenu{ width: min(94vw, var(--startmenu-w)); }
    .searchmenu{ width: min(94vw, 620px); }
    .widgetmenu{ width: min(86vw, 420px); }
    .filemenu{ width: 94vw; left: 50%; transform: translateX(-50%); }
    .icon{ width: 68px; }
    .exp-sidebar{ width: 150px; }
}

/* 3) 手机 ≤768px：图标紧凑化，托盘精简，面板近全屏 */
@media (max-width: 768px){
    :root{ --tb-height: 52px; --startmenu-w: 100%; }
    body[data-theme="win10"]{ --tb-height: 48px; }

    /* 桌面图标：更紧凑，一屏容纳更多 */
    .desktopIcons{ padding: 8px 4px; }
    .icon{ width: 62px; margin: 2px 3px; font-size: 10px; }
    .icon img{ width: 32px; }

    /* 任务栏：压缩中间按钮 */
    .tb-center{ gap: 1px; }
    .tb-btn{ padding: 5px 6px; }
    .tb-btn img{ width: 22px; height: 22px; }
    body[data-theme="win10"] .tb-btn img{ width: 20px; height: 20px; }

    /* 托盘：隐藏百分比文字与主题文字，图标保留 */
    .bat-txt{ display: none; }
    .tb-t-txt{ display: none; }
    .tb-theme{ padding: 5px 8px; }
    .tb-ime{ padding: 5px 7px; font-size: 11px; }
    .tb-clock{ padding: 3px 6px; }
    .tb-time{ font-size: 11.5px; }
    .tb-date{ font-size: 9.5px; }

    /* 面板：接近全屏，留出安全边距 */
    .startmenu{ width: calc(100vw - 16px); max-height: 70vh; padding: 12px; }
    .searchmenu{ width: calc(100vw - 16px); max-height: 70vh; padding: 10px; }
    .widgetmenu{ width: calc(100vw - 16px); padding: 12px; }
    .filemenu{ width: calc(100vw - 16px); height: 74vh; }
    .wp-panel{ width: calc(100vw - 24px); }

    /* 小组件网格：两列 */
    .wg-grid{ grid-template-columns: 1fr 1fr; }
    .wg-time{ font-size: 32px; }

    /* 开始菜单应用网格：3 列 */
    .sm-grid{ grid-template-columns: repeat(3, 1fr); }
}

/* 4) 小屏手机 ≤480px：进一步精简，让任务栏放得下 */
@media (max-width: 480px){
    .icon{ width: 58px; margin: 2px 2px; font-size: 9.5px; }
    .icon img{ width: 28px; margin: 1px; }

    /* 隐藏网络与输入法图标，优先保证核心功能可见 */
    .tb-icons #icoNet{ display: none; }
    .tb-ime{ display: none; }

    .tb-btn{ padding: 5px 4px; }
    .tb-btn img{ width: 20px; height: 20px; }

    /* 小组件单列，时钟独占 */
    .wg-grid{ grid-template-columns: 1fr; }
    .wg-clock{ grid-column: span 1; padding: 16px; }

    /* 资源管理器侧栏隐藏，内容区占满 */
    .exp-sidebar{ display: none; }
    .exp-toolbar{ flex-wrap: wrap; height: auto; padding: 6px 8px; }

    .sm-grid{ grid-template-columns: repeat(3, 1fr); }
    .wp-grid{ grid-template-columns: repeat(2, 1fr); }
}

/* 5) 触控设备：增大点击热区，去掉 hover 依赖 */
@media (hover: none) and (pointer: coarse){
    .icon{ padding: 6px 2px; }
    .tb-btn, .tb-ico{ min-width: 38px; min-height: 38px; }
    .tb-theme{ min-height: 38px; }
    .ctx-item{ padding: 12px 14px; }
    .np-clear{ padding: 8px 12px; }
    .icon{ cursor: default; }
}

/* 6) 横屏手机（矮屏）：面板高度放宽 */
@media (max-height: 480px) and (orientation: landscape){
    .desktopIcons{ height: calc(100dvh - 56px); }
    .startmenu, .searchmenu{ max-height: 86vh; }
    .filemenu{ height: 82vh; }
    .widgetmenu{ padding: 10px; }
}

/* 7) 安全区：iPhone 底部横条 / 刘海 */
@supports (padding: env(safe-area-inset-bottom)){
    .taskbar{
        height: auto;
        min-height: var(--tb-height);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .startmenu, .searchmenu, .filemenu{
        margin-bottom: env(safe-area-inset-bottom);
    }
}

/* 8) 降低动效偏好：尊重系统设置 */
@media (prefers-reduced-motion: reduce){
    *{ transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
