/* Statuen-Generator - on top of text-generators.css, texture-editor.css and painting-generator.css (pg-label, pg-range) */
.st-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: 18px;
    align-items: start;
}

.st-stage {
    height: min(62vh, 540px);
    overflow: hidden;
    border-radius: 12px;
    background: radial-gradient(circle at 50% 30%, #3b5578, #141c2b 75%);
}

#stCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

.st-side {
    display: grid;
    gap: 18px;
}

.st-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.st-list {
    display: grid;
    gap: 6px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.st-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 1px solid var(--tg-line);
    border-radius: 10px;
    background: var(--tg-field);
    text-align: left;
}

.st-item.active {
    border-color: var(--tg-accent);
    background: var(--tg-accent-soft);
}

.st-item canvas {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    image-rendering: pixelated;
}

.st-item span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.st-item b {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-overflow: ellipsis;
}

.st-item small {
    overflow: hidden;
    color: var(--text-muted);
    font-family: var(--mono-font);
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main .st-empty,
.main .st-none {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.st-empty[hidden],
.st-edit[hidden] {
    display: none;
}

.st-poses {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.main .st-chip {
    padding: 6px 12px;
    border: 1px solid var(--tg-line);
    border-radius: 999px;
    background: var(--tg-field);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.main .st-chip:hover,
.main .st-chip.active {
    border-color: var(--tg-accent);
    color: var(--text-primary);
}

.main .st-chip.active {
    background: var(--tg-accent-soft);
}

.st-layers,
.st-flags {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 10px;
}

.st-flags {
    grid-template-columns: minmax(0, 1fr);
}

.tg-panel .st-layers .toggle-row,
.tg-panel .st-flags .toggle-row {
    justify-content: flex-start;
    margin: 4px 0;
    text-align: left;
}

/* data pack + commands */
.st-pack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 14px;
}

.tg-panel .st-pack label {
    display: grid;
    gap: 4px;
    margin: 0;
    font-size: 0.8rem;
}

.st-cmds {
    display: grid;
    gap: 10px;
}

.st-cmd-group {
    display: grid;
    gap: 6px;
}

.st-cmd-group .pg-label {
    margin: 4px 0 0;
}

.ar-cmd {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 10px;
    padding: 8px 10px;
    border: 1px solid var(--tg-line);
    border-radius: 10px;
    background: var(--tg-field);
    text-align: left;
}

.ar-cmd-head {
    grid-column: 1 / -1;
}

.ar-cmd-head b {
    color: var(--text-primary);
    font-size: 0.8rem;
}

.ar-cmd code {
    font-size: 0.75rem;
    text-align: center;
    overflow-wrap: anywhere;
}

.main .st-below .tg-panel + .tg-panel {
    margin-top: 24px;
}

.st-steps {
    padding-left: 22px;
}

@media (max-width: 1000px) {
    .st-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .st-stage {
        height: 400px;
    }
}

@media (max-width: 520px) {
    .st-pack {
        grid-template-columns: minmax(0, 1fr);
    }

    .st-layers {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* the preview sticks while the settings scroll - only side by side */
@media (min-width: 1001px) {
    .st-view {
        position: sticky;
        top: 96px;
        max-height: calc(100vh - 112px);
        overflow-y: auto;
    }
}

/* equipment */
.st-armor,
.st-hands {
    display: grid;
    gap: 8px;
}

.st-armor-row,
.st-hand {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.tg-panel .st-armor-row label {
    margin: 0;
    font-size: 0.82rem;
    text-align: left;
}

.tg-panel .st-armor-row select {
    padding: 7px 10px;
    font-size: 0.85rem;
}

.st-armor-row input[type="color"] {
    width: 38px;
    height: 32px;
    padding: 1px;
    border: 1px solid var(--tg-line);
    border-radius: 8px;
    background: var(--tg-field);
}

.st-armor-row input[hidden],
.st-picker[hidden] {
    display: none;
}

.st-hand > span {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
}

.main .st-hand-pick {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 5px 10px;
    border: 1px solid var(--tg-line);
    border-radius: 10px;
    background: var(--tg-field);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}

.st-hand.active .st-hand-pick {
    border-color: var(--tg-accent);
}

.st-hand-pick img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.st-picker {
    margin-top: 10px;
    padding: 8px;
    border: 1px solid var(--tg-accent);
    border-radius: 12px;
    background: var(--tg-field);
}

.st-picker-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    margin-bottom: 8px;
}

.tg-panel .st-picker-head input {
    padding: 8px 12px;
    border: 1px solid var(--tg-line);
    border-radius: 10px;
    background: var(--bg-secondary, #0f1624);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.85rem;
}

.st-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.main .st-item-pick {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 5px 2px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.6rem;
    line-height: 1.15;
    cursor: pointer;
}

.st-item-pick img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.st-item-pick span {
    display: -webkit-box;
    overflow: hidden;
    max-width: 100%;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.main .st-item-pick:hover {
    border-color: var(--tg-accent);
    background: var(--tg-accent-soft);
    color: var(--text-primary);
}

@media (max-width: 520px) {
    .st-armor-row,
    .st-hand {
        grid-template-columns: 90px minmax(0, 1fr) auto;
    }
}

/* item picker: one block per category over the full grid width, folding open and shut */
.item-cat {
    grid-column: 1 / -1;
}

.main .item-group {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin: 2px 0;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.main .item-group:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.item-group small {
    color: var(--text-muted);
    font-weight: 500;
}

.item-group i {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform 0.15s;
}

.item-cat.collapsed .item-group i {
    transform: rotate(-90deg);
}

.item-cat-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 4px;
    padding-bottom: 6px;
}

.item-cat.collapsed .item-cat-body {
    display: none;
}
