/* --- WinUI 3 Design Tokens (Dark Theme) --- */
:root {
    --bg-app: #202020;
    --bg-card: #2c2c2c;
    --bg-card-border: rgba(255, 255, 255, 0.08);
    --bg-control: rgba(255, 255, 255, 0.06);
    --bg-control-hover: rgba(255, 255, 255, 0.09);
    --accent-default: #60cdff;
    --accent-hover: #74d3ff;
    --accent-pressed: #4cb2e6;
    --accent-text: #000000;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-disabled: rgba(255, 255, 255, 0.36);
    --radius-sm: 4px;
    --radius-md: 8px;
    --control-border: rgba(255, 255, 255, 0.12);
    --shadow-flyout: 0 8px 32px rgba(0, 0, 0, 0.4);
    --font-family: 'Segoe UI Variable', 'Segoe UI', 'Microsoft YaHei', sans-serif;
    --success: #6ccb5f;
    --danger: #ff99a4;
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    margin: 0;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: rgba(255,255,255,0.4);
    }

.material-symbols-outlined {
    font-size: 20px;
    vertical-align: middle;
    user-select: none;
}

.icon {
    font-size: 18px;
}

.icon-md {
    font-size: 20px;
}

.icon-lg {
    font-size: 24px;
}

.icon-xl {
    font-size: 48px;
    color: var(--text-secondary);
}

/* 标题栏 & 导航 */
.title-bar {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--bg-card-border);
    user-select: none;
    -webkit-app-region: drag;
    position: relative;
    z-index: 10;
}

.app-logo {
    font-weight: 600;
    font-size: 14px;
    margin-right: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.nav-tabs {
    display: flex;
    gap: 4px;
    -webkit-app-region: no-drag;
    height: 100%;
    align-items: center;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0 16px;
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.1s;
    position: relative;
    height: 36px;
    font-family: inherit;
    display: flex;
    align-items: center;
}

    .tab-btn:hover {
        background: rgba(255,255,255,0.04);
        color: var(--text-primary);
    }

    .tab-btn.active {
        background: transparent;
        color: var(--text-primary);
        font-weight: 600;
    }

        .tab-btn.active::after {
            content: '';
            position: absolute;
            bottom: -6px;
            left: 16px;
            right: 16px;
            height: 3px;
            background: var(--accent-default);
            border-radius: 3px 3px 0 0;
            transition: 0.2s;
        }

/* 布局 & 控件 */
.main-view {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: none;
    justify-content: center;
}

    .main-view.active {
        display: flex;
        animation: slideUpFade 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    }

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 40px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
}

.card-header {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}

.row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

    .row:last-child {
        margin-bottom: 0;
    }

.col {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 400;
    opacity: 0.9;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    background: var(--bg-control);
    border: 1px solid var(--control-border);
    border-bottom: 1px solid #8d8d8d;
    border-radius: var(--radius-sm);
    padding: 0 11px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.15s ease-out;
    height: 32px;
    width: 100%;
}

textarea {
    height: auto;
    min-height: 80px;
    resize: vertical;
    padding: 8px 11px;
    line-height: 1.5;
    white-space: pre-wrap;
}

    input:focus, select:focus, textarea:focus {
        background: var(--bg-app);
        border-color: rgba(255,255,255,0.7);
        border-bottom: 2px solid var(--accent-default);
        padding-bottom: 1px;
    }

input:disabled, select:disabled {
    color: var(--text-disabled);
    background: rgba(255,255,255,0.02);
    cursor: not-allowed;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    min-height: 32px;
}

input[type="checkbox"] {
    appearance: none;
    width: 40px;
    height: 20px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid #999;
    position: relative;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    transition: all 0.2s;
}

    input[type="checkbox"]::after {
        content: '';
        position: absolute;
        top: 3px;
        left: 3px;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        background: #999;
        transition: all 0.2s;
    }

    input[type="checkbox"]:checked {
        background: var(--accent-default);
        border-color: var(--accent-default);
    }

        input[type="checkbox"]:checked::after {
            left: 23px;
            background: var(--accent-text);
            width: 12px;
            height: 12px;
        }

.drop-box {
    background: var(--bg-control);
    border: 1px solid var(--bg-card-border);
    border-bottom: 1px solid #8d8d8d;
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    position: relative;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

    .drop-box:hover {
        background: var(--bg-control-hover);
    }

    .drop-box.dragover {
        background: rgba(96, 205, 255, 0.1);
        border-color: var(--accent-default);
        border-style: solid;
    }

    .drop-box input[type="file"] {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
        z-index: 10;
    }

.file-status {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.btn {
    height: 32px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    user-select: none;
    font-weight: 400;
}

    .btn:active {
        transform: scale(0.97);
    }

.btn-primary {
    background: var(--accent-default);
    color: var(--accent-text);
}

    .btn-primary:hover {
        background: var(--accent-hover);
    }

    .btn-primary:disabled {
        background: var(--bg-control);
        color: var(--text-disabled);
        cursor: not-allowed;
        transform: none;
    }

.btn-secondary {
    background: var(--bg-control);
    color: var(--text-primary);
    border: 1px solid var(--control-border);
    border-bottom-color: rgba(255,255,255,0.2);
}

    .btn-secondary:hover {
        background: var(--bg-control-hover);
    }

.preview-area {
    background: #1a1a1a;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    border: 1px solid var(--bg-card-border);
    padding: 20px;
    background-image: linear-gradient(45deg, #222 25%, transparent 25%), linear-gradient(-45deg, #222 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #222 75%), linear-gradient(-45deg, transparent 75%, #222 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

canvas, img.res-img {
    max-width: 100%;
    max-height: 500px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.6);
    border-radius: 2px;
}

.progress-container {
    display: none;
    margin-top: 16px;
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--bg-card-border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--bg-control);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-default);
    width: 0%;
    transition: width 0.1s linear;
}

.expander {
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    transition: background 0.2s;
}

    .expander:not(.open) {
        height: 48px;
        overflow: hidden;
    }

    .expander.open {
        height: auto;
        overflow: visible;
    }

.expander-header {
    padding: 0 16px;
    height: 48px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.expander.open .expander-header {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 1px solid var(--bg-card-border);
}

.expander-content {
    padding: 24px;
    display: none;
    background: #252525;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.expander.open .expander-content {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.chevron {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.expander.open .chevron {
    transform: rotate(180deg);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s infinite linear;
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: #2e2e2e;
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-flyout);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
    animation: slideUpToast 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

    .toast.error::before {
        content: '';
        display: block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
        background: var(--danger);
        box-shadow: 0 0 8px var(--danger);
    }

    .toast.success::before {
        content: '';
        display: block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
        background: var(--success);
        box-shadow: 0 0 8px var(--success);
    }

@keyframes slideUpToast {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(32,32,32,0.9);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

    .drag-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

/* 无痕预览模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    padding: 40px;
}

    .modal-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

.modal-content {
    max-width: 100%;
    max-height: calc(100% - 60px);
    background: #1e1e1e;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 24px 64px rgba(0,0,0,0.8);
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.modal-toolbar {
    padding: 12px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-media {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    margin: 0 auto;
}

.preview-text {
    padding: 20px;
    white-space: pre-wrap;
    font-family: Consolas, monospace;
    color: #ccc;
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
}

iframe.preview-media {
    width: 80vw;
    height: 75vh;
    border: none;
    background: #fff;
}
