.ptg-page {
    --ptg-card: var(--bg-card, #fff);
    --ptg-soft: var(--bg-body, #f7f8fa);
    --ptg-text: var(--color-text, #222);
    --ptg-muted: var(--color-text-secondary, #777);
    --ptg-border: var(--color-border, rgba(0, 0, 0, .08));
    --ptg-dashed: var(--color-border, #dcdfe6);
    --ptg-control: var(--bg-body, #f7f8fa);
    color: var(--ptg-text);
}

html[data-theme="dark"] .ptg-page {
    --ptg-card: #1b1b1d;
    --ptg-soft: #141417;
    --ptg-text: #f5f7fb;
    --ptg-muted: #c2c8d2;
    --ptg-border: rgba(255, 255, 255, .12);
    --ptg-dashed: rgba(255, 255, 255, .36);
    --ptg-control: #111216;
}

.ptg-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 14px;
    padding: 18px 22px;
    background: var(--ptg-card);
    border: 1px solid var(--ptg-border);
    border-radius: var(--border-radius, 8px);
}

.ptg-toolbar-main {
    min-width: 0;
}

.ptg-toolbar h1 {
    margin: 0 0 6px;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 800;
}

.ptg-toolbar p {
    margin: 0;
    color: var(--ptg-muted);
    font-size: 13px;
    line-height: 1.65;
}

.ptg-tabs {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    gap: 3px;
    padding: 4px;
    border-radius: 999px;
    background: var(--ptg-soft);
    border: 1px solid var(--ptg-border);
}

.ptg-tab {
    min-width: 92px;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ptg-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: color .2s, background .2s;
}

.ptg-tab.is-active {
    background: var(--ptg-card);
    color: var(--theme-color, #409eff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.ptg-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
    gap: 18px;
    align-items: start;
}

.ptg-main,
.ptg-result {
    min-width: 0;
}

.ptg-card {
    margin-bottom: 18px;
    padding: 24px 26px;
    background: var(--ptg-card);
    border: 1px solid var(--ptg-border);
    border-radius: var(--border-radius, 8px);
}

.ptg-upload-card,
.ptg-controls-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ptg-result-card {
    position: sticky;
    top: 72px;
    min-height: 510px;
}

.ptg-section-head {
    margin-bottom: 14px;
    padding-bottom: 0;
    border-bottom: 0;
}

.ptg-section-head--compact {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 0;
}

.ptg-control-head {
    margin-top: 0;
}

.ptg-control-titlebar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.ptg-section-head h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    font-size: 15px;
    line-height: 1.4;
    font-weight: 800;
}

.ptg-section-head h2::before {
    content: '';
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--theme-color, #409eff);
    flex-shrink: 0;
}

.ptg-section-head p {
    margin: 0;
    color: var(--ptg-muted);
    font-size: 12px;
    line-height: 1.65;
}

.ptg-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.ptg-upload-box {
    min-width: 0;
}

.ptg-upload-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 800;
}

.ptg-file-input {
    display: none !important;
}

.ptg-dropzone {
    min-height: 132px;
    padding: 18px 14px;
    border: 2px dashed var(--ptg-dashed);
    border-radius: var(--border-radius, 8px);
    background: var(--ptg-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

.ptg-dropzone:hover,
.ptg-dropzone.is-dragover {
    border-color: var(--theme-color, #409eff);
    background: rgba(64, 158, 255, .06);
}

.ptg-drop-icon {
    width: 30px;
    height: 30px;
    color: var(--theme-color, #409eff);
    opacity: .85;
}

.ptg-drop-icon svg {
    width: 100%;
    height: 100%;
}

.ptg-drop-title {
    font-size: 14px;
    font-weight: 800;
}

.ptg-drop-text {
    max-width: 240px;
    color: var(--ptg-muted);
    font-size: 12px;
    line-height: 1.55;
}

.ptg-file-card {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
    padding: 9px;
    border: 1px solid var(--ptg-border);
    border-radius: var(--border-radius, 8px);
    background: var(--ptg-soft);
}

.ptg-file-card img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 6px;
    background: #fff;
    flex-shrink: 0;
}

.ptg-file-card div {
    min-width: 0;
}

.ptg-file-card strong,
.ptg-file-card span {
    display: block;
    overflow-wrap: anywhere;
}

.ptg-file-card strong {
    margin-bottom: 3px;
    font-size: 12px;
}

.ptg-file-card span {
    color: var(--ptg-muted);
    font-size: 12px;
}

.ptg-control-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    padding: 16px;
    border-radius: var(--border-radius, 8px);
    background: var(--ptg-control);
}

.ptg-control-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.ptg-control-group label,
.ptg-switch-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--ptg-text);
    font-size: 12px;
    font-weight: 800;
}

.ptg-control-group label span {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    color: var(--theme-color, #409eff);
    flex-shrink: 0;
}

.ptg-control-group input[type="range"] {
    width: 100%;
    accent-color: var(--theme-color, #409eff);
}

.ptg-control-group small {
    color: var(--ptg-muted);
    font-size: 12px;
    line-height: 1.5;
}

.ptg-switch-row {
    align-items: center;
    justify-content: flex-start;
}

.ptg-switch-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--theme-color, #409eff);
}

.ptg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0;
}

.ptg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    max-width: 100%;
    padding: 0 18px;
    border-radius: var(--border-radius-sm, 4px);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: normal;
    transition: opacity .2s, transform .1s, border-color .2s;
}

.ptg-btn:hover {
    opacity: .86;
}

.ptg-btn:active {
    transform: translateY(1px);
}

.ptg-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.ptg-btn--primary {
    background: var(--theme-color, #409eff);
    color: #fff;
}

.ptg-btn--ghost {
    background: var(--ptg-card);
    color: var(--ptg-text);
    border-color: var(--ptg-border);
}

.ptg-status,
.ptg-warning {
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: var(--border-radius-sm, 4px);
    font-size: 13px;
    line-height: 1.65;
}

.ptg-status {
    color: var(--theme-color, #409eff);
    border: 1px solid rgba(64, 158, 255, .24);
    background: rgba(64, 158, 255, .08);
}

.ptg-status.is-error {
    color: #e74c3c;
    border-color: rgba(231, 76, 60, .22);
    background: rgba(231, 76, 60, .08);
}

.ptg-warning {
    color: #a66a00;
    border: 1px solid rgba(230, 162, 60, .28);
    background: rgba(230, 162, 60, .1);
}

.ptg-empty {
    min-height: 310px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    border: 2px dashed var(--ptg-dashed);
    border-radius: var(--border-radius, 8px);
    background: var(--ptg-soft);
    color: var(--ptg-muted);
    font-size: 14px;
    line-height: 1.7;
    text-align: center;
}

.ptg-preview {
    margin-top: 12px;
}

.ptg-preview--split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.ptg-preview-box {
    padding: 10px;
    border: 1px solid var(--ptg-border);
    border-radius: var(--border-radius, 8px);
    background: var(--ptg-soft);
}

.ptg-preview-box--white {
    background: #fff;
}

.ptg-preview-box--black {
    background: #000;
}

.ptg-preview-box--black .ptg-preview-title {
    color: rgba(255, 255, 255, .84);
}

.ptg-preview-title {
    margin-bottom: 8px;
    color: var(--ptg-text);
    font-size: 12px;
    font-weight: 800;
}

.ptg-preview-box img {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
    border-radius: 6px;
}

.ptg-output-meta {
    margin-top: 10px;
    color: var(--ptg-muted);
    font-size: 12px;
}

.ptg-canvas,
.is-hidden {
    display: none !important;
}

@media (max-width: 1080px) {
    .ptg-layout {
        grid-template-columns: 1fr;
    }

    .ptg-result-card {
        position: static;
    }
}

@media (max-width: 720px) {
    .ptg-toolbar {
        grid-template-columns: 1fr;
        padding: 18px 16px;
    }

    .ptg-card {
        padding: 18px 16px;
    }

    .ptg-section-head--compact {
        flex-direction: column;
    }

    .ptg-upload-grid,
    .ptg-control-panel,
    .ptg-preview--split {
        grid-template-columns: 1fr;
    }

    .ptg-tabs {
        width: 100%;
    }

    .ptg-tab {
        flex: 1;
        min-width: 0;
        padding: 0 10px;
    }
}
