/* 浏览器风格样式 */

:root {
    --header-height-desktop: 60px;
    --header-height-mobile: 80px;
}

.browser-body {
    height: 100vh;
    height: 100dvh; /* 使用动态视口高度，适配移动端浏览器地址栏 */
    height: calc(var(--vh, 1vh) * 100); /* 使用JavaScript计算的视口高度 */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
}

/* 窗口标签栏 */
.window-tabs {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    gap: 0.5rem;
    overflow-x: auto;
    flex-shrink: 0;
    min-width: 150px;
    max-width: 50%;
    visibility: visible;
    opacity: 1;
}

.window-tabs-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    overflow-x: auto;
}

.window-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    min-width: 80px;
    max-width: 150px;
    font-size: 0.85rem;
}

.window-tab:hover {
    background: #f0f0f0;
}

.window-tab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.window-tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.window-tab-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.window-tab-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.window-tab.active .window-tab-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.window-add-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.window-add-btn:hover {
    background: #45a049;
}

/* 窗口列表样式 */
.window-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.window-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
    gap: 0.75rem;
    min-width: 0;
}

.window-list-item:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.window-list-item.active {
    background: #e8f5e9;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.window-list-item-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.window-list-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    min-width: 0;
    flex-wrap: wrap;
}

.window-list-item-name {
    font-weight: 500;
    font-size: 0.95rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.window-list-item.active .window-list-item-name {
    color: var(--primary-color);
    font-weight: 600;
}

.window-list-item-badge {
    background: var(--primary-color);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}

.window-list-item-url {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    overflow: hidden;
    min-width: 0;
    line-height: 1.35;
}

.window-list-item.active .window-list-item-url {
    color: #555;
}

.window-list-item-url-label {
    color: #999;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.window-list-item-url-value {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.window-list-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    justify-content: flex-end;
}

.window-modal-actions {
    display: flex;
    gap: 0.5rem;
}

#windowModal .modal-content {
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#windowModal .modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#windowModal .window-list {
    flex: 1;
    min-height: 0;
    max-height: none;
}

/* 顶部搜索栏 */
.browser-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    flex-shrink: 0;
    height: var(--header-height-desktop);
    overflow: hidden; /* 移除滚动，搜索栏本身不滚动 */
}


.search-container {
    flex: 1;
    max-width: 100%;
}

/* 页面加载进度条 */
.page-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    width: 100%;
    background: #e0e0e0;
    overflow: hidden;
    z-index: 101;
    pointer-events: none;
}

.page-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #66bb6a);
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.page-progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* 用户菜单 */
.user-menu-container {
    position: relative;
    flex-shrink: 0;
}

.user-menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    text-decoration: none;
    color: inherit;
}

.user-menu-btn.login-btn {
    border-radius: 20px;
    width: auto;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-menu-btn.login-btn:hover {
    background: #45a049;
    color: white;
}

.user-menu-btn:hover {
    background: #f5f5f5;
}

.user-menu-btn.login-btn:hover {
    background: #45a049;
}

.user-menu-icon {
    font-size: 1.5rem;
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    max-width: calc(100vw - 2rem); /* 确保不超出视口 */
    z-index: 1000;
    overflow: hidden;
    /* 默认向下展开，JavaScript 会根据情况调整 */
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
    cursor: pointer;
}

.user-menu-item:hover {
    background: #f5f5f5;
}

.user-menu-item-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.user-menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 0.25rem 0;
}

/* 用户菜单弹窗样式 */
.user-menu-modal-list {
    display: flex;
    flex-direction: column;
}

.user-menu-modal-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.user-menu-modal-item:last-child {
    border-bottom: none;
}

.user-menu-modal-item:hover {
    background: #f5f5f5;
}

.user-menu-modal-item .user-menu-item-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.search-form {
    width: 100%;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 0.25rem 1rem;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.search-box:focus-within {
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    outline: none;
    color: var(--text-color);
    padding: 0.2rem 0;
}

.search-input::placeholder {
    color: #999;
}

.search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.3s;
    border-radius: 50%;
}

.search-btn:hover {
    color: var(--primary-color);
    background: rgba(76, 175, 80, 0.1);
}

.search-btn:active {
    transform: scale(0.95);
}

/* 中间内容区域 */
.browser-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    min-height: 0; /* 确保flex子元素可以缩小 */
    /* 为固定的搜索栏留出空间 */
    padding-top: var(--header-height-desktop, 60px);
    transition: padding-top 0.3s ease;
}

/* 当滚动区域显示时，通过 JavaScript 动态调整内容区域的 padding-top */

.content-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
    color: #666;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.content-placeholder h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.content-placeholder p {
    color: #999;
    margin-bottom: 2rem;
}

.quick-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.quick-link-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.quick-link-btn:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
    transform: translateY(-2px);
}

.quick-link-btn .icon {
    font-size: 2rem;
}

/* 内容包装器 */
.content-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.content-frame {
    flex: 1;
    overflow: auto;
    background: #fff;
    width: 100%;
    min-height: 600px;
    position: relative;
    margin-bottom: 0; /* 取消底部间距 */
}

/* 直接渲染的内容样式隔离 */
.content-frame > * {
    max-width: 100%;
}

/* 确保直接渲染的内容不会影响主页面布局 */
.content-frame {
    isolation: isolate;
}

.light-js-wrapper {
    padding: 0;
    height: 100%;
    min-height: 100%;
    position: relative;
    overflow: hidden;
    transform: none !important;
}

.light-js-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    background: #fff;
    transform: none !important;
}

.safari-content.is-light-js .light-js-frame {
    position: absolute;
    inset: 0;
}

.headless-screenshot-container {
    width: 100%;
    min-height: 100%;
    padding: 0;
    overflow: auto;
    background: #fff;
}

.safari-content.is-headless {
    overflow: hidden;
    overscroll-behavior: none;
}

.safari-content.is-headless .headless-screenshot-container {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    touch-action: none;
    overscroll-behavior: none;
}

.headless-screenshot-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(242, 242, 247, 0.96);
    border-bottom: 1px solid rgba(60, 60, 67, 0.16);
    color: #1c1c1e;
    font-size: 13px;
    line-height: 18px;
}

.headless-screenshot-badge {
    flex-shrink: 0;
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(0, 122, 255, 0.12);
    color: #007aff;
    font-weight: 600;
}

.headless-screenshot-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#headless-screenshot-img {
    max-width: 100%;
    height: auto;
    display: block;
    touch-action: pan-x pan-y;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
}

.safari-content.is-headless #headless-screenshot-img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: fill;
    object-position: top left;
    touch-action: none;
}

.advanced-config-target-marker {
    position: absolute;
    z-index: 20;
    border: 2px solid #ff3b30;
    border-radius: 8px;
    background: rgba(255, 59, 48, 0.12);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.08), 0 0 0 4px rgba(255, 59, 48, 0.18);
    pointer-events: none;
    transform: translateZ(0);
}

.advanced-config-target-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
    border-radius: 50%;
    background: #ff3b30;
    border: 2px solid #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}

.advanced-config-target-label {
    position: absolute;
    left: 50%;
    top: -30px;
    transform: translateX(-50%);
    padding: 3px 8px;
    border-radius: 999px;
    background: #ff3b30;
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.headless-input-bridge {
    position: fixed;
    left: 8px;
    bottom: 8px;
    width: 1px;
    height: 1px;
    min-width: 1px;
    min-height: 1px;
    border: 0;
    padding: 0;
    margin: 0;
    opacity: 0.01;
    color: transparent;
    background: transparent;
    caret-color: transparent;
    font-size: 16px;
    line-height: 16px;
    pointer-events: none;
    z-index: 2147483647;
    outline: none;
    resize: none;
}

/* 加载状态 */
.content-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态 */
.content-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.content-error h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--danger-color);
}

.content-error p {
    color: #666;
    margin-bottom: 1.5rem;
}

.browse-compat-notice .browse-compat-url {
    font-size: 12px;
    word-break: break-all;
    color: #8e8e93;
    margin-bottom: 1rem;
}

.browse-compat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 1rem;
}

.browse-compat-hint {
    font-size: 12px;
    color: #8e8e93;
    margin-bottom: 0;
}

/* SPA 警告条：仍渲染页面内容，仅提示 */
.browse-compat-banner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 10px;
    padding: 10px 12px;
    background: #fff8e6;
    border: 1px solid rgba(255, 149, 0, 0.35);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    color: #3a3a3c;
    box-sizing: border-box;
}

.browse-compat-banner-text {
    margin: 0;
}

.browse-compat-banner-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.browse-compat-banner-link {
    color: #007aff;
    text-decoration: none;
    font-weight: 500;
}

.browse-compat-banner-dismiss {
    border: none;
    background: rgba(0, 122, 255, 0.12);
    color: #007aff;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.browse-compat-banner-dismiss:active {
    opacity: 0.75;
}

.chrome-reveal-fab {
    position: fixed;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(120%);
    z-index: 2147482000;
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    background: rgba(0, 122, 255, 0.94);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.28s ease;
}

.chrome-reveal-fab.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chrome-reveal-fab:active {
    opacity: 0.85;
}

/* 搜索信息 */
.content-search {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.search-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.content-search h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.search-suggestions {
    margin-top: 2rem;
    text-align: left;
    max-width: 500px;
}

.search-suggestions ul {
    list-style: none;
    padding-left: 0;
}

.search-suggestions li {
    padding: 0.5rem 0;
    color: #666;
}

/* 底部功能选项 */
.browser-footer {
    background: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
    gap: 1rem;
}

.footer-left {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex: 1;
}

.footer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 8px;
    color: #666;
    flex: 1;
    max-width: 100px;
}

.footer-btn:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

.footer-btn:active {
    transform: scale(0.95);
}

.footer-icon {
    font-size: 1.5rem;
}

.footer-label {
    font-size: 0.75rem;
}

/* 移动端适配 */
@media (max-width: 768px) {
    /* 基础样式优化 */
    body {
        font-size: 14px;
    }

    /* 顶栏/底栏布局见 browser-safari.css */

    .search-box {
        padding: 0.3rem 0.75rem;
        border-radius: 20px;
    }

    .search-input {
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 0.15rem 0;
    }

    .search-btn {
        padding: 0.2rem;
        min-width: 28px;
        min-height: 28px;
    }

    /* 窗口标签栏 */
    .window-tabs {
        max-width: 100%;
        padding: 0.25rem;
        gap: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .window-tab {
        min-width: 70px;
        max-width: 120px;
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    .window-tab-name {
        font-size: 0.8rem;
    }

    .window-tab-close {
        width: 18px;
        height: 18px;
        font-size: 1rem;
    }

    .window-add-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* 内容区域 — padding 由 browser-safari.css / JS 计算 */
    .browser-content {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* 当滚动区域显示时，通过 JavaScript 动态调整内容区域的 padding-top */

    /* 普通页面内容框架 - 确保内容从正确位置开始 */
    .content-frame {
        margin-top: 0; /* 由父容器 browser-content 的 padding-top 处理 */
    }


    .content-placeholder {
        padding: 1.5rem;
    }

    .placeholder-icon {
        font-size: 3rem;
    }

    .content-placeholder h2 {
        font-size: 1.25rem;
    }

    .quick-links {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .quick-link-btn {
        width: 100%;
        padding: 1rem;
        min-width: auto;
    }

    .quick-link-btn .icon {
        font-size: 1.75rem;
    }

    /* 用户菜单 */
    .user-menu-btn {
        width: 36px;
        height: 36px;
    }

    .user-menu-btn.login-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .user-menu-dropdown {
        min-width: 160px;
        max-width: calc(100vw - 1rem); /* 移动端留出更多边距 */
        right: 0;
    }

    .user-menu-item {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* 模态框 */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 5% auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .close {
        font-size: 1.75rem;
        width: 32px;
        height: 32px;
    }

    .modal-body {
        padding: 1rem;
    }

    /* 新建动作模态框特定样式 */
    .action-modal-content {
        max-height: 70vh !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .action-modal-content .modal-body {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }

    .action-modal-content .modal-footer {
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-end;
        gap: 0.75rem;
        flex-shrink: 0;
    }

    .action-modal-content .modal-footer .btn {
        width: auto !important;
        min-width: 80px;
    }

    /* 窗口列表 */
    .window-list {
        max-height: 60vh;
    }

    .window-list-item {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
    }

    .window-list-item-header {
        width: 100%;
    }

    .window-list-item-url {
        align-items: flex-start;
        line-height: 1.35;
    }

    .window-list-item-url-value {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    .window-list-item-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
        flex-wrap: wrap;
    }

    /* 底部功能选项 */
    .browser-footer {
        padding: 0.5rem;
    }


    /* 内容包装器 */
    .content-wrapper {
        padding-bottom: 0;
    }

    /* 普通页面内容框架 */
    .content-frame {
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* 高级页面截图容器 */
    .headless-screenshot-container {
        padding-bottom: 0;
    }

    .footer-label {
        font-size: 0.7rem;
    }

    .footer-btn {
        padding: 0.4rem 0.5rem;
        max-width: none;
    }

    .footer-icon {
        font-size: 1.25rem;
    }

    /* 脚本抽屉 */
    .script-drawer {
        width: 95%;
        max-width: 95%;
        right: -95%;
        height: 100vh;
        height: 100dvh;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .script-drawer.open {
        right: 0;
    }

    .script-drawer-header {
        padding: 1rem 1rem 0.75rem 1rem;
        padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
    }

    .script-drawer-header h2 {
        font-size: 1.1rem;
        font-weight: 600;
    }

    .script-drawer-body {
        padding: 1rem;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
        -webkit-overflow-scrolling: touch;
    }

    .script-section {
        margin-bottom: 1.25rem;
    }

    .script-section h3 {
        font-size: 0.95rem;
        font-weight: 600;
        margin-bottom: 0.75rem;
    }

    .script-action-btn {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
        min-height: 44px; /* 触摸友好的最小高度 */
        width: auto;
        flex: 0 0 auto;
        justify-content: center;
    }

    .script-action-btn .icon {
        font-size: 1.1rem;
    }

    .action-item {
        padding: 0.875rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .action-controls {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 0.75rem;
        gap: 0.5rem;
    }

    .script-bottom-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding-top: 1rem;
        padding-bottom: 0.5rem;
    }

    .script-bottom-actions > div {
        display: flex;
        gap: 0.5rem;
        width: auto;
        flex: 0 0 auto;
    }

    .global-config-item {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .global-config-item input {
        min-height: 44px;
        font-size: 16px; /* 防止iOS自动缩放 */
        flex: 1;
        min-width: 100px;
    }

    .execution-status-panel {
        padding: 0.875rem;
    }

    .execution-status-summary {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    .execution-status-actions {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .execution-status-actions .btn {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    /* 脚本FAB按钮 */
    .script-fab {
        bottom: 100px; /* 与编辑按钮同一高度 */
        right: 16px; /* 统一右边距 */
        width: 56px; /* 统一大小 */
        height: 56px;
        font-size: 1.5rem;
    }

    .pure-mode-btn {
        bottom: 170px !important;
        font-size: 1.2rem !important;
        font-weight: bold;
    }

    .original-mode-btn {
        bottom: 170px !important;
        font-size: 1.2rem !important;
        font-weight: bold;
    }

    /* 表单元素 */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.75rem;
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    /* 按钮 */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
        min-height: 44px; /* iOS推荐的最小触摸目标 */
    }

    .btn-small {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-height: 36px;
    }

    /* 全局配置 */
    .global-config-item {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .global-config-item input {
        flex: 1;
        min-width: 80px;
    }

    /* 执行状态面板 */
    .execution-status-panel {
        padding: 0.75rem;
    }

    .execution-status-summary {
        font-size: 0.9rem;
    }

    .execution-status-actions {
        flex-direction: column;
    }

    .execution-status-actions .btn {
        width: 100%;
    }

    /* 无头浏览器截图容器 */
    .headless-screenshot-container {
        padding: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .safari-content.is-headless .headless-screenshot-container {
        overflow: hidden;
        touch-action: none;
        overscroll-behavior: none;
    }

    #headless-screenshot-img {
        max-width: 100%;
        height: auto;
        display: block;
        touch-action: pan-x pan-y;
    }

    .safari-content.is-headless #headless-screenshot-img {
        touch-action: none;
        overscroll-behavior: none;
    }

    .headless-screenshot-toolbar {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        background: rgba(242, 242, 247, 0.96);
        border-bottom: 1px solid rgba(60, 60, 67, 0.16);
        color: #1c1c1e;
        font-size: 13px;
        line-height: 18px;
    }

    .headless-screenshot-badge {
        flex-shrink: 0;
        border-radius: 999px;
        padding: 2px 7px;
        background: rgba(0, 122, 255, 0.12);
        color: #007aff;
        font-weight: 600;
    }

    .headless-screenshot-title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #headless-overlay {
        touch-action: none;
    }

    /* 编辑按钮移动端优化 */
    #headless-edit-button {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.6rem !important;
        bottom: 100px !important;
        left: 16px !important; /* 改为左边，避免与脚本按钮重叠 */
        right: auto !important;
        box-shadow: 0 6px 16px rgba(0,0,0,0.25) !important;
    }

    /* 输入框覆盖层移动端优化 */
    #headless-input-overlay {
        width: calc(100% - 32px) !important;
        max-width: 500px !important;
        height: 56px !important;
        bottom: 100px !important;
        border-radius: 12px !important;
        box-shadow: 0 6px 20px rgba(0,0,0,0.35) !important;
    }

    #headless-input-overlay input {
        font-size: 18px !important;
        padding: 0 16px !important;
    }

    /* OCR模态框移动端优化 */
    .ocr-modal .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 85vh;
    }

    .ocr-result {
        max-height: 60vh;
        font-size: 0.9rem;
        padding: 1rem;
    }

    /* 功能模态框移动端优化 */
    #functionModal .modal-content {
        width: 95%;
        max-width: 95%;
    }

    /* 窗口管理模态框移动端优化 */
    #windowModal .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 60vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #windowModal .modal-body {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    #windowModal .window-list {
        flex: 1;
        min-height: 0;
        max-height: none;
    }

    .window-modal-actions .btn {
        width: 100%;
        min-height: 44px;
    }
}

/* 右下角脚本按钮 */
.script-fab {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 1.5rem;
}

.pure-mode-btn {
    bottom: 170px !important;
    font-size: 1.2rem !important;
    font-weight: bold;
}

.original-mode-btn {
    bottom: 170px !important;
    font-size: 1.2rem !important;
    font-weight: bold;
}

.script-fab:hover {
    background: #45a049;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    transform: scale(1.1);
}

.script-fab:active {
    transform: scale(0.95);
}

/* 脚本抽屉 */
.script-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.script-drawer-overlay.show {
    display: block;
    opacity: 1;
}

.script-drawer {
    position: fixed;
    top: 0;
    right: -60%;
    width: 60%;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    z-index: 1002;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    visibility: visible;
}

.script-drawer.open {
    right: 0;
}

.script-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.script-drawer-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: var(--primary-color);
    color: white;
}

.script-drawer-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.script-drawer-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.3s;
}

.script-drawer-close:hover {
    background: rgba(255,255,255,0.2);
}

.script-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.script-section {
    margin-bottom: 2rem;
}

.script-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.script-list-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
}

.loading-scripts {
    padding: 1rem;
    text-align: center;
    color: #999;
}

.script-item-card {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.script-item-card:hover {
    background: #e8f5e9;
    border-color: var(--primary-color);
}

.script-item-card.selected {
    background: #c8e6c9;
    border-color: var(--primary-color);
}

.script-item-card:last-child {
    margin-bottom: 0;
}

.script-item-card h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    color: var(--text-color);
}

.script-item-card .script-type {
    font-size: 0.8rem;
    color: #666;
}

.script-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.script-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    width: auto;
    flex: 0 0 auto;
}

.script-action-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.script-action-btn:active {
    transform: translateY(0);
}

.script-action-btn-danger {
    background: var(--danger-color);
}

.script-action-btn-danger:hover {
    background: #da190b;
}

.script-action-btn .icon {
    font-size: 1.2rem;
}

.task-status-container {
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 6px;
    min-height: 100px;
}

.no-task {
    text-align: center;
    color: #999;
    padding: 2rem 0;
}

.task-status-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.task-status-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.task-status-item:last-child {
    border-bottom: none;
}

.task-status-label {
    font-weight: 500;
    color: #666;
}

.task-status-value {
    color: var(--text-color);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-running {
    background: #d1ecf1;
    color: #0c5460;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-completed {
    background: #d4edda;
    color: #155724;
}

.status-failed {
    background: #f8d7da;
    color: #721c24;
}

.status-cancelled {
    background: #e2e3e5;
    color: #383d41;
}

/* 全局配置 */
.global-config-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 6px;
}

.global-config-item label {
    font-weight: 500;
    color: var(--text-color);
    margin: 0;
}

/* 脚本动作列表 */
.script-actions-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
}

.no-actions {
    padding: 2rem;
    text-align: center;
    color: #999;
}

.execution-status-panel {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.execution-status-summary {
    font-size: 0.95rem;
    color: #333;
}

.execution-status-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.execution-logs-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #333;
}

.action-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
    transition: all 0.3s;
}

.action-item:hover {
    background: #e8f5e9;
}

.action-item:last-child {
    margin-bottom: 0;
}

.action-content {
    flex: 1;
}

.action-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.action-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: bold;
    flex-shrink: 0;
}

.action-type {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
}

.action-name {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.action-desc {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.25rem;
    word-break: break-all;
}

.action-status-message {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: #666;
}

.status-label {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background: #e0e0e0;
    color: #555;
}

.status-label.status-success {
    background: #d4edda;
    color: #256029;
}

.status-label.status-error {
    background: #f8d7da;
    color: #842029;
}

.status-label.status-paused {
    background: #fff3cd;
    color: #856404;
}

.status-label.status-stopped {
    background: #e2e3e5;
    color: #383d41;
}

.status-message {
    color: #555;
}

.action-delay {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.25rem;
}

.action-controls {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.2rem;
    transition: all 0.3s;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: rgba(0,0,0,0.1);
    transform: scale(1.1);
}

.action-btn-delete:hover {
    background: rgba(244, 67, 54, 0.1);
}

/* 底部操作按钮区域 */
.script-bottom-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.script-action-btn-secondary {
    background: var(--secondary-color);
}

.script-action-btn-secondary:hover {
    background: #1976D2;
}

/* 移动端脚本抽屉额外优化 */
@media (max-width: 768px) {
    .script-drawer-overlay {
        background: rgba(0,0,0,0.7);
        backdrop-filter: blur(2px);
    }

    .script-drawer-close {
        width: 40px;
        height: 40px;
        font-size: 1.75rem;
        min-width: 40px;
        min-height: 40px;
    }

    .script-list-container {
        max-height: 250px;
        -webkit-overflow-scrolling: touch;
    }

    .script-actions-list {
        max-height: calc(100vh - 500px);
        max-height: calc(100dvh - 500px);
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }

    .script-item-card {
        padding: 0.875rem;
        margin-bottom: 0.75rem;
    }

    .script-item-card h4 {
        font-size: 0.9rem;
        font-weight: 600;
    }

    .script-item-card .script-type {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* 优化动作项在移动端的显示 */
    .action-item {
        flex-direction: column;
        align-items: stretch;
        padding: 0.875rem;
        margin-bottom: 0.75rem;
    }

    .action-item-content {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    .action-item-title {
        font-size: 0.9rem;
        font-weight: 500;
    }

    .action-item-details {
        font-size: 0.85rem;
        margin-top: 0.5rem;
    }

    .action-title {
        font-size: 0.9rem;
    }

    .action-type {
        font-size: 0.9rem;
    }

    .action-desc {
        font-size: 0.85rem;
        margin-top: 0.5rem;
    }

    .action-status-message {
        font-size: 0.8rem;
        margin-top: 0.5rem;
    }

    /* 优化按钮组布局 */
    .script-bottom-actions button {
        flex: 0 0 auto;
        min-width: 44px;
    }

    /* 优化输入框和表单 */
    .script-drawer-body input,
    .script-drawer-body select,
    .script-drawer-body textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
        min-height: 44px;
        padding: 0.75rem;
    }

    /* 优化滚动条 */
    .script-drawer-body::-webkit-scrollbar {
        width: 4px;
    }

    .script-drawer-body::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.2);
        border-radius: 2px;
    }
}

/* 浏览器外壳与脚本抽屉样式已迁移至 easyclick-shell.css */
