.tablet {
    position: absolute;
    --tab-g-t: var(--ff-win-top, 13vh);
    --tab-g-r: var(--ff-win-right, 5vw);
    --tab-g-b: var(--ff-win-bottom, 7.5vh);
    --tab-g-l: var(--ff-win-left, 5vw);
    --tab-gap-y: clamp(12px, 1.8vh, 22px);
    --tab-gap-x: clamp(16px, 2.2vw, 34px);
    inset: var(--tab-g-t) var(--tab-g-r) var(--tab-g-b) var(--tab-g-l);
    z-index: 32;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vh, 18px);
    padding: var(--tab-gap-y) var(--tab-gap-x);
    color: #eaf3ff;
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(88, 132, 214, .30), rgba(12, 18, 33, 0) 62%),
        radial-gradient(90% 70% at 80% 110%, rgba(126, 84, 200, .22), rgba(12, 18, 33, 0) 60%),
        linear-gradient(168deg, #0d1424 0%, #0a1020 52%, #070b16 100%);
    transform-origin: 50% 0;
    transform: translateY(-14px) scale(.965);
    opacity: 0;
    transition:
        transform .36s cubic-bezier(.2, .9, .25, 1),
        opacity .26s ease;
    will-change: transform, opacity;
}

html.frame-fitted .tablet {
    padding: calc(var(--tab-g-t) + var(--tab-gap-y)) calc(var(--tab-g-r) + var(--tab-gap-x)) calc(var(--tab-g-b) + var(--tab-gap-y));
    /* 平板的 inset 是窗口外接矩形,而贴图窗四周是不规则的(斜角/圆角):
       平板四角会盖到金属边框上。用 frame 贴图自身做反向蒙版 ——
       贴图不透明处(金属框)裁掉,只露出窗口形状。蒙版要对齐视口,
       所以 position 取平板 inset 的负值、size 取整屏。 */
    -webkit-mask-image: linear-gradient(#fff, #fff), url("/wp-content/themes/tuagfey/screen/frame.webp");
    mask-image: linear-gradient(#fff, #fff), url("/wp-content/themes/tuagfey/screen/frame.webp");
    -webkit-mask-size: 100vw 100vh, 100vw 100vh;
    mask-size: 100vw 100vh, 100vw 100vh;
    -webkit-mask-position: calc(-1 * var(--tab-g-l)) calc(-1 * var(--tab-g-t)), calc(-1 * var(--tab-g-l)) calc(-1 * var(--tab-g-t));
    mask-position: calc(-1 * var(--tab-g-l)) calc(-1 * var(--tab-g-t)), calc(-1 * var(--tab-g-l)) calc(-1 * var(--tab-g-t));
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.tablet[hidden] { display: none; }

.tablet.is-on {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.tablet__glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, 0) 26%),
        radial-gradient(120% 60% at 50% 120%, rgba(120, 200, 255, .10), rgba(0, 0, 0, 0) 70%);
    mix-blend-mode: screen;
}

.tablet__status {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: clamp(.68rem, .84vw, .82rem);
    letter-spacing: .14em;
    color: rgba(198, 220, 246, .62);
}

.tablet__battery {
    position: relative;
    width: 26px;
    height: 12px;
    border: 1px solid rgba(198, 220, 246, .5);
    border-radius: 3px;
    padding: 1.5px;
}

.tablet__battery::after {
    content: "";
    position: absolute;
    right: -3px;
    top: 50%;
    width: 2px;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 0 1px 1px 0;
    background: rgba(198, 220, 246, .5);
}

.tablet__battery i {
    display: block;
    height: 100%;
    width: var(--batt, 86%);
    border-radius: 1.5px;
    background: rgba(198, 220, 246, .68);
    transition: width .3s ease;
}

.tablet__battery i.is-charging { background: #8ff0b8; }

.tablet__card {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid rgba(150, 190, 240, .20);
    background: rgba(255, 255, 255, .045);
    padding: clamp(10px, 1.5vh, 18px) clamp(12px, 1.5vw, 20px);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .3s ease, transform .34s cubic-bezier(.2, .9, .25, 1),
                border-color .2s ease, background .2s ease;
}

.tablet.is-on .tablet__card {
    opacity: 1;
    transform: none;
    transition-delay: 70ms, 70ms, 0s, 0s;
}

.tablet__card-title {
    flex: 0 0 auto;
    font-size: clamp(.62rem, .78vw, .74rem);
    letter-spacing: .2em;
    color: rgba(198, 220, 246, .5);
    margin-bottom: clamp(6px, 1vh, 10px);
}

.tablet__row {
    position: relative;
    display: grid;
    gap: clamp(8px, 1.4vw, 18px);
    min-height: 0;
}

.tablet__row--widgets {
    flex: 1.25 1 0;
    grid-template-columns: minmax(0, .85fr) auto minmax(0, 1.15fr);
}

.tablet__row--fill {
    flex: .85 1 0;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

.tablet__clock { justify-content: center; }

.tablet__time {
    font-variant-numeric: tabular-nums;
    font-size: clamp(2.4rem, 8.2vh, 5rem);
    font-weight: 300;
    letter-spacing: .02em;
    line-height: 1;
    color: #f2f8ff;
    text-shadow: 0 2px 14px rgba(0, 0, 0, .45);
}

.tablet__weekday {
    margin-top: clamp(4px, .8vh, 10px);
    font-size: clamp(.74rem, .98vw, .9rem);
    letter-spacing: .18em;
    color: rgba(198, 220, 246, .58);
}

.tablet__controls {
    justify-content: center;
    padding: clamp(10px, 1.5vh, 18px) clamp(10px, 1.2vw, 16px);
}

.tablet__controls .logo-switches {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(10px, 1.2vw, 18px);
}

.tablet__controls .theme-toggle {
    flex: 0 0 auto;
    width: clamp(34px, 4vh, 44px);
    height: clamp(34px, 4vh, 44px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    border: 1px solid rgba(150, 190, 240, .22);
    background: rgba(255, 255, 255, .05);
    color: #dceaff;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, color .18s ease;
}

.tablet__controls .theme-toggle:hover,
.tablet__controls .theme-toggle:focus-visible {
    border-color: rgba(170, 214, 255, .55);
    background: rgba(255, 255, 255, .09);
    color: #fff;
    outline: none;
}


.tablet__controls .volume-panel {
    position: static;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tablet__controls .volume-panel-title { display: none; }

.tablet__controls .volume-range {
    width: clamp(64px, 8vw, 130px);
    background: rgba(150, 190, 240, .28);
}

.tablet__controls .volume-value {
    margin-top: 0;
    min-width: 34px;
    color: rgba(198, 220, 246, .6);
}

.tablet__controls .palette-wrap { position: relative; }

.tablet__search { justify-content: flex-start; }

.tablet__search.is-searching {
    border-color: rgba(150, 200, 255, .5);
    background: rgba(255, 255, 255, .07);
}

.tablet__search-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    border: 1px solid rgba(150, 190, 240, .18);
    background: rgba(8, 13, 24, .5);
    padding: clamp(6px, .9vh, 10px) clamp(10px, 1.2vw, 16px);
    color: rgba(198, 220, 246, .6);
}

.tablet__search-box input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #eaf3ff;
    font: inherit;
    font-size: clamp(.86rem, 1.05vw, .98rem);
    letter-spacing: .04em;
    outline: none;
}

.tablet__search-box input::placeholder { color: rgba(198, 220, 246, .38); }
.tablet__search-box input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }

.tablet__search-results {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: clamp(8px, 1.2vh, 14px);
    overflow: auto;
    border-radius: 10px;
    border: 1px solid rgba(150, 190, 240, .18);
    background: rgba(8, 13, 24, .42);
    animation: tabletSearchIn .22s ease both;
}

@keyframes tabletSearchIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.tablet__recent-list,
.tablet__tag-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.tablet__recent-list { display: flex; flex-direction: column; }

.tablet__recent-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: clamp(6px, 1vh, 11px) 2px;
    border-bottom: 1px solid rgba(150, 190, 240, .10);
    color: rgba(226, 238, 252, .88);
    text-decoration: none;
    transition: color .18s ease, border-color .18s ease;
}

.tablet__recent-item:last-child { border-bottom: 0; }
.tablet__recent-item:hover { color: #fff; border-color: rgba(170, 214, 255, .35); }

.tablet__recent-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(.76rem, .95vw, .9rem);
    letter-spacing: .03em;
}

.tablet__recent-date {
    flex: 0 0 auto;
    font-size: clamp(.62rem, .78vw, .74rem);
    letter-spacing: .1em;
    color: rgba(198, 220, 246, .42);
}

.tablet__tag-list {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
}

.tablet__tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: clamp(5px, .8vh, 9px) clamp(11px, 1vw, 16px);
    border-radius: 999px;
    border: 1px solid rgba(150, 190, 240, .22);
    background: rgba(255, 255, 255, .05);
    color: rgba(216, 232, 252, .82);
    font-size: clamp(.72rem, .9vw, .84rem);
    letter-spacing: .04em;
    text-decoration: none;
    transition: border-color .18s ease, color .18s ease;
}

.tablet__tag:hover { border-color: rgba(170, 214, 255, .5); color: #fff; }
.tablet__tag i { font-style: normal; color: rgba(198, 220, 246, .45); }

.tablet__apps {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(8px, 1.4vh, 18px) clamp(18px, 2.6vw, 46px);
}

.tablet__app {
    width: clamp(78px, 7.6vw, 106px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(.94);
    transition: opacity .26s ease, transform .3s cubic-bezier(.2, .9, .25, 1.3);
}

.tablet.is-on .tablet__app {
    opacity: 1;
    transform: none;
    transition-delay: calc(90ms + var(--app-i, 0) * 34ms);
}

.tablet__app:hover .tablet__app-icon,
.tablet__app:focus-visible .tablet__app-icon {
    transform: translateY(-2px) scale(1.06);
    border-color: rgba(170, 214, 255, .55);
    box-shadow: 0 12px 26px rgba(0, 0, 0, .42), 0 0 0 1px rgba(170, 214, 255, .22);
}

.tablet__app:focus-visible { outline: none; }

.tablet__app-icon {
    width: clamp(56px, 8vh, 82px);
    height: clamp(56px, 8vh, 82px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 26%;
    border: 1px solid rgba(150, 190, 240, .20);
    background: linear-gradient(158deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .03));
    box-shadow: 0 6px 16px rgba(0, 0, 0, .32);
    color: #dceaff;
    transition: transform .22s cubic-bezier(.2, .9, .25, 1.3), border-color .2s ease,
                box-shadow .2s ease;
}

.tablet__app-icon svg {
    width: 50%;
    height: 50%;
    display: block;
}

.tablet__app-name {
    font-size: clamp(.7rem, .88vw, .82rem);
    letter-spacing: .08em;
    color: rgba(214, 232, 252, .78);
    white-space: nowrap;
}

.tablet__hint {
    flex: 0 0 auto;
    text-align: center;
    font-size: clamp(.62rem, .78vw, .74rem);
    letter-spacing: .12em;
    color: rgba(198, 220, 246, .38);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .3s ease, transform .34s cubic-bezier(.2, .9, .25, 1);
}

.tablet.is-on .tablet__hint {
    opacity: 1;
    transform: none;
    transition-delay: 70ms;
}

.tablet__hint kbd {
    font: inherit;
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid rgba(198, 220, 246, .28);
    background: rgba(255, 255, 255, .06);
}


html.home-boot .scene,
html.home-boot .intro-bg,
html.home-boot .statusbar-toggle {
    opacity: 0 !important;
}

.tablet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #000;
    pointer-events: none;
}

html.home-dark .tablet-backdrop { display: block; }

html.home-dark,
html.home-dark body { background: #000; }

.tablet.is-dark {
    background: #000;
    opacity: 1;
    transform: none;
    color: transparent;
    transition: none;
}

.tablet.is-dark,
.tablet.is-dark * {
    visibility: hidden !important;
}

.tablet.is-dark #home-eye,
.tablet.is-dark #home-eye *,
.tablet.is-dark #home-console,
.tablet.is-dark #home-console * {
    visibility: visible !important;
}

.tablet.is-scan::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    background: linear-gradient(100deg,
            rgba(127, 240, 255, 0) 42%,
            rgba(127, 240, 255, .10) 50%,
            rgba(234, 243, 255, .18) 52%,
            rgba(127, 240, 255, .10) 54%,
            rgba(127, 240, 255, 0) 62%);
    background-size: 260% 100%;
    animation: tablet-scan 1.5s cubic-bezier(.35, .1, .3, 1) 1 both;
}

@keyframes tablet-scan {
    from { background-position: 130% 0; }
    to { background-position: -130% 0; }
}

.home-eye {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 33;                     /* 高于平板(32),【低于窗框(34)】——
                                        它铺满整块屏幕,多出来的部分由窗框收口;
                                        换新外框(自带背景)之前这里必须高于窗框,
                                        否则眼睛会被金属框切掉一角 */
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity .5s ease, transform .55s cubic-bezier(.22, .61, .36, 1);
}

.home-eye.is-on { opacity: 1; }

.home-eye.is-docked {
    transition: opacity .5s ease,
        left .55s cubic-bezier(.22, .61, .36, 1),
        top .55s cubic-bezier(.22, .61, .36, 1),
        width .55s cubic-bezier(.22, .61, .36, 1),
        height .55s cubic-bezier(.22, .61, .36, 1),
        transform .55s cubic-bezier(.22, .61, .36, 1);
}

.home-eye__pre {
    margin: 0;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #fff;
    white-space: pre;
    line-height: 1;
    text-align: center;
    user-select: none;
    transition: color .05s linear;
}

.home-eye__pre.is-glitch { color: var(--eye-glitch, #dfe6ee); }

/* ★ “第 27 次”一句的加重:ECHO 提到未按时修正的瞬间,
   眼睛抖一帧红 + 整屏闪一下警告色(只加视觉,不加系统)。 */
.home-eye__pre.is-glitch-red { color: #ff5a5a; text-shadow: 0 0 8px rgba(255, 90, 90, .55); }
.ff-redflash {
    position: fixed;
    inset: 0;
    z-index: 120;
    pointer-events: none;
    background: rgba(255, 60, 60, .14);
    animation: ff-redflash .55s ease-out forwards;
}
@keyframes ff-redflash {
    from { opacity: 1; }
    to { opacity: 0; }
}

.home-console {
    position: absolute;
    left: calc(var(--ff-win-left, 5vw) + clamp(10px, 1.4vw, 30px));
    bottom: calc(var(--ff-win-bottom, 7.5vh) + clamp(12px, 2.2vh, 34px));
    z-index: 80;
    width: min(52%, 620px);
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-shadow: 0 2px 14px rgba(0, 0, 0, .8);
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .34s ease, transform .34s cubic-bezier(.2, .9, .25, 1);
}

.home-console[hidden] { display: none; }

.home-console.is-on {
    opacity: 1;
    transform: none;
}

.home-console__doc {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: clamp(4px, .8vh, 9px);
    font-size: clamp(.62rem, .74vw, .74rem);
    letter-spacing: .28em;
    color: rgba(127, 240, 255, .72);
    text-shadow: none;
}

.home-console__id {
    letter-spacing: .08em;
    color: rgba(198, 220, 246, .3);
}

.home-console__line {
    margin: 0;
    font-size: clamp(.92rem, 1.18vw, 1.22rem);
    line-height: 1.85;
    letter-spacing: .03em;
    min-height: 1.85em;
    white-space: pre-wrap;
    word-break: break-word;
}

.home-console__line::after {
    content: "";
    display: inline-block;
    width: .5em;
    height: 1.05em;
    margin-left: 3px;
    vertical-align: -0.16em;
    background: rgba(255, 255, 255, .8);
    animation: tablet-caret 1.06s steps(1, end) infinite;
}

.home-console.is-typed .home-console__line::after { opacity: .28; }

@keyframes tablet-caret {
    0%, 52% { opacity: 1; }
    53%, 100% { opacity: 0; }
}

html.guide-lock,
html.guide-lock * {
    pointer-events: none !important;
}

html.guide-lock .magnetic-cursor-cv { opacity: .55 !important; }

@media (prefers-reduced-motion: reduce) {
    .tablet.is-scan::after { animation: none; opacity: 0; }
    .home-eye,
    .home-console { transition-duration: .01ms; }
}

html.top-locked .statusbar-toggle,
.statusbar-toggle.is-locked {
    opacity: 0 !important;
    pointer-events: none !important;
}

html.slot-locked .slot-toggle,
.slot-toggle.is-locked {
    opacity: 0 !important;
    pointer-events: none !important;
}

.is-guide-pulse {
    animation: guide-glow 1.15s ease-in-out infinite !important;
}

@keyframes guide-glow {
    0%, 100% {
        outline: 2px solid rgba(127, 240, 255, .35);
        outline-offset: 2px;
    }
    50% {
        outline: 2px solid rgba(127, 240, 255, 1);
        outline-offset: 5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .is-guide-pulse {
        animation: none !important;
        outline: 2px solid rgba(127, 240, 255, .9);
        outline-offset: 3px;
    }
}

@media (max-width: 900px), (max-height: 560px) {
    .tablet__time { font-size: clamp(1.8rem, 5vh, 2.6rem); }

    .tablet__row--widgets,
    .tablet__row--fill {
        grid-template-columns: minmax(0, 1fr);
    }

    .tablet__apps { gap: 8px 14px; }

    .tablet__app { width: 72px; }

    .tablet__app-icon {
        width: 46px;
        height: 46px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tablet,
    .tablet__app,
    .tablet__app-icon,
    .tablet__card,
    .tablet__hint {
        transition-duration: .01ms !important;
        transition-delay: 0ms !important;
    }

    .tablet__app,
    .tablet__card,
    .tablet__hint {
        opacity: 1;
        transform: none;
    }
}

/* ============================================================
   手机竖屏提示(rotate-hint.html)
   ─────────────────────────────────────────────────────────────
   平板主界面是横向仿真屏,竖屏(~390px)放不下 ⇒ 不阉割、不缩放,
   盖一层"请横过来"的提示卡;横屏/宽屏这层自动消失,原样演示。
   纯 CSS 按 orientation 掐,零 JS。
   ============================================================ */
.m-rotate { display: none; }

@media (max-width: 900px) and (orientation: portrait) {
    .m-rotate {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 400;                       /* 高过平板(40)/开关(41)/黑屏底衬 */
        align-items: center;
        justify-content: center;
        padding: 24px;
        background: #05070d;
        color: #eaf3ff;
        font-family: "Alpha Sector", "Pixel CN", "PingFang SC", "Microsoft YaHei",
            "Noto Sans SC", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    }

    .m-rotate__card {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 14px;
        text-align: center;
        padding: 34px 30px;
        border: 1px solid rgba(234, 243, 255, 0.18);
        border-radius: 8px;
        background: rgba(234, 243, 255, 0.03);
        max-width: 300px;
    }

    .m-rotate__ico {
        width: 44px;
        height: 44px;
        color: rgba(160, 220, 255, 0.8);
        /* 轻微摇摆,示意"转过来" */
        animation: m-rotate-swing 2.6s ease-in-out infinite;
    }

    @keyframes m-rotate-swing {
        0%, 100% { transform: rotate(0deg); }
        35%      { transform: rotate(-90deg); }
        65%      { transform: rotate(-90deg); }
    }

    .m-rotate__t1 {
        font-size: 15px;
        letter-spacing: 0.26em;
        text-indent: 0.26em;
        color: #eaf3ff;
    }

    .m-rotate__t2 {
        font-size: 11px;
        letter-spacing: 0.14em;
        color: rgba(198, 220, 246, 0.5);
    }
}

@media (prefers-reduced-motion: reduce) {
    .m-rotate__ico { animation: none; }
}
