/* ===== SaveEditor 子站 — 与主站 style-modern 统一视觉 ===== */

:root {
    --primary: var(--accent, #6366f1);
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --primary-bg: rgba(99, 102, 241, 0.1);
    --accent: #8b5cf6;
    --bg-page: var(--bg-base, #f0f4ff);
    --bg-card: rgba(255, 255, 255, 0.82);
    --bg-input: rgba(255, 255, 255, 0.9);
    --border: var(--border-default, rgba(148, 163, 184, 0.35));
    --text: var(--text-primary, #0f172a);
    --text-muted: var(--text-secondary, #475569);
    --text-dim: #94a3b8;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-lg: var(--shadow-float, 0 12px 40px rgba(99, 102, 241, 0.18));
    --font-main: var(--font-sans, 'Noto Sans SC', 'DM Sans', sans-serif);
    --font-mono: 'JetBrains Mono', 'Noto Sans Mono', monospace;
    /* BaoQiangHero 别名 */
    --bg: var(--bg-page);
    --card: var(--bg-card);
    --input-bg: var(--bg-input);
    --muted: var(--text-muted);
    --dim: var(--text-dim);
    --r-sm: var(--radius-sm);
    --r: var(--radius-sm);
    --r-lg: var(--radius);
    --r-xl: var(--radius-xl);
    --shadow: var(--shadow-lg);
    --font: var(--font-main);
}

[data-theme="dark"] {
    --bg-page: #0f1117;
    --bg-card: rgba(24, 28, 38, 0.92);
    --bg-input: rgba(30, 34, 48, 0.95);
    --border: rgba(255, 255, 255, 0.08);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary-glow: rgba(129, 140, 248, 0.2);
    --primary-bg: rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .save-editor-body .login-card,
[data-theme="dark"] .save-editor-body .save-page,
[data-theme="dark"] .save-editor-body .detail-page,
[data-theme="dark"] .save-editor-body .page {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .save-editor-body .tbl tbody td,
[data-theme="dark"] .save-editor-body .save-table tbody td {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .save-editor-body .tbl tbody tr:hover td,
[data-theme="dark"] .save-editor-body .save-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.08) !important;
}

[data-theme="dark"] .save-editor-theme-toggle {
    background: rgba(24, 28, 38, 0.92);
    border-color: rgba(129, 140, 248, 0.22);
}

html.save-editor-page {
    overflow-y: scroll;
}

body.save-editor-body {
    font-family: var(--font-main) !important;
    background: transparent !important;
    color: var(--text) !important;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1.5rem !important;
    padding-top: max(1.5rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    position: relative;
    z-index: 1;
}

.save-editor-shell {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    position: relative;
    z-index: 1;
}

/* 主题切换 */
.save-editor-theme-toggle {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 500;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card, 0 4px 24px rgba(99, 102, 241, 0.08));
    cursor: pointer;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.save-editor-theme-toggle:hover {
    box-shadow: var(--shadow-float);
}

.save-editor-theme-toggle .icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.save-editor-theme-toggle .theme-icon-sun {
    display: none;
}

[data-theme="dark"] .save-editor-theme-toggle .theme-icon-moon {
    display: none;
}

[data-theme="dark"] .save-editor-theme-toggle .theme-icon-sun {
    display: block;
}

/* ===== 国王的勇士5 ===== */
.save-editor-body .login-card,
.save-editor-body .save-page,
.save-editor-body .detail-page {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.9) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-card, 0 4px 24px rgba(99, 102, 241, 0.08)) !important;
}

.save-editor-body .login-header,
.save-editor-body .save-header,
.save-editor-body .detail-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%) !important;
}

.save-editor-body .btn-primary,
.save-editor-body .btn.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: var(--shadow-btn, 0 4px 14px rgba(99, 102, 241, 0.35)) !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
}

.save-editor-body .btn-outline,
.save-editor-body .btn-secondary {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-muted) !important;
    border-radius: var(--radius-sm) !important;
}

.save-editor-body .input-group input,
.save-editor-body .input-group select,
.save-editor-body .input-group textarea {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text) !important;
}

.save-editor-body .save-table thead th {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.02)) !important;
    color: var(--text-muted) !important;
}

.save-editor-body .player-tab.active,
.save-editor-body .sub-tab.active,
.save-editor-body .detail-tab.active {
    color: var(--primary) !important;
    border-bottom-color: var(--primary) !important;
}

.save-editor-body .quick-btn:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

/* ===== 爆枪英雄 ===== */
.save-editor-body .page {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.9) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-card) !important;
}

.save-editor-body .hdr {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%) !important;
}

.save-editor-body .btn-p {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35) !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
}

.save-editor-body .btn-s,
.save-editor-body .btn-o {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-muted) !important;
    border-radius: var(--radius-sm) !important;
}

.save-editor-body .btn-s:hover,
.save-editor-body .btn-o:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

.save-editor-body .grp-btn.active,
.save-editor-body .sub-btn.active,
.save-editor-body .equip-tab.active {
    color: var(--primary) !important;
    border-bottom-color: var(--primary) !important;
    background: var(--bg-card) !important;
}

.save-editor-body .sub-btn.active,
.save-editor-body .equip-tab.active {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}

.save-editor-body .tbl thead th {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.02)) !important;
    color: var(--text-muted) !important;
}

.save-editor-body .ig input,
.save-editor-body .ig select,
.save-editor-body .info-item input,
.save-editor-body .info-item select,
.save-editor-body .edit-field input,
.save-editor-body .edit-field select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
}

.save-editor-body .modal {
    background: var(--bg-card) !important;
    border: 1px solid var(--border);
}

.save-editor-body .top-bar,
.save-editor-body .grp-nav,
.save-editor-body .sub-nav {
    background: var(--bg-input) !important;
}

.save-editor-body .loading-overlay {
    background: rgba(255, 255, 255, 0.75) !important;
}

[data-theme="dark"] .save-editor-body .loading-overlay {
    background: rgba(15, 17, 23, 0.75) !important;
}

.save-editor-body .toast-wrap {
    display: none !important;
}

/* 已启用 Toast 弹窗，隐藏旧版 status 条 */
.save-editor-body .status-bar,
.save-editor-body .status {
    display: none !important;
}

.save-editor-body .drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 0.5rem;
    background: var(--bg-input);
}

.save-editor-body .drop-zone:hover,
.save-editor-body .drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.save-editor-body .drop-zone p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.save-editor-body .login-mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.save-editor-body .login-mode-tabs .btn {
    flex: 1;
}

/* ===== Editor Toast（与主站 toast 一致） ===== */
.editor-toast-container {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.editor-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.14), 0 4px 16px rgba(15, 23, 42, 0.08);
    animation: editorToastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
    position: relative;
    overflow: hidden;
    min-width: 280px;
}

.editor-toast.is-leaving {
    animation: editorToastOut 0.32s ease forwards;
}

.editor-toast-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.editor-toast-icon .icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.editor-toast-body {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.editor-toast-message {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--text-primary, #0f172a);
    word-break: break-word;
}

.editor-toast-close {
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 4px;
    flex-shrink: 0;
}

.editor-toast-close:hover {
    color: var(--text-primary);
}

.editor-toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(148, 163, 184, 0.15);
}

.editor-toast-progress span {
    display: block;
    height: 100%;
    transform-origin: left center;
    animation: editorToastProgress var(--toast-duration, 2s) linear forwards;
}

.editor-toast-success { border-color: rgba(16, 185, 129, 0.35); }
.editor-toast-success .editor-toast-icon { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.editor-toast-success .editor-toast-progress span { background: linear-gradient(90deg, #10b981, #34d399); }

.editor-toast-error { border-color: rgba(239, 68, 68, 0.35); }
.editor-toast-error .editor-toast-icon { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.editor-toast-error .editor-toast-progress span { background: linear-gradient(90deg, #ef4444, #f87171); }

.editor-toast-info { border-color: rgba(14, 165, 233, 0.35); }
.editor-toast-info .editor-toast-icon { background: rgba(14, 165, 233, 0.12); color: #0ea5e9; }
.editor-toast-info .editor-toast-progress span { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }

.editor-toast-warning { border-color: rgba(245, 158, 11, 0.4); }
.editor-toast-warning .editor-toast-icon { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.editor-toast-warning .editor-toast-progress span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

@keyframes editorToastIn {
    from { opacity: 0; transform: translateX(40px) scale(0.94); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes editorToastOut {
    from { opacity: 1; transform: translateX(0); max-height: 120px; }
    to { opacity: 0; transform: translateX(24px); max-height: 0; }
}

@keyframes editorToastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

[data-theme="dark"] .editor-toast {
    background: rgba(24, 28, 38, 0.96);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .editor-toast-message {
    color: #f1f5f9;
}

@media (max-width: 768px) {
    .editor-toast-container {
        left: 12px;
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
        max-width: none;
    }

    .editor-toast {
        min-width: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .editor-toast {
        animation: none !important;
    }

    .editor-toast-progress span {
        animation: none !important;
    }
}

.save-editor-body .toast {
    backdrop-filter: blur(8px);
    border-radius: var(--radius-sm) !important;
}

/* 暗色滚动条 */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
}

/* ===== 手机端 ===== */
@media (max-width: 768px) {
    html.is-mobile {
        font-size: 13px;
    }

    body.save-editor-body {
        padding: 10px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .save-editor-theme-toggle {
        width: 36px;
        height: 36px;
    }

    .save-editor-body .page-login,
    .save-editor-body .page-saves,
    .save-editor-body .page-detail,
    .save-editor-body .login-card,
    .save-editor-body .save-page,
    .save-editor-body .detail-page {
        max-width: 100% !important;
        width: 100% !important;
    }

    .save-editor-body .page-detail {
        width: 100% !important;
    }

    .save-editor-body .panel {
        max-height: none !important;
        padding: 0.75rem !important;
    }

    .save-editor-body .grp-nav,
    .save-editor-body .sub-nav,
    .save-editor-body .player-tabs {
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .save-editor-body .grp-btn,
    .save-editor-body .sub-btn,
    .save-editor-body .player-tab {
        flex-shrink: 0;
    }

    .save-editor-body .body,
    .save-editor-body .save-body,
    .save-editor-body .login-body {
        padding: 0.75rem !important;
    }

    .save-editor-body .hdr,
    .save-editor-body .save-header,
    .save-editor-body .login-header,
    .save-editor-body .detail-header {
        padding: 0.75rem !important;
        font-size: 0.9rem;
    }

    .save-editor-body .info-grid {
        grid-template-columns: 1fr !important;
    }

    .save-editor-body .btn,
    .save-editor-body .btn-p,
    .save-editor-body .btn-s,
    .save-editor-body .btn-primary {
        min-height: 38px;
        padding: 7px 12px;
        font-size: 0.8125rem;
    }

    .save-editor-body .ig input,
    .save-editor-body .ig select,
    .save-editor-body .input-group input {
        min-height: 38px;
        font-size: 15px !important;
        padding: 6px 10px;
    }

    .save-editor-body .grp-btn,
    .save-editor-body .sub-btn,
    .save-editor-body .player-tab {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .save-editor-body .modal-mask {
        align-items: flex-end;
    }

    .save-editor-body .modal {
        width: 100% !important;
        max-width: none !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 92vh;
    }

    .save-editor-body .toast-wrap {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: max(12px, env(safe-area-inset-bottom));
        flex-direction: column;
    }

    .save-editor-body .toast {
        width: 100%;
    }
}

/* ===== 布局舒适化（编辑器子站）===== */
.save-editor-body {
    padding: 12px 16px 24px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.save-editor-shell {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    box-sizing: border-box;
}

.save-editor-body .login-card,
.save-editor-body .save-page,
.save-editor-body .detail-page {
    width: 100%;
    box-sizing: border-box;
}

.save-editor-body .detail-page.bq-detail-page,
.save-editor-body .detail-page.xy-detail-page,
.save-editor-body .detail-page.ys-detail-page {
    min-height: calc(100dvh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
}

.bq-content,
.xy-content {
    padding: 1rem 1.15rem 1.5rem;
}

.bq-content .panel,
.xy-content .panel {
    margin-bottom: 1rem;
}

@media (max-width: 900px) {
    .save-editor-body .detail-page.bq-detail-page {
        height: auto;
        max-height: none;
        min-height: calc(100dvh - 1.5rem);
    }

    .bq-detail-layout {
        min-height: 0;
        overflow: visible;
    }

    .bq-sidebar.open {
        max-height: min(45vh, 320px);
        overflow-y: auto;
    }

    .bq-content {
        min-height: 40vh;
        max-height: none;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .save-editor-body {
        padding: 8px 10px 20px;
    }

    .save-editor-body .detail-page,
    .save-editor-body .detail-page.xy-detail-page,
    .save-editor-body .detail-page.bq-detail-page,
    .save-editor-body .detail-page.ys-detail-page {
        height: auto;
        min-height: calc(100dvh - 1rem);
        max-height: none;
        border-radius: 14px;
    }

    .save-editor-body .detail-page .detail-header,
    .save-editor-body .save-header,
    .save-editor-body .login-header {
        padding: 0.85rem 1rem !important;
    }

    .bq-detail-stats {
        padding: 0.65rem 1rem;
        gap: 0.5rem 0.85rem;
    }

    .bq-detail-layout,
    .xy-detail-layout,
    .ys-detail-layout {
        flex-direction: column;
        overflow: visible;
        min-height: 0;
    }

    .bq-content,
    .xy-content {
        padding: 0.75rem 0.85rem 1.25rem;
        overflow-y: visible;
        min-height: 50vh;
    }

    .save-editor-body .tbl-wrap,
    .save-editor-body .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .save-editor-body .player-tabs {
        gap: 6px;
        padding: 8px 10px;
    }

    .save-editor-body .player-panel,
    .save-editor-body .tab-panels {
        padding: 0.75rem;
    }

    .save-editor-body .info-grid {
        gap: 0.65rem;
    }
}

@media (max-width: 480px) {
    .save-editor-body .btn-group {
        flex-wrap: wrap;
    }

    .xy-grid--modal {
        grid-template-columns: 1fr;
    }
}
