/* Rüstungsständer-Generator - on top of text-generators.css, texture-editor.css and painting-generator.css (pg-seg, pg-label, pg-range) */
.ar-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    gap: 18px;
    align-items: start;
}

.ar-stage {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: radial-gradient(circle at 50% 30%, #3b5578, #141c2b 75%);
}

#arCanvas {
    display: block;
    width: 100%;
    height: min(64vh, 560px);
    cursor: grab;
    touch-action: none;
}

.main .ar-error {
    position: absolute;
    inset: auto 12px 12px;
    margin: 0;
    color: var(--text-primary);
    font-size: 0.85rem;
}

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

.ar-view-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}

.tg-panel .ar-view-tools .toggle-row {
    margin: 0;
}

.ar-tabs {
    margin-bottom: 14px;
}

.ar-presets,
.ar-parts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

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

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

.main .ar-chip.is-changed::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--tg-accent);
    vertical-align: middle;
}

.ar-sliders {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.ar-slider {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 72px;
    align-items: center;
    gap: 10px;
}

.ar-slider b {
    color: var(--tg-accent);
}

.ar-slider input[type="range"] {
    width: 100%;
    accent-color: var(--tg-accent);
}

.tg-panel input.ar-num {
    padding: 5px 6px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.ar-pose-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.ar-armor {
    display: grid;
    gap: 8px;
}

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

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

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

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

.ar-hands {
    display: grid;
    gap: 8px;
}

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

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

.main .ar-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;
}

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

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

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

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

.tg-panel .ar-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;
}

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

.main .ar-item {
    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;
}

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

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

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

.main .ar-none {
    grid-column: 1 / -1;
    margin: 10px;
    color: var(--text-muted);
}

.ar-flags {
    display: grid;
    gap: 2px;
    margin-bottom: 8px;
}

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

/* commands */
.ar-opts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

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

.ar-cmds {
    display: grid;
    gap: 8px;
}

.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 {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    grid-column: 1 / -1;
}

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

.ar-cmd-head small {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.ar-cmd.is-long .ar-cmd-head small {
    color: var(--warning, #f59e0b);
}

.ar-cmd code {
    max-height: 140px;
    overflow-y: auto;
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

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

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

    #arCanvas {
        height: 420px;
    }
}

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

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

/* the 3D view sticks while the controls scroll - only side by side; never taller than the screen */
@media (min-width: 1001px) {
    .ar-view {
        position: sticky;
        top: 96px;
        max-height: calc(100vh - 112px);
        overflow-y: 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;
}
