.page-tool--css-transform-playground .tool-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Studio layout: controls beside a live preview that reacts as you drag. */
.page-tool--css-transform-playground .ctp-studio {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.page-tool--css-transform-playground .ctp-visual {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.page-tool--css-transform-playground .ctp-preview {
    position: sticky;
    top: calc(var(--header-h) + 16px);
}

.page-tool--css-transform-playground .ctp-controls__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-tool--css-transform-playground .ctp-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.page-tool--css-transform-playground .ctp-hint code,
.page-tool--css-transform-playground .ctp-about__text code {
    padding: 0.05rem 0.3rem;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    color: var(--ink-2);
    font-family: var(--font-mono);
}

.page-tool--css-transform-playground .ctp-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-tool--css-transform-playground .ctp-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.page-tool--css-transform-playground .ctp-group__title {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.page-tool--css-transform-playground .ctp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 18px;
}

/* Slider control: prominent range with a compact numeric readout. */
.page-tool--css-transform-playground .ctp-control {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.page-tool--css-transform-playground .ctp-control__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.page-tool--css-transform-playground .ctp-control__label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}

.page-tool--css-transform-playground .ctp-control__range {
    width: 100%;
    height: 1.6rem;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.page-tool--css-transform-playground .ctp-control__number {
    flex: 0 0 4.5rem;
    width: 4.5rem;
    min-height: 1.9rem;
    padding: 0.15rem 0.35rem;
    border-color: var(--line);
    background: var(--surface-3);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-align: right;
}

.page-tool--css-transform-playground .ctp-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    cursor: pointer;
}

.page-tool--css-transform-playground .ctp-toggle input {
    accent-color: var(--accent);
}

/* Transform origin: a 3x3 pad plus fine numeric sliders. */
.page-tool--css-transform-playground .ctp-origin {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
    align-items: center;
}

.page-tool--css-transform-playground .ctp-origin-pad {
    display: grid;
    grid-template-columns: repeat(3, 30px);
    grid-template-rows: repeat(3, 30px);
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.page-tool--css-transform-playground .ctp-origin-cell {
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--surface);
    cursor: pointer;
}

.page-tool--css-transform-playground .ctp-origin-cell:hover {
    border-color: var(--accent);
}

.page-tool--css-transform-playground .ctp-origin-cell[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.page-tool--css-transform-playground .ctp-origin-cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Live preview. */
.page-tool--css-transform-playground .ctp-preview__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.page-tool--css-transform-playground .ctp-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--surface-3);
    background-image:
        linear-gradient(var(--canvas-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
}

.page-tool--css-transform-playground .ctp-canvas {
    position: relative;
    width: 220px;
    height: 160px;
}

.page-tool--css-transform-playground .ctp-outline {
    position: absolute;
    inset: 0;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    pointer-events: none;
}

.page-tool--css-transform-playground .ctp-demo {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: var(--accent-fg);
    box-shadow: var(--shadow-md);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    will-change: transform;
}

.page-tool--css-transform-playground .ctp-origin-marker {
    position: absolute;
    z-index: 3;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border: 2px solid var(--danger);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--surface);
    pointer-events: none;
}

.page-tool--css-transform-playground .ctp-preview-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}

/* Output. */
.page-tool--css-transform-playground .ctp-output__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.page-tool--css-transform-playground .ctp-status {
    margin: 0;
    font-size: 0.8rem;
}

.page-tool--css-transform-playground .ctp-code {
    min-height: 6rem;
    max-height: 15rem;
    margin: 0;
}

.page-tool--css-transform-playground .ctp-matrix {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0;
}

.page-tool--css-transform-playground .ctp-matrix__label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}

.page-tool--css-transform-playground .ctp-matrix code {
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    overflow-wrap: anywhere;
}

.page-tool--css-transform-playground .ctp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-tool--css-transform-playground .ctp-about__text {
    max-width: 80ch;
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    .page-tool--css-transform-playground .ctp-studio {
        grid-template-columns: 1fr;
    }

    .page-tool--css-transform-playground .ctp-preview {
        position: static;
    }

    .page-tool--css-transform-playground .ctp-stage {
        min-height: 320px;
        padding: 28px;
    }
}

@media (max-width: 560px) {
    .page-tool--css-transform-playground .ctp-origin {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .page-tool--css-transform-playground .ctp-grid {
        grid-template-columns: 1fr;
    }
}
