/* Scoped typography & layout — overrides inherited 150% body / 120% box sizes */
.cyber-container.perler-page {
    width: 100%;
    max-width: 1080px;
}

.perler-page {
    font-size: 16px;
    line-height: 1.55;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1.25rem 1.5rem;
    box-sizing: border-box;
}

.perler-page *,
.perler-page *::before,
.perler-page *::after {
    box-sizing: border-box;
}

.perler-page div.box {
    font-size: 1rem;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem;
    padding: 1.15rem 1.25rem;
    border-width: 2px;
    border-radius: 14px;
    overflow-wrap: break-word;
}

.perler-page div.box:hover {
    box-shadow: 0 0 14px rgba(0, 255, 0, 0.45);
}

.perler-page h2.perler-section-title {
    margin: 0 0 0.65rem;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: left;
    color: #00ff88;
    letter-spacing: 0.02em;
}

/* Header */
.perler-header {
    margin-bottom: 1.25rem;
}

.perler-back {
    margin-bottom: 0.85rem;
    font-size: 0.9rem;
    padding: 0.45rem 0.9rem;
    border-width: 2px;
}

.perler-title {
    margin: 0 0 0.5rem;
    padding: 0.85rem 1rem;
    font-size: 1.65rem;
    line-height: 1.2;
    text-align: center;
    color: #00ff00;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.55);
    border: 2px solid #00ff00;
    border-radius: 12px;
    background: #080808;
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.35);
}

.perler-badge {
    margin: 0;
    text-align: center;
    color: #00ff88;
    font-size: 0.9rem;
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.45);
}

/* Notice */
.perler-notice {
    margin-bottom: 1.25rem;
}

.perler-notice-list {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.perler-notice-list li {
    margin: 0.35rem 0;
    font-size: 0.92rem;
    line-height: 1.45;
}

.warning-box {
    border-color: #ff6600;
    box-shadow: 0 0 10px rgba(255, 102, 0, 0.3);
}

/* Two-column workspace */
.perler-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    width: 100%;
    max-width: 100%;
}

.perler-column {
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.perler-card {
    overflow: hidden;
}

.perler-lead {
    margin: 0 0 0.85rem;
    font-size: 0.92rem;
    line-height: 1.5;
    opacity: 0.92;
}

/* Upload */
.perler-dropzone {
    margin: 0 0 1rem;
    padding: 1.35rem 1rem;
    border: 2px dashed #00ff00;
    border-radius: 12px;
    text-align: center;
    background: rgba(0, 255, 0, 0.04);
    transition: background 0.2s, border-color 0.2s;
}

.perler-dropzone.dragover {
    border-color: #ffff00;
    background: rgba(255, 255, 0, 0.08);
}

.perler-dropzone-label {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.perler-upload {
    display: inline-block;
    cursor: pointer;
}

.perler-btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-width: 2px;
    border-radius: 10px;
}

.perler-hint {
    margin: 0.65rem 0 0;
    font-size: 0.82rem;
    opacity: 0.72;
}

/* Options */
.perler-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.65rem;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}

.perler-option input {
    margin-top: 0.2rem;
    flex-shrink: 0;
}

.perler-border-option {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(0, 255, 0, 0.2);
}

.perler-addon-options {
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin: 1rem 0 0;
    min-width: 0;
    max-width: 100%;
}

.perler-addon-options legend {
    padding: 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #00ccff;
}

.perler-addon-note {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    opacity: 0.85;
    line-height: 1.4;
}

.perler-addon-unavailable {
    color: #ffaa66;
    opacity: 1;
}

.perler-addon-choice {
    margin-top: 0;
}

.perler-addon-options.is-disabled .perler-addon-choice {
    opacity: 0.55;
    cursor: not-allowed;
}

.perler-pixel-detect-options {
    border: 1px solid rgba(0, 204, 255, 0.35);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin: 1rem 0 0;
    min-width: 0;
    max-width: 100%;
}

.perler-pixel-detect-options legend {
    padding: 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #00ccff;
}

.perler-pixel-detect-note {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    opacity: 0.75;
    line-height: 1.4;
}

.perler-pixel-detect-result {
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    color: #00ff88;
    line-height: 1.45;
}

.perler-pixel-detect-result.is-none {
    color: #ffaa66;
}

.perler-pixel-detect-choice {
    margin-top: 0;
}

.perler-bg-options {
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin: 0;
    min-width: 0;
    max-width: 100%;
}

.perler-bg-options legend {
    padding: 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #00ccff;
}

.perler-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.perler-bg-choice {
    margin-top: 0;
}

.perler-bg-flood {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 255, 0, 0.2);
}

.perler-bg-flood-note {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    opacity: 0.75;
    line-height: 1.4;
}

.perler-bg-detected {
    margin: 0.65rem 0 0;
    font-size: 0.85rem;
    opacity: 0.9;
}

#bg-swatch {
    border: 1px solid rgba(255, 255, 255, 0.35);
}

/* Resize */
.perler-resize-box {
    border-color: #00ccff;
}

.perler-current-size {
    margin: 0 0 0.85rem;
    font-size: 0.92rem;
}

.perler-original-size {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.85rem;
    opacity: 0.75;
}

.perler-resize-actions {
    margin-bottom: 0.85rem;
}

.perler-resize-custom {
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin: 0;
    min-width: 0;
    max-width: 100%;
}

.perler-resize-custom legend {
    padding: 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.perler-resize-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.65rem;
}

.perler-resize-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.82rem;
}

.perler-resize-fields input[type="number"] {
    width: 5.5rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid #00ff00;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    color: inherit;
    font: inherit;
    font-size: 0.95rem;
}

.perler-resize-sep {
    align-self: center;
    opacity: 0.7;
    padding-bottom: 0.4rem;
}

.perler-lock-ratio {
    margin-top: 0;
    margin-bottom: 0.65rem;
}

/* Oversize warning */
.perler-oversize-box {
    border-color: #ff4444;
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.3);
    background: rgba(255, 51, 51, 0.06);
}

.perler-oversize-box .perler-section-title {
    color: #ff7777;
}

.perler-warn-btn {
    margin-top: 0.5rem;
}

/* Output column */
.perler-status-bar {
    margin-bottom: 1rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid rgba(0, 204, 255, 0.35);
    border-radius: 10px;
    background: rgba(0, 204, 255, 0.06);
}

.perler-status {
    margin: 0;
    min-height: 1.35em;
    font-size: 0.88rem;
    color: #00ccff;
}

.perler-empty-state {
    padding: 2rem 1.25rem;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.65;
    border: 1px dashed rgba(0, 255, 0, 0.25);
    border-radius: 12px;
}

.perler-empty-state[hidden] {
    display: none;
}

/* Results grid */
.perler-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 1rem;
    margin: 0;
}

.perler-stat {
    margin: 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: rgba(0, 255, 0, 0.04);
    border: 1px solid rgba(0, 255, 0, 0.15);
}

.perler-stat dt {
    margin: 0 0 0.2rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
    color: #00ccff;
}

.perler-stat dd {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #00ff88;
}

.perler-stat--highlight {
    grid-column: 1 / -1;
    background: rgba(0, 255, 136, 0.08);
    border-color: rgba(0, 255, 136, 0.35);
}

.perler-stat--highlight dd {
    font-size: 1.2rem;
}

.perler-stat--price dd {
    font-size: 1.25rem;
    color: #ffff66;
    text-shadow: 0 0 8px rgba(255, 255, 102, 0.35);
}

/* Preview */
.perler-dims {
    margin: 0 0 0.85rem;
    font-size: 0.88rem;
    opacity: 0.85;
}

.perler-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: start;
}

.perler-preview-panel h3 {
    margin: 0 0 0.2rem;
    font-size: 0.95rem;
    color: #00ff88;
}

.perler-preview-caption {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    opacity: 0.72;
    line-height: 1.4;
}

.perler-preview-panel canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    border: 2px solid #00ff00;
    border-radius: 8px;
    background: #111;
}

.perler-legend {
    margin: 0.65rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    line-height: 1.5;
}

.perler-legend li {
    margin: 0.2rem 0;
}

.swatch {
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    vertical-align: middle;
    border-radius: 2px;
    margin-right: 0.35rem;
}

.swatch.content {
    background: #00ff88;
}

.swatch.border {
    background: #646464;
    border: 1px solid #999;
}

.swatch.bg {
    background: #000;
    border: 1px solid #333;
}

/* Responsive */
@media (max-width: 820px) {
    .perler-page {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .perler-workspace {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }

    .perler-title {
        font-size: 1.4rem;
    }

    .perler-stats {
        grid-template-columns: 1fr;
    }

    .perler-stat--highlight {
        grid-column: auto;
    }
}

@media (max-width: 480px) {
    .perler-page {
        font-size: 15px;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .perler-page div.box {
        padding: 1rem;
    }

    .perler-header,
    .perler-notice,
    .perler-workspace {
        width: 100%;
        max-width: 100%;
    }
}