/* easyClick shell - ported */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --safari-top-chrome-h: 52px;
    --safari-bottom-chrome-h: calc(55px + env(safe-area-inset-bottom, 0px));
    /* 层叠：外站内容 < 底栏 < 脚本抽屉 < 全屏弹窗 < Toast */
    --z-safari-tabbar: 10000;
    --z-script-drawer-mask: 10100;
    --z-script-drawer: 10101;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    background: #fff;
    color: #000;
    overflow: hidden;
    overscroll-behavior: none;
}

#app {
    height: 100%;
}

.safari-browser {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    background: #fff;
    overflow: hidden;
    box-sizing: border-box;
}

/* iOS Safari 毛玻璃工具栏 */
.safari-chrome {
    flex-shrink: 0;
    background: rgba(248, 248, 248, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.safari-toolbar-top {
    padding: 6px 10px 8px;
    padding-top: max(6px, env(safe-area-inset-top));
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.18);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-safari-tabbar);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.28s ease;
    will-change: transform;
}

/* 外站注入样式不得压过应用顶/底栏（仅当未主动隐藏时） */
#app:not(.chrome-ui-hidden) #browserTopChrome,
#app:not(.chrome-ui-hidden) #browserBottomChrome {
    visibility: visible !important;
    pointer-events: auto !important;
}

/* 脚本执行中：隐藏地址栏与底栏个人中心 */
.safari-browser.is-script-executing #searchForm,
.safari-browser.is-script-executing #profileCenterBtn {
    display: none !important;
}

.safari-browser.is-script-executing .safari-toolbar-top-inner:empty {
    display: none;
}

/* 脚本执行中：仅保留暂停/停止，禁止编辑与次要入口 */
.script-drawer.script-edit-locked #scriptActionsList .script-item.clickable {
    pointer-events: none;
    opacity: 0.55;
    cursor: not-allowed;
}

.script-drawer.script-execution-controls-only .drawer-body .btn-add-script,
.script-drawer.script-execution-controls-only .drawer-body .btn-record-script,
.script-drawer.script-execution-controls-only #drawerMoreBtn,
.script-drawer.script-execution-controls-only #drawerConfigHelpBtn {
    display: none !important;
}

/* 执行中：全局配置仅展示，不可点击编辑 */
.script-drawer.script-execution-controls-only #drawerGlobalConfigBox {
    pointer-events: none;
    cursor: default;
    opacity: 1;
}

.script-drawer.script-execution-controls-only #drawerGlobalConfigBox .drawer-row-hint {
    display: none;
}

/* 底部 Safari 栏：固定在视口底部 */
.safari-bottom-chrome {
    flex-shrink: 0;
    flex-grow: 0;
    width: 100%;
    background: rgba(248, 248, 248, 0.96);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid rgba(60, 60, 67, 0.18);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-safari-tabbar);
    pointer-events: auto;
    min-height: var(--safari-bottom-chrome-h);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.28s ease;
    will-change: transform;
}

/* 顶栏/底栏自动隐藏（3 秒无操作） */
.safari-browser.chrome-ui-hidden #browserTopChrome {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.safari-browser.chrome-ui-hidden #browserBottomChrome {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* 标签页视图（点底栏「标签页」图标打开，与 Safari 一致） */
.safari-tabs-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.safari-tabs-switcher {
    flex: 1;
    min-height: 0;
    max-height: calc(100% - var(--safari-bottom-chrome-h));
    margin-bottom: var(--safari-bottom-chrome-h);
    background: #f2f2f7;
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.safari-tabs-switcher-header {
    display: grid;
    grid-template-columns: minmax(58px, 1fr) auto minmax(58px, 1fr);
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.18);
    flex-shrink: 0;
}

.safari-tabs-switcher-title {
    font-size: 17px;
    font-weight: 600;
    color: #1c1c1e;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.safari-tabs-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
}

.safari-tabs-header-btn {
    border: none;
    background: transparent;
    color: #007aff;
    font-size: 17px;
    padding: 4px 8px;
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
}

.safari-tabs-header-btn:active {
    opacity: 0.5;
}

.safari-tabs-header-btn.is-new {
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    padding: 0 10px;
}

.safari-tabs-header-btn.is-advanced {
    font-size: 14px;
    font-weight: 600;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(0, 122, 255, 0.12);
    line-height: 20px;
}

.safari-tabs-grid {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-content: start;
}

/* 窗口管理 sheet 列表 */
.window-manager-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px 16px;
}

.window-manager-list .window-list-item {
    margin-bottom: 8px;
}

.window-manager-action-btn {
    min-width: 52px;
    min-height: 34px;
    padding: 0 12px;
    border: none;
    border-radius: 7px;
    background: #f2f2f7;
    color: #111827;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.window-manager-action-btn:active {
    background: #e5e5ea;
}

.window-manager-action-btn.is-danger {
    background: #ff3b30;
    color: #fff;
}

.window-manager-action-btn.is-danger:active {
    background: #d70015;
}

.window-manager-empty {
    text-align: center;
    color: #8e8e93;
    font-size: 14px;
    padding: 24px 16px;
    line-height: 1.5;
    margin: 0;
}

.window-manager-login-link {
    color: #007aff;
    text-decoration: none;
    font-weight: 500;
}

.window-manager-login-link:active {
    opacity: 0.6;
}

.window-manager-overlay .window-manager-panel {
    max-height: 60vh;
    width: min(100%, 720px);
    margin-left: auto;
    margin-right: auto;
}

.window-manager-list .window-list-item {
    min-width: 0;
}

.window-manager-list .window-list-item-content {
    min-width: 0;
}

.window-manager-list .window-list-item-header {
    min-width: 0;
    flex-wrap: wrap;
    row-gap: 4px;
}

.window-manager-list .window-list-item-name {
    min-width: 0;
}

.window-manager-list .window-list-item-url {
    min-width: 0;
    max-width: 100%;
    align-items: flex-start;
    line-height: 1.35;
}

.window-manager-list .window-list-item-url-value {
    min-width: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.window-manager-list .window-list-item-actions {
    align-self: stretch;
    justify-content: flex-end;
}

.safari-tabs-card {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    min-height: 88px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    border: 2px solid transparent;
    touch-action: manipulation;
}

.safari-tabs-card.is-active {
    border-color: #007aff;
}

.safari-tabs-card.is-running .safari-tabs-card-dot {
    display: block;
}

.safari-tabs-card-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34c759;
    margin-bottom: 6px;
}

.safari-tabs-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1c1c1e;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
    word-break: break-all;
}

.safari-tabs-card-url {
    margin-top: 6px;
    font-size: 12px;
    color: #8e8e93;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.safari-tabs-card-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(118, 118, 128, 0.2);
    border-radius: 50%;
    color: #636366;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.safari-icon-btn .safari-tab-count {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #007aff;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

/* 顶部页面加载进度条（Safari / Chrome 风格） */
.safari-load-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.safari-load-progress.is-active {
    opacity: 1;
    transition: none;
}

.safari-load-progress-bar {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #007aff 0%, #5ac8fa 100%);
    transform-origin: 0 50%;
    transform: scaleX(0);
    will-change: transform;
}

.safari-load-progress.is-active .safari-load-progress-bar {
    transition: transform 0.2s ease;
}

.safari-load-progress.is-done .safari-load-progress-bar {
    transition: transform 0.25s ease-out;
}

/* 地址栏胶囊*/
.safari-address-bar {
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 10px;
    background: rgba(118, 118, 128, 0.12);
    border-radius: 10px;
    gap: 6px;
}

.safari-address-bar:focus-within {
    background: rgba(118, 118, 128, 0.18);
}

.safari-lock-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: #8e8e93;
}

.safari-lock-icon.secure {
    color: #34c759;
}

.safari-window-type-badge {
    flex-shrink: 0;
    border-radius: 999px;
    padding: 2px 6px;
    background: rgba(0, 122, 255, 0.12);
    color: #007aff;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    white-space: nowrap;
}

.safari-url-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    line-height: 22px;
    color: #000;
    text-align: center;
    font-family: inherit;
}

.safari-url-input::placeholder {
    color: #8e8e93;
}

.safari-url-input:focus {
    text-align: left;
}

.safari-reload-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: #007aff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.safari-reload-btn:active {
    opacity: 0.5;
}

.safari-reload-btn.loading svg {
    animation: safari-spin 0.8s linear infinite;
}

.safari-stop-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: #ff3b30;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.safari-stop-btn:active {
    opacity: 0.5;
}

@keyframes safari-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 网页区域：形成独立层叠上下文，避免站点内 position:fixed 全屏遮罩盖住应用弹窗 */
.safari-content {
    flex: 1;
    min-height: 0;
    position: relative;
    z-index: 1;
    background: #fff;
    transform: translateZ(0);
    isolation: isolate;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: var(--safari-top-chrome-h, 52px);
    padding-bottom: var(--safari-bottom-chrome-h);
    box-sizing: border-box;
    transition: padding-top 0.28s cubic-bezier(0.32, 0.72, 0, 1),
        padding-bottom 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.safari-content .content-wrapper,
.safari-content .content-frame {
    transform: translateZ(0);
    isolation: isolate;
    min-height: 100%;
    box-sizing: border-box;
    padding-bottom: 12px;
}

.safari-content iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.safari-content.is-light-js {
    transform: none !important;
    transition: none !important;
    overflow: hidden !important;
    -webkit-overflow-scrolling: auto;
}

.safari-content.is-light-js .content-wrapper,
.safari-content.is-light-js .content-frame,
.safari-content.is-light-js iframe {
    transform: none !important;
}

.safari-content.is-light-js .content-wrapper {
    padding: 0 !important;
}

.proxy-page-host {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: block;
    background: #fff;
    position: relative;
}

/* 服务端包裹的游戏页根节点（遮罩清理仅作用于此层） */
#rendered-content-frame {
    contain: layout style paint;
    isolation: isolate;
    position: relative;
    min-height: 100%;
    box-sizing: border-box;
}

.safari-content:not(.is-start-page) .content-wrapper,
.safari-content:not(.is-start-page) #rendered-content-frame,
.safari-content:not(.is-start-page) .content-frame {
    padding-left: 3px;
    padding-right: 3px;
    box-sizing: border-box;
}

#rendered-content-frame .loadBox {
    width: 100% !important;
    height: auto !important;
    min-height: 40vh !important;
    max-height: calc(100dvh - var(--safari-top-chrome-h, 52px) - var(--safari-bottom-chrome-h, 55px)) !important;
}

#rendered-content-frame .pageLoading {
    max-height: 48px;
}

#rendered-content-frame .ab-game-host {
    min-height: 100%;
    position: relative;
    box-sizing: border-box;
    padding-bottom: 20px;
}

.safari-start-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f2f2f7;
    color: #8e8e93;
    gap: 12px;
}

.safari-start-page .compass {
    width: 64px;
    height: 64px;
    opacity: 0.35;
}

.safari-start-page p {
    margin: 0;
    font-size: 15px;
}

/* 底部工具栏（后退/前进/标签页等） */
.safari-toolbar-bottom {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    flex-shrink: 0;
    min-height: 49px;
    padding: 2px 8px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    border-top: 0.5px solid rgba(60, 60, 67, 0.1);
}

.safari-nav-group {
    display: flex;
    flex: 1.2;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.safari-icon-btn {
    flex: 1;
    max-width: 72px;
    min-width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: #007aff;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    position: relative;
    z-index: 1;
}

.safari-icon-btn.is-disabled {
    color: #c7c7cc;
    opacity: 0.55;
}

.safari-icon-btn:not(.is-disabled):active {
    opacity: 0.4;
}

.safari-icon-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Toast：高于窗口管理/收藏等弹层 */
.safari-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 2147483100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.safari-toast.show {
    opacity: 1;
}

/* 脚本 FAB */
.script-fab {
    position: fixed;
    right: 16px;
    bottom: calc(55px + env(safe-area-inset-bottom));
    z-index: 100;
    width: 52px;
    height: 52px;
    border-radius: 26px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    color: #007aff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

.script-fab:active {
    opacity: 0.7;
}

/* 遮罩与抽屉 - 浅色 */
.drawer-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: var(--z-script-drawer-mask);
    display: none;
    pointer-events: none;
}

.script-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 78%;
    max-width: 320px;
    height: 100%;
    background: #f5f5f7;
    color: #1c1c1e;
    z-index: var(--z-script-drawer);
    display: flex;
    flex-direction: column;
    font-size: 13px;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

.drawer-handle {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 48px;
    background: #f5f5f7;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-right: none;
    border-radius: 8px 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #8e8e93;
    cursor: pointer;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.drawer-box {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    background: #fff;
    cursor: pointer;
}

.drawer-box:active {
    background: #ebebef;
}

.drawer-box-title {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.drawer-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    color: #3c3c43;
}

.drawer-row-hint {
    color: #8e8e93;
    font-size: 11px;
    padding-top: 2px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: 4px;
}

.drawer-section-title {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.script-item {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
}

.script-item.clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.script-item.clickable:active {
    background: #f5f5f7;
}

.script-item.picked {
    border-color: #007aff;
    background: #f0f7ff;
}

.script-item.active {
    border-color: #34c759;
    background: #f0fff4;
}

.script-item.active.picked {
    border-color: #34c759;
}

.modal-panel-sheet {
    padding-bottom: 0;
}

.modal-sheet-preview {
    font-size: 13px;
    color: #3c3c43;
    padding: 0 0 12px;
    line-height: 1.4;
    word-break: break-all;
}

.modal-actions-col {
    flex-direction: column;
    margin: 0 -16px -16px;
}

.modal-actions-col button {
    border-right: none;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-actions-col button.danger {
    color: #ff3b30;
    font-weight: 600;
}

.modal-actions-col button.cancel-btn {
    color: #8e8e93;
}

.modal-actions-col button:disabled {
    color: #c7c7cc;
    cursor: not-allowed;
}

.script-item-icon {
    width: 18px;
    flex-shrink: 0;
    text-align: center;
    color: #007aff;
}

.script-item-body {
    flex: 1;
    min-width: 0;
}

.script-item-action {
    font-size: 12px;
    color: #1c1c1e;
    line-height: 1.35;
}

.script-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #8e8e93;
    margin-top: 4px;
}

.script-item-row .script-item-repeat-val {
    color: #1c1c1e;
    font-weight: 500;
}

.script-item.script-item-disabled {
    opacity: 0.62;
    background: #f2f2f7;
}

.script-item.script-item-disabled .script-item-icon,
.script-item.script-item-disabled .script-item-action,
.script-item.script-item-disabled .script-item-row {
    color: #8e8e93;
}

.script-item.script-item-disabled.active {
    border-color: rgba(0, 0, 0, 0.08);
    background: #f2f2f7;
}

.script-item-tag {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1.2;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-item-tag--idle,
.script-item-tag--pending {
    color: #636366;
    background: rgba(142, 142, 147, 0.16);
}

.script-item-tag--queued {
    color: #0056b3;
    background: rgba(0, 122, 255, 0.14);
}

.script-item-tag--running {
    color: #fff;
    background: #34c759;
}

.script-item-tag--success {
    color: #1e7e34;
    background: rgba(52, 199, 89, 0.18);
}

.script-item-tag--error {
    color: #d70015;
    background: rgba(255, 59, 48, 0.14);
}

.script-item-tag--skipped {
    color: #c93400;
    background: rgba(255, 149, 0, 0.16);
}

.script-item-tag--paused {
    color: #8e6b00;
    background: rgba(255, 204, 0, 0.28);
}

.script-item-tag--stopped {
    color: #636366;
    background: rgba(142, 142, 147, 0.2);
}

.script-item-tag--disabled {
    color: #636366;
    background: rgba(142, 142, 147, 0.22);
}

.btn-add-script {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: #fff;
    border: 1px dashed rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    color: #007aff;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
    position: relative;
    z-index: 2;
}

.btn-record-script {
    width: 100%;
    min-height: 40px;
    padding: 11px 12px;
    margin-top: 8px;
    background: rgba(255, 59, 48, 0.08);
    border: 1px solid rgba(255, 59, 48, 0.28);
    border-radius: 8px;
    color: #c92a22;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    position: relative;
    z-index: 2;
}

.btn-record-script.is-recording {
    background: #ff3b30;
    border-color: #ff3b30;
    color: #fff;
}

.recording-status-panel {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(var(--safari-bottom-chrome-h) + 14px);
    z-index: 10080;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 10px 12px;
    min-height: 48px;
    max-width: calc(100vw - 28px);
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
}

.recording-status-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.recording-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #ff3b30;
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.22);
}

#recordingStopBtn {
    min-height: 32px;
    padding: 0 10px;
    border: none;
    border-radius: 7px;
    background: #fff;
    color: #1c1c1e;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.recording-insert-choice-mask {
    z-index: 2147483003;
}

.recording-insert-choice-panel {
    width: min(320px, calc(100vw - 48px));
    padding: 20px 20px 16px;
    border-radius: 12px;
    text-align: center;
}

.recording-insert-choice-title {
    margin: 0 0 10px;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
}

.recording-insert-choice-message {
    margin: 0 0 20px;
    color: #8e8e93;
    font-size: 14px;
    line-height: 1.45;
}

.recording-insert-choice-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.recording-insert-choice-btn {
    min-height: 44px;
    padding: 0 12px;
    border: none;
    border-radius: 9px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.recording-insert-choice-btn.is-secondary {
    background: #f2f2f7;
    color: #111827;
}

.recording-insert-choice-btn.is-primary {
    background: #007aff;
    color: #fff;
}

.recording-insert-choice-btn:active {
    transform: scale(0.98);
}

@media (max-width: 520px) {
    .window-manager-overlay {
        overflow-x: hidden;
    }

    .window-manager-overlay .window-manager-panel {
        width: 100%;
        max-height: 60dvh;
        border-radius: 12px 12px 0 0;
    }

    .safari-tabs-switcher-header {
        grid-template-columns: minmax(48px, 1fr) auto minmax(84px, 1fr);
        padding: 10px 12px;
    }

    .safari-tabs-switcher-title {
        font-size: 16px;
    }

    .safari-tabs-header-btn {
        padding-left: 6px;
        padding-right: 6px;
    }

    .safari-tabs-header-btn.is-advanced {
        font-size: 13px;
        padding-left: 7px;
        padding-right: 7px;
    }

    .safari-tabs-header-btn.is-new {
        min-width: 34px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .window-manager-list {
        padding: 8px 10px 14px;
    }

    .window-manager-list .window-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .window-manager-list .window-list-item-content {
        width: 100%;
    }

    .window-manager-list .window-list-item-header {
        width: 100%;
        margin-bottom: 6px;
    }

    .window-manager-list .window-list-item-url {
        align-items: flex-start;
        line-height: 1.35;
    }

    .window-manager-list .window-list-item-url-value {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    .window-manager-list .window-list-item-actions {
        width: 100%;
        margin-top: 0;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .window-manager-list .window-manager-action-btn {
        min-width: 64px;
        flex: 0 0 auto;
    }

    .recording-status-panel {
        left: 12px;
        right: 12px;
        justify-content: space-between;
    }
}

.drawer-summary {
    text-align: center;
    font-size: 12px;
    color: #8e8e93;
    margin: 8px 0;
}

.drawer-footer {
    display: flex;
    align-items: stretch;
    border-top: 0.5px solid rgba(60, 60, 67, 0.18);
    flex-shrink: 0;
    background: rgba(248, 248, 248, 0.96);
    padding-bottom: env(safe-area-inset-bottom);
    min-height: 50px;
}

.drawer-footer-btn {
    flex: 1;
    min-height: 50px;
    padding: 12px 8px;
    background: transparent;
    border: none;
    color: #007aff;
    font-size: 15px;
    cursor: pointer;
    border-right: 0.5px solid rgba(60, 60, 67, 0.12);
    -webkit-appearance: none;
    appearance: none;
}

.drawer-footer-btn:last-child {
    border-right: none;
}

.drawer-footer-btn:active {
    background: rgba(0, 0, 0, 0.06);
}

/* 弹窗 - 浅色 */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* 脚本抽屉高于底栏、低于应用弹窗；应用弹窗须高于浏览页内 fixed 遮罩（常见 9999+） */
#appActionModal,
#appConfigHelpModal,
#appGlobalConfigModal,
#appBeforeEachModal,
#appBranchScriptModal,
#actionMenuModal,
#scriptDrawerMoreModal,
#scriptFileBrowserModal {
    z-index: 2147483000 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-mask.app-modal-open {
    display: flex !important;
}

.modal-mask.modal-mask-branch {
    z-index: 310;
}

.modal-mask.modal-mask-top {
    z-index: 320;
}

.modal-panel {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    width: 100%;
    max-width: 340px;
    color: #1c1c1e;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-subtitle {
    font-size: 13px;
    font-weight: 600;
    color: #8e8e93;
    margin: 4px 0 10px;
}

.modal-row-static {
    align-items: center;
}

.modal-static-val {
    flex: 1;
    font-size: 14px;
    color: #1c1c1e;
    text-align: right;
}

.modal-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

.modal-label {
    width: 72px;
    flex-shrink: 0;
    font-size: 14px;
    color: #3c3c43;
}

.modal-input {
    flex: 1;
    background: #f5f5f7;
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #1c1c1e;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 8px;
}

.modal-type-btn {
    padding: 6px 12px;
    border: 1px solid #007aff;
    background: rgba(0, 122, 255, 0.08);
    color: #007aff;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
}

.form-input-list {
    margin-bottom: 8px;
}

.form-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-input-row .modal-input {
    flex: 1;
}

.form-input-row .form-input-del {
    flex-shrink: 0;
    padding: 6px 10px;
    border: 1px solid #ff3b30;
    color: #ff3b30;
    background: transparent;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.form-input-row .form-input-del:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.form-input-add {
    margin-bottom: 12px;
    padding: 6px 12px;
    border: 1px dashed #007aff;
    background: transparent;
    color: #007aff;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
}

.modal-select {
    flex: 1;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #f5f5f7;
}

.modal-panel-scroll {
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.modal-panel-scroll > .modal-title {
    flex-shrink: 0;
    padding: 16px 16px 0;
    margin-bottom: 0;
}

.modal-panel-scroll .modal-panel-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-panel-scroll .modal-panel-body,
.modal-panel-scroll > .modal-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.modal-panel-scroll .modal-actions {
    flex-shrink: 0;
    margin: 0;
    border-radius: 0 0 12px 12px;
}

.modal-hint {
    font-size: 12px;
    color: #8e8e93;
    margin: -6px 0 10px 0;
}

.config-help-link {
    display: block;
    width: 100%;
    margin: 4px 0 12px;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: #007aff;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
}

.config-help-link:active {
    opacity: 0.6;
}

.config-help-section {
    margin-bottom: 16px;
}

.config-help-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #000;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.15);
}

.config-help-item {
    margin-bottom: 10px;
}

.config-help-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 2px;
}

.config-help-item-desc {
    font-size: 13px;
    color: #636366;
    line-height: 1.45;
}

.drawer-help-link {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    border: none;
    background: transparent;
    color: #007aff;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
}

.drawer-help-link-after-add {
    margin-top: 4px;
    margin-bottom: 4px;
}

.drawer-lib-btn {
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    color: #007aff;
    font-size: 13px;
    cursor: pointer;
}

.modal-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    font-size: 13px;
    color: #3c3c43;
}

.modal-actions {
    display: flex;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin: 16px -16px -16px;
    background: #fff;
}

.modal-actions button {
    flex: 1;
    padding: 14px;
    background: transparent;
    border: none;
    color: #007aff;
    font-size: 16px;
    cursor: pointer;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-actions button:last-child {
    border-right: none;
    font-weight: 600;
}

.modal-actions button:active {
    background: rgba(0, 0, 0, 0.05);
}

/* --- 自动浏览器扩展（贴合 easyClick，保留业务功能） --- */

#app.safari-browser,
#app.safari-browser .safari-chrome {
    color-scheme: light;
}

.safari-toolbar-top-inner {
    display: flex;
    align-items: center;
    gap: 6px;
}

.safari-user-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: #007aff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.safari-user-btn.login-link {
    font-size: 13px;
    width: auto;
    padding: 0 6px;
    white-space: nowrap;
}

.safari-user-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.window-tab-strip {
    display: none !important;
}

.safari-content.is-start-page {
    background: #f2f2f7;
}

.safari-content .content-frame,
.safari-content .content-loading {
    width: 100%;
    height: 100%;
    min-height: 200px;
}



.start-page {
    padding: 12px 16px 24px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.start-page-section {
    margin-bottom: 20px;
}

.start-page-section h3 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1c1c1e;
    margin: 0 0 12px 4px;
}

.start-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 20px 16px;
}

.start-page-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #1c1c1e;
}

.start-page-favicon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    color: #007aff;
}

.start-page-item span {
    font-size: 11px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #8e8e93;
}

.start-page-empty {
    font-size: 15px;
    line-height: 1.45;
    color: #8e8e93;
    padding: 16px 18px;
    margin: 0;
    background: #fff;
    border-radius: 12px;
    border: 0.5px solid rgba(60, 60, 67, 0.18);
}

.safari-tabs-overlay[aria-hidden="true"],
.safari-tabs-overlay[style*="display: none"],
.safari-tabs-overlay[style*="display:none"] {
    display: none !important;
}

.safari-tabs-overlay:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex;
}

.script-drawer {
    transform: translateX(100%);
    transition: transform 0.28s ease;
}

.script-drawer.open {
    transform: translateX(0);
}

.drawer-mask.show {
    display: block;
    pointer-events: auto;
}

.script-fab.original-mode-btn {
    bottom: calc(55px + 64px + env(safe-area-inset-bottom));
}

.modal-mask.share-sheet-mask,
.modal-mask.profile-sheet-mask {
    z-index: 2147483002;
    align-items: flex-end;
    padding: 0;
}

.profile-sheet-panel {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    padding: 8px 0 0;
    margin-bottom: 0;
}

.profile-sheet-title {
    margin: 0;
    padding: 8px 16px 4px;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    color: #1c1c1e;
}

.profile-sheet-user {
    margin: 0;
    padding: 0 16px 8px;
    font-size: 14px;
    color: #8e8e93;
    text-align: center;
}

.profile-sheet-desc {
    margin: 0;
    padding: 0 20px 16px;
    font-size: 15px;
    color: #8e8e93;
    text-align: center;
    line-height: 1.45;
}

.profile-sheet-actions-col {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 0.5px solid rgba(60, 60, 67, 0.12);
}

.profile-sheet-btn {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: #007aff;
    font-size: 17px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}

.profile-sheet-btn-primary {
    font-weight: 600;
}

.profile-sheet-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.modal-mask.share-sheet-mask .modal-panel {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    padding: 8px 0 0;
    margin-bottom: 0;
}

.share-sheet-actions {
    display: flex;
    flex-direction: column;
}

.share-sheet-actions button {
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: #007aff;
    font-size: 17px;
    text-align: center;
    cursor: pointer;
    border-top: 0.5px solid rgba(60, 60, 67, 0.12);
}

.share-sheet-actions button.danger {
    color: #ff3b30;
    font-weight: 600;
}

.share-sheet-actions button:active {
    background: rgba(0, 0, 0, 0.05);
}

.share-sheet-grabber {
    width: 36px;
    height: 5px;
    background: rgba(60, 60, 67, 0.3);
    border-radius: 3px;
    margin: 8px auto 4px;
}

/* 收藏 sheet：偏上居中，底栏固定在最下方 */
.modal-mask.favorites-sheet-mask {
    z-index: 2147483002;
    align-items: flex-start;
    justify-content: center;
    padding: calc(var(--safari-top-chrome-h, 52px) + 12px) 16px var(--safari-bottom-chrome-h);
    box-sizing: border-box;
}

.modal-mask.favorites-sheet-mask.is-open,
.modal-mask.favorites-sheet-mask[style*="display: flex"],
.modal-mask.favorites-sheet-mask[style*="display:flex"] {
    display: flex !important;
}

.modal-mask.favorites-sheet-mask .favorites-sheet-panel {
    width: 100%;
    max-width: 520px;
    max-height: min(50vh, 420px);
    border-radius: 14px;
    padding: 0 0 8px;
    margin: 0 auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.favorites-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 16px 12px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.12);
    flex-shrink: 0;
}

.favorites-sheet-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1c1c1e;
}

.favorites-sheet-add-btn {
    border: none;
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.favorites-sheet-add-btn:active {
    background: rgba(0, 122, 255, 0.18);
}

.favorites-sheet-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px 4px;
    -webkit-overflow-scrolling: touch;
}

.favorites-sheet-summary {
    margin: 0 0 10px;
    font-size: 13px;
    color: #8e8e93;
}

.favorites-sheet-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.favorite-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 0.5px solid rgba(60, 60, 67, 0.12);
    border-radius: 10px;
    background: #f5f5f7;
}

.favorite-card-main {
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
}

.favorite-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-card-url {
    font-size: 12px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-card-time {
    font-size: 11px;
    color: #aeaeb2;
    margin-top: 4px;
}

.favorite-card-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.favorites-empty {
    text-align: center;
    padding: 28px 12px 20px;
    color: #8e8e93;
}

.favorites-empty-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.favorites-empty h3 {
    margin: 0 0 6px;
    font-size: 16px;
    color: #1c1c1e;
}

.favorites-empty p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.modal-mask.favorites-edit-mask {
    z-index: 2147483003;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-mask.favorites-edit-mask.is-open,
.modal-mask.favorites-edit-mask[style*="display: flex"],
.modal-mask.favorites-edit-mask[style*="display:flex"] {
    display: flex !important;
}

.favorites-edit-panel {
    width: 100%;
    max-width: 400px;
    padding: 16px 16px 12px;
    border-radius: 14px;
}

.favorites-edit-title {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 600;
    color: #1c1c1e;
}

.favorites-edit-field {
    margin-bottom: 12px;
}

.favorites-edit-field label {
    display: block;
    font-size: 13px;
    color: #8e8e93;
    margin-bottom: 6px;
}

.favorites-edit-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 0.5px solid rgba(60, 60, 67, 0.2);
    border-radius: 10px;
    background: #f5f5f7;
    box-sizing: border-box;
}

.favorites-edit-input:focus {
    outline: none;
    border-color: #007aff;
    background: #fff;
}

.favorites-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.favorite-card-actions .fav-edit-btn {
    color: #007aff;
}

.user-menu-modal-list a {
    display: block;
    padding: 14px 16px;
    color: #007aff;
    text-decoration: none;
    font-size: 17px;
    border-top: 0.5px solid rgba(60, 60, 67, 0.12);
}

.user-menu-modal-list a:active {
    background: rgba(0, 0, 0, 0.05);
}

.drawer-global-delay {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.drawer-global-delay input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    font-size: 14px;
    background: #f5f5f7;
}

.no-actions {
    text-align: center;
    color: #8e8e93;
    padding: 16px;
    font-size: 13px;
}

.safari-reload-btn.hidden,
.safari-stop-btn.hidden {
    display: none !important;
}

#app .modal.legacy-modal-bridge {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#app .modal.legacy-modal-bridge .modal-content {
    background: #fff;
    border-radius: 12px;
    max-width: 340px;
    width: 100%;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    color: #1c1c1e;
}

.safari-icon-btn.is-active-tab {
    opacity: 0.5;
}

/* 覆盖 browser.css 中与 easyClick 冲突的规则 */
body > .script-drawer {
    right: 0 !important;
    width: 78% !important;
    max-width: 320px !important;
    transform: translateX(100%) !important;
    transition: transform 0.28s ease !important;
    background: #f5f5f7 !important;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1) !important;
    z-index: var(--z-script-drawer) !important;
    visibility: visible !important;
}

body > .script-drawer.open {
    transform: translateX(0) !important;
    right: 0 !important;
}

.script-drawer-overlay {
    display: none !important;
}

/* 遗留 .modal 弹窗 iOS 化 */
body > .modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.35);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

body > .modal[style*="display: block"],
body > .modal[style*="display:block"] {
    display: flex !important;
}

body > .modal .modal-content {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    width: 100%;
    color: #1c1c1e;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    margin: 0 !important;
    max-height: 85vh;
    overflow-y: auto;
}

body > .modal .modal-header {
    background: transparent !important;
    color: #1c1c1e !important;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.18);
    padding: 0 0 12px !important;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body > .modal .modal-header h2,
body > .modal .modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

body > .modal .close {
    color: #8e8e93 !important;
    background: transparent !important;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal-mask[style*="display: block"],
.modal-mask[style*="display:block"] {
    display: flex !important;
}

.script-item.active {
    border-color: #34c759;
    background: #f0fff4;
}

/* 脚本文件管理器弹窗 */
.script-fs-panel {
    max-width: 420px;
    width: 100%;
    max-height: min(88vh, 640px);
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
}

.script-fs-header {
    padding: 14px 16px 8px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.15);
    flex-shrink: 0;
}

.script-fs-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.script-fs-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.12);
    flex-shrink: 0;
    background: rgba(248, 248, 248, 0.9);
}

.script-fs-tool-btn {
    flex-shrink: 0;
    border: none;
    background: rgba(118, 118, 128, 0.12);
    color: #007aff;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.script-fs-tool-btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.script-fs-tool-btn:active {
    opacity: 0.65;
}

.script-fs-tool-btn-danger {
    color: #ff3b30;
}

.script-fs-tool-btn-danger:disabled {
    color: #c7c7cc;
}

.script-fs-move-hint {
    margin: 0 0 10px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--color-label-secondary, #636366);
    background: rgba(0, 122, 255, 0.08);
    border-radius: 10px;
}

.script-fs-move-hint[hidden],
.script-fs-move-bar[hidden] {
    display: none !important;
}

.script-fs-move-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.script-fs-move-here {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--color-tint, #007aff);
    cursor: pointer;
}

.script-fs-move-cancel {
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    background: var(--color-fill-secondary, rgba(118, 118, 128, 0.12));
    color: var(--color-label, #1c1c1e);
    cursor: pointer;
}

.script-fs-breadcrumb {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 13px;
    -webkit-overflow-scrolling: touch;
}

.script-fs-new-folder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.12);
    background: rgba(0, 122, 255, 0.06);
    flex-shrink: 0;
}

.script-fs-new-folder[hidden] {
    display: none !important;
}

.script-fs-new-folder-input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(60, 60, 67, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 16px;
    background: #fff;
}

.script-fs-new-folder-ok,
.script-fs-new-folder-cancel {
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 15px;
    cursor: pointer;
}

.script-fs-new-folder-ok {
    background: #007aff;
    color: #fff;
    font-weight: 600;
}

.script-fs-new-folder-cancel {
    background: rgba(118, 118, 128, 0.15);
    color: #1c1c1e;
}

.script-fs-crumb {
    border: none;
    background: none;
    color: #007aff;
    padding: 2px 0;
    font-size: 13px;
    cursor: pointer;
}

.script-fs-crumb-sep {
    color: #8e8e93;
    margin: 0 2px;
}

.script-fs-list {
    flex: 1;
    min-height: 180px;
    max-height: 42vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0;
}

.script-fs-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 16px;
    cursor: pointer;
    color: #1c1c1e;
}

.script-fs-row:active,
.script-fs-row.is-selected {
    background: rgba(0, 122, 255, 0.1);
}

.script-fs-icon {
    flex-shrink: 0;
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.script-fs-name {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-fs-meta {
    flex-shrink: 0;
    font-size: 12px;
    color: #8e8e93;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-fs-empty,
.script-fs-loading,
.script-fs-error {
    padding: 24px 16px;
    text-align: center;
    font-size: 15px;
    color: #8e8e93;
}

.script-fs-error {
    color: #ff3b30;
}

.script-fs-footer {
    padding: 10px 16px max(12px, env(safe-area-inset-bottom));
    border-top: 0.5px solid rgba(60, 60, 67, 0.15);
    flex-shrink: 0;
    background: #fff;
}

.script-fs-field {
    margin-bottom: 10px;
}

.script-fs-field label {
    display: block;
    font-size: 13px;
    color: #8e8e93;
    margin-bottom: 4px;
}

.script-fs-field input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(60, 60, 67, 0.2);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    background: #f9f9f9;
}

.script-fs-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.script-fs-actions button {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    cursor: pointer;
}

.script-fs-actions .script-fs-cancel {
    background: rgba(118, 118, 128, 0.12);
    color: #1c1c1e;
}

.script-fs-actions .script-fs-confirm {
    background: #007aff;
    color: #fff;
    font-weight: 600;
}

/* 应用内确认框（替代 confirm） */
.app-confirm-mask {
    z-index: 2147483050 !important;
    align-items: center;
    padding: 20px;
}

.app-confirm-panel {
    max-width: 340px;
    width: 100%;
    padding: 20px 16px 16px;
    text-align: center;
}

.app-confirm-title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 600;
    color: #1c1c1e;
}

.app-confirm-message {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.45;
    color: #3a3a3c;
    white-space: pre-wrap;
}

.app-confirm-actions {
    display: flex;
    gap: 10px;
}

.app-confirm-btn {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    cursor: pointer;
}

.app-confirm-cancel {
    background: rgba(118, 118, 128, 0.14);
    color: #1c1c1e;
}

.app-confirm-ok {
    background: #007aff;
    color: #fff;
    font-weight: 600;
}

.app-confirm-ok.is-danger {
    background: #ff3b30;
}

/* 应用内输入框（替代 prompt） */
.app-prompt-mask {
    z-index: 2147483050 !important;
    align-items: center;
    padding: 20px;
}

.app-prompt-panel {
    max-width: 360px;
    width: 100%;
    padding: 20px 16px 16px;
    text-align: left;
}

.app-prompt-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: #1c1c1e;
    text-align: center;
}

.app-prompt-message {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.45;
    color: #3a3a3c;
    text-align: center;
    white-space: pre-wrap;
}

.app-prompt-body {
    margin-bottom: 16px;
}

.app-prompt-field + .app-prompt-field {
    margin-top: 12px;
}

.app-prompt-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #636366;
}

.app-prompt-input,
.app-prompt-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid rgba(60, 60, 67, 0.2);
    border-radius: 10px;
    font-size: 16px;
    color: #1c1c1e;
    background: #f2f2f7;
    outline: none;
}

.app-prompt-input:focus,
.app-prompt-textarea:focus {
    border-color: #007aff;
    background: #fff;
}

.app-prompt-textarea {
    resize: vertical;
    min-height: 72px;
    font-family: inherit;
}

.app-dialog-toast-fallback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 2147483100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.app-dialog-toast-fallback.show {
    opacity: 1;
}

@media (max-width: 768px) {
    /* 脚本配置弹窗 — 防止 iOS 自动缩放 */
    .modal-input,
    .modal-select,
    .drawer-global-delay input {
        font-size: 16px;
    }

    /* 代理浏览的目标页表单 — 防止 iOS 自动缩放 */
    #rendered-content-frame input[type="text"],
    #rendered-content-frame input[type="password"],
    #rendered-content-frame input[type="email"],
    #rendered-content-frame input[type="number"],
    #rendered-content-frame input[type="tel"],
    #rendered-content-frame input[type="url"],
    #rendered-content-frame input[type="search"],
    #rendered-content-frame input:not([type]),
    #rendered-content-frame textarea,
    #rendered-content-frame select {
        font-size: 16px !important;
    }
}
