/* 3D viewers, rendered thumbnails and the character editor. */
.avatar-viewport {
    width: 100%;
    height: 340px;
    background: #e8edf3;
    border: 1px solid #cfd6de;
    position: relative;
    overflow: hidden;
    touch-action: none;
}
.avatar-viewport-small { height: 260px; }
.avatar-viewport-large { height: 420px; }
.avatar-viewport canvas { display: block; cursor: grab; }
.avatar-viewport canvas.dragging { cursor: grabbing; }
.viewer-hint { color: var(--muted); font-size: 11px; text-align: center; margin: 4px 0 6px; }
.viewer-fallback { padding: 40px 14px; color: #777; text-align: center; font-size: 12px; }
.viewer-controls { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

.avatar-thumb, .item-thumb {
    background: #eef1f5;
    border: 1px solid #d5dbe2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: none;
}
.avatar-thumb img, .item-thumb img { width: 100%; height: 100%; display: block; }
.avatar-thumb.loading, .item-thumb.loading { background: #eef1f5 linear-gradient(90deg, #eef1f5, #f7f9fb, #eef1f5); }
.avatar-thumb.no-webgl::after, .item-thumb.no-webgl::after { content: "No preview"; color: #999; font-size: 11px; }

/* Editor layout */
.avatar-editor { display: grid; grid-template-columns: 320px 1fr; gap: 12px; align-items: start; }
.avatar-editor .panel { margin-bottom: 12px; }
.editor-save { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.editor-status { width: 100%; font-size: 12px; min-height: 16px; }
.editor-status.success { color: #24561a; font-weight: bold; }
.editor-status.error { color: #a1251a; font-weight: bold; }

.tabs-in-panel { border-bottom: 1px solid var(--border); background: #eef3f9; padding: 4px 4px 0; margin: 0; }

/* Body part picker: a little flat blocky figure */
.body-picker { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 8px 0 10px; }
.bp-row { display: flex; gap: 3px; }
.bp { border: 1px solid #555; cursor: pointer; padding: 0; border-radius: 0; }
.bp:hover { outline: 2px solid #8ab4e6; }
.bp.selected { outline: 3px solid #0e5aa6; outline-offset: 1px; }
.bp-head { width: 44px; height: 44px; }
.bp-torso { width: 74px; height: 74px; }
.bp-arm { width: 34px; height: 74px; }
.bp-leg { width: 35px; height: 74px; }

.selected-part { margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.palette { display: grid; grid-template-columns: repeat(10, 26px); gap: 3px; margin-bottom: 10px; }
.swatch { width: 26px; height: 26px; border: 1px solid #777; cursor: pointer; padding: 0; border-radius: 0; }
.swatch:hover { outline: 2px solid #8ab4e6; }
.swatch.selected { outline: 3px solid #0e5aa6; outline-offset: 1px; }

.editor-item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.editor-item {
    background: #fff;
    border: 1px solid var(--border);
    padding: 6px;
    cursor: pointer;
    text-align: center;
    font: 12px Arial, Helvetica, sans-serif;
    border-radius: 0;
}
.editor-item:hover { border-color: #6aa0d8; background: #f5f9fd; }
.editor-item.worn { border: 2px solid var(--green); background: #f1faef; padding: 5px; }
.editor-item .item-name { margin-top: 4px; word-break: break-word; }

@media (max-width: 860px) {
    .avatar-editor { grid-template-columns: 1fr; }
    .palette { grid-template-columns: repeat(auto-fill, 26px); }
}
