:root {
    --pix-red: #eb0c27;
    --pix-red-dark: #c90018;
    --pix-black: #111111;
    --pix-muted: #5f6368;
    --pix-line: #d8d8d8;
    --pix-line-dark: #111111;
    --pix-bg: #ffffff;
    --pix-work: #f6f6f6;
    --pix-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html,
body.pixplet-editor-body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    background: #ffffff !important;
    color: var(--pix-black) !important;
    font-family: var(--pix-font) !important;
    font-size: 14px;
    line-height: 1.4;
}

body.pixplet-editor-body * {
    box-sizing: border-box;
}

body.pixplet-editor-body a {
    color: inherit;
}

body.pixplet-editor-body button,
body.pixplet-editor-body input,
body.pixplet-editor-body select,
body.pixplet-editor-body textarea {
    font: inherit;
}

.screen-reader-text,
.pix-file-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

[hidden] { display: none !important; }

.pix-app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: 58px minmax(0, 1fr) auto;
    background: #ffffff;
    color: var(--pix-black);
    font-family: var(--pix-font);
}

.pix-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.pix-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pix-appbar {
    min-width: 0;
    height: 58px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: #ffffff;
    border-bottom: 1px solid var(--pix-line);
}

.pix-brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    text-decoration: none;
}

.pix-brand img {
    width: 118px;
    height: auto;
    display: block;
}

.pix-app-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.pix-button,
.pix-mini,
.pix-quick button,
.pix-tabs button,
.pix-choice,
.pix-position button,
.pix-shapes button,
.pix-layer-actions button,
.pix-background button,
.pix-preset,
.pix-lock,
.pix-history button,
.pix-modal-head button {
    appearance: none;
    border-radius: 0;
    cursor: pointer;
    background: #ffffff;
    color: var(--pix-black);
    border: 1px solid var(--pix-line);
    text-decoration: none;
    user-select: none;
}

.pix-button {
    min-height: 38px;
    padding: 0 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
}

.pix-button-wide { width: 100%; }
.pix-button-primary { background: var(--pix-red); border-color: var(--pix-red); color: #ffffff; }
.pix-button-primary:hover:not(:disabled) { background: var(--pix-red-dark); border-color: var(--pix-red-dark); }
.pix-button-secondary { background: #ffffff; border-color: var(--pix-line); }
.pix-button-ghost { color: var(--pix-muted); border-color: transparent; }

button:disabled,
.pix-button:disabled,
.pix-mini:disabled,
.pix-preset:disabled {
    cursor: not-allowed;
    opacity: .42;
}

.pix-button:hover:not(:disabled),
.pix-mini:hover:not(:disabled),
.pix-quick button:hover:not(:disabled),
.pix-tabs button:hover:not(:disabled),
.pix-choice:hover:not(:disabled),
.pix-position button:hover:not(:disabled),
.pix-shapes button:hover:not(:disabled),
.pix-layer-actions button:hover:not(:disabled),
.pix-background button:hover:not(:disabled),
.pix-preset:hover:not(:disabled),
.pix-lock:hover:not(:disabled),
.pix-history button:hover:not(:disabled) {
    border-color: var(--pix-line-dark);
}

.pix-main {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    border-bottom: 1px solid var(--pix-line);
}

.pix-stage-card {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: 58px minmax(0, 1fr) 32px;
    background: #ffffff;
}

.pix-stage-head {
    min-width: 0;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--pix-line);
    background: #ffffff;
}

.pix-file-summary {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.pix-file-summary strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 800;
}

.pix-file-summary span,
.pix-stage-status,
.pix-help,
.pix-empty p,
.pix-empty small {
    color: var(--pix-muted);
}

.pix-quick {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.pix-quick button {
    min-height: 36px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 650;
}

.pix-quick .is-active,
.pix-tabs .is-active,
.pix-background .is-active,
.pix-choice.is-active,
.pix-lock.is-active {
    color: #ffffff;
    background: var(--pix-red);
    border-color: var(--pix-red);
}

.pix-choice.is-active strong,
.pix-choice.is-active span {
    color: #ffffff;
}

.pix-stage {
    min-height: 0;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    background: var(--pix-work);
}

.pix-history {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid var(--pix-line);
}

.pix-history button {
    width: 38px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-right: 1px solid var(--pix-line);
    background: #ffffff;
    color: var(--pix-black);
}

.pix-history button:last-child {
    border-right: 0;
}

.pix-history button:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.pix-history button:not(:disabled):active {
    color: #ffffff;
    background: var(--pix-red);
}

.pix-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border: 1px solid var(--pix-black);
    background: #ffffff;
    touch-action: none;
    image-rendering: auto;
}

.pix-empty {
    width: min(460px, 94%);
    padding: 28px;
    display: grid;
    justify-items: center;
    gap: 12px;
    text-align: center;
    border: 1px solid var(--pix-line);
    background: #ffffff;
}

.pix-empty-icon {
    color: var(--pix-red);
}

.pix-empty strong {
    font-size: 22px;
    font-weight: 850;
}

.pix-canvas-note {
    display: none !important;
}

.pix-stage-status {
    min-width: 0;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--pix-line);
    background: #ffffff;
    font-size: 12px;
}

.pix-stage-status span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pix-panel {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
    border-left: 1px solid var(--pix-line);
    background: #ffffff;
}

.pix-tabs {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid var(--pix-line);
}

.pix-tabs button {
    min-width: 0;
    border: 0;
    border-right: 1px solid var(--pix-line);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 800;
}

.pix-tabs button:last-child { border-right: 0; }

.pix-panel-body {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #ffffff;
}

.pix-panel-section {
    min-height: 0;
    height: 100%;
    padding: 18px 16px 20px;
    overflow: auto;
}

.pix-panel-section[data-panel="resize"] {
    display: grid;
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    overflow: hidden;
}

.pix-section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
}

.pix-section-head p {
    margin: 0 0 4px;
    color: var(--pix-red);
    font-size: 11px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.pix-section-head h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.08;
    font-weight: 900;
    color: var(--pix-black);
}

.pix-mini {
    min-height: 36px;
    padding: 0 12px;
    font-weight: 650;
}

.pix-size-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}

.pix-field {
    min-width: 0;
    display: grid;
    gap: 6px;
    color: var(--pix-muted);
    font-weight: 750;
}

.pix-field span,
.pix-field input,
.pix-field select {
    width: 100%;
}

.pix-field span {
    min-height: 44px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--pix-line);
    color: var(--pix-muted);
}

.pix-field input,
.pix-field select {
    min-width: 0;
    height: 42px;
    border: 1px solid var(--pix-line);
    background: #ffffff;
    color: var(--pix-black);
    padding: 0 10px;
    font-weight: 700;
}

.pix-field span input {
    height: 40px;
    padding: 0;
    border: 0;
}

.pix-field-full { margin-bottom: 12px; }

.pix-lock {
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pix-filter-select {
    margin: 14px 0 12px;
    display: grid;
    gap: 6px;
    color: var(--pix-muted);
    font-size: 12px;
    font-weight: 800;
}

.pix-filter-select select {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--pix-line);
    border-radius: 0;
    background: #ffffff;
    color: var(--pix-black);
    font-weight: 800;
    appearance: auto;
}

.pix-filter-select select:focus {
    outline: 2px solid rgba(235, 12, 39, .18);
    outline-offset: 1px;
    border-color: var(--pix-red);
}

.pix-presets {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
    padding: 0 6px 4px 0;
}

.pix-preset {
    min-width: 0;
    min-height: 112px;
    padding: 12px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    overflow: hidden;
    align-content: start;
}

.pix-preset span {
    display: block;
    color: var(--pix-muted);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pix-preset strong {
    display: block;
    color: var(--pix-black);
    font-size: 14px;
    font-weight: 850;
    line-height: 1.25;
    min-height: 34px;
    max-height: 54px;
    overflow: hidden;
    word-break: normal;
}

.pix-preset em {
    display: block;
    margin-top: auto;
    color: var(--pix-muted);
    font-size: 12px;
    font-weight: 750;
    font-style: normal;
    line-height: 1.2;
}

.pix-preset.is-selected {
    border-color: var(--pix-red);
    box-shadow: inset 3px 0 0 var(--pix-red);
}

.pix-choice-grid,
.pix-shapes,
.pix-layer-actions,
.pix-position {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.pix-choice {
    min-height: 88px;
    padding: 13px;
    display: grid;
    gap: 4px;
    text-align: left;
}

.pix-choice strong { font-weight: 850; }
.pix-choice span { color: var(--pix-muted); font-size: 12px; }

.pix-control {
    display: grid;
    gap: 8px;
    margin: 18px 0;
}

.pix-control label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--pix-muted);
    font-weight: 800;
}

.pix-control strong { color: var(--pix-black); }
input[type="range"] {
    width: 100%;
    accent-color: var(--pix-red);
}

.pix-position { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pix-position button,
.pix-shapes button,
.pix-layer-actions button,
.pix-background button {
    min-height: 42px;
    padding: 0 10px;
    font-weight: 700;
}

.pix-shapes {
    margin: 12px 0 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pix-layer-box {
    border-top: 1px solid var(--pix-line);
    padding-top: 16px;
    margin-top: 16px;
}

.pix-layer-title {
    margin: 0 0 12px;
    font-weight: 900;
    color: var(--pix-red);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 12px;
}

.pix-help {
    margin: 14px 0 0;
    font-size: 13px;
}

.pix-footer {
    min-width: 0;
    display: grid;
    gap: 8px;
    align-content: center;
    justify-items: center;
    padding: 10px 16px 9px;
    background: #ffffff;
    border-top: 1px solid var(--pix-line);
    font-size: 12px;
}

.pix-footer-tools,
.pix-footer-pages {
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pix-footer-tools {
    gap: 6px 8px;
    flex-wrap: wrap;
}

.pix-footer-pages {
    gap: 8px 22px;
    flex-wrap: wrap;
}

.pix-footer-tool {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 5px 9px;
    color: var(--pix-black);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.pix-footer-tool:hover,
.pix-footer-tool:focus-visible {
    color: var(--pix-red);
    background: #fff5f6;
    outline: none;
}

.pix-footer-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    display: inline-grid;
    place-items: center;
    color: var(--pix-red);
}

.pix-footer-icon svg {
    width: 17px;
    height: 17px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pix-footer-pages a {
    color: #334155;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
}

.pix-footer-pages a:hover,
.pix-footer-pages a:focus-visible {
    color: var(--pix-red);
    outline: none;
}

.pix-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    padding: 20px;
}

.pix-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .76);
}

.pix-modal-card {
    position: relative;
    width: min(430px, 100%);
    background: #ffffff;
    border: 1px solid var(--pix-black);
}

.pix-modal-head {
    min-height: 54px;
    padding: 0 14px;
    border-bottom: 1px solid var(--pix-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pix-modal-head h2 { margin: 0; font-size: 20px; font-weight: 900; }
.pix-history button,
.pix-modal-head button { width: 36px; height: 36px; display: grid; place-items: center; }
.pix-modal-body { padding: 16px; }

.pix-background {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 14px 0;
}

.pix-background p { grid-column: 1 / -1; margin: 0; color: var(--pix-muted); font-weight: 800; }

.pix-toast {
    position: fixed;
    left: 50%;
    bottom: 46px;
    transform: translateX(-50%);
    z-index: 1000000;
    max-width: min(520px, calc(100vw - 28px));
    padding: 10px 12px;
    border: 1px solid var(--pix-black);
    background: #ffffff;
    color: var(--pix-black);
    font-weight: 800;
}

@media (max-width: 1180px) {
    .pix-main { grid-template-columns: minmax(0, 1fr) 340px; }
    .pix-panel-section { padding: 16px 12px 18px; }
    .pix-presets { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    html,
    body.pixplet-editor-body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }
    .pix-app {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        display: block;
    }
    .pix-appbar {
        min-height: 58px;
        height: auto;
        padding: 10px 12px;
    }
    .pix-app-actions { gap: 6px; }
    .pix-button { min-height: 36px; padding: 0 10px; }
    .pix-main {
        display: block;
        overflow: visible;
        border-bottom: 0;
    }
    .pix-stage-card {
        height: 62vh;
        min-height: 420px;
        border-bottom: 1px solid var(--pix-line);
    }
    .pix-panel {
        display: block;
        height: auto;
        overflow: visible;
        border-left: 0;
        border-bottom: 1px solid var(--pix-line);
    }
    .pix-tabs {
        position: sticky;
        top: 0;
        z-index: 3;
        height: 52px;
        background: #ffffff;
    }
    .pix-panel-body {
        height: auto;
        max-height: none;
        overflow: visible;
    }
    .pix-panel-section {
        height: auto;
        min-height: 0;
        overflow: visible;
    }
    .pix-panel-section[data-panel="resize"] {
        display: block;
    }
    .pix-presets {
        max-height: 54vh;
        overflow-y: auto;
    }
    .pix-presets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .pix-stage-head {
        padding: 8px 10px;
        align-items: stretch;
        flex-direction: column;
    }
    .pix-quick {
        width: 100%;
        overflow-x: auto;
    }
    .pix-quick button { flex: 1 0 auto; }
}

@media (max-width: 560px) {
    .pix-appbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }
    .pix-brand {
        width: 100%;
        justify-content: center;
    }
    .pix-app-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }
    .pix-app-actions .pix-button { width: 100%; }
    .pix-stage-card { height: 58vh; min-height: 360px; }
    .pix-stage { padding: 12px; }
    .pix-history { top: 10px; right: 10px; }
    .pix-history button { width: 34px; height: 32px; }
    .pix-section-head h2 { font-size: 21px; }
    .pix-tabs button { font-size: 0; }
    .pix-tabs .pix-icon { width: 18px; height: 18px; }
    .pix-presets { grid-template-columns: 1fr; }
    .pix-size-grid { grid-template-columns: 1fr 42px 1fr; }
    .pix-shapes { grid-template-columns: 1fr; }
    .pix-layer-actions { grid-template-columns: 1fr 1fr; }
    .pix-footer { padding: 10px 8px 11px; gap: 7px; }
    .pix-footer-tools {
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }
    .pix-footer-tool {
        flex: 0 0 auto;
        min-height: 32px;
        padding: 5px 8px;
        font-size: 11px;
    }
    .pix-footer-pages { gap: 8px 14px; }
    .pix-footer-pages a { font-size: 12px; }
}

.pix-layer-actions button[data-layer-delete] {
    grid-column: 1 / -1;
}

/* v1.7 text-layer controls */
.pix-text-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
}

.pix-text-options button {
    min-height: 40px;
    padding: 0 8px;
    appearance: none;
    border-radius: 0;
    border: 1px solid var(--pix-line);
    background: #ffffff;
    color: var(--pix-black);
    cursor: pointer;
    font-weight: 800;
}

.pix-text-options button:hover:not(:disabled) {
    border-color: var(--pix-line-dark);
}

.pix-text-options button.is-active {
    color: #ffffff;
    background: var(--pix-red);
    border-color: var(--pix-red);
}

.pix-text-options button:focus-visible,
.pix-field select:focus-visible {
    outline: 2px solid rgba(235, 12, 39, .18);
    outline-offset: 1px;
    border-color: var(--pix-red);
}

@media (max-width: 560px) {
    .pix-text-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* v1.9 polish: export filename, shortcuts and cleaner mobile actions */
.pix-estimate {
    margin: 10px 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--pix-line);
    color: var(--pix-muted);
    font-size: 12px;
    font-weight: 800;
    background: #fafafa;
}

.pix-background {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pix-background input[type="color"] {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 40px;
    padding: 2px;
    border: 1px solid var(--pix-line);
    background: #ffffff;
}

.pix-background button.is-active {
    color: #ffffff;
    background: var(--pix-red);
    border-color: var(--pix-red);
}

.pix-shortcuts-card {
    width: min(560px, 100%);
}

.pix-shortcuts-list {
    margin: 0;
    display: grid;
    gap: 0;
    border: 1px solid var(--pix-line);
}

.pix-shortcuts-list div {
    display: grid;
    grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--pix-line);
}

.pix-shortcuts-list div:last-child {
    border-bottom: 0;
}

.pix-shortcuts-list dt,
.pix-shortcuts-list dd {
    margin: 0;
}

.pix-shortcuts-list dt {
    color: var(--pix-black);
    font-weight: 900;
}

.pix-shortcuts-list dd {
    color: var(--pix-muted);
    font-weight: 700;
}

@media (max-width: 560px) {
    .pix-app-actions {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .pix-app-actions .pix-button {
        min-width: 0;
        padding: 0 6px;
        gap: 4px;
        font-size: 11px;
        white-space: nowrap;
    }
    .pix-shortcuts-open {
        font-size: 0 !important;
    }
    .pix-shortcuts-open .pix-icon {
        width: 18px;
        height: 18px;
    }
    .pix-shortcuts-list div {
        grid-template-columns: 1fr;
        gap: 3px;
    }
    .pix-background {
        grid-template-columns: 1fr;
    }
}
