:root {
    --sts-brand: #2563eb;
    --sts-brand-dark: #1d4ed8;
    --sts-brand-soft: #eff6ff;
    --sts-footer: #0f2740;
    --sts-ink: #0f172a;
    --sts-muted: #475569;
    --sts-line: #94a3b8;
    --sts-surface: #ffffff;
    --sts-danger: #a72828;
    --sts-radius: 14px;
    --sts-shadow: 0 8px 28px rgba(15, 39, 64, 0.08);
}

.sts-tool,
.sts-tool * {
    box-sizing: border-box;
}

.sts-tool {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 1.5rem;
    color: var(--sts-ink);
    font: inherit;
}

.sts-tool-page h1,
.sts-tool-page .wp-block-post-title,
.sts-tool-page .entry-title {
    margin-block: 0 !important;
    padding-block-start: 1.25rem !important;
    padding-block-end: 0.5rem !important;
    font-family: Lato, sans-serif !important;
    font-size: 1.875rem !important;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}

/* Keep the title wrapper and content together despite the theme block gap. */
html body.sts-tool-page main.wp-block-group > .wp-block-group:has(> .wp-block-post-title) + .wp-block-post-content,
html body.sts-tool-page main.wp-block-group > .wp-block-group:has(> .entry-title) + .entry-content {
    margin-block-start: 0 !important;
}

html body.sts-tool-page .wp-block-post-content > p:first-of-type,
html body.sts-tool-page .entry-content > p:first-of-type {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
    padding-block-end: 0 !important;
}

html body.sts-tool-page .wp-block-post-content > p:has(+ .sts-tool),
html body.sts-tool-page .entry-content > p:has(+ .sts-tool) {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
    padding-block-end: 0 !important;
}

html body.sts-tool-page .wp-block-post-content > p + .sts-tool,
html body.sts-tool-page .entry-content > p + .sts-tool {
    margin-block-start: 0.5rem !important;
    margin-block-end: 0 !important;
}

html body.sts-tool-page .wp-block-post-content > .sts-tool,
html body.sts-tool-page .entry-content > .sts-tool {
    margin-block-end: 0 !important;
}

html body.sts-tool-page .wp-block-post-content > .sts-tool + .wp-block-spacer,
html body.sts-tool-page .entry-content > .sts-tool + .wp-block-spacer {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

html body.sts-tool-page .wp-block-post-content > .sts-tool + p,
html body.sts-tool-page .wp-block-post-content > .sts-tool + .wp-block-spacer + p,
html body.sts-tool-page .entry-content > .sts-tool + p,
html body.sts-tool-page .entry-content > .sts-tool + .wp-block-spacer + p {
    margin-block-start: 0.5rem !important;
}

@media (min-width: 768px) {
    .sts-tool-page h1,
    .sts-tool-page .wp-block-post-title,
    .sts-tool-page .entry-title {
        font-size: 1.875rem !important;
    }
}

.sts-tool__header {
    margin-bottom: 0.65rem;
    text-align: center;
}

.sts-tool__title {
    margin: 0 0 0.4rem;
    color: var(--sts-ink);
    font-size: clamp(1.45rem, 4.5vw, 2rem);
    line-height: 1.2;
}

.sts-tool__intro {
    max-width: 65ch;
    margin: 0 auto;
    color: var(--sts-muted);
    line-height: 1.5;
}

.sts-tool__intro-line {
    display: block;
}

.sts-upload {
    position: relative;
    border: 2px dashed var(--sts-line);
    border-radius: var(--sts-radius);
    background: var(--sts-surface);
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.sts-upload:hover,
.sts-upload.is-dragging {
    border-color: var(--sts-brand);
    background: var(--sts-brand-soft);
}

.sts-upload.is-dragging {
    transform: scale(1.005);
}

.sts-upload__input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.sts-upload__input:focus-visible + .sts-upload__label {
    outline: 3px solid rgba(37, 99, 235, 0.3);
    outline-offset: 3px;
}

.sts-upload__label {
    display: flex;
    min-height: 128px;
    padding: 0.85rem 0.9rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
}

.sts-upload__icon {
    display: grid;
    width: 46px;
    height: 46px;
    margin-bottom: 0.25rem;
    border-radius: 50%;
    place-items: center;
    color: #fff;
    background: var(--sts-brand);
    font-size: 1.5rem;
    font-weight: 700;
}

.sts-upload__prompt strong {
    color: var(--sts-brand-dark);
}

.sts-upload__help {
    color: var(--sts-muted);
    font-size: 0.875rem;
}

.sts-alert {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border: 1px solid #e6b3b3;
    border-radius: 10px;
    color: var(--sts-danger);
    background: #fff4f4;
}

.sts-workspace {
    display: grid;
    gap: 1.25rem;
}

.sts-workspace > * {
    min-width: 0;
}

.sts-controls {
    order: 1;
}

.sts-result {
    order: 2;
}

.sts-preview-card {
    order: 3;
}

.sts-preview-card,
.sts-controls,
.sts-result {
    border: 1px solid var(--sts-line);
    border-radius: var(--sts-radius);
    background: var(--sts-surface);
    box-shadow: var(--sts-shadow);
}

.sts-preview-wrap {
    display: grid;
    min-height: 180px;
    max-height: 420px;
    padding: 1rem;
    overflow: hidden;
    place-items: center;
    border-radius: var(--sts-radius) var(--sts-radius) 0 0;
    background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%), linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e2e8f0 75%), linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.sts-preview {
    display: block;
    max-width: 100%;
    max-height: 385px;
    object-fit: contain;
}

.sts-file-facts {
    display: grid;
    grid-template-columns: 1fr;
    margin: 0;
    padding: 0.9rem 1rem;
    gap: 0.65rem;
}

.sts-file-facts div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.sts-file-facts dt {
    color: var(--sts-muted);
}

.sts-file-facts dd {
    min-width: 0;
    margin: 0;
    font-weight: 650;
    text-align: right;
    overflow-wrap: anywhere;
}

.sts-controls {
    padding: 1.1rem;
}

.sts-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0 0 1.25rem;
    border: 0;
}

.sts-fieldset + .sts-fieldset {
    padding-top: 1.15rem;
    border-top: 1px solid var(--sts-line);
}

.sts-fieldset legend {
    width: 100%;
    margin-bottom: 0.9rem;
    padding: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.sts-dimension-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
    gap: 0.45rem;
    align-items: end;
}

.sts-output-grid {
    display: grid;
    gap: 1rem;
}

.sts-field {
    display: grid;
    min-width: 0;
    gap: 0.4rem;
    color: var(--sts-ink);
    font-weight: 650;
}

.sts-field small {
    color: var(--sts-muted);
    font-size: 0.8em;
    font-weight: 400;
}

.sts-field__help {
    margin: -0.15rem 0 0;
    color: var(--sts-muted);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.4;
}

.sts-field input[type="number"],
.sts-field select {
    width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--sts-line);
    border-radius: 9px;
    color: var(--sts-ink);
    background: #fff;
    font: inherit;
}

.sts-field input:focus,
.sts-field select:focus,
.sts-field input[type="range"]:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    border-color: var(--sts-brand);
}

.sts-ratio-button {
    display: grid;
    width: 38px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--sts-line);
    border-radius: 9px;
    place-items: center;
    color: var(--sts-muted);
    background: #fff;
    cursor: pointer;
}

.sts-ratio-button.is-locked {
    color: #fff;
    border-color: var(--sts-brand);
    background: var(--sts-brand);
}

.sts-check {
    display: flex;
    margin-top: 0.9rem;
    gap: 0.55rem;
    align-items: center;
    color: var(--sts-muted);
    cursor: pointer;
}

.sts-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--sts-brand);
}

.sts-field input[type="range"] {
    width: 100%;
    margin: 0.6rem 0;
    accent-color: var(--sts-brand);
}

.sts-format-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.sts-format-option {
    display: flex;
    min-height: 52px;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--sts-line);
    border-radius: 9px;
    align-items: center;
    gap: 0.6rem;
    color: var(--sts-ink);
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}

.sts-format-option:hover {
    border-color: var(--sts-brand);
    background: var(--sts-brand-soft);
}

.sts-format-option:has(input:checked) {
    color: var(--sts-brand-dark);
    border-color: var(--sts-brand);
    background: var(--sts-brand-soft);
}

.sts-format-option:has(input:focus-visible) {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

.sts-format-option input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--sts-brand);
}

.sts-converter-note {
    margin-top: 0.75rem;
}

.sts-converter-note + .sts-converter-note {
    margin-top: 0.4rem;
}

.sts-actions {
    display: grid;
    padding-top: 0.25rem;
    gap: 0.7rem;
}

.sts-button {
    display: inline-flex;
    min-height: 46px;
    margin: 0;
    padding: 0.7rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    color: var(--sts-ink);
    background: #fff;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.sts-button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

.sts-button--primary,
.sts-button--download {
    color: #fff;
    border-color: var(--sts-brand);
    background: var(--sts-brand);
}

.sts-button--primary:hover,
.sts-button--download:hover {
    color: #fff;
    background: var(--sts-brand-dark);
}

.sts-button--secondary {
    border-color: var(--sts-line);
}

.sts-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.sts-result {
    display: grid;
    padding: 1rem;
    gap: 1rem;
    border-color: #bfdbfe;
    background: var(--sts-brand-soft);
}

.sts-result p {
    margin: 0.25rem 0 0;
    color: var(--sts-muted);
}

.sts-tool [hidden] {
    display: none !important;
}

@media (min-width: 560px) {
    .sts-upload__label {
        min-height: 160px;
        padding: 1.25rem 1.1rem;
    }

    .sts-file-facts {
        grid-template-columns: repeat(3, 1fr);
    }

    .sts-file-facts div {
        display: block;
    }

    .sts-file-facts dd {
        margin-top: 0.2rem;
        text-align: left;
    }

    .sts-output-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
    }

    .sts-actions {
        grid-template-columns: minmax(150px, 1fr) minmax(150px, auto);
    }

    .sts-result {
        grid-template-columns: 1fr auto;
        align-items: center;
    }
}

@media (min-width: 760px) {
    .sts-preview-card,
    .sts-controls,
    .sts-result {
        order: initial;
    }

    .sts-workspace {
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
        align-items: start;
    }

    .sts-result {
        grid-column: 1 / -1;
    }

    .sts-controls {
        padding: 1.35rem;
    }

    .sts-image-converter .sts-file-facts {
        grid-template-columns: 1fr;
    }

    .sts-image-converter .sts-file-facts div {
        display: flex;
        min-width: 0;
    }

    .sts-image-converter .sts-file-facts dd {
        text-align: right;
    }

}

.sts-tool-page .wp-block-post-content,
.sts-tool-page .entry-content {
    padding-block-end: 1.5rem;
}

.sts-tool-page .wp-block-post-content > h2,
.sts-tool-page .entry-content > h2 {
    margin-block-end: 0.75rem !important;
}

.sts-tool-page .wp-block-post-content > h3,
.sts-tool-page .entry-content > h3 {
    margin-block-start: 1.5rem !important;
    margin-block-end: 0.5rem !important;
}

.sts-tool-page .wp-block-post-content > p,
.sts-tool-page .wp-block-post-content > ol,
.sts-tool-page .wp-block-post-content > ul,
.sts-tool-page .entry-content > p,
.sts-tool-page .entry-content > ol,
.sts-tool-page .entry-content > ul {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
}

.sts-ad-slot {
    box-sizing: border-box;
    width: 100%;
    max-width: 900px;
    margin-block-start: 0.75rem;
    margin-block-end: 1.25rem;
    margin-inline: auto;
}

.sts-ad-preview {
    display: flex;
    min-height: var(--sts-ad-preview-height, 100px);
    padding: 0.75rem;
    border: 1px dashed var(--sts-line);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    color: var(--sts-muted);
    background: #f8fafc;
    font-size: 0.8125rem;
    line-height: 1.35;
    text-align: center;
}

@media (max-width: 767px) {
    .sts-tool-page .wp-block-post-content > h2,
    .sts-tool-page .entry-content > h2 {
        margin-block-start: 1.4rem !important;
        margin-block-end: 0.5rem !important;
        font-size: 1.1875rem !important;
        line-height: 1.25;
    }

    .sts-tool-page .wp-block-post-content > h3,
    .sts-tool-page .entry-content > h3 {
        margin-block-start: 1.1rem !important;
        margin-block-end: 0.35rem !important;
        font-size: 1rem !important;
        line-height: 1.3;
    }

    .sts-tool-page .wp-block-post-content > p,
    .sts-tool-page .wp-block-post-content > ol,
    .sts-tool-page .wp-block-post-content > ul,
    .sts-tool-page .entry-content > p,
    .sts-tool-page .entry-content > ol,
    .sts-tool-page .entry-content > ul {
        line-height: 1.45;
    }

    .sts-ad-slot {
        margin-block-start: 0.5rem;
        margin-block-end: 1rem;
    }
}

@media (max-width: 559px) {
    .sts-image-compressor .sts-file-facts {
        padding: 0.7rem 0.8rem;
        gap: 0.4rem;
        font-size: 0.9375rem;
        line-height: 1.3;
    }

    .sts-image-compressor .sts-file-facts div {
        gap: 0.75rem;
    }

    .sts-image-compressor .sts-controls {
        padding: 0.7rem;
        font-size: 0.9375rem;
        line-height: 1.35;
    }

    .sts-image-compressor .sts-fieldset {
        padding-bottom: 0.65rem;
    }

    .sts-image-compressor .sts-fieldset legend {
        margin-bottom: 0.45rem;
        font-size: 0.9375rem;
    }

    .sts-image-compressor .sts-output-grid {
        gap: 0.55rem;
    }

    .sts-image-compressor .sts-field {
        gap: 0.2rem;
    }

    .sts-image-compressor .sts-field__help {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .sts-image-compressor .sts-field select {
        min-height: 44px;
        padding: 0.5rem 0.65rem;
    }

    .sts-image-compressor .sts-field input[type="range"] {
        margin: 0.15rem 0;
    }

    .sts-image-compressor .sts-actions {
        padding-top: 0;
        gap: 0.45rem;
    }

    .sts-image-compressor .sts-button {
        min-height: 44px;
        padding: 0.6rem 0.9rem;
        font-size: 0.9375rem;
    }

    .sts-image-compressor .sts-result {
        padding: 0.8rem;
        gap: 0.65rem;
        font-size: 0.9375rem;
        line-height: 1.35;
    }

    .sts-image-compressor .sts-result p {
        margin-top: 0.15rem;
    }

    .sts-image-converter .sts-file-facts {
        padding: 0.7rem 0.8rem;
        gap: 0.4rem;
        font-size: 0.9375rem;
        line-height: 1.3;
    }

    .sts-image-converter .sts-file-facts div {
        gap: 0.75rem;
    }

    .sts-image-converter .sts-file-facts dd {
        max-width: 65%;
        overflow-wrap: anywhere;
    }

    .sts-image-converter .sts-controls {
        padding: 0.7rem;
        font-size: 0.9375rem;
        line-height: 1.35;
    }

    .sts-image-converter .sts-fieldset {
        padding-bottom: 0.65rem;
    }

    .sts-image-converter .sts-fieldset legend {
        margin-bottom: 0.45rem;
        font-size: 0.9375rem;
    }

    .sts-image-converter .sts-format-options {
        gap: 0.45rem;
    }

    .sts-image-converter .sts-format-option {
        min-height: 44px;
        padding: 0.5rem 0.65rem;
    }

    .sts-image-converter .sts-field__help {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .sts-image-converter .sts-actions {
        padding-top: 0;
        gap: 0.45rem;
    }

    .sts-image-converter .sts-button {
        min-height: 44px;
        padding: 0.6rem 0.9rem;
        font-size: 0.9375rem;
    }

    .sts-image-converter .sts-result {
        padding: 0.8rem;
        gap: 0.65rem;
        font-size: 0.9375rem;
        line-height: 1.35;
    }

    .sts-image-converter .sts-result p {
        margin-top: 0.15rem;
    }
}

@media (max-width: 359px) {
    .sts-tool-page .wp-block-post-content > h2,
    .sts-tool-page .entry-content > h2 {
        margin-block-start: 1.2rem !important;
        font-size: 1.125rem !important;
    }

    .sts-tool-page .wp-block-post-content > h3,
    .sts-tool-page .entry-content > h3 {
        margin-block-start: 1rem !important;
        font-size: 0.975rem !important;
    }

    .sts-tool-page .wp-block-post-content > p,
    .sts-tool-page .wp-block-post-content > ol,
    .sts-tool-page .wp-block-post-content > ul,
    .sts-tool-page .entry-content > p,
    .sts-tool-page .entry-content > ol,
    .sts-tool-page .entry-content > ul {
        font-size: 0.9375rem;
        line-height: 1.42;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sts-upload {
        transition: none;
    }

    .sts-tool * {
        scroll-behavior: auto !important;
    }
}
