/*
 * theme26 多屏幕 / Safari 页面缩放自适应补丁
 * 仅处理排版和安全区域，保留原主题颜色、接口、业务脚本和交互。
 * 不使用 transform:scale / zoom 全页强制缩放，也不强迫一屏塞下所有内容。
 */

html, body {
    max-width:100%;
    overflow-x:hidden;
    /* 控制各浏览器自动文字膨胀，字体大小由下方响应规则管理。 */
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
}

body.ice-theme {
    min-width:0;
    min-height:100vh;
    min-height:100dvh;
    overflow-x:clip;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
}

#page-container {
    box-sizing:border-box;
    min-width:0;
    width:100%;
    max-width:425px;
    padding-top:env(safe-area-inset-top, 0px);
    padding-bottom:0;
}

/* 标题、左右操作按钮的布局允许中间名称收缩，不遮挡两侧按钮。 */
.topbar, .topbar.long-brand {
    min-width:0;
    height:auto;
    min-height:46px;
    grid-template-columns:clamp(62px, 17vw, 72px) minmax(0,1fr) clamp(72px, 20vw, 82px);
    gap:clamp(4px, 1.4vw, 7px);
}
.topbar > *, .brand-lockup, .brand-copy {min-width:0;}
.brand-lockup {max-width:100%;}
.brand-copy {flex:0 1 auto;overflow:hidden;}
.brand-lockup .app-title {
    max-width:100%;
    line-height:1.25;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.top-action {
    min-width:0;
    padding-inline:4px!important;
}
.top-action span {white-space:nowrap;}

/* 公告只在自身的滚动区域移动，不影响父级宽度。 */
.site-notice {min-width:0;max-width:100%;}
.site-notice .notice-window {min-width:0;max-width:100%;}

/* 防止 Safari 字号/页面放大之后，文字突破固定高的表单区。 */
.form-shell {min-width:0;overflow:visible;}
.ice-card.field-card {
    height:auto;
    min-height:88px;
    padding:7px 0 10px;
}
.ice-card.apps-card {
    height:auto;
    min-height:125px;
    padding:7px 0 9px;
}
.card-heading, .apps-card .card-heading {
    height:auto;
    min-height:36px;
}
.card-heading h2 {line-height:1.25;overflow-wrap:anywhere;}
.field-row {
    min-width:0;
    width:100%;
    height:auto;
    min-height:36px;
    align-items:stretch;
}
.field-row input {
    display:block;
    flex:1 1 0;
    width:0;
    min-width:0;
    height:auto;
    min-height:36px;
    padding-top:0;
    padding-bottom:0;
    line-height:normal;
    font-size:16px; /* 避免 iOS Safari 聚焦输入框时自动放大页面 */
    border-radius:0;
}
#udid {font-size:clamp(11px, 3.35vw, 13px);}
#udid.udid-long {font-size:clamp(10px, 2.75vw, 10.5px);}
.get-udid-btn {
    box-sizing:border-box;
    flex:0 0 clamp(82px, 25vw, 99px);
    width:auto;
    height:auto;
    min-height:36px;
    padding:0 5px!important;
    white-space:nowrap;
}
.get-udid-btn svg {flex:0 0 18px;}
.copy-code-btn {height:auto;min-height:36px;flex:0 0 42px;}
.app-count {max-width:52%;flex:0 0 auto;}

/* 应用选项可横向滚动，纵向随名称内容增长，避免选中标识被裁切。 */
.app-select {
    min-width:0;
    width:100%;
    height:auto;
    min-height:81px;
    padding-bottom:5px!important;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-inline:contain;
    scroll-snap-type:x proximity;
}
.app-select label {
    flex:0 0 58px;
    height:auto;
    min-height:75px;
    scroll-snap-align:start;
}
.app-select .app-name {
    max-width:100%;
    min-height:12px;
}
.app-icon-tile {flex:0 0 52px;}

.install-button {
    box-sizing:border-box;
    min-height:36px;
    height:auto;
    padding-block:8px;
    text-align:center;
    line-height:1.25;
}
.install-button .run-label {overflow-wrap:anywhere;}

/* 横幅始终按原图比例显示，无裁剪、不拉伸。 */
.source-hero {
    width:auto;
    max-width:100%;
    height:auto;
    aspect-ratio:851 / 404;
    background-size:100% 100%;
    background-repeat:no-repeat;
}

/* 底栏不再依赖固定总高度，非全面屏/大字号能够完整滚动看到。 */
.floating-links {
    box-sizing:border-box;
    height:auto;
    min-height:78px;
    margin-bottom:max(16px, env(safe-area-inset-bottom, 0px));
}
.floating-link {height:auto;min-height:62px;}
.floating-link .action-copy {max-width:100%;}
.floating-link .action-copy strong {line-height:1.3;}

/* 弹窗在 iPhone SE、旧款 Home 键屏以及横屏时仍可滚动和操作。 */
.ad-modal, .tutorial-modal {
    box-sizing:border-box;
    padding-top:max(12px, env(safe-area-inset-top, 0px));
    padding-bottom:max(12px, env(safe-area-inset-bottom, 0px));
}
.ad-modal-content, .ad-modal-inside, .tutorial-modal-card {max-width:100%;}
.ad-modal-inside {
    max-height:calc(100vh - 32px);
    max-height:calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
.tutorial-modal-card {
    max-height:calc(100vh - 32px);
    max-height:calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    display:flex;
    flex-direction:column;
}
.tutorial-modal-body {min-height:0;flex:1 1 auto;overflow:auto;}
.layui-layer {box-sizing:border-box;max-width:calc(100vw - 20px)!important;}
.layui-layer-content {overflow-wrap:anywhere;}

/* 100% 缩放下的常见手机：保持第三张参考图的单行标题与三列应用。 */
@media (min-width:356px) and (max-width:390px) {
    .brand-lockup {gap:7px;}
    .topbar .app-title {font-size:clamp(15px, 4.6vw, 18px);}
}

/* Safari 页缩放 >100%、320/360px 旧款屏幕：标题换行排列，避免硬截断。 */
@media (max-width:355px) {
    .topbar, .topbar.long-brand {
        margin:0 12px 9px;
        min-height:0;
        height:auto;
        grid-template-columns:minmax(0,1fr) minmax(0,1fr);
        grid-template-rows:46px 34px;
        gap:4px 10px;
    }
    .topbar .brand-lockup {
        grid-column:1 / -1;
        grid-row:1;
        justify-self:center;
    }
    .topbar .reset-btn {grid-column:1;grid-row:2;justify-self:stretch;}
    .topbar .query-btn {grid-column:2;grid-row:2;justify-self:stretch;}
    .topbar .top-action {min-height:34px!important;font-size:12px;}
    .topbar .app-title,.topbar.long-brand .app-title {font-size:17px;}
    .brand-logo-wrap,.backend-logo,.theme-logo {
        width:40px!important;
        height:40px!important;
        flex-basis:40px;
    }
    .site-notice,.form-shell {margin-left:12px;margin-right:12px;}
    .form-shell {padding-inline:10px;}
    .install-button,.source-hero {margin-left:14px;margin-right:14px;}
    .install-button {width:calc(100% - 28px);}
    .floating-links {margin-left:12px;margin-right:12px;padding-inline:6px;}
    .get-udid-btn {gap:4px;font-size:11px;}
    .get-udid-btn svg {width:15px;flex-basis:15px;height:15px;}
    .app-count {font-size:10px;padding-inline:7px;}
    .app-select.is-balanced {justify-content:space-around;}
}

/* 可用高度较矮时适度收紧空白，不牺牲可读性；剩余内容正常纵向滚动。 */
@media (max-height:730px) and (min-width:356px) {
    .topbar {margin-bottom:7px;}
    .site-notice {margin-bottom:7px;}
    .form-shell {margin-top:6px;margin-bottom:9px;}
    .install-button {margin-bottom:9px;}
    .floating-links {margin-top:9px;}
}

/* 浏览器放大或横屏时，不让横幅、模态框导致横向超出。 */
@media (orientation:landscape) and (max-height:520px) {
    .ad-modal,.tutorial-modal {align-items:flex-start;overflow-y:auto;}
    .ad-modal-content,.tutorial-modal-card {margin:auto;}
    .app-select {scroll-snap-type:none;}
}

/* 窄屏按系统实际显示宽度排列，禁止误触发双向滚动。 */
@media (max-width:300px) {
    .topbar .top-action {font-size:11px;}
    .site-notice {margin-inline:8px;padding-left:31px;padding-right:28px;}
    .form-shell {margin-inline:8px;padding-inline:8px;}
    .install-button,.source-hero {margin-inline:10px;}
    .install-button {width:calc(100% - 20px);}
    .floating-links {margin-inline:8px;}
    .app-select label {flex-basis:53px;min-width:53px;}
    .app-icon-tile {width:47px;height:47px;flex-basis:47px;}
    .app-select .app-name {font-size:9px;}
}

/* 输入框聚焦时保证 iOS 不触发 Safari 的 16px 以下字体自动放大。 */
.field-row input:focus,
#udid:focus,
#udid.udid-long:focus {font-size:16px;}

/*
 * Safari「页面缩放」设为 75%/85% 等较小时，其 CSS viewport 往往会变宽。
 * 在手机的粗指针环境下，以 vw 等比扩展布局和文字，使可视物理尺寸
 * 仍接近 100% 下的 390px 参考页面，而不靠 transform/zoom 拉伸整页。
 * 平板完整宽屏 >=700px 沿用常规 425px 窄栏。
 */
@media (pointer:coarse) and (min-width:450px) and (max-width:699px) {
    #page-container {max-width:100%;}
    .topbar, .topbar.long-brand {
        min-height:11.8vw;
        margin:0 4.6vw 2.8vw;
        grid-template-columns:18.5vw minmax(0,1fr) 21vw;
        gap:1.6vw;
    }
    .top-action, .long-brand .top-action {
        height:8.72vw;
        min-height:8.72vw!important;
        border-radius:3.6vw!important;
        font-size:3.08vw!important;
        gap:1.54vw;
    }
    .top-action svg,.long-brand .top-action svg {width:4.62vw;height:4.62vw;}
    .brand-lockup,.long-brand .brand-lockup {gap:2.8vw;}
    .brand-logo-wrap,.backend-logo,.theme-logo {
        width:11.8vw!important;
        height:11.8vw!important;
        flex-basis:11.8vw;
        border-radius:3.3vw!important;
    }
    .brand-lockup .app-title,.long-brand .app-title {font-size:4.7vw!important;}
    .site-notice {
        height:9.23vw;
        margin:0 4.6vw 2.56vw;
        padding:0 9.74vw 0 9.23vw;
        border-radius:4.36vw;
        font-size:2.82vw;
        line-height:8.72vw;
    }
    .site-notice .notice-window,.site-notice .notice-track{height:8.72vw;}
    .site-notice::before {left:3.33vw;width:4.9vw;height:4.9vw;}
    .site-notice::after {right:3.33vw;font-size:6.4vw;}
    .form-shell {
        margin:2.05vw 4.6vw 3.08vw;
        padding:1.28vw 3.33vw 2.05vw;
        border-radius:6.15vw;
    }
    .ice-card.field-card {min-height:22.56vw;padding:1.8vw 0 2.56vw;}
    .ice-card.apps-card {min-height:32.05vw;padding:1.8vw 0 2.3vw;}
    .card-heading,.apps-card .card-heading {min-height:9.23vw;padding-inline:1.03vw;}
    .card-heading h2 {font-size:3.59vw;}
    .field-row {
        min-height:9.23vw;
        margin-top:1.03vw;
        border-radius:3.33vw;
    }
    .field-row input {min-height:9.23vw;font-size:max(16px, 4.1vw);padding-inline:3.08vw;}
    #udid {font-size:max(16px, 3.33vw);padding-inline:2.56vw 1.54vw;}
    #udid.udid-long {font-size:max(13px,2.69vw);}
    .field-row input:focus,#udid:focus,#udid.udid-long:focus {font-size:max(16px, 4.1vw);}
    .get-udid-btn {
        min-height:9.23vw;
        flex-basis:25.4vw;
        border-radius:3.33vw;
        font-size:3.08vw;
        gap:1.79vw;
    }
    .get-udid-btn svg {width:4.62vw;height:4.62vw;flex-basis:4.62vw;}
    .copy-code-btn {min-height:9.23vw;flex-basis:10.77vw;}
    .copy-code-btn svg {width:4.87vw;height:4.87vw;}
    .app-count {height:6.67vw;padding-inline:2.3vw;border-radius:3.59vw;font-size:2.82vw;}
    .app-count::after {font-size:4.87vw;}
    .app-select {min-height:20.77vw;gap:2.05vw;padding-top:1.54vw!important;padding-bottom:1.28vw!important;}
    .app-select label {
        flex-basis:14.87vw;
        min-width:14.87vw;
        min-height:19.23vw;
        font-size:2.56vw;
    }
    .app-select .app-name {width:15.9vw;line-height:3.08vw;min-height:3.08vw;}
    .app-icon-tile {
        width:13.33vw;
        height:13.33vw;
        flex-basis:13.33vw;
        margin-bottom:1.28vw;
        border-width:1.28vw;
        border-radius:3.85vw;
    }
    .app-icon-tile svg {width:6.41vw;height:6.41vw;}
    .app-select input:checked+label::before {
        top:-1.03vw;
        width:4.87vw;
        height:4.87vw;
        border-width:.51vw;
        font-size:2.82vw;
    }
    .install-button {
        min-height:9.23vw;
        margin:0 5.38vw 2.82vw;
        width:calc(100% - 10.76vw);
        padding-block:2.05vw;
        border-radius:4.62vw;
        font-size:3.59vw;
    }
    .source-hero {margin-inline:5.38vw;border-radius:3.85vw;}
    .floating-links {
        min-height:20vw;
        margin:3.08vw 4.6vw max(5.13vw, env(safe-area-inset-bottom, 0px));
        padding:1.8vw 2.56vw;
        border-radius:7.69vw;
        gap:1.03vw;
    }
    .floating-link {min-height:15.9vw;gap:1.28vw;padding:1.03vw 1.28vw;}
    .action-icon {width:7.44vw;height:7.44vw;flex-basis:7.44vw;}
    .action-icon svg {width:6.92vw;height:6.92vw;}
    .action-copy strong {font-size:2.56vw;}
    .tutorial-link {height:auto;min-height:16.4vw;transform:translateY(-.5vw);}
    .tutorial-link .action-icon {width:11vw;height:11vw;flex-basis:11vw;}
    .tutorial-link .action-icon svg {width:5.9vw;height:5.9vw;}
    .tutorial-link .action-copy strong {font-size:2.44vw;}
}

/*
 * v2: 与参考截图对齐的纵向节奏。
 * 原补丁 field-card/apps-card 的 auto + 大 min-height 使表单比设计稿多出约 40px。
 * 保留输入触控面积 >=36px 和应用图标，不靠裁剪或强制缩放整页。
 */
@media (max-width:449px) and (min-width:356px) {
    .ice-card.field-card {
        height:auto;
        min-height:86px;
        padding:5px 0;
    }
    .card-heading,.apps-card .card-heading {
        height:34px;
        min-height:34px;
    }
    .field-row {height:36px;min-height:36px;margin-top:4px;}
    .field-row input,.get-udid-btn,.copy-code-btn {min-height:36px;}
    .ice-card.apps-card {height:auto;min-height:116px;padding:4px 0 5px;}
    .app-select {height:72px;min-height:72px;padding-top:5px!important;padding-bottom:1px!important;}
    .app-select label {min-height:66px;}
}

/*
 * Safari 网页缩小（例如 80%）后可能产生更宽的 CSS viewport。
 * 用 vw 的设备比例布局仍需要按参考图的紧凑度配置，否则之前的比例会纵向放大。
 * 所有调整仍是自然文档流：不干涉浏览器的缩放设置，也不影响固定定位的弹窗。
 */
@media (pointer:coarse) and (min-width:450px) and (max-width:699px) {
    .form-shell {padding-top:.85vw;padding-bottom:1.55vw;}
    .ice-card.field-card {height:auto;min-height:21.5vw;padding:1.1vw 0;}
    .card-heading,.apps-card .card-heading {height:8.15vw;min-height:8.15vw;}
    .field-row {height:9.0vw;min-height:9.0vw;margin-top:.8vw;}
    .field-row input,.get-udid-btn,.copy-code-btn {min-height:9vw;}
    .ice-card.apps-card {height:auto;min-height:29.6vw;padding:1vw 0 1.1vw;}
    .app-select {height:18.25vw;min-height:18.25vw;padding-top:.6vw!important;padding-bottom:.55vw!important;}
    .app-select label {min-height:17.1vw;}
    .app-select .app-name {min-height:2.8vw;line-height:2.8vw;}
    .app-icon-tile {margin-bottom:.6vw;}
    .topbar {margin-bottom:1.8vw;}
    .site-notice {margin-bottom:1.6vw;}
    .form-shell {margin-top:1.4vw;margin-bottom:2.1vw;}
    .install-button {margin-bottom:2vw;}
    .floating-links {margin-top:2vw;}
}

/* 非全面屏、小型 Safari 可视区：优先收紧空白，而非隐藏导航。 */
@media (max-width:449px) {
html.theme26-fit-tight .form-shell {margin-top:5px;margin-bottom:8px;}
html.theme26-fit-tight .topbar {margin-bottom:6px;}
html.theme26-fit-tight .site-notice {margin-bottom:6px;}
html.theme26-fit-tight .floating-links {margin-top:8px;margin-bottom:8px;}
html.theme26-fit-tight .install-button {margin-bottom:7px;}
html.theme26-fit-tight .ice-card.field-card {padding-top:3px;padding-bottom:3px;min-height:82px;}
html.theme26-fit-tight .ice-card.apps-card {padding-top:3px;padding-bottom:3px;min-height:110px;}
html.theme26-fit-tight .card-heading,html.theme26-fit-tight .apps-card .card-heading {min-height:32px;height:32px;}
html.theme26-fit-tight .app-select {min-height:70px;height:70px;}
}

/* 在超窄、放大网页和小尺寸 Home 键机型上完整保留导航，必要时允许滚动。 */
@media (max-width:355px) {
    .form-shell {overflow:visible;}
    .floating-links {margin-bottom:max(10px,env(safe-area-inset-bottom,0px));}
}

/* 缩小了 Safari 页面后，CSS 可视宽度变大时对应的紧凑布局。 */
@media (pointer:coarse) and (min-width:450px) and (max-width:699px) {
    html.theme26-fit-tight .topbar {margin-bottom:.9vw;}
    html.theme26-fit-tight .site-notice {margin-bottom:1vw;}
    html.theme26-fit-tight .form-shell {margin-top:.8vw;margin-bottom:1vw;padding-top:.6vw;padding-bottom:1vw;}
    html.theme26-fit-tight .ice-card.field-card {min-height:20vw;padding:.8vw 0;}
    html.theme26-fit-tight .card-heading,
    html.theme26-fit-tight .apps-card .card-heading {height:7.9vw;min-height:7.9vw;}
    html.theme26-fit-tight .ice-card.apps-card {min-height:27.4vw;padding:.7vw 0;}
    html.theme26-fit-tight .app-select {height:17.5vw;min-height:17.5vw;}
    html.theme26-fit-tight .app-select label {min-height:17vw;}
    html.theme26-fit-tight .install-button {margin-bottom:1vw;}
    html.theme26-fit-tight .floating-links {margin-top:.8vw;}
}
